Skip to content

Commit becb352

Browse files
committed
build: update dist
1 parent 2b0872e commit becb352

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

dist/index.d.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { CSSProperties, HTMLAttributes } from 'react';
2+
import { UseEditorOptions } from '@tiptap/react';
23

34
interface Tag {
45
type: 'tag'
@@ -20,12 +21,14 @@ interface MixInputProps extends HTMLAttributes<HTMLDivElement> {
2021
onChange: (value: MixInputValues) => void
2122
readonly?: boolean
2223
tagClassName?: string
24+
editorOptions?: UseEditorOptions
2325
// multiline?: boolean
2426
// showTagDeleteBtn?: boolean
2527
}
2628

2729
interface MixInputRef {
28-
editor: HTMLDivElement | null
30+
element: HTMLDivElement | null
31+
editor: Editor | null
2932
insertContent: (content: MixInputValue | MixInputValue[]) => void
3033
}
3134

dist/index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { CSSProperties, HTMLAttributes } from 'react';
2+
import { UseEditorOptions } from '@tiptap/react';
23

34
interface Tag {
45
type: 'tag'
@@ -20,12 +21,14 @@ interface MixInputProps extends HTMLAttributes<HTMLDivElement> {
2021
onChange: (value: MixInputValues) => void
2122
readonly?: boolean
2223
tagClassName?: string
24+
editorOptions?: UseEditorOptions
2325
// multiline?: boolean
2426
// showTagDeleteBtn?: boolean
2527
}
2628

2729
interface MixInputRef {
28-
editor: HTMLDivElement | null
30+
element: HTMLDivElement | null
31+
editor: Editor | null
2932
insertContent: (content: MixInputValue | MixInputValue[]) => void
3033
}
3134

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"use client";
2-
import b,{forwardRef as I,useEffect as T,useImperativeHandle as N,useRef as E}from"react";function y(r){return typeof r=="object"&&r.type==="tag"}function h(r){return{type:"tag",attrs:{...r.attrs}}}function l(r){let a=[];return r.forEach(t=>{var n;t.type==="paragraph"&&(a.push([]),(n=t==null?void 0:t.content)==null||n.forEach(e=>{var o,s;e.type==="text"&&e.text&&((o=a.at(-1))==null||o.push(e.text)),e.type==="tag"&&((s=a.at(-1))==null||s.push(h(e)))}))}),a}function d(r){let a=[];return r.forEach((t,n)=>{Array.isArray(a[n])||a.push({type:"paragraph",content:[]});let e=a.at(-1);typeof t=="string"&&(e!=null&&e.content)&&e.content.push({type:"text",text:t}),!Array.isArray(t)&&y(t)&&(e!=null&&e.content)&&e.content.push({type:"tag",attrs:{...t.attrs}}),Array.isArray(t)&&t.forEach(o=>{typeof o=="string"&&(e!=null&&e.content)&&e.content.push({type:"text",text:o}),typeof o=="object"&&o.type==="tag"&&(e!=null&&e.content)&&e.content.push({type:"tag",attrs:{...o.attrs}})})}),a}import{EditorContent as A,useEditor as C}from"@tiptap/react";import O from"@tiptap/extension-document";import R from"@tiptap/extension-paragraph";import P from"@tiptap/extension-text";import J from"@tiptap/extension-placeholder";import{mergeAttributes as M,Node as V}from"@tiptap/core";var f=V.create({name:"tag",group:"inline",inline:!0,atom:!0,selectable:!1,parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:r}){return["span",M(r)]},addNodeView:()=>({node:r,extension:a})=>{let t=document.createElement("span");t.className="mi-tag",t.innerHTML=r.attrs.label,t.setAttribute("data-type","tag"),r.attrs.id&&t.setAttribute("data-id",r.attrs.id),a.options.tagClassName&&t.classList.add(a.options.tagClassName),r.attrs.class&&(Array.isArray(r.attrs.class)?r.attrs.class.forEach(e=>{t.classList.add(e)}):t.classList.add(r.attrs.class)),r.attrs.style&&Object.assign(t.style,r.attrs.style);let n=document.createElement("span");return n.appendChild(t),n.appendChild(document.createTextNode("\u200B")),{dom:n}},addAttributes(){return{label:void 0,id:void 0,class:void 0,style:void 0}}});var L=I((r,a)=>{let{onChange:t,value:n,placeholder:e,readonly:o=!1,tagClassName:s,...g}=r,u=E(null),i=C({editorProps:{attributes:{class:"mix-input"}},extensions:[O,R.configure({HTMLAttributes:{class:"mi-paragraph"}}),P,J.configure({placeholder:e}),f.configure({tagClassName:s})],onUpdate:({editor:p})=>{var c;t==null||t(l(((c=p==null?void 0:p.getJSON())==null?void 0:c.content)||[]))}}),m=p=>{i==null||i.chain().focus().insertContent(p).run()};return T(()=>{let p=d(n);JSON.stringify(p)!==JSON.stringify(i==null?void 0:i.getJSON().content)&&(i==null||i.commands.setContent(p))},[n]),N(a,()=>({editor:u.current,insertContent:m})),b.createElement(A,{editor:i,innerRef:u,...g})}),x=L;var W=x;export{W as default};
2+
import I,{forwardRef as T,useEffect as N,useImperativeHandle as E,useRef as A}from"react";function h(r){return typeof r=="object"&&r.type==="tag"}function M(r){return{type:"tag",attrs:{...r.attrs}}}function l(r){let a=[];return r.forEach(t=>{var i;t.type==="paragraph"&&(a.push([]),(i=t==null?void 0:t.content)==null||i.forEach(e=>{var p,s;e.type==="text"&&e.text&&((p=a.at(-1))==null||p.push(e.text)),e.type==="tag"&&((s=a.at(-1))==null||s.push(M(e)))}))}),a}function f(r){let a=[];return r.forEach((t,i)=>{Array.isArray(a[i])||a.push({type:"paragraph",content:[]});let e=a.at(-1);typeof t=="string"&&(e!=null&&e.content)&&e.content.push({type:"text",text:t}),!Array.isArray(t)&&h(t)&&(e!=null&&e.content)&&e.content.push({type:"tag",attrs:{...t.attrs}}),Array.isArray(t)&&t.forEach(p=>{typeof p=="string"&&(e!=null&&e.content)&&e.content.push({type:"text",text:p}),typeof p=="object"&&p.type==="tag"&&(e!=null&&e.content)&&e.content.push({type:"tag",attrs:{...p.attrs}})})}),a}import{EditorContent as C,useEditor as O}from"@tiptap/react";import R from"@tiptap/extension-document";import J from"@tiptap/extension-paragraph";import P from"@tiptap/extension-text";import S from"@tiptap/extension-placeholder";import{mergeAttributes as V,Node as b}from"@tiptap/core";var d=b.create({name:"tag",group:"inline",inline:!0,atom:!0,selectable:!1,parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:r}){return["span",V(r)]},addNodeView:()=>({node:r,extension:a})=>{let t=document.createElement("span");t.className="mi-tag",t.innerHTML=r.attrs.label,t.setAttribute("data-type","tag"),r.attrs.id&&t.setAttribute("data-id",r.attrs.id),a.options.tagClassName&&t.classList.add(a.options.tagClassName),r.attrs.class&&(Array.isArray(r.attrs.class)?r.attrs.class.forEach(e=>{t.classList.add(e)}):t.classList.add(r.attrs.class)),r.attrs.style&&Object.assign(t.style,r.attrs.style);let i=document.createElement("span");return i.appendChild(t),i.appendChild(document.createTextNode("\u200B")),{dom:i}},addAttributes(){return{label:void 0,id:void 0,class:void 0,style:void 0}}});var L=T((r,a)=>{let{onChange:t,value:i,placeholder:e,readonly:p=!1,tagClassName:s,editorOptions:g,...m}=r,u=A(null),n=O({editorProps:{attributes:{class:"mix-input"}},extensions:[R,J.configure({HTMLAttributes:{class:"mi-paragraph"}}),P,S.configure({placeholder:e}),d.configure({tagClassName:s})],onUpdate:({editor:o})=>{var c;t==null||t(l(((c=o==null?void 0:o.getJSON())==null?void 0:c.content)||[]))},...g}),y=o=>{n==null||n.chain().focus().insertContent(o).run()};return N(()=>{let o=f(i);o.length===0&&(o=[{type:"paragraph"}]),JSON.stringify(o)!==JSON.stringify(n==null?void 0:n.getJSON().content)&&(console.log({updatedValueFromParent:o,value:n==null?void 0:n.getJSON().content}),n==null||n.commands.setContent(o))},[i]),E(a,()=>({element:u.current,editor:n,insertContent:y})),I.createElement(C,{editor:n,innerRef:u,...m})}),x=L;var X=x;export{X as default};
33
//# sourceMappingURL=index.mjs.map

0 commit comments

Comments
 (0)