daisy-tiptap-test 0.0.16 → 0.0.18

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 H,ref as f,computed as x,onBeforeMount as K,onMounted as G,onBeforeUnmount as W,openBlock as b,createBlock as X,unref as i,normalizeStyle as Y,normalizeClass as y,withCtx as U,createElementVNode as Z,createElementBlock as E,createVNode as P,createCommentVNode as L,Fragment as j,renderList as J}from"vue";import{Editor as Q}from"@tiptap/core";import{NodeViewWrapper as ee}from"@tiptap/vue-3";import{ResizeObserver as te}from"@juggle/resize-observer";import{resolveImg as oe,IMAGE_DISPLAY_PRESETS as d,clamp as B}from"../utils";import{Icon as T}from".";const ne=["src","title","alt","width"],re=["onMousedown"],w=50,$=1e5,ve=H({__name:"ImageView",props:{editor:{type:Q,required:!0},selected:{type:Boolean,required:!0},node:{type:Object,required:!0},getPos:{type:Function,required:!0},updateAttributes:{type:Function,required:!0},deleteNode:{type:Function,required:!0}},setup(F){const e=F,v=f(!1),M=f({width:0,height:0}),h=f({width:$,height:$}),R=f(["tl","tr","bl","br"]),c=f(!1),p=f({x:0,y:0,w:0,h:0,dir:""}),k=x(()=>e.node.attrs.src),I=x(()=>e.node.attrs.width),a=x(()=>e.node.attrs.display);let g;function O(){e.editor.commands.setNodeSelection(e.getPos())}function q(){const{width:o,paddingLeft:t,paddingRight:s}=getComputedStyle(e.editor.view.dom);h.value.width=parseInt(o,10)-parseInt(t,10)-parseInt(s,10)}function D(o,t){o.preventDefault(),o.stopPropagation(),p.value.x=o.clientX,p.value.y=o.clientY;const s=M.value.width,r=M.value.height,m=s/r;let{width:n,height:u}=e.node.attrs;const l=h.value.width;n&&!u?(n=n>l?l:n,u=Math.round(n/m)):u&&!n?(n=Math.round(u*m),n=n>l?l:n):!n&&!u?(n=s>l?l:s,u=Math.round(n/m)):n=n>l?l:n,p.value.w=n,p.value.h=u,p.value.dir=t,c.value=!0,V()}function N(o){var C,A;if(o.preventDefault(),o.stopPropagation(),!c.value)return;const{x:t,y:s,w:r,h:m,dir:n}=p.value,u=(o.clientX-t)*(/l/.test(n)?-1:1),l=(o.clientY-s)*(/t/.test(n)?-1:1);a.value===d.BLOCK_CENTER?(C=e.updateAttributes)==null||C.call(e,{width:B(r+2*u,w,h.value.width),height:Math.max(m+2*l,w)}):(A=e.updateAttributes)==null||A.call(e,{width:B(r+u,w,h.value.width),height:Math.max(m+l,w)})}function S(o){o.preventDefault(),o.stopPropagation(),c.value&&(c.value=!1,p.value={x:0,y:0,w:0,h:0,dir:""},_(),O())}function V(){document.addEventListener("mousemove",N,!0),document.addEventListener("mouseup",S,!0)}function _(){document.removeEventListener("mousemove",N,!0),document.removeEventListener("mouseup",S,!0)}function z(o){let t=null;console.log(e.node.nodeSize),o==="top"?t=e.getPos():o==="bottom"&&(t=e.getPos()+e.node.nodeSize-1),console.log(t),e.editor.commands.insertContentAt(t,"<p></p>",{updateSelection:!0})}return K(async()=>{const o=await oe(k.value);o.complete||(o.width=w,o.height=w),M.value={width:o.width,height:o.height},I.value===null&&(h.value.width>=o.width?e.updateAttributes({width:o.width}):e.updateAttributes({width:h.value.width}))}),G(()=>{g=new te(()=>{q()}),g.observe(e.editor.view.dom)}),W(()=>{g==null||g.disconnect()}),(o,t)=>(b(),X(i(ee),{as:"figure",style:Y(`width: ${I.value}px`),"data-image":a.value===i(d).INLINE?"inline":"block",class:y(["align-baseline relative",{"my-3 block ml-0 mr-auto":a.value===i(d).BLOCK_LEFT,"my-3 block mx-auto":a.value===i(d).BLOCK_CENTER,"my-3 block ml-auto mr-0":a.value===i(d).BLOCK_RIGHT,"inline-block":a.value===i(d).INLINE,"my-3 block float-left ml-0":a.value===i(d).FLOAT_LEFT,"my-3 block float-right mr-0":a.value===i(d).FLOAT_RIGHT}])},{default:U(()=>{var s;return[Z("img",{src:k.value,title:e.node.attrs.title,alt:e.node.attrs.alt,width:I.value,class:"cursor-pointer",onMouseenter:t[0]||(t[0]=r=>v.value=!0),onMouseleave:t[1]||(t[1]=r=>v.value=!1)},null,40,ne),(s=e.editor)!=null&&s.isEditable?(b(),E("div",{key:0,class:y(["border-2 border-solid border-transparent w-full h-full absolute left-0 top-0 pointer-events-none transition-all",{"border-warning":v.value&&!e.selected&&!c.value,"!border-info":e.selected||c.value}])},[a.value!==i(d).INLINE?(b(),E("div",{key:0,class:y(["btn btn-circle btn-xs absolute -top-3 pointer-events-auto opacity-0",{"btn-warning opacity-100":v.value&&!e.selected,"btn-info opacity-100":e.selected}]),style:{left:"min(10%, 50px)"},onMouseenter:t[2]||(t[2]=r=>v.value=!0),onMouseleave:t[3]||(t[3]=r=>v.value=!1),onClick:t[4]||(t[4]=r=>z("top"))},[P(i(T),{name:"enter",width:"18",height:"18"})],34)):L("",!0),a.value!==i(d).INLINE?(b(),E("div",{key:1,class:y(["btn btn-circle btn-xs absolute -bottom-3 pointer-events-auto opacity-0",{"btn-warning opacity-100":v.value&&!e.selected,"btn-info opacity-100":e.selected}]),style:{right:"min(10%, 50px)"},onMouseenter:t[5]||(t[5]=r=>v.value=!0),onMouseleave:t[6]||(t[6]=r=>v.value=!1),onClick:t[7]||(t[7]=r=>z("bottom"))},[P(i(T),{name:"enter",width:"18",height:"18"})],34)):L("",!0),(b(!0),E(j,null,J(R.value,r=>(b(),E("span",{key:r,class:y(["border border-solid rounded-sm box-border block w-3 h-3 absolute pointer-events-auto transition-all",{"border-white bg-info":e.selected||c.value,"border-transparent bg-transparent":!e.selected&&!c.value,"cursor-nw-resize -left-1.5 -top-1.5":r==="tl","cursor-ne-resize -right-1.5 -top-1.5":r==="tr","cursor-sw-resize -bottom-1.5 -left-1.5":r==="bl","cursor-se-resize -bottom-1.5 -right-1.5":r==="br"}]),onMousedown:m=>D(m,r)},null,42,re))),128))],2)):L("",!0)]}),_:1},8,["style","data-image","class"]))}});export{ve as default};
1
+ import{defineComponent as H,ref as f,computed as x,onBeforeMount as K,onMounted as G,onBeforeUnmount as W,openBlock as b,createBlock as X,unref as i,normalizeStyle as Y,normalizeClass as y,withCtx as U,createElementVNode as Z,createElementBlock as E,createVNode as P,createCommentVNode as L,Fragment as j,renderList as J}from"vue";import{Editor as Q}from"@tiptap/core";import{NodeViewWrapper as ee}from"@tiptap/vue-3";import{ResizeObserver as te}from"@juggle/resize-observer";import{resolveImg as oe,IMAGE_DISPLAY_PRESETS as d,clamp as B}from"../utils";import{Icon as T}from".";const ne=["src","title","alt","width"],re=["onMousedown"],w=50,$=1e5,ve=H({__name:"ImageView",props:{editor:{type:Q,required:!0},selected:{type:Boolean,required:!0},node:{type:Object,required:!0},getPos:{type:Function,required:!0},updateAttributes:{type:Function,required:!0},deleteNode:{type:Function,required:!0}},setup(F){const e=F,v=f(!1),M=f({width:0,height:0}),h=f({width:$,height:$}),R=f(["tl","tr","bl","br"]),c=f(!1),p=f({x:0,y:0,w:0,h:0,dir:""}),k=x(()=>e.node.attrs.src),I=x(()=>e.node.attrs.width),a=x(()=>e.node.attrs.display);let g;function O(){e.editor.commands.setNodeSelection(e.getPos())}function q(){const{width:o,paddingLeft:t,paddingRight:s}=getComputedStyle(e.editor.view.dom);h.value.width=parseInt(o,10)-parseInt(t,10)-parseInt(s,10)}function D(o,t){o.preventDefault(),o.stopPropagation(),p.value.x=o.clientX,p.value.y=o.clientY;const s=M.value.width,r=M.value.height,m=s/r;let{width:n,height:u}=e.node.attrs;const l=h.value.width;n&&!u?(n=n>l?l:n,u=Math.round(n/m)):u&&!n?(n=Math.round(u*m),n=n>l?l:n):!n&&!u?(n=s>l?l:s,u=Math.round(n/m)):n=n>l?l:n,p.value.w=n,p.value.h=u,p.value.dir=t,c.value=!0,V()}function N(o){var C,A;if(o.preventDefault(),o.stopPropagation(),!c.value)return;const{x:t,y:s,w:r,h:m,dir:n}=p.value,u=(o.clientX-t)*(/l/.test(n)?-1:1),l=(o.clientY-s)*(/t/.test(n)?-1:1);a.value===d.BLOCK_CENTER?(C=e.updateAttributes)==null||C.call(e,{width:B(r+2*u,w,h.value.width),height:Math.max(m+2*l,w)}):(A=e.updateAttributes)==null||A.call(e,{width:B(r+u,w,h.value.width),height:Math.max(m+l,w)})}function S(o){o.preventDefault(),o.stopPropagation(),c.value&&(c.value=!1,p.value={x:0,y:0,w:0,h:0,dir:""},_(),O())}function V(){document.addEventListener("mousemove",N,!0),document.addEventListener("mouseup",S,!0)}function _(){document.removeEventListener("mousemove",N,!0),document.removeEventListener("mouseup",S,!0)}function z(o){let t=null;console.log(e.node.nodeSize),o==="top"?t=e.getPos():o==="bottom"&&(t=e.getPos()+e.node.nodeSize-1),console.log(t),e.editor.commands.insertContentAt(t,"<p></p>",{updateSelection:!0})}return K(async()=>{const o=await oe(k.value);o.complete||(o.width=w,o.height=w),M.value={width:o.width,height:o.height},I.value===null&&(h.value.width>=o.width?e.updateAttributes({width:o.width}):e.updateAttributes({width:h.value.width}))}),G(()=>{g=new te(()=>{q()}),g.observe(e.editor.view.dom)}),W(()=>{g==null||g.disconnect()}),(o,t)=>(b(),X(i(ee),{as:"figure",style:Y(`width: min(100%, ${I.value}px)`),"data-image":a.value===i(d).INLINE?"inline":"block",class:y(["align-baseline relative",{"my-3 block ml-0 mr-auto":a.value===i(d).BLOCK_LEFT,"my-3 block mx-auto":a.value===i(d).BLOCK_CENTER,"my-3 block ml-auto mr-0":a.value===i(d).BLOCK_RIGHT,"inline-block":a.value===i(d).INLINE,"my-3 block float-left ml-0":a.value===i(d).FLOAT_LEFT,"my-3 block float-right mr-0":a.value===i(d).FLOAT_RIGHT}])},{default:U(()=>{var s;return[Z("img",{src:k.value,title:e.node.attrs.title,alt:e.node.attrs.alt,width:I.value,class:"cursor-pointer",onMouseenter:t[0]||(t[0]=r=>v.value=!0),onMouseleave:t[1]||(t[1]=r=>v.value=!1)},null,40,ne),(s=e.editor)!=null&&s.isEditable?(b(),E("div",{key:0,class:y(["border-2 border-solid border-transparent w-full h-full absolute left-0 top-0 pointer-events-none transition-all",{"border-warning":v.value&&!e.selected&&!c.value,"!border-info":e.selected||c.value}])},[a.value!==i(d).INLINE?(b(),E("div",{key:0,class:y(["btn btn-circle btn-xs absolute -top-3 pointer-events-auto opacity-0",{"btn-warning opacity-100":v.value&&!e.selected,"btn-info opacity-100":e.selected}]),style:{left:"min(10%, 50px)"},onMouseenter:t[2]||(t[2]=r=>v.value=!0),onMouseleave:t[3]||(t[3]=r=>v.value=!1),onClick:t[4]||(t[4]=r=>z("top"))},[P(i(T),{name:"enter",width:"18",height:"18"})],34)):L("",!0),a.value!==i(d).INLINE?(b(),E("div",{key:1,class:y(["btn btn-circle btn-xs absolute -bottom-3 pointer-events-auto opacity-0",{"btn-warning opacity-100":v.value&&!e.selected,"btn-info opacity-100":e.selected}]),style:{right:"min(10%, 50px)"},onMouseenter:t[5]||(t[5]=r=>v.value=!0),onMouseleave:t[6]||(t[6]=r=>v.value=!1),onClick:t[7]||(t[7]=r=>z("bottom"))},[P(i(T),{name:"enter",width:"18",height:"18"})],34)):L("",!0),(b(!0),E(j,null,J(R.value,r=>(b(),E("span",{key:r,class:y(["border border-solid rounded-sm box-border block w-3 h-3 absolute pointer-events-auto transition-all",{"border-white bg-info":e.selected||c.value,"border-transparent bg-transparent":!e.selected&&!c.value,"cursor-nw-resize -left-1.5 -top-1.5":r==="tl","cursor-ne-resize -right-1.5 -top-1.5":r==="tr","cursor-sw-resize -bottom-1.5 -left-1.5":r==="bl","cursor-se-resize -bottom-1.5 -right-1.5":r==="br"}]),onMousedown:m=>D(m,r)},null,42,re))),128))],2)):L("",!0)]}),_:1},8,["style","data-image","class"]))}});export{ve as default};
@@ -1 +1 @@
1
- import{Extension as f}from"@tiptap/core";import{Plugin as m,PluginKey as p}from"@tiptap/pm/state";import{DecorationSet as c,Decoration as h}from"@tiptap/pm/view";const g=f.create({name:"focus",addOptions(){return{className:"text-success",mode:"all"}},addProseMirrorPlugins(){return[new m({key:new p("focus"),props:{decorations:({doc:s,selection:a})=>{const{isEditable:u,isFocused:d}=this.editor,{anchor:r}=a,n=[];if(!u||!d)return c.create(s,[]);let i=0;this.options.mode==="deepest"&&s.descendants((t,e)=>{if(t.isText)return;if(!(r>=e&&r<=e+t.nodeSize-1))return!1;i+=1});let o=0;return s.descendants((t,e)=>{if(t.isText||!(r>=e&&r<=e+t.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&i-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";n.push(h.node(e,e+t.nodeSize,{class:this.options.className}))}),c.create(s,n)}}})]}});export{g as Focus};
1
+ import{Extension as f}from"@tiptap/core";import{Plugin as m,PluginKey as p}from"@tiptap/pm/state";import{DecorationSet as a,Decoration as h}from"@tiptap/pm/view";const g=f.create({name:"focus",addOptions(){return{className:"",mode:"all"}},addProseMirrorPlugins(){return[new m({key:new p("focus"),props:{decorations:({doc:s,selection:c})=>{const{isEditable:u,isFocused:d}=this.editor,{anchor:r}=c,n=[];if(!u||!d)return a.create(s,[]);let i=0;this.options.mode==="deepest"&&s.descendants((t,e)=>{if(t.isText)return;if(!(r>=e&&r<=e+t.nodeSize-1))return!1;i+=1});let o=0;return s.descendants((t,e)=>{if(t.isText||!(r>=e&&r<=e+t.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&i-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";n.push(h.node(e,e+t.nodeSize,{class:this.options.className}))}),a.create(s,n)}}})]}});export{g as Focus};
@@ -1 +1 @@
1
- import{Node as i,mergeAttributes as s,nodeInputRule as a}from"@tiptap/core";import{VueNodeViewRenderer as u}from"@tiptap/vue-3";import{DEFAULT_IMAGE_URL_REGEX as d,DEFAULT_IMAGE_DISPLAY as m,IMAGE_DISPLAY_PRESETS as r}from"../utils";import{InsertImageDropdown as c,ImageView as f}from"../components";const p=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,h=i.create({name:"image-block",addOptions(){return{allowBase64:!1,HTMLAttributes:{},urlPattern:d,btn({editor:e,i18n:t}){return{component:c,componentProps:{editor:e,tooltip:t("editor.extensions.Image.buttons.insert_image.tooltip"),isActive:e.isActive("block-image"),isDisabled:!1}}}}},inline:!1,group:"block",draggable:!0,addAttributes(){return{src:{default:null,parseHTML:e=>e.children[0].src||""},alt:{default:null},title:{default:null},width:{default:null,parseHTML:e=>{const t=e.style.width||e.getAttribute("width")||null;return t==null?null:parseInt(t,10)},renderHTML:e=>({width:e.width})},display:{default:m,parseHTML:e=>{const t=e.className;return t.indexOf("float-left")!==-1?r.FLOAT_LEFT:t.indexOf("float-right")!==-1?r.FLOAT_RIGHT:t.indexOf("mr-auto")!==-1?r.BLOCK_LEFT:t.indexOf("ml-auto")!==-1?r.BLOCK_RIGHT:r.BLOCK_CENTER},renderHTML:e=>{if(e.display===r.FLOAT_LEFT)return{class:"my-3 block float-left ml-0"};if(e.display===r.FLOAT_RIGHT)return{class:"my-3 block float-right mr-0"};if(e.display===r.BLOCK_LEFT)return{class:"my-3 block ml-0 mr-auto"};if(e.display===r.BLOCK_RIGHT)return{class:"my-3 block ml-auto mr-0"};if(e.display===r.BLOCK_CENTER)return{class:"my-3 block mx-auto"}}}}},parseHTML(){return[{tag:'figure[data-image="block"]'}]},renderHTML({HTMLAttributes:e}){const t={...e};return t.src=null,t.width&&(t.style=`width: ${t.width}px`,t.width=null),e.class=null,["figure",s({class:"align-baseline relative","data-image":"block"},t),["img",s(this.options.HTMLAttributes,e)]]},addCommands(){return{setBlockImage:e=>({state:t,view:l,chain:n})=>{if(l.endOfTextblock("left")){const o=t.selection.from-1;return n().insertContentAt(o,{type:this.name,attrs:e}).setNodeSelection(o).run()}else{const o=t.selection.from;return n().insertContent({type:this.name,attrs:e}).setNodeSelection(o+1).run()}},toggleBlockImage:e=>({state:t,chain:l})=>{if(t.selection.$anchor.parent.childCount===1){const n=t.selection.from;return l().deleteNode("paragraph").insertContentAt(n-1,{type:this.name,attrs:e}).setNodeSelection(n-1).run()}else return l().setBlockImage(e).run()}}},addInputRules(){return[a({find:p,type:this.type,getAttributes:e=>{const[,,t,l,n]=e;return{src:l,alt:t,title:n}}})]},addNodeView(){return u(f)}});export{h as ImageBlock,p as inputRegex};
1
+ import{Node as i,mergeAttributes as s,nodeInputRule as a}from"@tiptap/core";import{VueNodeViewRenderer as u}from"@tiptap/vue-3";import{DEFAULT_IMAGE_URL_REGEX as d,DEFAULT_IMAGE_DISPLAY as m,IMAGE_DISPLAY_PRESETS as r}from"../utils";import{InsertImageDropdown as c,ImageView as f}from"../components";const p=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,h=i.create({name:"image-block",addOptions(){return{allowBase64:!1,HTMLAttributes:{},urlPattern:d,btn({editor:e,i18n:t}){return{component:c,componentProps:{editor:e,tooltip:t("editor.extensions.Image.buttons.insert_image.tooltip"),isActive:e.isActive("block-image"),isDisabled:!1}}}}},inline:!1,group:"block",draggable:!0,addAttributes(){return{src:{default:null,parseHTML:e=>e.children[0].src||""},alt:{default:null},title:{default:null},width:{default:null,parseHTML:e=>{const t=e.style.width||e.getAttribute("width")||null;return t==null?null:parseInt(t,10)},renderHTML:e=>({width:e.width})},display:{default:m,parseHTML:e=>{const t=e.className;return t.indexOf("float-left")!==-1?r.FLOAT_LEFT:t.indexOf("float-right")!==-1?r.FLOAT_RIGHT:t.indexOf("mr-auto")!==-1?r.BLOCK_LEFT:t.indexOf("ml-auto")!==-1?r.BLOCK_RIGHT:r.BLOCK_CENTER},renderHTML:e=>{if(e.display===r.FLOAT_LEFT)return{class:"my-3 block float-left ml-0"};if(e.display===r.FLOAT_RIGHT)return{class:"my-3 block float-right mr-0"};if(e.display===r.BLOCK_LEFT)return{class:"my-3 block ml-0 mr-auto"};if(e.display===r.BLOCK_RIGHT)return{class:"my-3 block ml-auto mr-0"};if(e.display===r.BLOCK_CENTER)return{class:"my-3 block mx-auto"}}}}},parseHTML(){return[{tag:'figure[data-image="block"]'}]},renderHTML({HTMLAttributes:e}){const t={...e};return t.src=null,t.width&&(t.style=`width: min(100%, ${t.width}px)`,t.width=null),e.class=null,["figure",s({class:"align-baseline relative","data-image":"block"},t),["img",s(this.options.HTMLAttributes,e)]]},addCommands(){return{setBlockImage:e=>({state:t,view:l,chain:n})=>{if(l.endOfTextblock("left")){const o=t.selection.from-1;return n().insertContentAt(o,{type:this.name,attrs:e}).setNodeSelection(o).run()}else{const o=t.selection.from;return n().insertContent({type:this.name,attrs:e}).setNodeSelection(o+1).run()}},toggleBlockImage:e=>({state:t,chain:l})=>{if(t.selection.$anchor.parent.childCount===1){const n=t.selection.from;return l().deleteNode("paragraph").insertContentAt(n-1,{type:this.name,attrs:e}).setNodeSelection(n-1).run()}else return l().setBlockImage(e).run()}}},addInputRules(){return[a({find:p,type:this.type,getAttributes:e=>{const[,,t,l,n]=e;return{src:l,alt:t,title:n}}})]},addNodeView(){return u(f)}});export{h as ImageBlock,p as inputRegex};
@@ -1 +1 @@
1
- import{Node as i,mergeAttributes as u,nodeInputRule as s}from"@tiptap/core";import{VueNodeViewRenderer as l}from"@tiptap/vue-3";import{IMAGE_DISPLAY_PRESETS as d}from"../utils";import{ImageView as a}from"../components";const o=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,I=i.create({name:"image-inline",addOptions(){return{HTMLAttributes:{}}},inline:!0,group:"inline",draggable:!0,addAttributes(){return{src:{default:null,parseHTML:e=>e.getAttribute("src")||null,renderHTML:e=>({src:e.src})},alt:{default:null},width:{default:null,parseHTML:e=>{const t=e.getAttribute("width")||null;return t===null?null:parseInt(t,10)},renderHTML:e=>({width:e.width})},display:{default:d.INLINE}}},parseHTML(){return[{tag:"img[src]"}]},renderHTML({HTMLAttributes:e}){return["img",u(this.options.HTMLAttributes,e,{class:"inline-block align-baseline"})]},addCommands(){return{setInlineImage:e=>({state:t,chain:r})=>{const n=t.selection.from;return r().insertContent({type:this.name,attrs:e}).setNodeSelection(n+1).run()}}},addInputRules(){return[s({find:o,type:this.type,getAttributes:e=>{const[,,t,r,n]=e;return{src:r,alt:t,title:n}}})]},addNodeView(){return l(a)}});export{I as ImageInline};
1
+ import{Node as i,mergeAttributes as u,nodeInputRule as l}from"@tiptap/core";import{VueNodeViewRenderer as s}from"@tiptap/vue-3";import{IMAGE_DISPLAY_PRESETS as d}from"../utils";import{ImageView as a}from"../components";const o=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,I=i.create({name:"image-inline",addOptions(){return{HTMLAttributes:{}}},inline:!0,group:"inline",draggable:!0,addAttributes(){return{src:{default:null,parseHTML:e=>e.getAttribute("src")||null,renderHTML:e=>({src:e.src})},alt:{default:null},width:{default:null,parseHTML:e=>{const t=e.getAttribute("width")||null;return t===null?null:parseInt(t,10)},renderHTML:e=>({width:e.width,style:`width: min(100%, ${e.width}px)`})},display:{default:d.INLINE}}},parseHTML(){return[{tag:"img[src]"}]},renderHTML({HTMLAttributes:e}){return["img",u(this.options.HTMLAttributes,e,{class:"inline-block align-baseline"})]},addCommands(){return{setInlineImage:e=>({state:t,chain:r})=>{const n=t.selection.from;return r().insertContent({type:this.name,attrs:e}).setNodeSelection(n+1).run()}}},addInputRules(){return[l({find:o,type:this.type,getAttributes:e=>{const[,,t,r,n]=e;return{src:r,alt:t,title:n}}})]},addNodeView(){return s(a)}});export{I as ImageInline};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "daisy-tiptap-test",
3
3
  "private": false,
4
- "version": "0.0.16",
4
+ "version": "0.0.18",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "@juggle/resize-observer": "^3.4.0",