reactjs-tiptap-editor 0.3.30 → 0.4.0
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/README.md +8 -2
- package/lib/{ActionMenuButton-wiDnIxE2.cjs → ActionMenuButton-CYdM1xx5.cjs} +1 -1
- package/lib/{ActionMenuButton-B6fitGKu.js → ActionMenuButton-DKRF6oa0.js} +5 -5
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.d.cts +47 -51
- package/lib/Attachment.d.ts +47 -51
- package/lib/Attachment.js +7 -6
- package/lib/BaseKit.cjs +3 -0
- package/lib/BaseKit.d.cts +481 -0
- package/lib/BaseKit.d.ts +481 -0
- package/lib/BaseKit.js +132 -0
- package/lib/Blockquote.cjs +5 -1
- package/lib/Blockquote.d.cts +47 -51
- package/lib/Blockquote.d.ts +47 -51
- package/lib/Blockquote.js +33 -17
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.d.cts +47 -51
- package/lib/Bold.d.ts +47 -51
- package/lib/Bold.js +23 -16
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.d.cts +48 -52
- package/lib/BulletList.d.ts +48 -52
- package/lib/BulletList.js +11 -57
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.d.cts +47 -51
- package/lib/Clear.d.ts +47 -51
- package/lib/Clear.js +4 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.d.cts +47 -51
- package/lib/Code.d.ts +47 -51
- package/lib/Code.js +29 -25
- package/lib/CodeBlock.cjs +2 -2
- package/lib/CodeBlock.d.cts +47 -51
- package/lib/CodeBlock.d.ts +47 -51
- package/lib/CodeBlock.js +5 -4
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.d.cts +47 -51
- package/lib/CodeView.d.ts +47 -51
- package/lib/CodeView.js +3 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.d.cts +48 -52
- package/lib/Color.d.ts +48 -52
- package/lib/Color.js +42 -74
- package/lib/Document.cjs +1 -1
- package/lib/Document.d.cts +47 -51
- package/lib/Document.d.ts +47 -51
- package/lib/Document.js +4 -8
- package/lib/{Drawer-BKTU9CpU.js → Drawer-CaAfmqNo.js} +268 -265
- package/lib/Drawer-CdvCMSzN.cjs +1 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.d.cts +47 -51
- package/lib/Drawer.d.ts +47 -51
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.d.cts +50 -52
- package/lib/Emoji.d.ts +50 -52
- package/lib/Emoji.js +19790 -178
- package/lib/Excalidraw-BbMQhNvs.cjs +1 -0
- package/lib/Excalidraw-CVWz2Vyn.js +290 -0
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.d.cts +47 -51
- package/lib/Excalidraw.d.ts +47 -51
- package/lib/Excalidraw.js +3 -3
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.d.cts +47 -51
- package/lib/ExportPdf.d.ts +47 -51
- package/lib/ExportPdf.js +4 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.d.cts +47 -51
- package/lib/ExportWord.d.ts +47 -51
- package/lib/ExportWord.js +22 -51
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.d.cts +48 -52
- package/lib/FontFamily.d.ts +48 -52
- package/lib/FontFamily.js +46 -74
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.d.cts +47 -51
- package/lib/FontSize.d.ts +47 -51
- package/lib/FontSize.js +11 -8
- package/lib/FormatPainter.cjs +1 -1
- package/lib/FormatPainter.d.cts +47 -51
- package/lib/FormatPainter.d.ts +47 -51
- package/lib/FormatPainter.js +4 -2
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.d.cts +47 -51
- package/lib/Heading.d.ts +47 -51
- package/lib/Heading.js +77 -65
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.d.cts +47 -51
- package/lib/Highlight.d.ts +47 -51
- package/lib/Highlight.js +5 -4
- package/lib/History.cjs +1 -1
- package/lib/History.d.cts +49 -53
- package/lib/History.d.ts +49 -53
- package/lib/History.js +39 -403
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.d.cts +47 -51
- package/lib/HorizontalRule.d.ts +47 -51
- package/lib/HorizontalRule.js +16 -65
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.d.cts +47 -51
- package/lib/Iframe.d.ts +47 -51
- package/lib/Iframe.js +4 -4
- package/lib/Image.cjs +1 -1
- package/lib/Image.d.cts +47 -51
- package/lib/Image.d.ts +47 -51
- package/lib/Image.js +3 -3
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.d.cts +47 -51
- package/lib/ImageGif.d.ts +47 -51
- package/lib/ImageGif.js +5 -5
- package/lib/ImportWord.cjs +72 -72
- package/lib/ImportWord.d.cts +47 -51
- package/lib/ImportWord.d.ts +47 -51
- package/lib/ImportWord.js +5654 -5616
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.d.cts +47 -51
- package/lib/Indent.d.ts +47 -51
- package/lib/Indent.js +4 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.d.cts +47 -51
- package/lib/Italic.d.ts +47 -51
- package/lib/Italic.js +20 -14
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.d.cts +47 -51
- package/lib/Katex.d.ts +47 -51
- package/lib/Katex.js +49 -48
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.d.cts +47 -51
- package/lib/LineHeight.d.ts +47 -51
- package/lib/LineHeight.js +21 -18
- package/lib/Link.cjs +1 -1
- package/lib/Link.d.cts +47 -51
- package/lib/Link.d.ts +47 -51
- package/lib/Link.js +4 -4
- package/lib/ListItem.cjs +1 -1
- package/lib/ListItem.d.cts +52 -52
- package/lib/ListItem.d.ts +52 -52
- package/lib/ListItem.js +4 -30
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.d.cts +47 -51
- package/lib/Mention.d.ts +47 -51
- package/lib/Mention.js +161 -132
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.d.cts +47 -51
- package/lib/Mermaid.d.ts +47 -51
- package/lib/Mermaid.js +150 -147
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.d.cts +47 -51
- package/lib/MoreMark.d.ts +47 -51
- package/lib/MoreMark.js +5 -3
- package/lib/MultiColumn.cjs +1 -1
- package/lib/MultiColumn.d.cts +47 -51
- package/lib/MultiColumn.d.ts +47 -51
- package/lib/MultiColumn.js +2 -2
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.d.cts +48 -52
- package/lib/OrderedList.d.ts +48 -52
- package/lib/OrderedList.js +11 -75
- package/lib/RichTextEditor-CxvwGvQG.cjs +142 -0
- package/lib/RichTextEditor-DGcKEUGr.js +22166 -0
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.d.cts +60 -134
- package/lib/SearchAndReplace.d.ts +60 -134
- package/lib/SearchAndReplace.js +207 -194
- package/lib/Selection.cjs +1 -1
- package/lib/Selection.d.cts +47 -51
- package/lib/Selection.d.ts +47 -51
- package/lib/Selection.js +1 -1
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.d.cts +47 -51
- package/lib/SlashCommand.d.ts +47 -51
- package/lib/SlashCommand.js +177 -222
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.d.cts +47 -51
- package/lib/Strike.d.ts +47 -51
- package/lib/Strike.js +20 -14
- package/lib/SubAndSuperScript.cjs +1 -1
- package/lib/SubAndSuperScript.d.cts +47 -51
- package/lib/SubAndSuperScript.d.ts +47 -51
- package/lib/SubAndSuperScript.js +5 -3
- package/lib/Table.cjs +8 -10
- package/lib/Table.d.cts +50 -54
- package/lib/Table.d.ts +50 -54
- package/lib/Table.js +382 -2021
- package/lib/TableOfContent.cjs +1 -1
- package/lib/TableOfContent.d.cts +47 -51
- package/lib/TableOfContent.d.ts +47 -51
- package/lib/TableOfContent.js +53 -52
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.d.cts +49 -53
- package/lib/TaskList.d.ts +49 -53
- package/lib/TaskList.js +12 -154
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.d.cts +47 -51
- package/lib/TextAlign.d.ts +47 -51
- package/lib/TextAlign.js +11 -8
- package/lib/TextBubble.cjs +1 -1
- package/lib/TextBubble.d.cts +47 -51
- package/lib/TextBubble.d.ts +47 -51
- package/lib/TextBubble.js +5 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.d.cts +47 -51
- package/lib/TextDirection.d.ts +47 -51
- package/lib/TextDirection.js +15 -15
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.d.cts +47 -51
- package/lib/TextUnderline.d.ts +47 -51
- package/lib/TextUnderline.js +40 -12
- package/lib/TrailingNode.cjs +1 -1
- package/lib/TrailingNode.d.cts +47 -51
- package/lib/TrailingNode.d.ts +47 -51
- package/lib/TrailingNode.js +1 -1
- package/lib/Twitter-BFULyqdR.js +1628 -0
- package/lib/Twitter-Cutpkh3h.cjs +1 -0
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.d.cts +47 -51
- package/lib/Twitter.d.ts +47 -51
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.d.cts +47 -51
- package/lib/Video.d.ts +47 -51
- package/lib/Video.js +3 -3
- package/lib/bubble-extra.cjs +2 -2
- package/lib/bubble-extra.d.cts +47 -51
- package/lib/bubble-extra.d.ts +47 -51
- package/lib/bubble-extra.js +200 -192
- package/lib/dom-dataset-_6-diIRQ.cjs +33 -0
- package/lib/dom-dataset-lYeH6gfI.js +2361 -0
- package/lib/index-5iBZLua9.cjs +12 -0
- package/lib/index-6D1J-A-o.cjs +1 -0
- package/lib/index-B96Cclrj.cjs +3 -0
- package/lib/index-BBz7Nmv9.js +55 -0
- package/lib/index-BeCTd5v2.cjs +1 -0
- package/lib/index-ByurDDMv.js +237 -0
- package/lib/index-CUogRI7j.cjs +1 -0
- package/lib/index-Ch6dBBad.js +709 -0
- package/lib/index-DF2Lp4HZ.cjs +100 -0
- package/lib/{index-LUL9mqY4.js → index-D_L6n8O8.js} +4 -4
- package/lib/index-Dbvi-Bvh.cjs +1 -0
- package/lib/index-DpCrt7xs.cjs +1 -0
- package/lib/index-DsAX1Vq8.cjs +1 -0
- package/lib/index-Dy4DlW9o.js +12 -0
- package/lib/index-J3jHHZ4d.js +200 -0
- package/lib/{index-CsK90iVd.js → index-LmrOdnen.js} +302 -389
- package/lib/index-VvXaaKe3.js +898 -0
- package/lib/index-kbO3iWqL.js +13432 -0
- package/lib/index.cjs +1 -2
- package/lib/index.d.cts +49 -251
- package/lib/index.d.ts +49 -251
- package/lib/index.js +2 -588
- package/lib/jsx-runtime-CT7Pcg-t.js +13 -0
- package/lib/jsx-runtime-C_NLcKys.cjs +1 -0
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.d.cts +47 -51
- package/lib/locale-bundle.d.ts +47 -51
- package/lib/locale-bundle.js +1 -1
- package/lib/style.css +1 -1
- package/lib/{textarea-D5WVZMgt.cjs → textarea-DFo_aXnj.cjs} +1 -1
- package/lib/{textarea-BglwYF6b.js → textarea-aPtytkDx.js} +1 -1
- package/package.json +76 -70
- package/lib/Drawer-CmoEF-Zg.cjs +0 -1
- package/lib/Excalidraw-CM74U5tG.js +0 -289
- package/lib/Excalidraw-DAPP9qgY.cjs +0 -1
- package/lib/RichTextEditor-BQN2eLD_.js +0 -12775
- package/lib/RichTextEditor-C8Sm1E6J.cjs +0 -140
- package/lib/Twitter-CL2pu4QM.cjs +0 -17
- package/lib/Twitter-Dg6WWauX.js +0 -1743
- package/lib/dom-dataset-Byuf1YmW.cjs +0 -33
- package/lib/dom-dataset-Di3tIRrR.js +0 -1031
- package/lib/index-BI-IcZcN.cjs +0 -1
- package/lib/index-ByRfqzMr.cjs +0 -89
- package/lib/index-C1fzuXpN.js +0 -46
- package/lib/index-CbQQFj2T.js +0 -133
- package/lib/index-DI9T3iLd.js +0 -12354
- package/lib/index-D_A0TBRA.cjs +0 -1
- package/lib/index-DclQSrIx.cjs +0 -1
- package/lib/index-Z4b9rzn-.cjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as r, m as e } from "./index-
|
|
2
|
-
|
|
1
|
+
import { M as r, m as e } from "./index-kbO3iWqL.js";
|
|
2
|
+
var u = r.create({
|
|
3
3
|
name: "subscript",
|
|
4
4
|
addOptions() {
|
|
5
5
|
return {
|
|
@@ -34,7 +34,7 @@ const u = r.create({
|
|
|
34
34
|
"Mod-,": () => this.editor.commands.toggleSubscript()
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
}),
|
|
37
|
+
}), a = r.create({
|
|
38
38
|
name: "superscript",
|
|
39
39
|
addOptions() {
|
|
40
40
|
return {
|
|
@@ -72,5 +72,5 @@ const u = r.create({
|
|
|
72
72
|
});
|
|
73
73
|
export {
|
|
74
74
|
u as S,
|
|
75
|
-
|
|
75
|
+
a
|
|
76
76
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("./index-DF2Lp4HZ.cjs");var h=t.Node3.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:r}){return["hr",t.mergeAttributes(this.options.HTMLAttributes,r)]},markdownTokenName:"hr",parseMarkdown:(r,o)=>o.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:r,state:o})=>{if(!t.canInsertNode(o,o.schema.nodes[this.name]))return!1;const{selection:i}=o,{$to:l}=i,s=r();return t.isNodeSelection(i)?s.insertContentAt(l.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:u,tr:e,dispatch:p})=>{if(p){const{$to:n}=e.selection,c=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?e.setSelection(t.TextSelection.create(e.doc,n.pos+1)):n.nodeAfter.isBlock?e.setSelection(t.NodeSelection.create(e.doc,n.pos)):e.setSelection(t.TextSelection.create(e.doc,n.pos));else{const a=u.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,d=a==null?void 0:a.create();d&&(e.insert(c,d),e.setSelection(t.TextSelection.create(e.doc,c+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[t.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});exports.HorizontalRule=h;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const w=require("./index-DF2Lp4HZ.cjs");function G(p){var c;const{char:D,allowSpaces:b,allowToIncludeChar:P,allowedPrefixes:_,startOfLine:F,$position:v}=p,B=b&&!P,m=w.escapeForRegEx(D),K=new RegExp(`\\s${m}$`),y=F?"^":"",M=P?"":m,N=B?new RegExp(`${y}${m}.*?(?=\\s${M}|$)`,"gm"):new RegExp(`${y}(?:^)?${m}[^\\s${M}]*`,"gm"),h=((c=v.nodeBefore)==null?void 0:c.isText)&&v.nodeBefore.text;if(!h)return null;const O=v.pos-h.length,l=Array.from(h.matchAll(N)).pop();if(!l||l.input===void 0||l.index===void 0)return null;const e=l.input.slice(Math.max(0,l.index-1),l.index),j=new RegExp(`^[${_==null?void 0:_.join("")}\0]?$`).test(e);if(_!==null&&!j)return null;const S=O+l.index;let x=S+l[0].length;return B&&K.test(h.slice(x-1,x+1))&&(l[0]+=" ",x+=1),S<v.pos&&x>=v.pos?{range:{from:S,to:x},query:l[0].slice(D.length),text:l[0]}:null}var H=new w.PluginKey("suggestion");function L({pluginKey:p=H,editor:c,char:D="@",allowSpaces:b=!1,allowToIncludeChar:P=!1,allowedPrefixes:_=[" "],startOfLine:F=!1,decorationTag:v="span",decorationClass:B="suggestion",decorationContent:m="",decorationEmptyClass:K="is-empty",command:y=()=>null,items:M=()=>[],render:N=()=>({}),allow:h=()=>!0,findSuggestionMatch:O=G}){let l;const e=N==null?void 0:N(),j=()=>{const n=c.state.selection.$anchor.pos,a=c.view.coordsAtPos(n),{top:r,right:s,bottom:o,left:i}=a;try{return new DOMRect(i,r,s-i,o-r)}catch{return null}},S=(n,a)=>a?()=>{const r=p.getState(c.state),s=r==null?void 0:r.decorationId,o=n.dom.querySelector(`[data-decoration-id="${s}"]`);return(o==null?void 0:o.getBoundingClientRect())||null}:j;function x(n,a){var r;try{const o=p.getState(n.state),i=o!=null&&o.decorationId?n.dom.querySelector(`[data-decoration-id="${o.decorationId}"]`):null,u={editor:c,range:(o==null?void 0:o.range)||{from:0,to:0},query:(o==null?void 0:o.query)||null,text:(o==null?void 0:o.text)||null,items:[],command:f=>y({editor:c,range:(o==null?void 0:o.range)||{from:0,to:0},props:f}),decorationNode:i,clientRect:S(n,i)};(r=e==null?void 0:e.onExit)==null||r.call(e,u)}catch{}const s=n.state.tr.setMeta(a,{exit:!0});n.dispatch(s)}const C=new w.Plugin({key:p,view(){return{update:async(n,a)=>{var r,s,o,i,u,f,q;const t=(r=this.key)==null?void 0:r.getState(a),g=(s=this.key)==null?void 0:s.getState(n.state),d=t.active&&g.active&&t.range.from!==g.range.from,E=!t.active&&g.active,A=t.active&&!g.active,I=!E&&!A&&t.query!==g.query,R=E||d&&I,k=I||d,T=A||d&&I;if(!R&&!k&&!T)return;const $=T&&!R?t:g,U=n.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`);l={editor:c,range:$.range,query:$.query,text:$.text,items:[],command:z=>y({editor:c,range:$.range,props:z}),decorationNode:U,clientRect:S(n,U)},R&&((o=e==null?void 0:e.onBeforeStart)==null||o.call(e,l)),k&&((i=e==null?void 0:e.onBeforeUpdate)==null||i.call(e,l)),(k||R)&&(l.items=await M({editor:c,query:$.query})),T&&((u=e==null?void 0:e.onExit)==null||u.call(e,l)),k&&((f=e==null?void 0:e.onUpdate)==null||f.call(e,l)),R&&((q=e==null?void 0:e.onStart)==null||q.call(e,l))},destroy:()=>{var n;l&&((n=e==null?void 0:e.onExit)==null||n.call(e,l))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(n,a,r,s){const{isEditable:o}=c,{composing:i}=c.view,{selection:u}=n,{empty:f,from:q}=u,t={...a},g=n.getMeta(p);if(g&&g.exit)return t.active=!1,t.decorationId=null,t.range={from:0,to:0},t.query=null,t.text=null,t;if(t.composing=i,o&&(f||c.view.composing)){(q<a.range.from||q>a.range.to)&&!i&&!a.composing&&(t.active=!1);const d=O({char:D,allowSpaces:b,allowToIncludeChar:P,allowedPrefixes:_,startOfLine:F,$position:u.$from}),E=`id_${Math.floor(Math.random()*4294967295)}`;d&&h({editor:c,state:s,range:d.range,isActive:a.active})?(t.active=!0,t.decorationId=a.decorationId?a.decorationId:E,t.range=d.range,t.query=d.query,t.text=d.text):t.active=!1}else t.active=!1;return t.active||(t.decorationId=null,t.range={from:0,to:0},t.query=null,t.text=null),t}},props:{handleKeyDown(n,a){var r,s,o,i;const{active:u,range:f}=C.getState(n.state);if(!u)return!1;if(a.key==="Escape"||a.key==="Esc"){const t=C.getState(n.state),g=(r=l==null?void 0:l.decorationNode)!=null?r:null,d=g??(t!=null&&t.decorationId?n.dom.querySelector(`[data-decoration-id="${t.decorationId}"]`):null);if(((s=e==null?void 0:e.onKeyDown)==null?void 0:s.call(e,{view:n,event:a,range:t.range}))||!1)return!0;const A={editor:c,range:t.range,query:t.query,text:t.text,items:[],command:I=>y({editor:c,range:t.range,props:I}),decorationNode:d,clientRect:d?()=>d.getBoundingClientRect()||null:null};return(o=e==null?void 0:e.onExit)==null||o.call(e,A),x(n,p),!0}return((i=e==null?void 0:e.onKeyDown)==null?void 0:i.call(e,{view:n,event:a,range:f}))||!1},decorations(n){const{active:a,range:r,decorationId:s,query:o}=C.getState(n);if(!a)return null;const i=!(o!=null&&o.length),u=[B];return i&&u.push(K),w.DecorationSet.create(n.doc,[w.Decoration.inline(r.from,r.to,{nodeName:v,class:u.join(" "),"data-decoration-id":s,"data-decoration-content":m})])}}});return C}var J=L;exports.Suggestion=L;exports.index_default=J;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const d=require("./index-DF2Lp4HZ.cjs");function L(i={}){return new d.Plugin({view(e){return new G(e,i)}})}class G{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let s=o=>{this[r](o)};return e.dom.addEventListener(r,s),{name:r,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,s=r.getBoundingClientRect(),o=s.width/r.offsetWidth,l=s.height/r.offsetHeight;if(t){let c=e.nodeBefore,h=e.nodeAfter;if(c||h){let m=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(m){let v=m.getBoundingClientRect(),E=c?v.bottom:v.top;c&&h&&(E=(E+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;n={left:v.left,right:v.right,top:E-x,bottom:E+x}}}}if(!n){let c=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;n={left:c.left-h,right:c.left+h,top:c.top,bottom:c.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let u,p;if(!a||a==document.body&&getComputedStyle(a).position=="static")u=-pageXOffset,p=-pageYOffset;else{let c=a.getBoundingClientRect(),h=c.width/a.offsetWidth,m=c.height/a.offsetHeight;u=c.left-a.scrollLeft*h,p=c.top-a.scrollTop*m}this.element.style.left=(n.left-u)/o+"px",this.element.style.top=(n.top-p)/l+"px",this.element.style.width=(n.right-n.left)/o+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,s=typeof r=="function"?r(this.editorView,t,e):r;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=d.dropPoint(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class f extends d.Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return f.valid(n)?new f(n):d.Selection.near(n)}content(){return d.Slice.empty}eq(e){return e instanceof f&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new f(e.resolve(t.pos))}getBookmark(){return new O(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!B(e)||!K(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&f.valid(e))return e;let r=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;r+=t;let a=e.doc.resolve(r);if(f.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!d.NodeSelection.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),n=!1;continue e}break}s=o,r+=t;let l=e.doc.resolve(r);if(f.valid(l))return l}return null}}}f.prototype.visible=!1;f.findFrom=f.findGapCursorFrom;d.Selection.jsonID("gapcursor",f);class O{constructor(e){this.pos=e}map(e){return new O(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return f.valid(t)?new f(t):d.Selection.near(t)}}function N(i){return i.isAtom||i.spec.isolating||i.spec.createGapCursor}function B(i){for(let e=i.depth;e>=0;e--){let t=i.index(e),n=i.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let r=n.child(t-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||N(r.type))return!0;if(r.inlineContent)return!1}}return!0}function K(i){for(let e=i.depth;e>=0;e--){let t=i.indexAfter(e),n=i.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let r=n.child(t);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||N(r.type))return!0;if(r.inlineContent)return!1}}return!0}function _(){return new d.Plugin({props:{decorations:U,createSelectionBetween(i,e,t){return e.pos==t.pos&&f.valid(t)?new f(t):null},handleClick:W,handleKeyDown:H,handleDOMEvents:{beforeinput:j}}})}const H=d.keydownHandler({ArrowLeft:M("horiz",-1),ArrowRight:M("horiz",1),ArrowUp:M("vert",-1),ArrowDown:M("vert",1)});function M(i,e){const t=i=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,r,s){let o=n.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof d.TextSelection){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let u=f.findGapCursorFrom(l,e,a);return u?(r&&r(n.tr.setSelection(new f(u))),!0):!1}}function W(i,e,t){if(!i||!i.editable)return!1;let n=i.state.doc.resolve(e);if(!f.valid(n))return!1;let r=i.posAtCoords({left:t.clientX,top:t.clientY});return r&&r.inside>-1&&d.NodeSelection.isSelectable(i.state.doc.nodeAt(r.inside))?!1:(i.dispatch(i.state.tr.setSelection(new f(n))),!0)}function j(i,e){if(e.inputType!="insertCompositionText"||!(i.state.selection instanceof f))return!1;let{$from:t}=i.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(i.state.schema.nodes.text);if(!n)return!1;let r=d.Fragment.empty;for(let o=n.length-1;o>=0;o--)r=d.Fragment.from(n[o].createAndFill(null,r));let s=i.state.tr.replace(t.pos,t.pos,new d.Slice(r,0,0));return s.setSelection(d.TextSelection.near(s.doc.resolve(t.pos+1))),i.dispatch(s),!1}function U(i){if(!(i.selection instanceof f))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",d.DecorationSet.create(i.doc,[d.Decoration.widget(i.selection.head,e,{key:"gapcursor"})])}var I=200,g=function(){};g.prototype.append=function(e){return e.length?(e=g.from(e),!this.length&&e||e.length<I&&this.leafAppend(e)||this.length<I&&e.leafPrepend(this)||this.appendInner(e)):this};g.prototype.prepend=function(e){return e.length?g.from(e).append(this):this};g.prototype.appendInner=function(e){return new X(this,e)};g.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?g.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};g.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};g.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};g.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(s,o){return r.push(e(s,o))},t,n),r};g.from=function(e){return e instanceof g?e:e&&e.length?new z(e):g.empty};var z=(function(i){function e(n){i.call(this),this.values=n}i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,s){return r==0&&s==this.length?this:new e(this.values.slice(r,s))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,s,o,l){for(var a=s;a<o;a++)if(r(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,l){for(var a=s-1;a>=o;a--)if(r(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=I)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=I)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(g);g.empty=new z([]);var X=(function(i){function e(t,n){i.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,r,s,o){var l=this.left.length;if(r<l&&this.left.forEachInner(n,r,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(n,Math.max(r-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,r,s,o){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(n,r-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(n,Math.min(r,l),s,o)===!1)return!1},e.prototype.sliceInner=function(n,r){if(n==0&&r==this.length)return this;var s=this.left.length;return r<=s?this.left.slice(n,r):n>=s?this.right.slice(n-s,r-s):this.left.slice(n,s).append(this.right.slice(0,r-s))},e.prototype.leafAppend=function(n){var r=this.right.leafAppend(n);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(n){var r=this.left.leafPrepend(n);if(r)return new e(r,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(g);const Y=500;class w{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let r,s;t&&(r=this.remapping(n,this.items.length),s=r.maps.length);let o=e.tr,l,a,u=[],p=[];return this.items.forEach((c,h)=>{if(!c.step){r||(r=this.remapping(n,h+1),s=r.maps.length),s--,p.push(c);return}if(r){p.push(new y(c.map));let m=c.step.map(r.slice(s)),v;m&&o.maybeStep(m).doc&&(v=o.mapping.maps[o.mapping.maps.length-1],u.push(new y(v,void 0,void 0,u.length+p.length))),s--,v&&r.appendMap(v,s)}else o.maybeStep(c.step);if(c.selection)return l=r?c.selection.map(r.slice(s)):c.selection,a=new w(this.items.slice(0,n).append(p.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,n,r){let s=[],o=this.eventCount,l=this.items,a=!r&&l.length?l.get(l.length-1):null;for(let p=0;p<e.steps.length;p++){let c=e.steps[p].invert(e.docs[p]),h=new y(e.mapping.maps[p],c,t),m;(m=a&&a.merge(h))&&(h=m,p?s.pop():l=l.slice(0,l.length-1)),s.push(h),t&&(o++,t=void 0),r||(a=h)}let u=o-n.depth;return u>Z&&(l=J(l,u),o-=u),new w(l.append(s),o)}remapping(e,t){let n=new d.Mapping;return this.items.forEach((r,s)=>{let o=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?n.maps.length-r.mirrorOffset:void 0;n.appendMap(r.map,o)},e,t),n}addMaps(e){return this.eventCount==0?this:new w(this.items.append(e.map(t=>new y(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},r);let a=t;this.items.forEach(h=>{let m=s.getMirror(--a);if(m==null)return;o=Math.min(o,m);let v=s.maps[m];if(h.step){let E=e.steps[m].invert(e.docs[m]),x=h.selection&&h.selection.map(s.slice(a+1,m));x&&l++,n.push(new y(v,E,x))}else n.push(new y(v))},r);let u=[];for(let h=t;h<o;h++)u.push(new y(s.maps[h]));let p=this.items.slice(0,r).append(u).append(n),c=new w(p,l);return c.emptyItemCount()>Y&&(c=c.compress(this.items.length-n.length)),c}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)r.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(n)),u=a&&a.getMap();if(n--,u&&t.appendMap(u,n),a){let p=o.selection&&o.selection.map(t.slice(n));p&&s++;let c=new y(u.invert(),a,p),h,m=r.length-1;(h=r.length&&r[m].merge(c))?r[m]=h:r.push(c)}}else o.map&&n--},this.items.length,0),new w(g.from(r.reverse()),s)}}w.empty=new w(g.empty,0);function J(i,e){let t;return i.forEach((n,r)=>{if(n.selection&&e--==0)return t=r,!1}),i.slice(t)}class y{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new y(t.getMap().invert(),t,this.selection)}}}class C{constructor(e,t,n,r,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=s}}const Z=20;function Q(i,e,t,n){let r=t.getMeta(P),s;if(r)return r.historyState;t.getMeta(ee)&&(i=new C(i.done,i.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return i;if(o&&o.getMeta(P))return o.getMeta(P).redo?new C(i.done.addTransform(t,void 0,n,S(e)),i.undone,A(t.mapping.maps),i.prevTime,i.prevComposition):new C(i.done,i.undone.addTransform(t,void 0,n,S(e)),null,i.prevTime,i.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=i.prevTime==0||!o&&i.prevComposition!=l&&(i.prevTime<(t.time||0)-n.newGroupDelay||!q(t,i.prevRanges)),u=o?b(i.prevRanges,t.mapping):A(t.mapping.maps);return new C(i.done.addTransform(t,a?e.selection.getBookmark():void 0,n,S(e)),w.empty,u,t.time,l??i.prevComposition)}else return(s=t.getMeta("rebased"))?new C(i.done.rebased(t,s),i.undone.rebased(t,s),b(i.prevRanges,t.mapping),i.prevTime,i.prevComposition):new C(i.done.addMaps(t.mapping.maps),i.undone.addMaps(t.mapping.maps),b(i.prevRanges,t.mapping),i.prevTime,i.prevComposition)}function q(i,e){if(!e)return!1;if(!i.docChanged)return!0;let t=!1;return i.mapping.maps[0].forEach((n,r)=>{for(let s=0;s<e.length;s+=2)n<=e[s+1]&&r>=e[s]&&(t=!0)}),t}function A(i){let e=[];for(let t=i.length-1;t>=0&&e.length==0;t--)i[t].forEach((n,r,s,o)=>e.push(s,o));return e}function b(i,e){if(!i)return null;let t=[];for(let n=0;n<i.length;n+=2){let r=e.map(i[n],1),s=e.map(i[n+1],-1);r<=s&&t.push(r,s)}return t}function $(i,e,t){let n=S(e),r=P.get(e).spec.config,s=(t?i.undone:i.done).popEvent(e,n);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?i.done:i.undone).addTransform(s.transform,e.selection.getBookmark(),r,n),a=new C(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(P,{redo:t,historyState:a})}let T=!1,D=null;function S(i){let e=i.plugins;if(D!=e){T=!1,D=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){T=!0;break}}return T}const P=new d.PluginKey("history"),ee=new d.PluginKey("closeHistory");function te(i={}){return i={depth:i.depth||100,newGroupDelay:i.newGroupDelay||500},new d.Plugin({key:P,state:{init(){return new C(w.empty,w.empty,null,0,-1)},apply(e,t,n){return Q(t,n,e,i)}},config:i,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n=="historyUndo"?R:n=="historyRedo"?V:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function F(i,e){return(t,n)=>{let r=P.getState(t);if(!r||(i?r.undone:r.done).eventCount==0)return!1;if(n){let s=$(r,t,i);s&&n(e?s.scrollIntoView():s)}return!0}}const R=F(!1,!0),V=F(!0,!0);var ne=d.Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:i=>i.length,wordCounter:i=>i.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=i=>{const e=(i==null?void 0:i.node)||this.editor.state.doc;if(((i==null?void 0:i.mode)||this.options.mode)==="textSize"){const n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=i=>{const e=(i==null?void 0:i.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let i=!1;return[new d.Plugin({key:new d.PluginKey("characterCount"),appendTransaction:(e,t,n)=>{if(i)return;const r=this.options.limit;if(r==null||r===0){i=!0;return}const s=this.storage.characters({node:n.doc});if(s>r){const o=s-r,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const u=n.tr.deleteRange(l,a);return i=!0,u}i=!0},filterTransaction:(e,t)=>{const n=this.options.limit;if(!e.docChanged||n===0||n===null||n===void 0)return!0;const r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=n||r>n&&s>n&&s<=r)return!0;if(r>n&&s>n&&s>r||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=s-n,u=l-a,p=l;return e.deleteRange(u,p),!(this.storage.characters({node:e.doc})>n)}})]}}),re=d.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[L(this.options)]}}),ie=d.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new d.Plugin({key:new d.PluginKey("focus"),props:{decorations:({doc:i,selection:e})=>{const{isEditable:t,isFocused:n}=this.editor,{anchor:r}=e,s=[];if(!t||!n)return d.DecorationSet.create(i,[]);let o=0;this.options.mode==="deepest"&&i.descendants((a,u)=>{if(a.isText)return;if(!(r>=u&&r<=u+a.nodeSize-1))return!1;o+=1});let l=0;return i.descendants((a,u)=>{if(a.isText||!(r>=u&&r<=u+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(d.Decoration.node(u,u+a.nodeSize,{class:this.options.className}))}),d.DecorationSet.create(i,s)}}})]}}),se=d.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[_()]},extendNodeSchema(i){var e;const t={name:i.name,options:i.options,storage:i.storage};return{allowGapCursor:(e=d.callOrReturn(d.getExtensionField(i,"allowGapCursor",t)))!=null?e:null}}}),oe=d.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new d.Plugin({key:new d.PluginKey("placeholder"),props:{decorations:({doc:i,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:n}=e,r=[];if(!t)return null;const s=this.editor.isEmpty;return i.descendants((o,l)=>{const a=n>=l&&n<=l+o.nodeSize,u=!o.isLeaf&&d.isNodeEmpty(o);if((a||!this.options.showOnlyCurrent)&&u){const p=[this.options.emptyNodeClass];s&&p.push(this.options.emptyEditorClass);const c=d.Decoration.node(l,l+o.nodeSize,{class:p.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});r.push(c)}return this.options.includeChildren}),d.DecorationSet.create(i,r)}}})]}}),le=d.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:i,options:e}=this;return[new d.Plugin({key:new d.PluginKey("selection"),props:{decorations(t){return t.selection.empty||i.isFocused||!i.isEditable||d.isNodeSelection(t.selection)||i.view.dragging?null:d.DecorationSet.create(t.doc,[d.Decoration.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function k({types:i,node:e}){return e&&Array.isArray(i)&&i.includes(e.type)||(e==null?void 0:e.type)===i}var ae=d.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var i;const e=new d.PluginKey(this.name),t=this.options.node||((i=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:i.name)||"paragraph",n=Object.entries(this.editor.schema.nodes).map(([,r])=>r).filter(r=>(this.options.notAfter||[]).concat(t).includes(r.name));return[new d.Plugin({key:e,appendTransaction:(r,s,o)=>{const{doc:l,tr:a,schema:u}=o,p=e.getState(o),c=l.content.size,h=u.nodes[t];if(p)return a.insert(c,h.create())},state:{init:(r,s)=>{const o=s.tr.doc.lastChild;return!k({node:o,types:n})},apply:(r,s)=>{if(!r.docChanged||r.getMeta("__uniqueIDTransaction"))return s;const o=r.doc.lastChild;return!k({node:o,types:n})}}})]}}),de=d.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:i,dispatch:e})=>R(i,e),redo:()=>({state:i,dispatch:e})=>V(i,e)}},addProseMirrorPlugins(){return[te(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});exports.CharacterCount=ne;exports.Dropcursor=re;exports.Focus=ie;exports.Gapcursor=se;exports.Placeholder=oe;exports.Selection=le;exports.TrailingNode=ae;exports.UndoRedo=de;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { a as L, P as z, D as G, j as H, k as J } from "./index-kbO3iWqL.js";
|
|
2
|
+
function Q(p) {
|
|
3
|
+
var c;
|
|
4
|
+
const { char: w, allowSpaces: A, allowToIncludeChar: D, allowedPrefixes: _, startOfLine: b, $position: m } = p, P = A && !D, x = J(w), j = new RegExp(`\\s${x}$`), y = b ? "^" : "", B = D ? "" : x, M = P ? new RegExp(`${y}${x}.*?(?=\\s${B}|$)`, "gm") : new RegExp(`${y}(?:^)?${x}[^\\s${B}]*`, "gm"), h = ((c = m.nodeBefore) == null ? void 0 : c.isText) && m.nodeBefore.text;
|
|
5
|
+
if (!h)
|
|
6
|
+
return null;
|
|
7
|
+
const F = m.pos - h.length, a = Array.from(h.matchAll(M)).pop();
|
|
8
|
+
if (!a || a.input === void 0 || a.index === void 0)
|
|
9
|
+
return null;
|
|
10
|
+
const e = a.input.slice(Math.max(0, a.index - 1), a.index), K = new RegExp(`^[${_ == null ? void 0 : _.join("")}\0]?$`).test(e);
|
|
11
|
+
if (_ !== null && !K)
|
|
12
|
+
return null;
|
|
13
|
+
const S = F + a.index;
|
|
14
|
+
let v = S + a[0].length;
|
|
15
|
+
return P && j.test(h.slice(v - 1, v + 1)) && (a[0] += " ", v += 1), S < m.pos && v >= m.pos ? {
|
|
16
|
+
range: {
|
|
17
|
+
from: S,
|
|
18
|
+
to: v
|
|
19
|
+
},
|
|
20
|
+
query: a[0].slice(w.length),
|
|
21
|
+
text: a[0]
|
|
22
|
+
} : null;
|
|
23
|
+
}
|
|
24
|
+
var V = new L("suggestion");
|
|
25
|
+
function W({
|
|
26
|
+
pluginKey: p = V,
|
|
27
|
+
editor: c,
|
|
28
|
+
char: w = "@",
|
|
29
|
+
allowSpaces: A = !1,
|
|
30
|
+
allowToIncludeChar: D = !1,
|
|
31
|
+
allowedPrefixes: _ = [" "],
|
|
32
|
+
startOfLine: b = !1,
|
|
33
|
+
decorationTag: m = "span",
|
|
34
|
+
decorationClass: P = "suggestion",
|
|
35
|
+
decorationContent: x = "",
|
|
36
|
+
decorationEmptyClass: j = "is-empty",
|
|
37
|
+
command: y = () => null,
|
|
38
|
+
items: B = () => [],
|
|
39
|
+
render: M = () => ({}),
|
|
40
|
+
allow: h = () => !0,
|
|
41
|
+
findSuggestionMatch: F = Q
|
|
42
|
+
}) {
|
|
43
|
+
let a;
|
|
44
|
+
const e = M == null ? void 0 : M(), K = () => {
|
|
45
|
+
const n = c.state.selection.$anchor.pos, l = c.view.coordsAtPos(n), { top: r, right: s, bottom: o, left: i } = l;
|
|
46
|
+
try {
|
|
47
|
+
return new DOMRect(i, r, s - i, o - r);
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}, S = (n, l) => l ? () => {
|
|
52
|
+
const r = p.getState(c.state), s = r == null ? void 0 : r.decorationId, o = n.dom.querySelector(`[data-decoration-id="${s}"]`);
|
|
53
|
+
return (o == null ? void 0 : o.getBoundingClientRect()) || null;
|
|
54
|
+
} : K;
|
|
55
|
+
function v(n, l) {
|
|
56
|
+
var r;
|
|
57
|
+
try {
|
|
58
|
+
const o = p.getState(n.state), i = o != null && o.decorationId ? n.dom.querySelector(`[data-decoration-id="${o.decorationId}"]`) : null, u = {
|
|
59
|
+
// @ts-ignore editor is available in closure
|
|
60
|
+
editor: c,
|
|
61
|
+
range: (o == null ? void 0 : o.range) || { from: 0, to: 0 },
|
|
62
|
+
query: (o == null ? void 0 : o.query) || null,
|
|
63
|
+
text: (o == null ? void 0 : o.text) || null,
|
|
64
|
+
items: [],
|
|
65
|
+
command: (f) => y({ editor: c, range: (o == null ? void 0 : o.range) || { from: 0, to: 0 }, props: f }),
|
|
66
|
+
decorationNode: i,
|
|
67
|
+
clientRect: S(n, i)
|
|
68
|
+
};
|
|
69
|
+
(r = e == null ? void 0 : e.onExit) == null || r.call(e, u);
|
|
70
|
+
} catch {
|
|
71
|
+
}
|
|
72
|
+
const s = n.state.tr.setMeta(l, { exit: !0 });
|
|
73
|
+
n.dispatch(s);
|
|
74
|
+
}
|
|
75
|
+
const N = new z({
|
|
76
|
+
key: p,
|
|
77
|
+
view() {
|
|
78
|
+
return {
|
|
79
|
+
update: async (n, l) => {
|
|
80
|
+
var r, s, o, i, u, f, q;
|
|
81
|
+
const t = (r = this.key) == null ? void 0 : r.getState(l), g = (s = this.key) == null ? void 0 : s.getState(n.state), d = t.active && g.active && t.range.from !== g.range.from, E = !t.active && g.active, C = t.active && !g.active, I = !E && !C && t.query !== g.query, R = E || d && I, k = I || d, O = C || d && I;
|
|
82
|
+
if (!R && !k && !O)
|
|
83
|
+
return;
|
|
84
|
+
const $ = O && !R ? t : g, T = n.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`);
|
|
85
|
+
a = {
|
|
86
|
+
editor: c,
|
|
87
|
+
range: $.range,
|
|
88
|
+
query: $.query,
|
|
89
|
+
text: $.text,
|
|
90
|
+
items: [],
|
|
91
|
+
command: (U) => y({
|
|
92
|
+
editor: c,
|
|
93
|
+
range: $.range,
|
|
94
|
+
props: U
|
|
95
|
+
}),
|
|
96
|
+
decorationNode: T,
|
|
97
|
+
clientRect: S(n, T)
|
|
98
|
+
}, R && ((o = e == null ? void 0 : e.onBeforeStart) == null || o.call(e, a)), k && ((i = e == null ? void 0 : e.onBeforeUpdate) == null || i.call(e, a)), (k || R) && (a.items = await B({
|
|
99
|
+
editor: c,
|
|
100
|
+
query: $.query
|
|
101
|
+
})), O && ((u = e == null ? void 0 : e.onExit) == null || u.call(e, a)), k && ((f = e == null ? void 0 : e.onUpdate) == null || f.call(e, a)), R && ((q = e == null ? void 0 : e.onStart) == null || q.call(e, a));
|
|
102
|
+
},
|
|
103
|
+
destroy: () => {
|
|
104
|
+
var n;
|
|
105
|
+
a && ((n = e == null ? void 0 : e.onExit) == null || n.call(e, a));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
state: {
|
|
110
|
+
// Initialize the plugin's internal state.
|
|
111
|
+
init() {
|
|
112
|
+
return {
|
|
113
|
+
active: !1,
|
|
114
|
+
range: {
|
|
115
|
+
from: 0,
|
|
116
|
+
to: 0
|
|
117
|
+
},
|
|
118
|
+
query: null,
|
|
119
|
+
text: null,
|
|
120
|
+
composing: !1
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
// Apply changes to the plugin state from a view transaction.
|
|
124
|
+
apply(n, l, r, s) {
|
|
125
|
+
const { isEditable: o } = c, { composing: i } = c.view, { selection: u } = n, { empty: f, from: q } = u, t = { ...l }, g = n.getMeta(p);
|
|
126
|
+
if (g && g.exit)
|
|
127
|
+
return t.active = !1, t.decorationId = null, t.range = { from: 0, to: 0 }, t.query = null, t.text = null, t;
|
|
128
|
+
if (t.composing = i, o && (f || c.view.composing)) {
|
|
129
|
+
(q < l.range.from || q > l.range.to) && !i && !l.composing && (t.active = !1);
|
|
130
|
+
const d = F({
|
|
131
|
+
char: w,
|
|
132
|
+
allowSpaces: A,
|
|
133
|
+
allowToIncludeChar: D,
|
|
134
|
+
allowedPrefixes: _,
|
|
135
|
+
startOfLine: b,
|
|
136
|
+
$position: u.$from
|
|
137
|
+
}), E = `id_${Math.floor(Math.random() * 4294967295)}`;
|
|
138
|
+
d && h({
|
|
139
|
+
editor: c,
|
|
140
|
+
state: s,
|
|
141
|
+
range: d.range,
|
|
142
|
+
isActive: l.active
|
|
143
|
+
}) ? (t.active = !0, t.decorationId = l.decorationId ? l.decorationId : E, t.range = d.range, t.query = d.query, t.text = d.text) : t.active = !1;
|
|
144
|
+
} else
|
|
145
|
+
t.active = !1;
|
|
146
|
+
return t.active || (t.decorationId = null, t.range = { from: 0, to: 0 }, t.query = null, t.text = null), t;
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
props: {
|
|
150
|
+
// Call the keydown hook if suggestion is active.
|
|
151
|
+
handleKeyDown(n, l) {
|
|
152
|
+
var r, s, o, i;
|
|
153
|
+
const { active: u, range: f } = N.getState(n.state);
|
|
154
|
+
if (!u)
|
|
155
|
+
return !1;
|
|
156
|
+
if (l.key === "Escape" || l.key === "Esc") {
|
|
157
|
+
const t = N.getState(n.state), g = (r = a == null ? void 0 : a.decorationNode) != null ? r : null, d = g ?? (t != null && t.decorationId ? n.dom.querySelector(`[data-decoration-id="${t.decorationId}"]`) : null);
|
|
158
|
+
if (((s = e == null ? void 0 : e.onKeyDown) == null ? void 0 : s.call(e, { view: n, event: l, range: t.range })) || !1)
|
|
159
|
+
return !0;
|
|
160
|
+
const C = {
|
|
161
|
+
editor: c,
|
|
162
|
+
range: t.range,
|
|
163
|
+
query: t.query,
|
|
164
|
+
text: t.text,
|
|
165
|
+
items: [],
|
|
166
|
+
command: (I) => y({ editor: c, range: t.range, props: I }),
|
|
167
|
+
decorationNode: d,
|
|
168
|
+
// If we have a cached decoration node, use it for the clientRect
|
|
169
|
+
// to avoid another DOM lookup. If not, leave clientRect null and
|
|
170
|
+
// let consumer decide if they want to query.
|
|
171
|
+
clientRect: d ? () => d.getBoundingClientRect() || null : null
|
|
172
|
+
};
|
|
173
|
+
return (o = e == null ? void 0 : e.onExit) == null || o.call(e, C), v(n, p), !0;
|
|
174
|
+
}
|
|
175
|
+
return ((i = e == null ? void 0 : e.onKeyDown) == null ? void 0 : i.call(e, { view: n, event: l, range: f })) || !1;
|
|
176
|
+
},
|
|
177
|
+
// Setup decorator on the currently active suggestion.
|
|
178
|
+
decorations(n) {
|
|
179
|
+
const { active: l, range: r, decorationId: s, query: o } = N.getState(n);
|
|
180
|
+
if (!l)
|
|
181
|
+
return null;
|
|
182
|
+
const i = !(o != null && o.length), u = [P];
|
|
183
|
+
return i && u.push(j), G.create(n.doc, [
|
|
184
|
+
H.inline(r.from, r.to, {
|
|
185
|
+
nodeName: m,
|
|
186
|
+
class: u.join(" "),
|
|
187
|
+
"data-decoration-id": s,
|
|
188
|
+
"data-decoration-content": x
|
|
189
|
+
})
|
|
190
|
+
]);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
return N;
|
|
195
|
+
}
|
|
196
|
+
var Y = W;
|
|
197
|
+
export {
|
|
198
|
+
W as S,
|
|
199
|
+
Y as i
|
|
200
|
+
};
|