@kedataindo/docflow-vue 0.0.63 → 0.0.64
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.
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -15227,7 +15227,7 @@ ${n.innerHTML}
|
|
|
15227
15227
|
</terms>
|
|
15228
15228
|
</locale>
|
|
15229
15229
|
`,qE=HE,wa={"chicago-notes-bibliography":{id:"chicago-notes-bibliography",name:"Chicago (notes & bibliography)",category:"note",xml:RE},"chicago-author-date":{id:"chicago-author-date",name:"Chicago (author-date)",category:"in-text",xml:BE},apa:{id:"apa",name:"APA",category:"in-text",xml:FE},"modern-language-association":{id:"modern-language-association",name:"MLA",category:"in-text",xml:UE}},jE="chicago-notes-bibliography",$E=qE,Td=0;function Qm(){return Td+=1,`cite-${Date.now().toString(36)}-${Td.toString(36)}`}var WE=/^<\/?(i|b|em|strong|sup|sub|span|nobr)( style="font-variant: ?small-caps;?")?\/?>$|^<div class="csl-entry">$|^<\/div>$/;function Nd(e){return e.replace(/<[^>]*>/g,t=>WE.test(t)?t:t.replace(/</g,"<").replace(/>/g,">"))}var GE=class{constructor(e={}){fn(this,"sources",new Map);fn(this,"style");fn(this,"clusters",new Map);fn(this,"order",[]);fn(this,"rendered",new Map);fn(this,"bibliography",[]);fn(this,"listeners",new Set);fn(this,"lastSignature","");this.style=e.style&&wa[e.style]?e.style:jE,this.updateSources(e.sources??[],!1)}getStyle(){return this.style}isNoteStyle(){var e;return((e=wa[this.style])==null?void 0:e.category)==="note"}getSource(e){return this.sources.get(e)}getSourceIds(){return[...this.sources.keys()]}getCitedSourceIds(){const e=new Set;for(const t of this.clusters.values())t.sourceId&&e.add(t.sourceId);return[...e]}setStyle(e){!wa[e]||e===this.style||(this.style=e,this.recompute(),this.emitChange())}updateSources(e,t=!0){this.sources=new Map(e.map(n=>[n.id,n])),this.recompute(),t&&this.emitChange()}onChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}syncCitations(e){const t=e.map(n=>{const i=n.attrs;return`${n.citationId}|${i.sourceId??""}|${i.locator??""}|${i.label??""}|${i.mode??""}|${i.prefix??""}|${i.suffix??""}`}).join(`
|
|
15230
|
-
`);return t===this.lastSignature?!1:(this.lastSignature=t,this.clusters=new Map(e.map(n=>[n.citationId,n.attrs])),this.order=e.map(n=>n.citationId),this.recompute(),this.emitChange(),!0)}renderCluster(e){return this.rendered.get(e)??""}getBibliography(){return this.bibliography}emitChange(){for(const e of this.listeners)e()}recompute(){const e=wa[this.style],t=new d3.Engine({retrieveLocale:()=>$E,retrieveItem:a=>this.sources.get(a)},e.xml,"en-US"),n=new Map,i=[];let r=0;for(const a of this.order){const o=this.clusters.get(a);if(!(o!=null&&o.sourceId)||!this.sources.has(o.sourceId)){n.set(a,"");continue}r+=1;try{const[,l]=t.processCitationCluster({citationID:a,citationItems:[{id:o.sourceId,locator:o.locator||void 0,label:o.label||void 0,prefix:o.prefix||void 0,suffix:o.suffix||void 0,"suppress-author":o.mode==="suppress-author"||void 0,"author-only":o.mode==="author-only"||void 0}],properties:{noteIndex:e.category==="note"?r:0}},i,[]);i.push([a,r]);for(const[,c,u]of l??[])n.set(u,Nd(c));n.has(a)||n.set(a,"")}catch{n.set(a,"")}}this.rendered=n;try{const a=t.makeBibliography();this.bibliography=a?a[1].map(o=>Nd(o).trim()):[]}catch{this.bibliography=[]}}};function Od(e){const t=e.storage.citationEngine;return(t==null?void 0:t.engine)??null}var KE=Se.create({name:"bibliography",group:"block",selectable:!0,draggable:!0,atom:!0,parseHTML(){return[{tag:'div[data-node-type="bibliography"]'}]},renderHTML({HTMLAttributes:e}){return["div",Be(e,{"data-node-type":"bibliography",class:"docs-bibliography"})]},addNodeView(){return e=>{const t=e.editor,n=document.createElement("div");n.className="docs-bibliography",n.setAttribute("data-node-type","bibliography");const i=()=>{const o=Od(t),l=(o==null?void 0:o.getBibliography())??[];if(n.innerHTML="",l.length===0){const f=document.createElement("p");f.className="docs-bibliography__empty",f.textContent="Bibliography",n.appendChild(f);return}const c=document.createElement("h2");c.className="docs-bibliography__heading",c.textContent="Bibliography",n.appendChild(c);const u=document.createElement("div");u.className="docs-bibliography__entries";for(const f of l){const m=document.createElement("p");m.className="docs-bibliography__entry",m.innerHTML=f,u.appendChild(m)}n.appendChild(u)};i();const r=Od(t),a=r==null?void 0:r.onChange(i);return{dom:n,update(o){var l;return((l=o==null?void 0:o.type)==null?void 0:l.name)==="bibliography"},destroy(){a==null||a()}}}}});function Ym(e,t){const n=Qm();return e.isNoteStyle()?{type:"footnote",attrs:{content:"",sourceId:t.sourceId,locator:t.locator??"",citationId:n}}:{type:"citation",attrs:{citationId:n,sourceId:t.sourceId,locator:t.locator??""}}}function Ri(e){return e.storage.citationEngine?e.storage.citationEngine.engine??null:null}var XE=qe.create({name:"citationEngine",addStorage(){return{engine:null}},onUpdate(){var r,a;const e=this.editor,t=Ri(e);if(!t)return;{const o=new Set,l=[];if(e.state.doc.descendants((c,u)=>{if(c.type.name==="citation"||c.type.name==="footnote"&&c.attrs.sourceId){const f=c.attrs.citationId;f&&(o.has(f)?l.push({pos:u,attrs:{...c.attrs}}):o.add(f))}return!0}),l.length>0){const c=e.state.tr;for(const{pos:u,attrs:f}of l)c.setNodeMarkup(u,void 0,{...f,citationId:Qm()});e.view.dispatch(c);return}}const n=[];if(e.state.doc.descendants((o,l)=>((o.type.name==="citation"||o.type.name==="footnote"&&o.attrs.sourceId)&&n.push({citationId:o.attrs.citationId??`anon-${l}`,attrs:{sourceId:o.attrs.sourceId??null,locator:o.attrs.locator||"",label:o.attrs.label||"page",mode:o.attrs.mode||"normal",prefix:o.attrs.prefix||"",suffix:o.attrs.suffix||""}}),!0)),t.syncCitations(n)){const o=e.storage.editorContext;(a=(r=o==null?void 0:o.citation)==null?void 0:r.onSourcesChange)==null||a.call(r,t.getCitedSourceIds())}{const o=[];if(e.state.doc.descendants((l,c)=>{if(l.type.name==="footnote"&&l.attrs.sourceId){const u=l.attrs.citationId;if(!u)return!0;const f=t.renderCluster(u);f&&f!==l.attrs.content&&o.push({pos:c,content:f})}return!0}),o.length>0){const l=e.state.tr;for(const{pos:c,content:u}of o){const f=e.state.doc.nodeAt(c);f&&l.setNodeMarkup(c,void 0,{...f.attrs,content:u})}e.view.dispatch(l)}}}}),JE=Se.create({name:"citation",group:"inline",inline:!0,selectable:!0,draggable:!1,atom:!0,addAttributes(){return{citationId:{default:null,parseHTML:e=>e.getAttribute("data-citation-id"),renderHTML:e=>({"data-citation-id":e.citationId})},sourceId:{default:null,parseHTML:e=>e.getAttribute("data-citation-source-id"),renderHTML:e=>({"data-citation-source-id":e.sourceId})},locator:{default:"",parseHTML:e=>e.getAttribute("data-citation-locator")??"",renderHTML:e=>({"data-citation-locator":e.locator})},label:{default:"page",parseHTML:e=>e.getAttribute("data-citation-label")??"page",renderHTML:e=>({"data-citation-label":e.label})},mode:{default:"normal",parseHTML:e=>e.getAttribute("data-citation-mode")??"normal",renderHTML:e=>({"data-citation-mode":e.mode})},prefix:{default:""},suffix:{default:""}}},parseHTML(){return[{tag:'span[data-node-type="citation"]'}]},renderHTML({HTMLAttributes:e}){return["span",Be(e,{"data-node-type":"citation",class:"docs-citation"}),""]},addNodeView(){return e=>{const t=e.editor,n=e.node??e,i=document.createElement("span");i.className="docs-citation",i.setAttribute("data-node-type","citation");const r=()=>{const l=Ri(t),c=n.attrs.citationId,u=l&&c?l.renderCluster(c):"";u?(i.innerHTML=u,i.classList.remove("docs-citation--missing")):(i.textContent="[?]",i.classList.add("docs-citation--missing")),i.setAttribute("data-citation-id",String(n.attrs.citationId??"")),i.setAttribute("data-citation-source-id",String(n.attrs.sourceId??""))};r();const a=Ri(t),o=a==null?void 0:a.onChange(r);return{dom:i,update(l){var c;if(((c=l==null?void 0:l.type)==null?void 0:c.name)!=="citation")return!1;try{Object.assign(n.attrs,l.attrs),r()}catch{}return!0},destroy(){o==null||o()}}}}});function Md(e,t,n){const i=Ym(t,n);return i.type==="footnote"&&!e.schema.nodes.footnote?!1:e.chain().focus().insertContent({type:i.type,attrs:i.attrs}).run()}we.definePlugin({id:"citation",tiptapExtensions:[XE,JE,KE],toolbar:[{id:"insert-citation",label:"Citation",action:"insertCitation",iconComponent:"Quote"}],slashCommands:[{name:"Citation",command:"insertCitation"},{name:"Bibliography",command:"insertBibliography"}],commands:{insertCitation:(e,...t)=>{var o;const n=Ri(e);if(!n)return console.warn("[citation] no citation engine — inject the CitationPort to enable citations"),!1;const i=t[0];if(i!=null&&i.sourceId)return Md(e,n,{sourceId:i.sourceId,locator:i.locator});const r=e.storage.editorContext,a=(o=r==null?void 0:r.citation)==null?void 0:o.onSourceRequest;return a?(a().then(l=>{l&&Md(e,n,{sourceId:l})}),!0):!1},insertBibliography:e=>{let t=!1;return e.state.doc.descendants(n=>(n.type.name==="bibliography"&&(t=!0),!t)),t?!1:e.chain().focus().insertContent({type:"bibliography"}).run()},setCitationStyle:(e,...t)=>{const n=Ri(e),i=t[0];return!n||!i?!1:(n.setStyle(i),!0)}},hooks:{onInit(e){const t=e.storage.editorContext,n=t==null?void 0:t.citation;if(!n)return;const i=typeof n.sources=="function"?n.sources():n.sources,r=new GE({sources:i,style:n.style});e.storage.citationEngine.engine=r},onDestroy(e){e.storage.citationEngine.engine=null}}});function ZE(e){const t=e.storage.markdown;if(!t||typeof t!="object")return;const n=t.parser;if(!(!n||typeof n!="object"||!("parse"in n)))return n}function eh(e,t,n){const i=ZE(e);if(!i)return null;let r;try{r=i.parse(t,{inline:n.inline})}catch{return null}if(typeof r!="string")return null;const a=Di(r,e.schema,{slice:!0,parseOptions:{preserveWhitespace:"full"}});return a
|
|
15230
|
+
`);return t===this.lastSignature?!1:(this.lastSignature=t,this.clusters=new Map(e.map(n=>[n.citationId,n.attrs])),this.order=e.map(n=>n.citationId),this.recompute(),this.emitChange(),!0)}renderCluster(e){return this.rendered.get(e)??""}getBibliography(){return this.bibliography}emitChange(){for(const e of this.listeners)e()}recompute(){const e=wa[this.style],t=new d3.Engine({retrieveLocale:()=>$E,retrieveItem:a=>this.sources.get(a)},e.xml,"en-US"),n=new Map,i=[];let r=0;for(const a of this.order){const o=this.clusters.get(a);if(!(o!=null&&o.sourceId)||!this.sources.has(o.sourceId)){n.set(a,"");continue}r+=1;try{const[,l]=t.processCitationCluster({citationID:a,citationItems:[{id:o.sourceId,locator:o.locator||void 0,label:o.label||void 0,prefix:o.prefix||void 0,suffix:o.suffix||void 0,"suppress-author":o.mode==="suppress-author"||void 0,"author-only":o.mode==="author-only"||void 0}],properties:{noteIndex:e.category==="note"?r:0}},i,[]);i.push([a,r]);for(const[,c,u]of l??[])n.set(u,Nd(c));n.has(a)||n.set(a,"")}catch{n.set(a,"")}}this.rendered=n;try{const a=t.makeBibliography();this.bibliography=a?a[1].map(o=>Nd(o).trim()):[]}catch{this.bibliography=[]}}};function Od(e){const t=e.storage.citationEngine;return(t==null?void 0:t.engine)??null}var KE=Se.create({name:"bibliography",group:"block",selectable:!0,draggable:!0,atom:!0,parseHTML(){return[{tag:'div[data-node-type="bibliography"]'}]},renderHTML({HTMLAttributes:e}){return["div",Be(e,{"data-node-type":"bibliography",class:"docs-bibliography"})]},addNodeView(){return e=>{const t=e.editor,n=document.createElement("div");n.className="docs-bibliography",n.setAttribute("data-node-type","bibliography");const i=()=>{const o=Od(t),l=(o==null?void 0:o.getBibliography())??[];if(n.innerHTML="",l.length===0){const f=document.createElement("p");f.className="docs-bibliography__empty",f.textContent="Bibliography",n.appendChild(f);return}const c=document.createElement("h2");c.className="docs-bibliography__heading",c.textContent="Bibliography",n.appendChild(c);const u=document.createElement("div");u.className="docs-bibliography__entries";for(const f of l){const m=document.createElement("p");m.className="docs-bibliography__entry",m.innerHTML=f,u.appendChild(m)}n.appendChild(u)};i();const r=Od(t),a=r==null?void 0:r.onChange(i);return{dom:n,update(o){var l;return((l=o==null?void 0:o.type)==null?void 0:l.name)==="bibliography"},destroy(){a==null||a()}}}}});function Ym(e,t){const n=Qm();return e.isNoteStyle()?{type:"footnote",attrs:{content:"",sourceId:t.sourceId,locator:t.locator??"",citationId:n}}:{type:"citation",attrs:{citationId:n,sourceId:t.sourceId,locator:t.locator??""}}}function Ri(e){return e.storage.citationEngine?e.storage.citationEngine.engine??null:null}var XE=qe.create({name:"citationEngine",addStorage(){return{engine:null}},onUpdate(){var r,a;const e=this.editor,t=Ri(e);if(!t)return;{const o=new Set,l=[];if(e.state.doc.descendants((c,u)=>{if(c.type.name==="citation"||c.type.name==="footnote"&&c.attrs.sourceId){const f=c.attrs.citationId;f&&(o.has(f)?l.push({pos:u,attrs:{...c.attrs}}):o.add(f))}return!0}),l.length>0){const c=e.state.tr;for(const{pos:u,attrs:f}of l)c.setNodeMarkup(u,void 0,{...f,citationId:Qm()});e.view.dispatch(c);return}}const n=[];if(e.state.doc.descendants((o,l)=>((o.type.name==="citation"||o.type.name==="footnote"&&o.attrs.sourceId)&&n.push({citationId:o.attrs.citationId??`anon-${l}`,attrs:{sourceId:o.attrs.sourceId??null,locator:o.attrs.locator||"",label:o.attrs.label||"page",mode:o.attrs.mode||"normal",prefix:o.attrs.prefix||"",suffix:o.attrs.suffix||""}}),!0)),t.syncCitations(n)){const o=e.storage.editorContext;(a=(r=o==null?void 0:o.citation)==null?void 0:r.onSourcesChange)==null||a.call(r,t.getCitedSourceIds())}{const o=[];if(e.state.doc.descendants((l,c)=>{if(l.type.name==="footnote"&&l.attrs.sourceId){const u=l.attrs.citationId;if(!u)return!0;const f=t.renderCluster(u);f&&f!==l.attrs.content&&o.push({pos:c,content:f})}return!0}),o.length>0){const l=e.state.tr;for(const{pos:c,content:u}of o){const f=e.state.doc.nodeAt(c);f&&l.setNodeMarkup(c,void 0,{...f.attrs,content:u})}e.view.dispatch(l)}}}}),JE=Se.create({name:"citation",group:"inline",inline:!0,selectable:!0,draggable:!1,atom:!0,addAttributes(){return{citationId:{default:null,parseHTML:e=>e.getAttribute("data-citation-id"),renderHTML:e=>({"data-citation-id":e.citationId})},sourceId:{default:null,parseHTML:e=>e.getAttribute("data-citation-source-id"),renderHTML:e=>({"data-citation-source-id":e.sourceId})},locator:{default:"",parseHTML:e=>e.getAttribute("data-citation-locator")??"",renderHTML:e=>({"data-citation-locator":e.locator})},label:{default:"page",parseHTML:e=>e.getAttribute("data-citation-label")??"page",renderHTML:e=>({"data-citation-label":e.label})},mode:{default:"normal",parseHTML:e=>e.getAttribute("data-citation-mode")??"normal",renderHTML:e=>({"data-citation-mode":e.mode})},prefix:{default:""},suffix:{default:""}}},parseHTML(){return[{tag:'span[data-node-type="citation"]'}]},renderHTML({HTMLAttributes:e}){return["span",Be(e,{"data-node-type":"citation",class:"docs-citation"}),""]},addNodeView(){return e=>{const t=e.editor,n=e.node??e,i=document.createElement("span");i.className="docs-citation",i.setAttribute("data-node-type","citation");const r=()=>{const l=Ri(t),c=n.attrs.citationId,u=l&&c?l.renderCluster(c):"";u?(i.innerHTML=u,i.classList.remove("docs-citation--missing")):(i.textContent="[?]",i.classList.add("docs-citation--missing")),i.setAttribute("data-citation-id",String(n.attrs.citationId??"")),i.setAttribute("data-citation-source-id",String(n.attrs.sourceId??""))};r();const a=Ri(t),o=a==null?void 0:a.onChange(r);return{dom:i,update(l){var c;if(((c=l==null?void 0:l.type)==null?void 0:c.name)!=="citation")return!1;try{Object.assign(n.attrs,l.attrs),r()}catch{}return!0},destroy(){o==null||o()}}}}});function Md(e,t,n){const i=Ym(t,n);return i.type==="footnote"&&!e.schema.nodes.footnote?!1:e.chain().focus().insertContent({type:i.type,attrs:i.attrs}).run()}we.definePlugin({id:"citation",tiptapExtensions:[XE,JE,KE],toolbar:[{id:"insert-citation",label:"Citation",action:"insertCitation",iconComponent:"Quote"}],slashCommands:[{name:"Citation",command:"insertCitation"},{name:"Bibliography",command:"insertBibliography"}],commands:{insertCitation:(e,...t)=>{var o;const n=Ri(e);if(!n)return console.warn("[citation] no citation engine — inject the CitationPort to enable citations"),!1;const i=t[0];if(i!=null&&i.sourceId)return Md(e,n,{sourceId:i.sourceId,locator:i.locator});const r=e.storage.editorContext,a=(o=r==null?void 0:r.citation)==null?void 0:o.onSourceRequest;return a?(a().then(l=>{l&&Md(e,n,{sourceId:l})}),!0):!1},insertBibliography:e=>{let t=!1;return e.state.doc.descendants(n=>(n.type.name==="bibliography"&&(t=!0),!t)),t?!1:e.chain().focus().insertContent({type:"bibliography"}).run()},setCitationStyle:(e,...t)=>{const n=Ri(e),i=t[0];return!n||!i?!1:(n.setStyle(i),!0)}},hooks:{onInit(e){const t=e.storage.editorContext,n=t==null?void 0:t.citation;if(!n)return;const i=typeof n.sources=="function"?n.sources():n.sources,r=new GE({sources:i,style:n.style});e.storage.citationEngine.engine=r},onDestroy(e){e.storage.citationEngine.engine=null}}});function ZE(e){const t=e.storage.markdown;if(!t||typeof t!="object")return;const n=t.parser;if(!(!n||typeof n!="object"||!("parse"in n)))return n}function eh(e,t,n){const i=ZE(e);if(!i)return null;let r;try{r=i.parse(t,{inline:n.inline})}catch{return null}if(typeof r!="string")return null;const a=Di(r,e.schema,{slice:!0,parseOptions:{preserveWhitespace:"full"}});if(a instanceof J)return a;const o=a;return o&&typeof o.forEach=="function"&&typeof o.size=="number"?o:J.from(a)}function QE(e,t,n){const i=e.steps.length-1;if(i<t)return;const r=e.steps[i];if(!(r instanceof je||r instanceof Xe))return;const a=e.mapping.maps[i];let o=0;a.forEach((l,c,u,f)=>{o===0&&(o=f)}),e.setSelection(ge.near(e.doc.resolve(o),n))}function Dd(e,t,n,i,r){const a=eh(e,r,{inline:!1});if(!a){t.dispatch(t.state.tr.insertText(r,n,i));return}const o=t.state.tr;let l=n,c=i;if(l===c){let f=!0;if(a.forEach(m=>{m.isBlock||(f=!1)}),f){const p=o.doc.resolve(l).parent;p.isTextblock&&!p.type.spec.code&&!p.childCount&&(l-=1,c+=1)}}let u=!0;if(a.forEach(f=>{(!f.isText||f.marks.length>0)&&(u=!1)}),u){let f="";a.forEach(m=>{m.isText&&(f+=m.text??"")}),o.insertText(f,l,c)}else o.replaceWith(l,c,a);QE(o,0,-1),t.dispatch(o)}var nt=new et("docflow-ai"),zd=1500;function xl(e){var t;return(t=e.storage.editorContext)==null?void 0:t.aiStream}function Id(e,t,n){return{before:e.doc.textBetween(Math.max(0,t-zd),t,`
|
|
15231
15231
|
`," "),after:e.doc.textBetween(n,Math.min(e.doc.content.size,n+zd),`
|
|
15232
15232
|
`," ")}}function Rd(e,t,n){const i=xl(e);i&&(async()=>{const r=a=>{n.signal.aborted||e.isDestroyed||e.view.dispatch(e.state.tr.setMeta(nt,a))};try{for await(const a of i(t,n.signal)){if(n.signal.aborted||e.isDestroyed)return;r({type:"chunk",text:a})}r({type:"done"})}catch(a){r({type:"error",message:a instanceof Error?a.message:"AI request failed"})}})()}function Ld(e){var n;const t=e.storage.ai;(n=t.abort)==null||n.abort(),t.abort=null}var YE=qe.create({name:"ai",addStorage(){return{preview:null,abort:null}},addCommands(){return{aiTransform:e=>({editor:t,state:n,dispatch:i})=>{if(nt.getState(n))return!1;if(!xl(t))return console.warn("[ai] no aiStream port injected — AI actions are inert"),!1;const{from:r,to:a,empty:o}=n.selection;if(o)return!1;const l=n.doc.textBetween(r,a,`
|
|
15233
15233
|
`," ");if(!l.trim())return!1;const c=new AbortController;t.storage.ai.abort=c,i==null||i(n.tr.setMeta(nt,{type:"start",mode:"transform",status:"streaming",from:r,to:a,originalText:l,action:e.action}));const u={action:e.action,selection:l,context:Id(n,r,a),...e.prompt?{prompt:e.prompt}:{}};return Rd(t,u,c),!0},aiGenerate:()=>({editor:e,state:t,dispatch:n})=>{if(nt.getState(t))return!1;if(!xl(e))return console.warn("[ai] no aiStream port injected — AI actions are inert"),!1;const i=t.selection.to;return n==null||n(t.tr.setMeta(nt,{type:"start",mode:"generate",status:"prompt",from:i,to:i,originalText:"",action:"generate"})),!0},aiPromptSubmit:e=>({editor:t,state:n,dispatch:i})=>{var c;const r=nt.getState(n);if(!r||r.mode!=="generate"||r.status!=="prompt")return!1;const a=(c=e.prompt)==null?void 0:c.trim();if(!a)return!1;const o=new AbortController;t.storage.ai.abort=o,i==null||i(n.tr.setMeta(nt,{type:"start",mode:"generate",status:"streaming",from:r.from,to:r.to,originalText:"",action:"generate"}));const l={action:"generate",prompt:a,context:Id(n,r.from,r.to)};return Rd(t,l,o),t.commands.focus(),!0},aiAccept:()=>({editor:e,state:t,dispatch:n})=>{const i=nt.getState(t);if(!i||i.status==="prompt")return!1;if(Ld(e),!n)return!0;const r=t.tr;if(i.text.trim()){const a=eh(e,i.text,{inline:!0});a?r.replaceWith(i.from,i.to,a):r.replaceWith(i.from,i.to,t.schema.text(i.text))}return r.setMeta(nt,{type:"clear"}),n(r),!0},aiReject:()=>({editor:e,state:t,dispatch:n})=>nt.getState(t)?(Ld(e),n==null||n(t.tr.setMeta(nt,{type:"clear"})),!0):!1}},addProseMirrorPlugins(){const e=this.editor;let t=null;function n(){if(t)return t;const r=document.createElement("span");r.className="docs-ai-prompt";const a=document.createElement("input");return a.type="text",a.className="docs-ai-prompt__input",a.placeholder="Ask AI to write… (Enter ⏎ · Esc cancel)",a.addEventListener("keydown",o=>{o.key==="Enter"?(o.preventDefault(),e.commands.aiPromptSubmit({prompt:a.value})):o.key==="Escape"&&(o.preventDefault(),e.commands.aiReject())}),a.addEventListener("blur",()=>{const o=nt.getState(e.state);(o==null?void 0:o.status)==="prompt"&&e.commands.aiReject()}),r.appendChild(a),setTimeout(()=>a.focus(),0),t={dom:r,stopEvent:o=>o.target instanceof Node&&r.contains(o.target)},t}function i(r){const a=document.createElement("span");let o=null;if(r.status==="error")a.className="docs-ai-ghost docs-ai-ghost--error",a.textContent=` ${r.error??"AI error"} — press Esc`;else{a.className="docs-ai-ghost";const l=document.createElement("span");if(!r.text&&r.status==="streaming"?(l.textContent="AI writing…",l.className="docs-ai-ghost-placeholder"):l.textContent=r.text+(r.status==="streaming"?"▌":""),a.appendChild(l),r.status==="done"){o=document.createElement("span"),o.className="docs-ai-ghost-actions";const c=document.createElement("button");c.type="button",c.className="docs-ai-ghost-btn docs-ai-ghost-btn--accept",c.textContent="✓ Accept",c.title="Accept (Enter)",c.addEventListener("mousedown",f=>{f.preventDefault(),e.commands.aiAccept()});const u=document.createElement("button");u.type="button",u.className="docs-ai-ghost-btn docs-ai-ghost-btn--reject",u.textContent="✗ Reject",u.title="Reject (Esc)",u.addEventListener("mousedown",f=>{f.preventDefault(),e.commands.aiReject()}),o.appendChild(c),o.appendChild(u),a.appendChild(o)}}return{dom:a,stopEvent:l=>o!==null&&l.target instanceof Node&&o.contains(l.target)}}return[new ot({key:nt,state:{init:()=>null,apply(r,a){const o=r.getMeta(nt);if(o)switch(o.type){case"start":return{mode:o.mode,status:o.status,from:o.from,to:o.to,originalText:o.originalText,text:"",action:o.action};case"chunk":return a&&{...a,text:a.text+o.text};case"done":return a&&{...a,status:"done"};case"error":return a&&{...a,status:"error",error:o.message};case"clear":return null}if(!a)return a;if(a.status==="prompt"&&r.selectionSet)return null;if(r.docChanged){if(a.mode==="generate"){const u=r.mapping.map(a.from,1);return{...a,from:u,to:u}}const l=r.mapping.map(a.from,-1),c=r.mapping.map(a.to,1);return c<=l||r.doc.textBetween(l,c,`
|
package/dist/index.js
CHANGED
|
@@ -46499,7 +46499,9 @@ function _h(e, t, i) {
|
|
|
46499
46499
|
slice: !0,
|
|
46500
46500
|
parseOptions: { preserveWhitespace: "full" }
|
|
46501
46501
|
});
|
|
46502
|
-
|
|
46502
|
+
if (a instanceof ie) return a;
|
|
46503
|
+
const s = a;
|
|
46504
|
+
return s && typeof s.forEach == "function" && typeof s.size == "number" ? s : ie.from(a);
|
|
46503
46505
|
}
|
|
46504
46506
|
function q6(e, t, i) {
|
|
46505
46507
|
const n = e.steps.length - 1;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kedataindo/docflow-vue",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.64",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"lucide-vue-next": "^1.0.0",
|
|
26
26
|
"prosemirror-model": "^1.25.11",
|
|
27
|
-
"@kedataindo/docflow-core": "0.0.
|
|
28
|
-
"@kedataindo/docflow-layout-engine": "0.0.
|
|
29
|
-
"@kedataindo/docflow-plugins": "0.0.
|
|
27
|
+
"@kedataindo/docflow-core": "0.0.61",
|
|
28
|
+
"@kedataindo/docflow-layout-engine": "0.0.60",
|
|
29
|
+
"@kedataindo/docflow-plugins": "0.0.63"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"vue": "^3.5.0"
|