daisy-tiptap-test 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as
|
|
1
|
+
import{defineComponent as E,ref as m,watch as v,watchEffect as U,unref as r,toRaw as D,provide as s,computed as H,onBeforeUnmount as z,openBlock as d,createElementBlock as f,normalizeStyle as I,normalizeClass as i,createBlock as h,createCommentVNode as u,createElementVNode as C,withDirectives as N,createVNode as V,vShow as L,toDisplayString as g}from"vue";import{useEditor as R,EditorContent as W}from"@tiptap/vue-3";import{ulid as A}from"ulid";import{CharacterCount as P,Placeholder as j}from"../extensions";import{zh as J,Trans as w}from"../i18n";import{useCodeView as $,useCharacterCount as q,useEditorStyle as G}from"../hooks";import{BubbleMenu as K,FloatingMenu as Q,MenuBar as X}from".";const Y=["id"],Z={class:"text-left flex-1 overflow-hidden"},se=E({__name:"DaisyTiptap",props:{extensions:{},content:{default:""},modelContent:{default:""},placeholder:{default:""},width:{},height:{},output:{default:"html"},readOnly:{type:Boolean,default:!1},tooltip:{type:Boolean,default:!0},enableCharCount:{type:Boolean,default:!0},charCountMax:{},spellCheck:{type:Boolean,default:!0},locale:{default:J},showFloatingMenu:{type:Boolean,default:!1},editorClass:{default:""},editorContentClass:{default:""},editorMenubarClass:{default:""},editorBubbleMenuClass:{default:""},editorFooterClass:{default:""}},emits:["onBeforeCreate","onCreate","onUpdate","onSelectionUpdate","onTransaction","onFocus","onBlur","onDestroy","update:content"],setup(B,{emit:_}){const t=B,l=_,b=t.enableCharCount?t.extensions.concat([P.configure({limit:t.charCountMax})]):t.extensions,o=m();R({content:t.content||t.modelContent,editable:!t.readOnly,extensions:[...b,j.configure({emptyEditorClass:"daisy-tiptap-editor__placeholder",showOnlyCurrent:!1,placeholder:()=>String(t.placeholder)})],parseOptions:{preserveWhitespace:"full"},onBeforeCreate:({editor:e})=>{l("onBeforeCreate",{editor:e})},onCreate:({editor:e})=>{o.value=e,v(()=>t.content,n=>{e.getHTML()!==n&&e.commands.setContent(n,!1)}),v(()=>t.modelContent,n=>{e.getHTML()!==n&&e.commands.setContent(n,!1)}),l("onCreate",{editor:e})},onUpdate:({editor:e})=>{let n;t.output==="html"?n=e.getHTML():n=e.getJSON(),l("update:content",n),l("onUpdate",{output:n,editor:e})},onSelectionUpdate:({editor:e})=>{l("onSelectionUpdate",{editor:e})},onTransaction:({editor:e})=>{l("onTransaction",{editor:e})},onFocus:({editor:e})=>{l("onFocus",{editor:e})},onBlur:({editor:e})=>{l("onBlur",{editor:e})},onDestroy:()=>{l("onDestroy")}}),U(()=>{var e;(e=r(o))==null||e.setOptions({editorProps:{attributes:{spellCheck:String(t.spellCheck)}}})});const M=w.buildI18nHandler(D(t.locale)),x=(...e)=>M.apply(w,e),a=m(!1),k=e=>{a.value=e};s("readOnly",t.readOnly),s("isFullscreen",a),s("toggleFullscreen",k),s("enableTooltip",t.tooltip);const{isCodeViewMode:c,cmTextAreaRef:F}=$(o);s("isCodeViewMode",c);const{characters:S}=q(o),p=H(()=>t.enableCharCount&&!r(c)),T=G({width:t.width,height:t.height});s("i18n",x),s("editor",o);const O=A(),y=m(`daisy-tiptap__wrapper-${O}`);return s("editorWrapperId",y),z(()=>{var e;(e=o.value)==null||e.destroy()}),(e,n)=>(d(),f("div",{id:y.value,class:"daisy-tiptap-editor__wrapper max-w-full w-full max-h-full h-full"},[o.value?(d(),f("div",{key:0,style:I(r(T)),class:i(["box-border flex flex-col min-w-0 max-w-full w-full max-h-full h-full border-2 border-solid, border-neutral-content",{"rounded-none fixed top-0 left-0 right-0 bottom-0 z-50 bg-base-200":a.value,"rounded-lg relative":!a.value},t.editorClass])},[o.value?(d(),h(r(K),{key:0,editor:o.value,extensions:r(b),class:i(t.editorBubbleMenuClass)},null,8,["editor","extensions","class"])):u("",!0),e.showFloatingMenu?(d(),h(r(Q),{key:1,editor:o.value},null,8,["editor"])):u("",!0),t.readOnly?u("",!0):(d(),h(r(X),{key:2,editor:o.value,extensions:t.extensions,class:i(["space-x-1 flex shrink-0 flex-wrap p-1.5 relative","before:bg-neutral-content before:absolute before:right-0 before:left-0 before:bottom-0 before:h-[1px] before:content-normal before:mx-2.5",{"rounded-none":a.value,"rounded-t-lg":!a.value},t.editorMenubarClass])},null,8,["editor","extensions","class"])),r(c)?(d(),f("div",{key:3,class:i({"daisy-tiptap-editor__codemirror":!0,"flex flex-grow text-base leading-6 overflow-scroll":!0,"border-bottom-radius":r(c)})},[C("textarea",{ref_key:"cmTextAreaRef",ref:F},null,512)],2)):u("",!0),C("div",Z,[N(V(r(W),{editor:o.value,class:i(["h-full",{"rounded-b-lg":!p.value,"rounded-b-none":p.value,"rounded-none":a.value},t.editorContentClass])},null,8,["editor","class"]),[[L,!r(c)]])]),p.value?(d(),f("div",{key:4,class:i(["items-center border-t-2 border-solid border-neutral-content flex text-sm justify-end p-2.5",{"rounded-none":a.value,"rounded-b-lg":!a.value},t.editorFooterClass])},[C("span",null,g(x("editor.characters"))+": "+g(r(S)),1)],2)):u("",!0)],6)):u("",!0)],8,Y))}});export{se as default};
|