@remarkablejames/editor 0.0.4 → 0.0.6
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/lib/{ActionMenuButton-BUtJUsfO.js → ActionMenuButton-CpmEfz31.js} +1 -1
- package/lib/{ActionMenuButton-M55VtCZ5.cjs → ActionMenuButton-NfiUDE60.cjs} +1 -1
- package/lib/Attachment.cjs +1 -19
- package/lib/Attachment.js +6 -305
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +2 -2
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +2 -2
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +2 -2
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +17 -18
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +2 -2
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +32 -33
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +3 -3
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +2 -2
- package/lib/{Drawer-mlmJ2nCT.js → Drawer-CayP4Ww4.js} +16 -16
- package/lib/{Drawer-CdQBnwUs.cjs → Drawer-DlgdaO_B.cjs} +2 -2
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +12 -12
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +29 -30
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +5 -5
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +5 -5
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +10 -10
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +3 -3
- package/lib/History.cjs +1 -1
- package/lib/History.js +3 -3
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +2 -2
- package/lib/{Iframe-CYgR99Ny.js → Iframe-C6Sb97KS.js} +4 -5
- package/lib/Iframe-CANdxSpV.cjs +1 -0
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +4 -4
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +24 -24
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +14 -14
- package/lib/{Indent-BMz2ILRl.js → Indent-CcFe8py3.js} +2 -2
- package/lib/{Indent-BAcoFdaq.cjs → Indent-DuB2U6Cs.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +2 -2
- package/lib/{Katex-DOlb4iTP.js → Katex-Bp6AnIUF.js} +64 -65
- package/lib/Katex-DFU1unCm.cjs +4 -0
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +4 -4
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-xnokk4G7.js → LinkEditBlock-BiHumIJR.js} +8 -8
- package/lib/{LinkEditBlock-Cqs5RxjV.cjs → LinkEditBlock-C2zX0WVK.cjs} +1 -1
- package/lib/Mention.js +3 -3
- package/lib/Mermaid-B8lQSOGn.cjs +2 -0
- package/lib/{Mermaid-Bs3pIGc6.js → Mermaid-Dlx0XTJj.js} +23 -24
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +2 -2
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +3 -3
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +2 -2
- package/lib/PaywallSeparator.cjs +1 -0
- package/lib/PaywallSeparator.js +140 -0
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +8 -8
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/SlashCommandNodeView-BfWNWGRr.cjs +1 -0
- package/lib/{SlashCommandNodeView-CYcf7mVz.js → SlashCommandNodeView-DzmsYaNc.js} +73 -57
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +2 -2
- package/lib/{Table-dlXTKKwJ.cjs → Table-BfM6ywrZ.cjs} +1 -1
- package/lib/{Table-bz1Wcojf.js → Table-IH34r4jd.js} +5 -5
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +3 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +3 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +2 -2
- package/lib/{Twitter-CNTXzgt0.js → Twitter-FVQKPaq6.js} +8 -8
- package/lib/{Twitter-DhEnGg6P.cjs → Twitter-axcoCgD7.cjs} +1 -1
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +5 -5
- package/lib/bubble.cjs +3 -3
- package/lib/bubble.js +84 -86
- package/lib/{clsx-CDyrfCnw.js → clsx-BUPZHhq3.js} +2 -2
- package/lib/components/SlashDialogTrigger/RenderDialogUploadAttachment.d.ts +1 -0
- package/lib/{dropdown-menu-BuSlU2uN.js → dropdown-menu-Ce2TorkG.js} +1 -1
- package/lib/{dropdown-menu-CfWNst4v.cjs → dropdown-menu-DirUyRAI.cjs} +1 -1
- package/lib/extensions/Attachment/Attachment.d.ts +17 -6
- package/lib/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.d.ts +1 -1
- package/lib/extensions/PaywallSeparator/PaywallSeparator.d.ts +35 -0
- package/lib/extensions/PaywallSeparator/components/PaywallIcon.d.ts +2 -0
- package/lib/extensions/PaywallSeparator/components/PaywallSeparatorView.d.ts +17 -0
- package/lib/extensions/PaywallSeparator/components/RichTextPaywallSeparator.d.ts +1 -0
- package/lib/extensions/PaywallSeparator/components/index.d.ts +2 -0
- package/lib/extensions/PaywallSeparator/index.d.ts +1 -0
- package/lib/{index-DZfkCNKr.js → index-BGd2HiwP.js} +50 -20
- package/lib/index-BynXHtjJ.cjs +28 -0
- package/lib/{index-8B00E8e4.js → index-CnKgiZFQ.js} +1766 -1245
- package/lib/{index-CsSfYR30.js → index-D4M4hrH4.js} +1 -1
- package/lib/{index-DjDf4BK8.js → index-DZj2z9_1.js} +1 -1
- package/lib/index-DgOXAdKt.cjs +1 -0
- package/lib/{index-C1WCZhyA.js → index-Dl3OjzmR.js} +1 -1
- package/lib/{index-C-tDsIKJ.js → index-RkKGy5oa.js} +1 -1
- package/lib/index.cjs +3 -3
- package/lib/index.js +19 -19
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +1 -1
- package/lib/locales/en.d.ts +5 -0
- package/lib/locales/fi.d.ts +5 -0
- package/lib/locales/hu.d.ts +5 -0
- package/lib/locales/index.d.ts +30 -0
- package/lib/locales/pt-br.d.ts +5 -0
- package/lib/locales/vi.d.ts +5 -0
- package/lib/locales/zh-cn.d.ts +5 -0
- package/lib/{popover-51mwx3UY.cjs → popover-BdLwAlrM.cjs} +1 -1
- package/lib/{popover-DMPRgXD3.js → popover-BzJyaFvy.js} +1 -1
- package/lib/{renderNodeView-BJSrgyGj.js → renderNodeView-dj6AaFSX.js} +2 -2
- package/lib/{separator-kB9YUfeO.cjs → separator-CoQaQmFK.cjs} +1 -1
- package/lib/{separator-CpqX9KQC.js → separator-D-fyzbfx.js} +14 -14
- package/lib/style.css +1 -1
- package/lib/types.d.ts +5 -5
- package/lib/{updatePosition-e90ZrFWW.js → updatePosition-C294Pixi.js} +2 -2
- package/lib/utils/customEvents/events.constant.d.ts +1 -0
- package/package.json +14 -1
- package/lib/Iframe-B_a_AoZc.cjs +0 -1
- package/lib/Katex-bIhj82VV.cjs +0 -4
- package/lib/Mermaid-DiOdgQv1.cjs +0 -2
- package/lib/SlashCommandNodeView-CLimjqhb.cjs +0 -1
- package/lib/dom-dataset-BqoJhJXt.cjs +0 -1
- package/lib/dom-dataset-CIEeltF6.js +0 -47
- package/lib/index-BrxL7y9p.cjs +0 -1
- package/lib/index-Bt9LiArC.cjs +0 -10
- package/lib/select-B7v1Scb-.cjs +0 -1
- package/lib/select-BxFDMaZi.js +0 -120
- package/lib/textarea-C5DsgzSy.js +0 -20
- package/lib/textarea-bQSzjqg3.cjs +0 -1
package/lib/CodeBlock.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./clsx-CXbNJWDD.cjs"),r=require("react/jsx-runtime"),u=require("./index-Bt9LiArC.cjs"),x=require("react");require("./theme.cjs");const S=require("prism-code-editor-lightweight"),p=require("prism-code-editor-lightweight/commands"),T=require("prism-code-editor-lightweight/cursor"),I=require("prism-code-editor-lightweight/guides"),B=require("prism-code-editor-lightweight/highlight-brackets"),R=require("prism-code-editor-lightweight/match-brackets"),E=require("prism-code-editor-lightweight/match-tags"),s=require("./select-B7v1Scb-.cjs"),z=require("./delete-node-CosiBes5.cjs");require("prism-code-editor-lightweight/prism/languages/bash");require("prism-code-editor-lightweight/prism/languages/css");require("prism-code-editor-lightweight/prism/languages/css-extras");require("prism-code-editor-lightweight/prism/languages/ini");require("prism-code-editor-lightweight/prism/languages/kotlin");require("prism-code-editor-lightweight/prism/languages/xml");require("prism-code-editor-lightweight/prism/languages/markup");require("prism-code-editor-lightweight/prism/languages/r");require("prism-code-editor-lightweight/prism/languages/basic");require("prism-code-editor-lightweight/prism/languages/vbnet");require("prism-code-editor-lightweight/prism/languages/c");require("prism-code-editor-lightweight/prism/languages/opencl");require("prism-code-editor-lightweight/prism/languages/diff");require("prism-code-editor-lightweight/prism/languages/java");require("prism-code-editor-lightweight/prism/languages/less");require("prism-code-editor-lightweight/prism/languages/objectivec");require("prism-code-editor-lightweight/prism/languages/ruby");require("prism-code-editor-lightweight/prism/languages/sql");require("prism-code-editor-lightweight/prism/languages/wasm");require("prism-code-editor-lightweight/prism/languages/cpp");require("prism-code-editor-lightweight/prism/languages/go");require("prism-code-editor-lightweight/prism/languages/javascript");require("prism-code-editor-lightweight/prism/languages/js-templates");require("prism-code-editor-lightweight/prism/languages/jsx");require("prism-code-editor-lightweight/prism/languages/lua");require("prism-code-editor-lightweight/prism/languages/perl");require("prism-code-editor-lightweight/prism/languages/python");require("prism-code-editor-lightweight/prism/languages/rust");require("prism-code-editor-lightweight/prism/languages/swift");require("prism-code-editor-lightweight/prism/languages/clike");require("prism-code-editor-lightweight/prism/languages/csharp");require("prism-code-editor-lightweight/prism/languages/graphql");require("prism-code-editor-lightweight/prism/languages/json");require("prism-code-editor-lightweight/prism/languages/makefile");require("prism-code-editor-lightweight/prism/languages/scss");require("prism-code-editor-lightweight/prism/languages/typescript");require("prism-code-editor-lightweight/prism/languages/tsx");require("prism-code-editor-lightweight/prism/languages/yaml");require("prism-code-editor-lightweight/prism/languages/regex");require("prism-code-editor-lightweight/prism/languages/php");require("prism-code-editor-lightweight/prism/languages/markdown");function L(){const e=u.useButtonProps(C.name),{icon:a=void 0,tooltip:n=void 0,tooltipOptions:h={},action:c=void 0,isActive:m=void 0}=(e==null?void 0:e.componentProps)??{},{dataState:o,disabled:b,update:v}=u.useToggleActive(m),f=()=>{b||c&&(c(),v())};return e?r.jsx(u.ActionButton,{action:f,dataState:o,disabled:b,icon:a,tooltip:n,tooltipOptions:h}):r.jsx(r.Fragment,{})}const M="_wrap_1x3wi_1",W="_blockInfoEditable_1x3wi_30",N={wrap:M,blockInfoEditable:W},g=[{value:"plaintext",label:"plaintext"},{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"python",label:"Python"},{value:"java",label:"Java"},{value:"cpp",label:"C++"},{value:"go",label:"Go"},{value:"rust",label:"Rust"},{value:"sql",label:"SQL"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"markdown",label:"Markdown"},{value:"bash",label:"Bash"},{value:"php",label:"PHP"}],q=[2,4,8];function H(e){const a=u.useEditableEditor(),n=x.useRef(null),h=x.useCallback(()=>z.deleteNode(C.name,e==null?void 0:e.editor),[e==null?void 0:e.editor]),c=x.useRef(null),m=e.node.attrs.code||e.node.textContent||"",o=x.useCallback(t=>{t==null||t.stopPropagation(),setTimeout(()=>{var i,d,j;(j=(d=(i=c.current)==null?void 0:i.textarea)==null?void 0:d.focus)==null||j.call(d)},0)},[]),b=async()=>{if(m)try{if(navigator.clipboard)await navigator.clipboard.writeText(m);else{const t=document.createElement("textarea");t.value=m,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}}catch(t){console.error("Error:",t)}finally{o()}},v=()=>{e.updateAttributes({lineNumbers:!e.node.attrs.lineNumbers}),o()},f=()=>{e.updateAttributes({wordWrap:!e.node.attrs.wordWrap}),o()},k=t=>{const i={...t};return i.language&&!g.some(d=>d.value===i.language)&&(i.language="plaintext",e.updateAttributes({language:"plaintext"})),i},w=x.useCallback(t=>{o(t)},[o]);return x.useEffect(()=>{if(n.current){const t=k(e.node.attrs);c.current=S.createEditor(n.current,{readOnly:!a,language:t.language||"plaintext",tabSize:t.tabSize??2,lineNumbers:t.lineNumbers??!0,wordWrap:t.wordWrap??!1,value:m,rtl:!1,onUpdate(i){queueMicrotask(()=>{e.updateAttributes({code:i})})}}),c.current.addExtensions(R.matchBrackets(),E.matchTags(),I.indentGuides(),B.highlightBracketPairs(),T.cursorPosition(),p.defaultCommands(),p.editHistory()),e.node.attrs.shouldFocus&&setTimeout(()=>{o(),e.updateAttributes({shouldFocus:!1})},0)}return()=>{var t,i;(t=c.current)!=null&&t.remove&&((i=c.current)==null||i.remove())}},[n]),x.useEffect(()=>{var t,i;if((t=c.current)!=null&&t.setOptions){const d=k(e.node.attrs);(i=c.current)==null||i.setOptions(d)}},[c,e.node.attrs]),r.jsx(l.NodeViewWrapper,{className:l.clsx(N.wrap,"render-wrapper"),children:r.jsx("div",{onClick:w,ref:n,className:l.clsx("richtext-node-container richtext-hover-shadow richtext-select-outline richtext-node-code-block !richtext-my-[10px]",{[N.blockInfoEditable]:!a}),children:r.jsxs("div",{className:"richtext-code-block-toolbar",children:[r.jsx("div",{children:r.jsxs(s.Select,{defaultValue:e.node.attrs.language,disabled:!a,onValueChange:t=>{e.updateAttributes({language:t}),o()},children:[r.jsx(s.SelectTrigger,{className:"richtext-h-7 richtext-w-[160px] richtext-border-none richtext-text-sm richtext-outline-none hover:richtext-bg-[#5a5d5e4f]",children:r.jsx(s.SelectValue,{placeholder:"Select language"})}),r.jsx(s.SelectContent,{onCloseAutoFocus:t=>t.preventDefault(),children:g==null?void 0:g.map(t=>r.jsx(s.SelectItem,{value:t.value,children:t.label},t.value))})]})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{className:"richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",onClick:b,children:r.jsx(u.IconComponent,{className:"richtext-size-4",name:"Copy"})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{onClick:v,className:l.clsx("richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",{"richtext-bg-[#5a5d5e4f]":e==null?void 0:e.node.attrs.lineNumbers}),children:r.jsx(u.IconComponent,{className:"richtext-size-4",name:"List"})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{onClick:f,className:l.clsx("richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",{"richtext-bg-[#5a5d5e4f]":e==null?void 0:e.node.attrs.wordWrap}),children:r.jsx(u.IconComponent,{className:"richtext-size-4",name:"WrapText"})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{children:r.jsxs(s.Select,{defaultValue:e.node.attrs.tabSize,disabled:!a,onValueChange:t=>{e.updateAttributes({tabSize:t}),o()},children:[r.jsx(s.SelectTrigger,{className:"richtext-h-7 richtext-w-[60px] richtext-border-none richtext-text-sm richtext-outline-none hover:richtext-bg-[#5a5d5e4f]",children:r.jsx(u.IconComponent,{className:"richtext-size-4",name:"IndentIncrease"})}),r.jsx(s.SelectContent,{onCloseAutoFocus:t=>t.preventDefault(),children:q==null?void 0:q.map(t=>r.jsx(s.SelectItem,{value:t,children:t},t))})]})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{className:"richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",onClick:h,children:r.jsx(u.IconComponent,{className:"richtext-size-4",name:"Trash2"})})]})})})}const y=/^`{3}([a-z]+)?\s$/,A=/^~{3}([a-z]+)?\s$/,C=l.Node3.create({name:"codeBlock",group:"block",atom:!0,content:"text*",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),languages:[],button:({editor:a,t:n})=>({componentProps:{action:()=>a.commands.setCodeBlock({}),isActive:()=>a.isActive("codeBlock"),disabled:!1,icon:"Code2",tooltip:n("editor.codeblock.tooltip")}})}},addAttributes(){return{code:{default:"",parseHTML:e=>e.textContent||""},language:{default:"plaintext"},lineNumbers:{default:!0},wordWrap:{default:!1},tabSize:{default:2},shouldFocus:{default:!0,parseHTML:()=>!1,renderHTML:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>({code:e.textContent||""})},{tag:"pre code",preserveWhitespace:"full",getAttrs:e=>({code:e.textContent||""})}]},renderHTML({HTMLAttributes:e,node:a}){var h;const n=a.attrs.code||((h=a.content.firstChild)==null?void 0:h.text)||"";return["pre",l.mergeAttributes(this.options.HTMLAttributes,e),["code",{},n]]},addNodeView(){return l.ReactNodeViewRenderer(H)},addCommands(){return{setCodeBlock:e=>({commands:a})=>a.insertContent({type:this.name,attrs:{...e,shouldFocus:!0}})}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.setCodeBlock({})}},addInputRules(){return[l.textblockTypeInputRule({find:y,type:this.type,getAttributes:e=>({language:e[1]})}),l.textblockTypeInputRule({find:A,type:this.type,getAttributes:e=>({language:e[1]})})]}});exports.CodeBlock=C;exports.RichTextCodeBlock=L;exports.backtickInputRegex=y;exports.tildeInputRegex=A;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./clsx-CXbNJWDD.cjs"),r=require("react/jsx-runtime"),i=require("./index-BynXHtjJ.cjs"),d=require("react");require("./theme.cjs");const w=require("prism-code-editor-lightweight"),j=require("prism-code-editor-lightweight/commands"),S=require("prism-code-editor-lightweight/cursor"),T=require("prism-code-editor-lightweight/guides"),I=require("prism-code-editor-lightweight/highlight-brackets"),B=require("prism-code-editor-lightweight/match-brackets"),R=require("prism-code-editor-lightweight/match-tags"),E=require("./delete-node-CosiBes5.cjs");require("prism-code-editor-lightweight/prism/languages/bash");require("prism-code-editor-lightweight/prism/languages/css");require("prism-code-editor-lightweight/prism/languages/css-extras");require("prism-code-editor-lightweight/prism/languages/ini");require("prism-code-editor-lightweight/prism/languages/kotlin");require("prism-code-editor-lightweight/prism/languages/xml");require("prism-code-editor-lightweight/prism/languages/markup");require("prism-code-editor-lightweight/prism/languages/r");require("prism-code-editor-lightweight/prism/languages/basic");require("prism-code-editor-lightweight/prism/languages/vbnet");require("prism-code-editor-lightweight/prism/languages/c");require("prism-code-editor-lightweight/prism/languages/opencl");require("prism-code-editor-lightweight/prism/languages/diff");require("prism-code-editor-lightweight/prism/languages/java");require("prism-code-editor-lightweight/prism/languages/less");require("prism-code-editor-lightweight/prism/languages/objectivec");require("prism-code-editor-lightweight/prism/languages/ruby");require("prism-code-editor-lightweight/prism/languages/sql");require("prism-code-editor-lightweight/prism/languages/wasm");require("prism-code-editor-lightweight/prism/languages/cpp");require("prism-code-editor-lightweight/prism/languages/go");require("prism-code-editor-lightweight/prism/languages/javascript");require("prism-code-editor-lightweight/prism/languages/js-templates");require("prism-code-editor-lightweight/prism/languages/jsx");require("prism-code-editor-lightweight/prism/languages/lua");require("prism-code-editor-lightweight/prism/languages/perl");require("prism-code-editor-lightweight/prism/languages/python");require("prism-code-editor-lightweight/prism/languages/rust");require("prism-code-editor-lightweight/prism/languages/swift");require("prism-code-editor-lightweight/prism/languages/clike");require("prism-code-editor-lightweight/prism/languages/csharp");require("prism-code-editor-lightweight/prism/languages/graphql");require("prism-code-editor-lightweight/prism/languages/json");require("prism-code-editor-lightweight/prism/languages/makefile");require("prism-code-editor-lightweight/prism/languages/scss");require("prism-code-editor-lightweight/prism/languages/typescript");require("prism-code-editor-lightweight/prism/languages/tsx");require("prism-code-editor-lightweight/prism/languages/yaml");require("prism-code-editor-lightweight/prism/languages/regex");require("prism-code-editor-lightweight/prism/languages/php");require("prism-code-editor-lightweight/prism/languages/markdown");function z(){const e=i.useButtonProps(q.name),{icon:c=void 0,tooltip:o=void 0,tooltipOptions:x={},action:n=void 0,isActive:h=void 0}=(e==null?void 0:e.componentProps)??{},{dataState:l,disabled:m,update:g}=i.useToggleActive(h),v=()=>{m||n&&(n(),g())};return e?r.jsx(i.ActionButton,{action:v,dataState:l,disabled:m,icon:c,tooltip:o,tooltipOptions:x}):r.jsx(r.Fragment,{})}const L="_wrap_1x3wi_1",M="_blockInfoEditable_1x3wi_30",p={wrap:L,blockInfoEditable:M},b=[{value:"plaintext",label:"plaintext"},{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"python",label:"Python"},{value:"java",label:"Java"},{value:"cpp",label:"C++"},{value:"go",label:"Go"},{value:"rust",label:"Rust"},{value:"sql",label:"SQL"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"markdown",label:"Markdown"},{value:"bash",label:"Bash"},{value:"php",label:"PHP"}],f=[2,4,8];function W(e){const c=i.useEditableEditor(),o=d.useRef(null),x=d.useCallback(()=>E.deleteNode(q.name,e==null?void 0:e.editor),[e==null?void 0:e.editor]),n=d.useRef(null),h=e.node.attrs.code||e.node.textContent||"",l=d.useCallback(t=>{t==null||t.stopPropagation(),setTimeout(()=>{var a,u,k;(k=(u=(a=n.current)==null?void 0:a.textarea)==null?void 0:u.focus)==null||k.call(u)},0)},[]),m=async()=>{if(h)try{if(navigator.clipboard)await navigator.clipboard.writeText(h);else{const t=document.createElement("textarea");t.value=h,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}}catch(t){console.error("Error:",t)}finally{l()}},g=()=>{e.updateAttributes({lineNumbers:!e.node.attrs.lineNumbers}),l()},v=()=>{e.updateAttributes({wordWrap:!e.node.attrs.wordWrap}),l()},C=t=>{const a={...t};return a.language&&!b.some(u=>u.value===a.language)&&(a.language="plaintext",e.updateAttributes({language:"plaintext"})),a},A=d.useCallback(t=>{l(t)},[l]);return d.useEffect(()=>{if(o.current){const t=C(e.node.attrs);n.current=w.createEditor(o.current,{readOnly:!c,language:t.language||"plaintext",tabSize:t.tabSize??2,lineNumbers:t.lineNumbers??!0,wordWrap:t.wordWrap??!1,value:h,rtl:!1,onUpdate(a){queueMicrotask(()=>{e.updateAttributes({code:a})})}}),n.current.addExtensions(B.matchBrackets(),R.matchTags(),T.indentGuides(),I.highlightBracketPairs(),S.cursorPosition(),j.defaultCommands(),j.editHistory()),e.node.attrs.shouldFocus&&setTimeout(()=>{l(),e.updateAttributes({shouldFocus:!1})},0)}return()=>{var t,a;(t=n.current)!=null&&t.remove&&((a=n.current)==null||a.remove())}},[o]),d.useEffect(()=>{var t,a;if((t=n.current)!=null&&t.setOptions){const u=C(e.node.attrs);(a=n.current)==null||a.setOptions(u)}},[n,e.node.attrs]),r.jsx(s.NodeViewWrapper,{className:s.clsx(p.wrap,"render-wrapper"),children:r.jsx("div",{onClick:A,ref:o,className:s.clsx("richtext-node-container richtext-hover-shadow richtext-select-outline richtext-node-code-block !richtext-my-[10px]",{[p.blockInfoEditable]:!c}),children:r.jsxs("div",{className:"richtext-code-block-toolbar",children:[r.jsx("div",{children:r.jsxs(i.Select,{defaultValue:e.node.attrs.language,disabled:!c,onValueChange:t=>{e.updateAttributes({language:t}),l()},children:[r.jsx(i.SelectTrigger,{className:"richtext-h-7 richtext-w-[160px] richtext-border-none richtext-text-sm richtext-outline-none hover:richtext-bg-[#5a5d5e4f]",children:r.jsx(i.SelectValue,{placeholder:"Select language"})}),r.jsx(i.SelectContent,{onCloseAutoFocus:t=>t.preventDefault(),children:b==null?void 0:b.map(t=>r.jsx(i.SelectItem,{value:t.value,children:t.label},t.value))})]})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{className:"richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",onClick:m,children:r.jsx(i.IconComponent,{className:"richtext-size-4",name:"Copy"})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{onClick:g,className:s.clsx("richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",{"richtext-bg-[#5a5d5e4f]":e==null?void 0:e.node.attrs.lineNumbers}),children:r.jsx(i.IconComponent,{className:"richtext-size-4",name:"List"})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{onClick:v,className:s.clsx("richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",{"richtext-bg-[#5a5d5e4f]":e==null?void 0:e.node.attrs.wordWrap}),children:r.jsx(i.IconComponent,{className:"richtext-size-4",name:"WrapText"})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{children:r.jsxs(i.Select,{defaultValue:e.node.attrs.tabSize,disabled:!c,onValueChange:t=>{e.updateAttributes({tabSize:t}),l()},children:[r.jsx(i.SelectTrigger,{className:"richtext-h-7 richtext-w-[60px] richtext-border-none richtext-text-sm richtext-outline-none hover:richtext-bg-[#5a5d5e4f]",children:r.jsx(i.IconComponent,{className:"richtext-size-4",name:"IndentIncrease"})}),r.jsx(i.SelectContent,{onCloseAutoFocus:t=>t.preventDefault(),children:f==null?void 0:f.map(t=>r.jsx(i.SelectItem,{value:t,children:t},t))})]})}),r.jsx("div",{className:"toolbar-divider"}),r.jsx("div",{className:"richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",onClick:x,children:r.jsx(i.IconComponent,{className:"richtext-size-4",name:"Trash2"})})]})})})}const N=/^`{3}([a-z]+)?\s$/,y=/^~{3}([a-z]+)?\s$/,q=s.Node3.create({name:"codeBlock",group:"block",atom:!0,content:"text*",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),languages:[],button:({editor:c,t:o})=>({componentProps:{action:()=>c.commands.setCodeBlock({}),isActive:()=>c.isActive("codeBlock"),disabled:!1,icon:"Code2",tooltip:o("editor.codeblock.tooltip")}})}},addAttributes(){return{code:{default:"",parseHTML:e=>e.textContent||""},language:{default:"plaintext"},lineNumbers:{default:!0},wordWrap:{default:!1},tabSize:{default:2},shouldFocus:{default:!0,parseHTML:()=>!1,renderHTML:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>({code:e.textContent||""})},{tag:"pre code",preserveWhitespace:"full",getAttrs:e=>({code:e.textContent||""})}]},renderHTML({HTMLAttributes:e,node:c}){var x;const o=c.attrs.code||((x=c.content.firstChild)==null?void 0:x.text)||"";return["pre",s.mergeAttributes(this.options.HTMLAttributes,e),["code",{},o]]},addNodeView(){return s.ReactNodeViewRenderer(W)},addCommands(){return{setCodeBlock:e=>({commands:c})=>c.insertContent({type:this.name,attrs:{...e,shouldFocus:!0}})}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.setCodeBlock({})}},addInputRules(){return[s.textblockTypeInputRule({find:N,type:this.type,getAttributes:e=>({language:e[1]})}),s.textblockTypeInputRule({find:y,type:this.type,getAttributes:e=>({language:e[1]})})]}});exports.CodeBlock=q;exports.RichTextCodeBlock=z;exports.backtickInputRegex=N;exports.tildeInputRegex=y;
|
package/lib/CodeBlock.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { h as L, j as h, N as M, t as k, k as W, m as j } from "./clsx-
|
|
1
|
+
import { h as L, j as h, N as M, t as k, k as W, m as j } from "./clsx-BUPZHhq3.js";
|
|
2
2
|
import { jsx as r, Fragment as R, jsxs as f } from "react/jsx-runtime";
|
|
3
|
-
import { u as H, d as V, A as P,
|
|
4
|
-
import { useRef as
|
|
3
|
+
import { u as H, d as V, A as P, G as F, S as y, p as A, q as O, r as w, s as S, I as u } from "./index-CnKgiZFQ.js";
|
|
4
|
+
import { useRef as T, useCallback as v, useEffect as E } from "react";
|
|
5
5
|
import "./theme.js";
|
|
6
|
-
import { createEditor as
|
|
7
|
-
import { defaultCommands as
|
|
8
|
-
import { cursorPosition as
|
|
6
|
+
import { createEditor as _ } from "prism-code-editor-lightweight";
|
|
7
|
+
import { defaultCommands as q, editHistory as G } from "prism-code-editor-lightweight/commands";
|
|
8
|
+
import { cursorPosition as J } from "prism-code-editor-lightweight/cursor";
|
|
9
9
|
import { indentGuides as D } from "prism-code-editor-lightweight/guides";
|
|
10
|
-
import { highlightBracketPairs as
|
|
11
|
-
import { matchBrackets as
|
|
12
|
-
import { matchTags as
|
|
13
|
-
import { S as w, a as S, b as K, c as T, d as E } from "./select-BxFDMaZi.js";
|
|
10
|
+
import { highlightBracketPairs as U } from "prism-code-editor-lightweight/highlight-brackets";
|
|
11
|
+
import { matchBrackets as $ } from "prism-code-editor-lightweight/match-brackets";
|
|
12
|
+
import { matchTags as K } from "prism-code-editor-lightweight/match-tags";
|
|
14
13
|
import { d as Q } from "./delete-node-eQHsyyhR.js";
|
|
15
14
|
import "prism-code-editor-lightweight/prism/languages/bash";
|
|
16
15
|
import "prism-code-editor-lightweight/prism/languages/css";
|
|
@@ -53,20 +52,20 @@ import "prism-code-editor-lightweight/prism/languages/yaml";
|
|
|
53
52
|
import "prism-code-editor-lightweight/prism/languages/regex";
|
|
54
53
|
import "prism-code-editor-lightweight/prism/languages/php";
|
|
55
54
|
import "prism-code-editor-lightweight/prism/languages/markdown";
|
|
56
|
-
function
|
|
55
|
+
function rt() {
|
|
57
56
|
const e = H(B.name), {
|
|
58
57
|
icon: i = void 0,
|
|
59
58
|
tooltip: n = void 0,
|
|
60
59
|
tooltipOptions: s = {},
|
|
61
60
|
action: o = void 0,
|
|
62
61
|
isActive: d = void 0
|
|
63
|
-
} = (e == null ? void 0 : e.componentProps) ?? {}, { dataState: c, disabled: m, update:
|
|
64
|
-
m || o && (o(),
|
|
62
|
+
} = (e == null ? void 0 : e.componentProps) ?? {}, { dataState: c, disabled: m, update: p } = V(d), b = () => {
|
|
63
|
+
m || o && (o(), p());
|
|
65
64
|
};
|
|
66
65
|
return e ? /* @__PURE__ */ r(
|
|
67
66
|
P,
|
|
68
67
|
{
|
|
69
|
-
action:
|
|
68
|
+
action: b,
|
|
70
69
|
dataState: c,
|
|
71
70
|
disabled: m,
|
|
72
71
|
icon: i,
|
|
@@ -97,7 +96,7 @@ const Y = "_wrap_1x3wi_1", X = "_blockInfoEditable_1x3wi_30", z = {
|
|
|
97
96
|
{ value: "php", label: "PHP" }
|
|
98
97
|
], g = [2, 4, 8];
|
|
99
98
|
function Z(e) {
|
|
100
|
-
const i = F(), n =
|
|
99
|
+
const i = F(), n = T(null), s = v(() => Q(B.name, e == null ? void 0 : e.editor), [e == null ? void 0 : e.editor]), o = T(null), d = e.node.attrs.code || e.node.textContent || "", c = v((t) => {
|
|
101
100
|
t == null || t.stopPropagation(), setTimeout(() => {
|
|
102
101
|
var a, l, N;
|
|
103
102
|
(N = (l = (a = o.current) == null ? void 0 : a.textarea) == null ? void 0 : l.focus) == null || N.call(l);
|
|
@@ -116,11 +115,11 @@ function Z(e) {
|
|
|
116
115
|
} finally {
|
|
117
116
|
c();
|
|
118
117
|
}
|
|
119
|
-
},
|
|
118
|
+
}, p = () => {
|
|
120
119
|
e.updateAttributes({
|
|
121
120
|
lineNumbers: !e.node.attrs.lineNumbers
|
|
122
121
|
}), c();
|
|
123
|
-
},
|
|
122
|
+
}, b = () => {
|
|
124
123
|
e.updateAttributes({
|
|
125
124
|
wordWrap: !e.node.attrs.wordWrap
|
|
126
125
|
}), c();
|
|
@@ -135,10 +134,10 @@ function Z(e) {
|
|
|
135
134
|
},
|
|
136
135
|
[c]
|
|
137
136
|
);
|
|
138
|
-
return
|
|
137
|
+
return E(() => {
|
|
139
138
|
if (n.current) {
|
|
140
139
|
const t = C(e.node.attrs);
|
|
141
|
-
o.current =
|
|
140
|
+
o.current = _(n.current, {
|
|
142
141
|
readOnly: !i,
|
|
143
142
|
language: t.language || "plaintext",
|
|
144
143
|
tabSize: t.tabSize ?? 2,
|
|
@@ -152,13 +151,13 @@ function Z(e) {
|
|
|
152
151
|
});
|
|
153
152
|
}
|
|
154
153
|
}), o.current.addExtensions(
|
|
155
|
-
U(),
|
|
156
154
|
$(),
|
|
155
|
+
K(),
|
|
157
156
|
D(),
|
|
158
|
-
|
|
157
|
+
U(),
|
|
158
|
+
J(),
|
|
159
159
|
q(),
|
|
160
|
-
|
|
161
|
-
J()
|
|
160
|
+
G()
|
|
162
161
|
), e.node.attrs.shouldFocus && setTimeout(() => {
|
|
163
162
|
c(), e.updateAttributes({
|
|
164
163
|
shouldFocus: !1
|
|
@@ -169,7 +168,7 @@ function Z(e) {
|
|
|
169
168
|
var t, a;
|
|
170
169
|
(t = o.current) != null && t.remove && ((a = o.current) == null || a.remove());
|
|
171
170
|
};
|
|
172
|
-
}, [n]),
|
|
171
|
+
}, [n]), E(() => {
|
|
173
172
|
var t, a;
|
|
174
173
|
if ((t = o.current) != null && t.setOptions) {
|
|
175
174
|
const l = C(e.node.attrs);
|
|
@@ -188,7 +187,7 @@ function Z(e) {
|
|
|
188
187
|
),
|
|
189
188
|
children: /* @__PURE__ */ f("div", { className: "richtext-code-block-toolbar", children: [
|
|
190
189
|
/* @__PURE__ */ r("div", { children: /* @__PURE__ */ f(
|
|
191
|
-
|
|
190
|
+
y,
|
|
192
191
|
{
|
|
193
192
|
defaultValue: e.node.attrs.language,
|
|
194
193
|
disabled: !i,
|
|
@@ -198,8 +197,8 @@ function Z(e) {
|
|
|
198
197
|
}), c();
|
|
199
198
|
},
|
|
200
199
|
children: [
|
|
201
|
-
/* @__PURE__ */ r(
|
|
202
|
-
/* @__PURE__ */ r(
|
|
200
|
+
/* @__PURE__ */ r(A, { className: "richtext-h-7 richtext-w-[160px] richtext-border-none richtext-text-sm richtext-outline-none hover:richtext-bg-[#5a5d5e4f]", children: /* @__PURE__ */ r(O, { placeholder: "Select language" }) }),
|
|
201
|
+
/* @__PURE__ */ r(w, { onCloseAutoFocus: (t) => t.preventDefault(), children: x == null ? void 0 : x.map((t) => /* @__PURE__ */ r(S, { value: t.value, children: t.label }, t.value)) })
|
|
203
202
|
]
|
|
204
203
|
}
|
|
205
204
|
) }),
|
|
@@ -216,7 +215,7 @@ function Z(e) {
|
|
|
216
215
|
/* @__PURE__ */ r(
|
|
217
216
|
"div",
|
|
218
217
|
{
|
|
219
|
-
onClick:
|
|
218
|
+
onClick: p,
|
|
220
219
|
className: h(
|
|
221
220
|
"richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",
|
|
222
221
|
{
|
|
@@ -230,7 +229,7 @@ function Z(e) {
|
|
|
230
229
|
/* @__PURE__ */ r(
|
|
231
230
|
"div",
|
|
232
231
|
{
|
|
233
|
-
onClick:
|
|
232
|
+
onClick: b,
|
|
234
233
|
className: h(
|
|
235
234
|
"richtext-flex richtext-size-7 richtext-cursor-pointer richtext-items-center richtext-justify-center richtext-rounded-sm hover:richtext-bg-[#5a5d5e4f]",
|
|
236
235
|
{
|
|
@@ -242,7 +241,7 @@ function Z(e) {
|
|
|
242
241
|
),
|
|
243
242
|
/* @__PURE__ */ r("div", { className: "toolbar-divider" }),
|
|
244
243
|
/* @__PURE__ */ r("div", { children: /* @__PURE__ */ f(
|
|
245
|
-
|
|
244
|
+
y,
|
|
246
245
|
{
|
|
247
246
|
defaultValue: e.node.attrs.tabSize,
|
|
248
247
|
disabled: !i,
|
|
@@ -252,8 +251,8 @@ function Z(e) {
|
|
|
252
251
|
}), c();
|
|
253
252
|
},
|
|
254
253
|
children: [
|
|
255
|
-
/* @__PURE__ */ r(
|
|
256
|
-
/* @__PURE__ */ r(
|
|
254
|
+
/* @__PURE__ */ r(A, { className: "richtext-h-7 richtext-w-[60px] richtext-border-none richtext-text-sm richtext-outline-none hover:richtext-bg-[#5a5d5e4f]", children: /* @__PURE__ */ r(u, { className: "richtext-size-4", name: "IndentIncrease" }) }),
|
|
255
|
+
/* @__PURE__ */ r(w, { onCloseAutoFocus: (t) => t.preventDefault(), children: g == null ? void 0 : g.map((t) => /* @__PURE__ */ r(S, { value: t, children: t }, t)) })
|
|
257
256
|
]
|
|
258
257
|
}
|
|
259
258
|
) }),
|
|
@@ -383,7 +382,7 @@ const ee = /^`{3}([a-z]+)?\s$/, te = /^~{3}([a-z]+)?\s$/, B = /* @__PURE__ */ M.
|
|
|
383
382
|
});
|
|
384
383
|
export {
|
|
385
384
|
B as CodeBlock,
|
|
386
|
-
|
|
385
|
+
rt as RichTextCodeBlock,
|
|
387
386
|
ee as backtickInputRegex,
|
|
388
387
|
te as tildeInputRegex
|
|
389
388
|
};
|
package/lib/CodeView.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./clsx-CXbNJWDD.cjs"),n=require("react/jsx-runtime"),c=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./clsx-CXbNJWDD.cjs"),n=require("react/jsx-runtime"),c=require("./index-BynXHtjJ.cjs");require("react");require("./theme.cjs");function v(){const e=c.useButtonProps(a.name),{icon:t=void 0,tooltip:o=void 0,shortcutKeys:i=void 0,tooltipOptions:d={},action:s=void 0,isActive:l=void 0}=(e==null?void 0:e.componentProps)??{},{dataState:u,disabled:r,update:p}=c.useToggleActive(l),g=()=>{r||s&&(s(),p())};return e?n.jsx(c.ActionButton,{action:g,dataState:u,disabled:r,icon:t,shortcutKeys:i,tooltip:o,tooltipOptions:d}):n.jsx(n.Fragment,{})}const a=m.Extension.create({name:"codeView",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:t,t:o}){return{componentProps:{action:()=>{t.commands.toggleCodeView()},isActive:()=>t.storage.codeView.isActive,disabled:!1,icon:"Html",tooltip:o("editor.codeView.tooltip")||"View HTML Code",customClass:"tiptap-code-view-button"}}}}},addStorage(){return{isActive:!1,originalContent:""}},addCommands(){return{toggleCodeView:()=>({editor:e})=>{const t=e.storage.codeView.isActive;if(t)e.commands.setContent(e.getText());else{const o=e.getHTML();e.storage.codeView.originalContent=o;const i=o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");e.commands.setContent(`<div class="tiptap-code-view-wrapper">${i}</div>`)}return e.storage.codeView.isActive=!t,!0}}}});exports.CodeView=a;exports.RichTextCodeView=v;
|
package/lib/CodeView.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as l } from "./clsx-
|
|
1
|
+
import { E as l } from "./clsx-BUPZHhq3.js";
|
|
2
2
|
import { jsx as c, Fragment as g } from "react/jsx-runtime";
|
|
3
|
-
import { u, d as v, A as w } from "./index-
|
|
3
|
+
import { u, d as v, A as w } from "./index-CnKgiZFQ.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "./theme.js";
|
|
6
6
|
function h() {
|
package/lib/Color.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./index-CjhjjJsN.cjs"),t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./index-CjhjjJsN.cjs"),t=require("react/jsx-runtime"),d=require("react"),l=require("./index-BynXHtjJ.cjs"),g=require("./separator-CoQaQmFK.cjs");require("./theme.cjs");function v({fill:e}){return t.jsx("svg",{height:"18px",version:"1.1",viewBox:"0 0 240 240",width:"18px",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("g",{fill:"none",fillRule:"evenodd",stroke:"none",strokeWidth:1,children:t.jsx("g",{transform:"translate(0.000000, 0.500000)",children:t.jsxs("g",{transform:"translate(39.000000, 17.353553)",children:[t.jsx("path",{d:"M11,201.146447 L167,201.146447 C173.075132,201.146447 178,206.071314 178,212.146447 C178,218.221579 173.075132,223.146447 167,223.146447 L11,223.146447 C4.92486775,223.146447 7.43989126e-16,218.221579 0,212.146447 C-7.43989126e-16,206.071314 4.92486775,201.146447 11,201.146447 Z",fill:typeof e=="string"?e:"#000",fillRule:"evenodd"}),t.jsx("path",{d:"M72.3425855,16.8295583 C75.799482,7.50883712 86.1577877,2.75526801 95.4785089,6.21216449 C100.284516,7.99463061 104.096358,11.7387855 105.968745,16.4968188 L106.112518,16.8745422 L159.385152,161.694068 C161.291848,166.877345 158.635655,172.624903 153.452378,174.531599 C148.358469,176.405421 142.719567,173.872338 140.716873,168.864661 L140.614848,168.598825 L89.211,28.86 L37.3759214,168.623816 C35.4885354,173.712715 29.8981043,176.351047 24.7909589,174.617647 L24.5226307,174.522368 C19.4337312,172.634982 16.7953993,167.044551 18.5287999,161.937406 L18.6240786,161.669077 L72.3425855,16.8295583 Z",fill:"currentColor",fillRule:"nonzero"}),t.jsx("path",{d:"M121,103.146447 C126.522847,103.146447 131,107.623599 131,113.146447 C131,118.575687 126.673329,122.994378 121.279905,123.142605 L121,123.146447 L55,123.146447 C49.4771525,123.146447 45,118.669294 45,113.146447 C45,107.717207 49.3266708,103.298515 54.7200952,103.150288 L55,103.146447 L121,103.146447 Z",fill:"currentColor",fillRule:"nonzero"})]})})})})}function j(){const e=l.useButtonProps(C.name),{tooltip:o=void 0,isActive:s=void 0,defaultColor:r=void 0,colors:n,action:i}=(e==null?void 0:e.componentProps)??{},{disabled:c,dataState:u}=l.useActive(s),[f,a]=d.useState(r);d.useEffect(()=>{a(u)},[u]);function x(h){c||i&&(i==null||i(h),a(h))}return e?t.jsx(g.ColorPicker,{colors:n,disabled:c,onChange:x,value:f,children:t.jsx(l.ActionButton,{disabled:c,tooltip:o,children:t.jsxs("span",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[4px] richtext-text-sm",children:[t.jsx(v,{fill:u}),t.jsx(l.IconComponent,{className:"!richtext-h-3 !richtext-w-3 richtext-text-zinc-500",name:"MenuDown"})]})})}):t.jsx(t.Fragment,{})}const C=p.Color.extend({addStorage(){return{currentColor:this.options.defaultColor||void 0}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:o,t:s,extension:r}){return{componentProps:{colors:r.options.colors,defaultColor:r.options.defaultColor,action:n=>{if(typeof n=="string"){o.storage.color.currentColor=n,o.chain().focus().setColor(n).run();return}o.chain().focus().unsetColor().run()},isActive:()=>{const{color:n}=o.getAttributes("textStyle");return n},disabled:!1,shortcutKeys:r.options.shortcutKeys??["⇧","alt","C"],tooltip:s("editor.color.tooltip")}}}}},addKeyboardShortcuts(){var e;return{...(e=this.parent)==null?void 0:e.call(this),"Alt-Shift-c":()=>{const o=this.storage.currentColor||this.options.defaultColor;if(!o){const{color:r}=this.editor.getAttributes("textStyle");return r?this.editor.chain().focus().unsetColor().run():!1}return this.editor.isActive("textStyle",{color:o})?this.editor.chain().focus().unsetColor().run():this.editor.chain().focus().setColor(o).run()}}}});exports.Color=C;exports.RichTextColor=j;
|
package/lib/Color.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as d } from "./index-
|
|
1
|
+
import { C as d } from "./index-Dl3OjzmR.js";
|
|
2
2
|
import { jsx as o, jsxs as h, Fragment as p } from "react/jsx-runtime";
|
|
3
3
|
import { useState as x, useEffect as m } from "react";
|
|
4
|
-
import { u as g, e as v, A as L, I as A } from "./index-
|
|
5
|
-
import { C as y } from "./separator-
|
|
4
|
+
import { u as g, e as v, A as L, I as A } from "./index-CnKgiZFQ.js";
|
|
5
|
+
import { C as y } from "./separator-D-fyzbfx.js";
|
|
6
6
|
import "./theme.js";
|
|
7
7
|
function S({ fill: t }) {
|
|
8
8
|
return /* @__PURE__ */ o(
|
package/lib/Column.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./clsx-CXbNJWDD.cjs"),x=require("@tiptap/pm/state"),A=require("@tiptap/pm/model"),f=require("react/jsx-runtime"),h=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./clsx-CXbNJWDD.cjs"),x=require("@tiptap/pm/state"),A=require("@tiptap/pm/model"),f=require("react/jsx-runtime"),h=require("./index-BynXHtjJ.cjs");require("react");require("./theme.cjs");function v(e,t,r=null){return r?e.createChecked({index:t},r):e.createAndFill({index:t})}function M(e){if(e.cached.columnsNodeTypes)return e.cached.columnsNodeTypes;const t={columns:e.nodes.columns,column:e.nodes.column};return e.cached.columnsNodeTypes=t,t}function H(e,t,r=null){const n=M(e),c=[];for(let o=0;o<t;o+=1){const s=v(n.column,o,r);s&&c.push(s)}return n.columns.createChecked({cols:t},c)}function C({state:e,dispatch:t,type:r}){const n=u.findParentNode(o=>o.type.name===b.name)(e.selection),c=u.findParentNode(o=>o.type.name===T.name)(e.selection);if(t&&n&&c){const o=n.node,s=c.node.attrs.index,i=o.toJSON();let l=s;r==="delete"?(l=s-1,i.content.splice(s,1)):(l=r==="addBefore"?s:s+1,i.content.splice(l,0,{type:"column",attrs:{index:s},content:[{type:"paragraph"}]})),i.attrs.cols=i.content.length,i.content.forEach((m,y)=>{m.attrs.index=y});const d=A.Node.fromJSON(e.schema,i);let a=n.pos;d.content.forEach((m,y,N)=>{N<l&&(a+=m.nodeSize)});const p=e.tr.setTime(Date.now());p.replaceWith(n.pos,n.pos+n.node.nodeSize,d).setSelection(x.TextSelection.near(p.doc.resolve(a))),t(p)}return!0}function S({state:e,dispatch:t,type:r}){const n=u.findParentNode(o=>o.type.name===b.name)(e.selection),c=u.findParentNode(o=>o.type.name===T.name)(e.selection);if(t&&n&&c){const o=n.node,s=c.node.attrs.index;let i=0;r==="before"?i=(s-1+o.attrs.cols)%o.attrs.cols:i=(s+1)%o.attrs.cols;let l=n.pos;o.content.forEach((a,p,m)=>{m<i&&(l+=a.nodeSize)});const d=e.tr.setTime(Date.now());return d.setSelection(x.TextSelection.near(d.doc.resolve(l))),t(d),!0}return!1}function O(){const e=h.useButtonProps(g.name),{icon:t=void 0,tooltip:r=void 0,shortcutKeys:n=void 0,tooltipOptions:c={},action:o=void 0,isActive:s=void 0}=(e==null?void 0:e.componentProps)??{},{dataState:i,disabled:l,update:d}=h.useToggleActive(s),a=()=>{l||o&&(o(),d())};return e?f.jsx(h.ActionButton,{action:a,dataState:i,disabled:l,icon:t,shortcutKeys:n,tooltip:r,tooltipOptions:c}):f.jsx(f.Fragment,{})}const L=200,g=u.Extension.create({name:"richtextColumnExtension",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button:({editor:t,t:r})=>({componentProps:{action:()=>{t.chain().focus().insertColumns({cols:2}).run()},icon:"Columns",tooltip:r("editor.columns.tooltip")}})}}}),T=u.Node3.create({name:"column",content:"block+",isolating:!0,addOptions(){return{HTMLAttributes:{class:"column"}}},addAttributes(){return{index:{default:0,parseHTML:e=>e.getAttribute("index")}}},parseHTML(){return[{tag:"div[class=column]"}]},renderHTML({HTMLAttributes:e}){return["div",u.mergeAttributes(this.options.HTMLAttributes,e),0]}}),b=u.Node3.create({name:"columns",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"column{1,}",priority:L,addOptions(){return{HTMLAttributes:{class:"columns"}}},addAttributes(){return{cols:{default:2,parseHTML:e=>e.getAttribute("cols")}}},parseHTML(){return[{tag:"div[class=grid]"}]},renderHTML({HTMLAttributes:e}){return["div",u.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{insertColumns:e=>({tr:t,dispatch:r,editor:n})=>{const c=H(n.schema,e&&e.cols||3);if(r){const o=t.selection.anchor+1;t.replaceSelectionWith(c).scrollIntoView().setSelection(x.TextSelection.near(t.doc.resolve(o)))}return!0},addColBefore:()=>({dispatch:e,state:t})=>C({dispatch:e,state:t,type:"addBefore"}),addColAfter:()=>({dispatch:e,state:t})=>C({dispatch:e,state:t,type:"addAfter"}),deleteCol:()=>({dispatch:e,state:t})=>C({dispatch:e,state:t,type:"delete"})}},addKeyboardShortcuts(){return{"Mod-Alt-G":()=>this.editor.commands.insertColumns(),Tab:()=>S({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"after"}),"Shift-Tab":()=>S({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"before"})}}});exports.Column=g;exports.ColumnNode=T;exports.MultipleColumnNode=b;exports.RichTextColumn=O;
|
package/lib/Column.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { l as p, E as v, N as b, m as y } from "./clsx-
|
|
1
|
+
import { l as p, E as v, N as b, m as y } from "./clsx-BUPZHhq3.js";
|
|
2
2
|
import { TextSelection as h } from "@tiptap/pm/state";
|
|
3
3
|
import { Node as N } from "@tiptap/pm/model";
|
|
4
4
|
import { jsx as T, Fragment as H } from "react/jsx-runtime";
|
|
5
|
-
import { u as M, d as L, A as O } from "./index-
|
|
5
|
+
import { u as M, d as L, A as O } from "./index-CnKgiZFQ.js";
|
|
6
6
|
import "react";
|
|
7
7
|
import "./theme.js";
|
|
8
8
|
function E(e, t, r = null) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { h as oe, $ as X, m as le, k as ne } from "./clsx-
|
|
2
|
-
import {
|
|
1
|
+
import { h as oe, $ as X, m as le, k as ne } from "./clsx-BUPZHhq3.js";
|
|
2
|
+
import { O as K, H as ie, c as g, h as se, u as ae, d as ce, D as he, m as de, A as ue, n as ge, o as me, t as pe, B as we, $ as ve, R as fe } from "./index-CnKgiZFQ.js";
|
|
3
3
|
import { jsx as e, jsxs as y, Fragment as j } from "react/jsx-runtime";
|
|
4
|
-
import { useState as H, useMemo as G, useCallback as q, useEffect as $, useRef as
|
|
5
|
-
import { I as
|
|
4
|
+
import { useState as H, useMemo as G, useCallback as q, useEffect as $, useRef as Q } from "react";
|
|
5
|
+
import { I as Y, i as J, j as Ce } from "./index-BGd2HiwP.js";
|
|
6
6
|
import { Color4 as m, Editor as Te, makeDropdownToolbar as be } from "easydrawer";
|
|
7
7
|
const W = {
|
|
8
8
|
TOP_LEFT: "tl",
|
|
@@ -12,8 +12,8 @@ const W = {
|
|
|
12
12
|
};
|
|
13
13
|
function xe({ editor: t, node: r, updateAttributes: o, getPos: n, selected: v }) {
|
|
14
14
|
const [b, M] = H({
|
|
15
|
-
width:
|
|
16
|
-
height:
|
|
15
|
+
width: Y,
|
|
16
|
+
height: Y
|
|
17
17
|
}), [d, a] = H({
|
|
18
18
|
width: 0,
|
|
19
19
|
height: 0
|
|
@@ -53,13 +53,13 @@ function xe({ editor: t, node: r, updateAttributes: o, getPos: n, selected: v })
|
|
|
53
53
|
const P = q(() => {
|
|
54
54
|
t.commands.setNodeSelection(n());
|
|
55
55
|
}, []), D = q(
|
|
56
|
-
|
|
56
|
+
K(() => {
|
|
57
57
|
const { width: u } = getComputedStyle(t.view.dom);
|
|
58
58
|
M((N) => ({
|
|
59
59
|
...N,
|
|
60
60
|
width: Number.parseInt(u, 10)
|
|
61
61
|
}));
|
|
62
|
-
},
|
|
62
|
+
}, J),
|
|
63
63
|
[t]
|
|
64
64
|
);
|
|
65
65
|
function V(u, N) {
|
|
@@ -76,7 +76,7 @@ function xe({ editor: t, node: r, updateAttributes: o, getPos: n, selected: v })
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
const p = q(
|
|
79
|
-
|
|
79
|
+
K((u) => {
|
|
80
80
|
if (u.preventDefault(), u.stopPropagation(), !x)
|
|
81
81
|
return;
|
|
82
82
|
const { x: N, w: L, dir: _ } = c, z = (u.clientX - N) * (/l/.test(_) ? -1 : 1), { width: f, height: A } = r == null ? void 0 : r.attrs, E = f / A, Z = ie(L + z, Ce, b.width), re = Math.round(Z / E);
|
|
@@ -84,7 +84,7 @@ function xe({ editor: t, node: r, updateAttributes: o, getPos: n, selected: v })
|
|
|
84
84
|
width: Z,
|
|
85
85
|
height: re
|
|
86
86
|
});
|
|
87
|
-
},
|
|
87
|
+
}, J),
|
|
88
88
|
[x, c, b, o, r == null ? void 0 : r.attrs]
|
|
89
89
|
), s = q(
|
|
90
90
|
(u) => {
|
|
@@ -379,13 +379,13 @@ function je(t) {
|
|
|
379
379
|
}
|
|
380
380
|
) });
|
|
381
381
|
}
|
|
382
|
-
const Ze = "_wrapper_pva9d_1", Xe = "_tool_pva9d_17",
|
|
382
|
+
const Ze = "_wrapper_pva9d_1", Xe = "_tool_pva9d_17", Ke = "_active_pva9d_37", Qe = "_pen_pva9d_41", Ye = "_line_pva9d_48", Je = "_options_pva9d_56", et = "_colorWrap_pva9d_66", tt = "_color_pva9d_66", rt = "_colorActive_pva9d_83", l = {
|
|
383
383
|
wrapper: Ze,
|
|
384
384
|
tool: Xe,
|
|
385
|
-
active:
|
|
386
|
-
pen:
|
|
387
|
-
line:
|
|
388
|
-
options:
|
|
385
|
+
active: Ke,
|
|
386
|
+
pen: Qe,
|
|
387
|
+
line: Ye,
|
|
388
|
+
options: Je,
|
|
389
389
|
colorWrap: et,
|
|
390
390
|
color: tt,
|
|
391
391
|
colorActive: rt
|
|
@@ -877,7 +877,7 @@ function ct(t = 8) {
|
|
|
877
877
|
}
|
|
878
878
|
let I = !1;
|
|
879
879
|
function vt() {
|
|
880
|
-
const t = se(), r = ae(ht.name), { isActive: o = void 0, upload: n } = (r == null ? void 0 : r.componentProps) ?? {}, { editorDisabled: v } = ce(o), [b, M] = H(!1), d =
|
|
880
|
+
const t = se(), r = ae(ht.name), { isActive: o = void 0, upload: n } = (r == null ? void 0 : r.componentProps) ?? {}, { editorDisabled: v } = ce(o), [b, M] = H(!1), d = Q(null), a = Q(null), S = () => {
|
|
881
881
|
(async () => {
|
|
882
882
|
const s = document.querySelector("#easydrawer");
|
|
883
883
|
s && (d.current = new Te(s, {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
`);let r=0,o="";for(;r<t.length;r++){const n=t.charCodeAt(r);n<128?o+=String.fromCharCode(n):n>127&&n<2048?(o+=String.fromCharCode(n>>6|192),o+=String.fromCharCode(63&n|128)):(o+=String.fromCharCode(n>>12|224),o+=String.fromCharCode(n>>6&63|128),o+=String.fromCharCode(63&n|128))}return o},te=t=>{let r,o,n,v,j,S,d,c=0,M="";for(t=ee(t);c<t.length;)r=t.charCodeAt(c++),o=t.charCodeAt(c++),n=t.charCodeAt(c++),v=r>>2,j=(3&r)<<4|o>>4,S=(15&o)<<2|n>>6,d=63&n,isNaN(o)?S=d=64:isNaN(n)&&(d=64),M=M+W.charAt(v)+W.charAt(j)+W.charAt(S)+W.charAt(d);return M},re=t=>typeof t=="string"?"string":typeof SVGElement<"u"&&t instanceof SVGElement?"element":void 0,$=t=>"data:image/svg+xml;base64,"+te(t),oe=t=>$(new XMLSerializer().serializeToString(t)),Z=t=>{switch(re(t)){case"string":return $(t);case"element":return oe(t);default:return t}};function le(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{color:"currentColor",d:"M2 9.2v3.6M12.8 2H9.2M7.5 20H9M20 7.5V9M2.133 4.699c.155-.727.415-1.274.854-1.712c.426-.426.954-.684 1.652-.84m15.228 2.552c-.155-.727-.415-1.274-.854-1.712c-.417-.417-.932-.673-1.608-.83M4.64 19.853c-.698-.156-1.226-.414-1.652-.84c-.43-.43-.69-.965-.845-1.673m11.638 3.626c-1.812.125-3.607-8.326-2.374-9.559s9.684.561 9.559 2.373c-.087 1.187-2.095 1.656-2.037 2.711c.018.309.408.59 1.188 1.154c.543.39 1.096.77 1.629 1.175a.66.66 0 0 1 .234.687a3.35 3.35 0 0 1-2.472 2.473a.66.66 0 0 1-.688-.235c-.404-.533-.784-1.086-1.175-1.628c-.563-.78-.844-1.17-1.153-1.188c-1.055-.059-1.524 1.95-2.71 2.037",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})})}function ne(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M20.06 18a4 4 0 0 1-.2-.89c-.67.7-1.48 1.05-2.41 1.05c-.83 0-1.52-.24-2.05-.71c-.53-.45-.8-1.06-.8-1.79c0-.88.33-1.56 1-2.05s1.61-.73 2.83-.73h1.4v-.64q0-.735-.45-1.17c-.3-.29-.75-.43-1.33-.43c-.52 0-.95.12-1.3.36c-.35.25-.52.54-.52.89h-1.46c0-.43.15-.84.45-1.24c.28-.4.71-.71 1.22-.94c.51-.21 1.06-.35 1.69-.35c.98 0 1.74.24 2.29.73s.84 1.16.86 2.02V16c0 .8.1 1.42.3 1.88V18zm-2.4-1.12c.45 0 .88-.11 1.29-.32c.4-.21.7-.49.88-.83v-1.57H18.7c-1.77 0-2.66.47-2.66 1.41c0 .43.15.73.46.96c.3.23.68.35 1.16.35m-12.2-3.17h4.07L7.5 8.29zM6.64 6h1.72l4.71 12h-1.93l-.97-2.57H4.82L3.86 18H1.93z",fill:"currentColor"})})}function se(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M3 21v-4.25L16.2 3.575q.3-.275.663-.425t.762-.15t.775.15t.65.45L20.425 5q.3.275.438.65T21 6.4q0 .4-.137.763t-.438.662L7.25 21zM17.6 7.8L19 6.4L17.6 5l-1.4 1.4z",fill:"currentColor"})})}function ie(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M253.66 106.34a8 8 0 0 0-11.32 0L192 156.69L107.31 72l50.35-50.34a8 8 0 1 0-11.32-11.32L96 60.69a16 16 0 0 0-2.82 18.81L72 100.69a16 16 0 0 0 0 22.62l4.69 4.69l-58.35 58.34a8 8 0 0 0 3.13 13.25l72 24A7.9 7.9 0 0 0 96 224a8 8 0 0 0 5.66-2.34L136 187.31l4.69 4.69a16 16 0 0 0 22.62 0l21.19-21.18a16 16 0 0 0 18.81-2.82l50.35-50.34a8 8 0 0 0 0-11.32M93.84 206.85l-55-18.35L88 139.31L124.69 176ZM152 180.69L83.31 112L104 91.31L172.69 160Z",fill:"currentColor"})})}function ae(t){return e.jsxs("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:[e.jsx("path",{d:"m2.648 9.937l7.29-7.288a2.21 2.21 0 0 1 3.124 0l2.29 2.288a2.21 2.21 0 0 1 0 3.126L10.413 13H12.5a.5.5 0 0 1 0 1H4.501a2.2 2.2 0 0 1-1.563-.647l.707-.707c.227.226.535.354.856.354h4.005a1.2 1.2 0 0 0 .848-.354l1.292-1.293l-4-4l-3.29 3.291a1.21 1.21 0 0 0 0 1.712l.29.29l-.708.707l-.29-.29a2.21 2.21 0 0 1 0-3.126M8 6h6.89a1.2 1.2 0 0 0-.246-.356L14 5H9zm2-2h3l-.645-.644a1.21 1.21 0 0 0-1.71 0zm4.89 3H7.708l1 1H14l.644-.644A1.2 1.2 0 0 0 14.891 7zM9.708 9l1.646 1.646L13 9z",fill:"currentColor"}),e.jsx("path",{d:"M14 11.5a.5.5 0 1 1-1 0a.5.5 0 0 1 1 0m1.5-.5a.5.5 0 1 0 0-1a.5.5 0 0 0 0 1m-1 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1z",fill:"currentColor"})]})}function ce(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function he(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function ue(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12 22q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4T6.325 6.325T4 12t2.325 5.675T12 20m0-8",fill:"currentColor"})})}function de(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M10.363 3.591L2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})}function ge(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"m6.8 21l-5.2-9l5.2-9h10.4l5.2 9l-5.2 9zm1.15-2h8.1l4.025-7l-4.025-7h-8.1L3.9 12zM12 12",fill:"currentColor"})})}function me(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsxs("g",{fill:"none",fillRule:"evenodd",children:[e.jsx("path",{d:"m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"}),e.jsx("path",{d:"M10.586 2.807a2 2 0 0 1 2.828 0l7.778 7.779a2 2 0 0 1 0 2.828l-7.778 7.778a2 2 0 0 1-2.828 0l-7.778-7.778a2 2 0 0 1 0-2.828zM12 4.222L4.222 12L12 19.778L19.778 12z",fill:"currentColor"})]})})}function pe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function xe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{clipRule:"evenodd",d:"M7.53 3.47a.75.75 0 0 1 0 1.06L5.81 6.25H15a5.75 5.75 0 0 1 0 11.5H8a.75.75 0 0 1 0-1.5h7a4.25 4.25 0 0 0 0-8.5H5.81l1.72 1.72a.75.75 0 1 1-1.06 1.06l-3-3a.75.75 0 0 1 0-1.06l3-3a.75.75 0 0 1 1.06 0",fill:"currentColor",fillRule:"evenodd"})})}function we(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{clipRule:"evenodd",d:"M16.47 3.47a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H9a4.25 4.25 0 0 0 0 8.5h7a.75.75 0 0 1 0 1.5H9a5.75 5.75 0 0 1 0-11.5h9.19l-1.72-1.72a.75.75 0 0 1 0-1.06",fill:"currentColor",fillRule:"evenodd"})})}function ve(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function Ce(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M211.81 83.79a28 28 0 0 1-33.12 4.83l-90.07 90.07a28 28 0 1 1-44.43-6.48a28 28 0 0 1 33.12-4.83l90.07-90.07a28 28 0 1 1 44.43 6.48",fill:"currentColor"})})}function fe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12 20.325q-.35 0-.712-.125t-.638-.4l-1.725-1.575q-2.65-2.425-4.788-4.812T2 8.15Q2 5.8 3.575 4.225T7.5 2.65q1.325 0 2.5.562t2 1.538q.825-.975 2-1.537t2.5-.563q2.35 0 3.925 1.575T22 8.15q0 2.875-2.125 5.275T15.05 18.25l-1.7 1.55q-.275.275-.637.4t-.713.125M11.05 6.75q-.725-1.025-1.55-1.563t-2-.537q-1.5 0-2.5 1t-1 2.5q0 1.3.925 2.763t2.213 2.837t2.65 2.575T12 18.3q.85-.775 2.213-1.975t2.65-2.575t2.212-2.837T20 8.15q0-1.5-1-2.5t-2.5-1q-1.175 0-2 .538T12.95 6.75q-.175.25-.425.375T12 7.25t-.525-.125t-.425-.375m.95 4.725",fill:"currentColor"})})}function Te(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"m7.625 6.4l2.8-3.625q.3-.4.713-.587T12 2t.863.188t.712.587l2.8 3.625l4.25 1.425q.65.2 1.025.738t.375 1.187q0 .3-.088.6t-.287.575l-2.75 3.9l.1 4.1q.025.875-.575 1.475t-1.4.6q-.05 0-.55-.075L12 19.675l-4.475 1.25q-.125.05-.275.063T6.975 21q-.8 0-1.4-.6T5 18.925l.1-4.125l-2.725-3.875q-.2-.275-.288-.575T2 9.75q0-.625.363-1.162t1.012-.763zM8.85 8.125L4 9.725L7.1 14.2L7 18.975l5-1.375l5 1.4l-.1-4.8L20 9.775l-4.85-1.65L12 4zM12 11.5",fill:"currentColor"})})}function je(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12.01 6c2.61 0 4.89 1.86 5.4 4.43l.3 1.5l1.52.11c1.56.11 2.78 1.41 2.78 2.96c0 1.65-1.35 3-3 3h-13c-2.21 0-4-1.79-4-4c0-2.05 1.53-3.76 3.56-3.97l1.07-.11l.5-.95A5.46 5.46 0 0 1 12.01 6m0-2C9.12 4 6.6 5.64 5.35 8.04C2.35 8.36.01 10.91.01 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5c0-2.64-2.05-4.78-4.64-4.96C18.68 6.59 15.65 4 12.01 4",fill:"currentColor"})})}function be(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M5.586 6.45A2 2 0 0 1 7.509 5h11.84a2 2 0 0 1 1.923 2.55l-2.858 10A2 2 0 0 1 16.491 19H4.651a2 2 0 0 1-1.923-2.55z",fill:"none",stroke:"currentColor",strokeWidth:"2"})})}const Se="_wrapper_pva9d_1",Me="_tool_pva9d_17",ye="_active_pva9d_37",Ee="_pen_pva9d_41",He="_line_pva9d_48",Ne="_options_pva9d_56",Le="_colorWrap_pva9d_66",ke="_color_pva9d_66",Ae="_colorActive_pva9d_83",l={wrapper:Se,tool:Me,active:ye,pen:Ee,line:He,options:Ne,colorWrap:Le,color:ke,colorActive:Ae},_e=[p.Color4.blackHighlight,p.Color4.ofRGBA(166/255,81/255,167/255,.3),p.Color4.ofRGBA(247/255,78/255,158/255,.3),p.Color4.ofRGBA(166/255,83/255,88/255,.3),p.Color4.ofRGBA(246/255,130/255,28/255,.3),p.Color4.ofRGBA(166/255,198/255,0,.3),p.Color4.ofRGBA(98/255,186/255,70/255,.3)],U=[p.Color4.black,p.Color4.fromHex("#007AFF"),p.Color4.fromHex("#A651A7"),p.Color4.fromHex("#F74E9E"),p.Color4.fromHex("#FF5358"),p.Color4.fromHex("#F6821C"),p.Color4.fromHex("#FFC600"),p.Color4.fromHex("#62BA46"),p.Color4.fromHex("#E6BFE8"),p.Color4.fromHex("#FEA3D2"),p.Color4.fromHex("#FFA0A3"),p.Color4.fromHex("#FBC276"),p.Color4.fromHex("#FFFB85"),p.Color4.fromHex("#AADC99")];function ze({onChange:t}){const[r,o]=m.useState(p.Color4.blackHighlight);return e.jsx("div",{className:l.colorWrap,children:_e.map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:i.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))})}function V({onChange:t}){const[r,o]=m.useState(p.Color4.black);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:l.colorWrap,children:U.slice(0,7).map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:i.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))}),e.jsx("div",{className:l.colorWrap,children:U.slice(7).map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:i.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))})]})}function Be({setColorPen:t,setThicknessPen:r}){const[o,n]=m.useState(2);return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx(V,{onChange:v=>t(v)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{max:10,min:1,step:.1,type:"range",value:o,onChange:v=>{r(Number.parseFloat(v.target.value)),n(Number.parseFloat(v.target.value))}})})]})}function qe({setColorHighlight:t}){return e.jsx("div",{className:l.options,children:e.jsx(ze,{onChange:r=>t(r)})})}function Pe({changeColorShape:t,changeBorderColorShape:r,onThicknessChange:o}){return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx(V,{onChange:n=>t(n)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx(V,{onChange:n=>r(n)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:n=>{o(Number.parseFloat(n.target.value))}})})]})}function X(t){const{setColorPen:r,refEditor:o,setThicknessPen:n,setColorHighlight:v,changeBorderColorShape:j,onUndo:S,changeColorShape:d,changeShape:c,onThicknessChange:M,onRedo:b,onClear:_}=t,[h,u]=m.useState(null),[T,f]=m.useState(0);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:l.wrapper,children:[e.jsxs("div",{className:l.pen,children:[e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="select"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="select"){u(null),s[0].setEnabled(!1);return}u("select"),s[0].setEnabled(!0)},children:e.jsx(le,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="text"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(o.current.toolController.setToolEnabled(s[1]),h==="text"){s[1].setEnabled(!1),u(null);return}u("text"),s[1].setEnabled(!0)},children:e.jsx(ne,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="pencil"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="pencil"){u(null),s[2].setEnabled(!1);return}u("pencil"),s[2].setEnabled(!0)},children:e.jsx(se,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="highlighter"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="highlighter"){u(null),s[3].setEnabled(!1);return}u("highlighter"),s[3].setEnabled(!0)},children:e.jsx(ie,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="eraser"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="eraser"){u(null),s[4].setEnabled(!1);return}u("eraser"),s[4].setEnabled(!0)},children:e.jsx(ae,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===0}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(0),f(0)},children:e.jsx(ce,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===1}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(1),f(1)},children:e.jsx(he,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===2}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(2),f(2)},children:e.jsx(ue,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===3}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(3),f(3)},children:e.jsx(de,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===4}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(4),f(4)},children:e.jsx(ge,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===5}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(5),f(5)},children:e.jsx(me,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===6}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(6),f(6)},children:e.jsx(pe,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===7}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(7),f(7)},children:e.jsx(Ce,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===8}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(8),f(8)},children:e.jsx(fe,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===9}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(9),f(9)},children:e.jsx(Te,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===10}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(10),f(10)},children:e.jsx(je,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===11}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(11),f(11)},children:e.jsx(be,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool),onClick:S,children:e.jsx(xe,{})}),e.jsx("button",{className:i.cn(l.tool),onClick:b,children:e.jsx(we,{})}),e.jsx("button",{className:i.cn(l.tool),onClick:_,children:e.jsx(ve,{})})]}),e.jsxs("div",{className:l.optionsWrap,children:[h==="pencil"&&e.jsx(Be,{setColorPen:r,setThicknessPen:n}),h==="highlighter"&&e.jsx(qe,{setColorHighlight:v}),h==="shapes"&&e.jsx(Pe,{changeBorderColorShape:j,changeColorShape:d,changeShape:c,onThicknessChange:M})]})]})})}function K(t=8){return Math.random().toString(36).substring(2,t+2)}let P=!1;function Ie(){const t=i.useEditorInstance(),r=i.useButtonProps(Q.name),{isActive:o=void 0,upload:n}=(r==null?void 0:r.componentProps)??{},{editorDisabled:v}=i.useToggleActive(o),[j,S]=m.useState(!1),d=m.useRef(null),c=m.useRef(null),M=()=>{(async()=>{const a=document.querySelector("#easydrawer");a&&(d.current=new p.Editor(a,{wheelEventsEnabled:!1,disableZoom:!0}),c.current=p.makeDropdownToolbar(d.current),c.current.addDefaultToolWidgets())})()};m.useEffect(()=>{j&&setTimeout(()=>{M()},200)},[j]);const b=async()=>{if(d.current){const x=d.current.toSVG(),a=x.outerHTML,w=`drawer-${K()}.svg`;let L=Z(x.outerHTML);if(n){const B=i.dataURLtoFile(L,w);L=await n(B)}t==null||t.chain().focus().setDrawer({type:"drawer",src:L,alt:encodeURIComponent(a),width:426,height:212},!!a).run()}S(!1)},_=x=>{const a=d.current.toolController.getPrimaryTools()[2],w=c.current.getWidgetById("pen-1");a&&w&&(a.setColor(x),w.serializeState())},h=x=>{const a=d.current.toolController.getPrimaryTools()[2],w=c.current.getWidgetById("pen-1");a&&w&&(a.setThickness(x),w.serializeState())},u=x=>{const a=d.current.toolController.getPrimaryTools()[3],w=c.current.getWidgetById("pen-2");a&&w&&(a.setColor(x),w.serializeState())},T=x=>{const a=c.current.getWidgetById("shape");a&&a.setShapeType(x)},f=x=>{const a=d.current.toolController.getPrimaryTools()[5],w=c.current.getWidgetById("shape");a&&w&&(a.setColor(x),w.serializeState())},s=x=>{const a=d.current.toolController.getPrimaryTools()[5],w=c.current.getWidgetById("shape");a&&w&&(a.setThickness(x),w.serializeState())},F=x=>{const a=d.current.toolController.getPrimaryTools()[5],w=c.current.getWidgetById("shape");a&&w&&(a.setBorderColor(x),w.serializeState())},z=()=>{if(P){for(;d.current.history.redoStackSize>0;)d.current.history.redo();P=!1;return}d.current.history.undo()},R=()=>{P||d.current.history.redo()},O=()=>{if(!P){for(;d.current.history.undoStackSize>0;)z();P=!0}};return r?e.jsxs(i.Dialog,{onOpenChange:S,open:j,children:[e.jsx(i.DialogTrigger,{asChild:!0,children:e.jsx(i.ActionButton,{disabled:v,action:()=>{v||S(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),e.jsxs(i.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[e.jsx(i.DialogTitle,{children:"Drawer"}),e.jsxs("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[e.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),e.jsx(X,{changeBorderColorShape:F,changeColorShape:f,changeShape:T,onClear:O,onRedo:R,onThicknessChange:s,onUndo:z,refEditor:d,setColorHighlight:u,setColorPen:_,setThicknessPen:h})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{onClick:b,type:"button",children:"Save changes"})})]})]}):e.jsx(e.Fragment,{})}const Q=i.index_default.extend({name:"richTextDrawer",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({t:r,extension:o})=>{var n;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,icon:"PencilRuler",tooltip:r("editor.drawer.tooltip"),upload:(n=o==null?void 0:o.options)==null?void 0:n.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:r=>{const o=r.querySelector("img"),n=o==null?void 0:o.getAttribute("width");return n?Number.parseInt(n,10):320},renderHTML:r=>({width:r.width})},height:{default:null,parseHTML:r=>{const o=r.querySelector("img"),n=o==null?void 0:o.getAttribute("height");return n?Number.parseInt(n,10):212},renderHTML:r=>({height:r.height})},align:{default:"center",parseHTML:r=>r.getAttribute("align"),renderHTML:r=>({align:r.align})}}},addNodeView(){return I.ReactNodeViewRenderer(J)},addCommands(){return{setDrawer:(t,r)=>({commands:o,editor:n})=>r?o.insertContent({type:this.name,attrs:t}):o.insertContentAt(n.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageDrawer:t=>({commands:r})=>r.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:r}=t;return["div",{style:r?`text-align: ${r};`:"",class:"imageDrawer"},["img",I.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageDrawer]",getAttrs:t=>{const r=t.querySelector("img"),o=r==null?void 0:r.getAttribute("width"),n=r==null?void 0:r.getAttribute("height");return{src:r==null?void 0:r.getAttribute("src"),alt:r==null?void 0:r.getAttribute("alt"),width:o?Number.parseInt(o,10):null,height:n?Number.parseInt(n,10):null,align:(r==null?void 0:r.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.ControlDrawer=X;exports.Drawer=Q;exports.RichTextDrawer=Ie;exports.i=Z;exports.shortId=K;
|
|
1
|
+
"use strict";const R=require("./clsx-CXbNJWDD.cjs"),i=require("./index-BynXHtjJ.cjs"),e=require("react/jsx-runtime"),m=require("react"),q=require("./index-DgOXAdKt.cjs"),p=require("easydrawer"),D={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function J({editor:t,node:r,updateAttributes:o,getPos:n,selected:v}){const[j,S]=m.useState({width:q.IMAGE_MAX_SIZE,height:q.IMAGE_MAX_SIZE}),[d,c]=m.useState({width:0,height:0}),[M]=m.useState([D.TOP_LEFT,D.TOP_RIGHT,D.BOTTOM_LEFT,D.BOTTOM_RIGHT]),[b,_]=m.useState(!1),[h,u]=m.useState({x:0,y:0,w:0,h:0,dir:""}),{align:T}=r==null?void 0:r.attrs,f=m.useMemo(()=>{const{src:g,alt:E,width:H,height:L}=r==null?void 0:r.attrs,k=R.isNumber(H)?`${H}px`:H,C=R.isNumber(L)?`${L}px`:L;return{src:g||void 0,alt:E||void 0,style:{width:k||void 0,height:C||void 0}}},[r==null?void 0:r.attrs]),s=m.useMemo(()=>{const{style:{width:g}}=f;return{width:g==="100%"?g:void 0}},[f]);function F(g){c({width:g.target.width,height:g.target.height})}const z=m.useCallback(()=>{t.commands.setNodeSelection(n())},[]),I=m.useCallback(i.throttle(()=>{const{width:g}=getComputedStyle(t.view.dom);S(E=>({...E,width:Number.parseInt(g,10)}))},q.IMAGE_THROTTLE_WAIT_TIME),[t]);function O(g,E){g.preventDefault(),g.stopPropagation();const H=d.width,L=d.height,k=H/L;let C=Number(r.attrs.width),N=Number(r.attrs.height);const y=j.width;C&&!N?(C=C>y?y:C,N=Math.round(C/k)):N&&!C?(C=Math.round(N*k),C=C>y?y:C):!C&&!N?(C=H>y?y:H,N=Math.round(C/k)):C=C>y?y:C,_(!0),u({x:g.clientX,y:g.clientY,w:C,h:N,dir:E})}const x=m.useCallback(i.throttle(g=>{if(g.preventDefault(),g.stopPropagation(),!b)return;const{x:E,w:H,dir:L}=h,k=(g.clientX-E)*(/l/.test(L)?-1:1),{width:C,height:N}=r==null?void 0:r.attrs,y=C/N,G=i.clamp(H+k,q.IMAGE_MIN_SIZE,j.width),Y=Math.round(G/y);o({width:G,height:Y})},q.IMAGE_THROTTLE_WAIT_TIME),[b,h,j,o,r==null?void 0:r.attrs]),a=m.useCallback(g=>{g.preventDefault(),g.stopPropagation(),b&&(u({x:0,y:0,w:0,h:0,dir:""}),_(!1),z())},[b,z]),w=m.useCallback(()=>{document==null||document.addEventListener("mousemove",x,!0),document==null||document.addEventListener("mouseup",a,!0)},[x,a]),A=m.useCallback(()=>{document==null||document.removeEventListener("mousemove",x,!0),document==null||document.removeEventListener("mouseup",a,!0)},[x,a]);m.useEffect(()=>(b?w():A(),()=>{A()}),[b,w,A]);const B=m.useMemo(()=>new ResizeObserver(()=>I()),[I]);return m.useEffect(()=>(B.observe(t.view.dom),()=>{B.disconnect()}),[t.view.dom,B]),e.jsx(R.NodeViewWrapper,{className:"image-view",style:{...s,width:"100%",textAlign:T},children:e.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...s,background:"#fff"},className:`image-view__body ${v?"image-view__body--focused":""} ${b?"image-view__body--resizing":""}`,children:[e.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:z,onLoad:F,src:f.src,style:f.style}),t.view.editable&&(v||b)&&e.jsx("div",{className:"image-resizer",children:M==null?void 0:M.map(g=>e.jsx("span",{className:`image-resizer__handler image-resizer__handler--${g}`,onMouseDown:E=>O(E,g)},`image-dir-${g}`))})]})})}const W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ee=t=>{t=t.replace(/\r\n/g,`
|
|
2
|
+
`);let r=0,o="";for(;r<t.length;r++){const n=t.charCodeAt(r);n<128?o+=String.fromCharCode(n):n>127&&n<2048?(o+=String.fromCharCode(n>>6|192),o+=String.fromCharCode(63&n|128)):(o+=String.fromCharCode(n>>12|224),o+=String.fromCharCode(n>>6&63|128),o+=String.fromCharCode(63&n|128))}return o},te=t=>{let r,o,n,v,j,S,d,c=0,M="";for(t=ee(t);c<t.length;)r=t.charCodeAt(c++),o=t.charCodeAt(c++),n=t.charCodeAt(c++),v=r>>2,j=(3&r)<<4|o>>4,S=(15&o)<<2|n>>6,d=63&n,isNaN(o)?S=d=64:isNaN(n)&&(d=64),M=M+W.charAt(v)+W.charAt(j)+W.charAt(S)+W.charAt(d);return M},re=t=>typeof t=="string"?"string":typeof SVGElement<"u"&&t instanceof SVGElement?"element":void 0,$=t=>"data:image/svg+xml;base64,"+te(t),oe=t=>$(new XMLSerializer().serializeToString(t)),Z=t=>{switch(re(t)){case"string":return $(t);case"element":return oe(t);default:return t}};function le(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{color:"currentColor",d:"M2 9.2v3.6M12.8 2H9.2M7.5 20H9M20 7.5V9M2.133 4.699c.155-.727.415-1.274.854-1.712c.426-.426.954-.684 1.652-.84m15.228 2.552c-.155-.727-.415-1.274-.854-1.712c-.417-.417-.932-.673-1.608-.83M4.64 19.853c-.698-.156-1.226-.414-1.652-.84c-.43-.43-.69-.965-.845-1.673m11.638 3.626c-1.812.125-3.607-8.326-2.374-9.559s9.684.561 9.559 2.373c-.087 1.187-2.095 1.656-2.037 2.711c.018.309.408.59 1.188 1.154c.543.39 1.096.77 1.629 1.175a.66.66 0 0 1 .234.687a3.35 3.35 0 0 1-2.472 2.473a.66.66 0 0 1-.688-.235c-.404-.533-.784-1.086-1.175-1.628c-.563-.78-.844-1.17-1.153-1.188c-1.055-.059-1.524 1.95-2.71 2.037",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})})}function ne(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M20.06 18a4 4 0 0 1-.2-.89c-.67.7-1.48 1.05-2.41 1.05c-.83 0-1.52-.24-2.05-.71c-.53-.45-.8-1.06-.8-1.79c0-.88.33-1.56 1-2.05s1.61-.73 2.83-.73h1.4v-.64q0-.735-.45-1.17c-.3-.29-.75-.43-1.33-.43c-.52 0-.95.12-1.3.36c-.35.25-.52.54-.52.89h-1.46c0-.43.15-.84.45-1.24c.28-.4.71-.71 1.22-.94c.51-.21 1.06-.35 1.69-.35c.98 0 1.74.24 2.29.73s.84 1.16.86 2.02V16c0 .8.1 1.42.3 1.88V18zm-2.4-1.12c.45 0 .88-.11 1.29-.32c.4-.21.7-.49.88-.83v-1.57H18.7c-1.77 0-2.66.47-2.66 1.41c0 .43.15.73.46.96c.3.23.68.35 1.16.35m-12.2-3.17h4.07L7.5 8.29zM6.64 6h1.72l4.71 12h-1.93l-.97-2.57H4.82L3.86 18H1.93z",fill:"currentColor"})})}function se(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M3 21v-4.25L16.2 3.575q.3-.275.663-.425t.762-.15t.775.15t.65.45L20.425 5q.3.275.438.65T21 6.4q0 .4-.137.763t-.438.662L7.25 21zM17.6 7.8L19 6.4L17.6 5l-1.4 1.4z",fill:"currentColor"})})}function ie(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M253.66 106.34a8 8 0 0 0-11.32 0L192 156.69L107.31 72l50.35-50.34a8 8 0 1 0-11.32-11.32L96 60.69a16 16 0 0 0-2.82 18.81L72 100.69a16 16 0 0 0 0 22.62l4.69 4.69l-58.35 58.34a8 8 0 0 0 3.13 13.25l72 24A7.9 7.9 0 0 0 96 224a8 8 0 0 0 5.66-2.34L136 187.31l4.69 4.69a16 16 0 0 0 22.62 0l21.19-21.18a16 16 0 0 0 18.81-2.82l50.35-50.34a8 8 0 0 0 0-11.32M93.84 206.85l-55-18.35L88 139.31L124.69 176ZM152 180.69L83.31 112L104 91.31L172.69 160Z",fill:"currentColor"})})}function ae(t){return e.jsxs("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:[e.jsx("path",{d:"m2.648 9.937l7.29-7.288a2.21 2.21 0 0 1 3.124 0l2.29 2.288a2.21 2.21 0 0 1 0 3.126L10.413 13H12.5a.5.5 0 0 1 0 1H4.501a2.2 2.2 0 0 1-1.563-.647l.707-.707c.227.226.535.354.856.354h4.005a1.2 1.2 0 0 0 .848-.354l1.292-1.293l-4-4l-3.29 3.291a1.21 1.21 0 0 0 0 1.712l.29.29l-.708.707l-.29-.29a2.21 2.21 0 0 1 0-3.126M8 6h6.89a1.2 1.2 0 0 0-.246-.356L14 5H9zm2-2h3l-.645-.644a1.21 1.21 0 0 0-1.71 0zm4.89 3H7.708l1 1H14l.644-.644A1.2 1.2 0 0 0 14.891 7zM9.708 9l1.646 1.646L13 9z",fill:"currentColor"}),e.jsx("path",{d:"M14 11.5a.5.5 0 1 1-1 0a.5.5 0 0 1 1 0m1.5-.5a.5.5 0 1 0 0-1a.5.5 0 0 0 0 1m-1 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1z",fill:"currentColor"})]})}function ce(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function he(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function ue(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12 22q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4T6.325 6.325T4 12t2.325 5.675T12 20m0-8",fill:"currentColor"})})}function de(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M10.363 3.591L2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})}function ge(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"m6.8 21l-5.2-9l5.2-9h10.4l5.2 9l-5.2 9zm1.15-2h8.1l4.025-7l-4.025-7h-8.1L3.9 12zM12 12",fill:"currentColor"})})}function me(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsxs("g",{fill:"none",fillRule:"evenodd",children:[e.jsx("path",{d:"m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"}),e.jsx("path",{d:"M10.586 2.807a2 2 0 0 1 2.828 0l7.778 7.779a2 2 0 0 1 0 2.828l-7.778 7.778a2 2 0 0 1-2.828 0l-7.778-7.778a2 2 0 0 1 0-2.828zM12 4.222L4.222 12L12 19.778L19.778 12z",fill:"currentColor"})]})})}function pe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function xe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{clipRule:"evenodd",d:"M7.53 3.47a.75.75 0 0 1 0 1.06L5.81 6.25H15a5.75 5.75 0 0 1 0 11.5H8a.75.75 0 0 1 0-1.5h7a4.25 4.25 0 0 0 0-8.5H5.81l1.72 1.72a.75.75 0 1 1-1.06 1.06l-3-3a.75.75 0 0 1 0-1.06l3-3a.75.75 0 0 1 1.06 0",fill:"currentColor",fillRule:"evenodd"})})}function we(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{clipRule:"evenodd",d:"M16.47 3.47a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H9a4.25 4.25 0 0 0 0 8.5h7a.75.75 0 0 1 0 1.5H9a5.75 5.75 0 0 1 0-11.5h9.19l-1.72-1.72a.75.75 0 0 1 0-1.06",fill:"currentColor",fillRule:"evenodd"})})}function ve(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function Ce(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M211.81 83.79a28 28 0 0 1-33.12 4.83l-90.07 90.07a28 28 0 1 1-44.43-6.48a28 28 0 0 1 33.12-4.83l90.07-90.07a28 28 0 1 1 44.43 6.48",fill:"currentColor"})})}function fe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12 20.325q-.35 0-.712-.125t-.638-.4l-1.725-1.575q-2.65-2.425-4.788-4.812T2 8.15Q2 5.8 3.575 4.225T7.5 2.65q1.325 0 2.5.562t2 1.538q.825-.975 2-1.537t2.5-.563q2.35 0 3.925 1.575T22 8.15q0 2.875-2.125 5.275T15.05 18.25l-1.7 1.55q-.275.275-.637.4t-.713.125M11.05 6.75q-.725-1.025-1.55-1.563t-2-.537q-1.5 0-2.5 1t-1 2.5q0 1.3.925 2.763t2.213 2.837t2.65 2.575T12 18.3q.85-.775 2.213-1.975t2.65-2.575t2.212-2.837T20 8.15q0-1.5-1-2.5t-2.5-1q-1.175 0-2 .538T12.95 6.75q-.175.25-.425.375T12 7.25t-.525-.125t-.425-.375m.95 4.725",fill:"currentColor"})})}function Te(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"m7.625 6.4l2.8-3.625q.3-.4.713-.587T12 2t.863.188t.712.587l2.8 3.625l4.25 1.425q.65.2 1.025.738t.375 1.187q0 .3-.088.6t-.287.575l-2.75 3.9l.1 4.1q.025.875-.575 1.475t-1.4.6q-.05 0-.55-.075L12 19.675l-4.475 1.25q-.125.05-.275.063T6.975 21q-.8 0-1.4-.6T5 18.925l.1-4.125l-2.725-3.875q-.2-.275-.288-.575T2 9.75q0-.625.363-1.162t1.012-.763zM8.85 8.125L4 9.725L7.1 14.2L7 18.975l5-1.375l5 1.4l-.1-4.8L20 9.775l-4.85-1.65L12 4zM12 11.5",fill:"currentColor"})})}function je(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12.01 6c2.61 0 4.89 1.86 5.4 4.43l.3 1.5l1.52.11c1.56.11 2.78 1.41 2.78 2.96c0 1.65-1.35 3-3 3h-13c-2.21 0-4-1.79-4-4c0-2.05 1.53-3.76 3.56-3.97l1.07-.11l.5-.95A5.46 5.46 0 0 1 12.01 6m0-2C9.12 4 6.6 5.64 5.35 8.04C2.35 8.36.01 10.91.01 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5c0-2.64-2.05-4.78-4.64-4.96C18.68 6.59 15.65 4 12.01 4",fill:"currentColor"})})}function be(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M5.586 6.45A2 2 0 0 1 7.509 5h11.84a2 2 0 0 1 1.923 2.55l-2.858 10A2 2 0 0 1 16.491 19H4.651a2 2 0 0 1-1.923-2.55z",fill:"none",stroke:"currentColor",strokeWidth:"2"})})}const Se="_wrapper_pva9d_1",Me="_tool_pva9d_17",ye="_active_pva9d_37",Ee="_pen_pva9d_41",He="_line_pva9d_48",Ne="_options_pva9d_56",Ae="_colorWrap_pva9d_66",Le="_color_pva9d_66",ke="_colorActive_pva9d_83",l={wrapper:Se,tool:Me,active:ye,pen:Ee,line:He,options:Ne,colorWrap:Ae,color:Le,colorActive:ke},_e=[p.Color4.blackHighlight,p.Color4.ofRGBA(166/255,81/255,167/255,.3),p.Color4.ofRGBA(247/255,78/255,158/255,.3),p.Color4.ofRGBA(166/255,83/255,88/255,.3),p.Color4.ofRGBA(246/255,130/255,28/255,.3),p.Color4.ofRGBA(166/255,198/255,0,.3),p.Color4.ofRGBA(98/255,186/255,70/255,.3)],U=[p.Color4.black,p.Color4.fromHex("#007AFF"),p.Color4.fromHex("#A651A7"),p.Color4.fromHex("#F74E9E"),p.Color4.fromHex("#FF5358"),p.Color4.fromHex("#F6821C"),p.Color4.fromHex("#FFC600"),p.Color4.fromHex("#62BA46"),p.Color4.fromHex("#E6BFE8"),p.Color4.fromHex("#FEA3D2"),p.Color4.fromHex("#FFA0A3"),p.Color4.fromHex("#FBC276"),p.Color4.fromHex("#FFFB85"),p.Color4.fromHex("#AADC99")];function ze({onChange:t}){const[r,o]=m.useState(p.Color4.blackHighlight);return e.jsx("div",{className:l.colorWrap,children:_e.map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:i.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))})}function V({onChange:t}){const[r,o]=m.useState(p.Color4.black);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:l.colorWrap,children:U.slice(0,7).map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:i.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))}),e.jsx("div",{className:l.colorWrap,children:U.slice(7).map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:i.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))})]})}function Be({setColorPen:t,setThicknessPen:r}){const[o,n]=m.useState(2);return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx(V,{onChange:v=>t(v)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{max:10,min:1,step:.1,type:"range",value:o,onChange:v=>{r(Number.parseFloat(v.target.value)),n(Number.parseFloat(v.target.value))}})})]})}function qe({setColorHighlight:t}){return e.jsx("div",{className:l.options,children:e.jsx(ze,{onChange:r=>t(r)})})}function Pe({changeColorShape:t,changeBorderColorShape:r,onThicknessChange:o}){return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx(V,{onChange:n=>t(n)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx(V,{onChange:n=>r(n)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:n=>{o(Number.parseFloat(n.target.value))}})})]})}function X(t){const{setColorPen:r,refEditor:o,setThicknessPen:n,setColorHighlight:v,changeBorderColorShape:j,onUndo:S,changeColorShape:d,changeShape:c,onThicknessChange:M,onRedo:b,onClear:_}=t,[h,u]=m.useState(null),[T,f]=m.useState(0);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:l.wrapper,children:[e.jsxs("div",{className:l.pen,children:[e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="select"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="select"){u(null),s[0].setEnabled(!1);return}u("select"),s[0].setEnabled(!0)},children:e.jsx(le,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="text"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(o.current.toolController.setToolEnabled(s[1]),h==="text"){s[1].setEnabled(!1),u(null);return}u("text"),s[1].setEnabled(!0)},children:e.jsx(ne,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="pencil"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="pencil"){u(null),s[2].setEnabled(!1);return}u("pencil"),s[2].setEnabled(!0)},children:e.jsx(se,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="highlighter"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="highlighter"){u(null),s[3].setEnabled(!1);return}u("highlighter"),s[3].setEnabled(!0)},children:e.jsx(ie,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="eraser"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(h==="eraser"){u(null),s[4].setEnabled(!1);return}u("eraser"),s[4].setEnabled(!0)},children:e.jsx(ae,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===0}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(0),f(0)},children:e.jsx(ce,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===1}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(1),f(1)},children:e.jsx(he,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===2}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(2),f(2)},children:e.jsx(ue,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===3}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(3),f(3)},children:e.jsx(de,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===4}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(4),f(4)},children:e.jsx(ge,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===5}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(5),f(5)},children:e.jsx(me,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===6}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(6),f(6)},children:e.jsx(pe,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===7}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(7),f(7)},children:e.jsx(Ce,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===8}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(8),f(8)},children:e.jsx(fe,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===9}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(9),f(9)},children:e.jsx(Te,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===10}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(10),f(10)},children:e.jsx(je,{})}),e.jsx("button",{className:i.cn(l.tool,{[l.active]:h==="shapes"&&T===11}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),u("shapes"),s[5].setEnabled(!0),c(11),f(11)},children:e.jsx(be,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:i.cn(l.tool),onClick:S,children:e.jsx(xe,{})}),e.jsx("button",{className:i.cn(l.tool),onClick:b,children:e.jsx(we,{})}),e.jsx("button",{className:i.cn(l.tool),onClick:_,children:e.jsx(ve,{})})]}),e.jsxs("div",{className:l.optionsWrap,children:[h==="pencil"&&e.jsx(Be,{setColorPen:r,setThicknessPen:n}),h==="highlighter"&&e.jsx(qe,{setColorHighlight:v}),h==="shapes"&&e.jsx(Pe,{changeBorderColorShape:j,changeColorShape:d,changeShape:c,onThicknessChange:M})]})]})})}function K(t=8){return Math.random().toString(36).substring(2,t+2)}let P=!1;function Re(){const t=i.useEditorInstance(),r=i.useButtonProps(Q.name),{isActive:o=void 0,upload:n}=(r==null?void 0:r.componentProps)??{},{editorDisabled:v}=i.useToggleActive(o),[j,S]=m.useState(!1),d=m.useRef(null),c=m.useRef(null),M=()=>{(async()=>{const a=document.querySelector("#easydrawer");a&&(d.current=new p.Editor(a,{wheelEventsEnabled:!1,disableZoom:!0}),c.current=p.makeDropdownToolbar(d.current),c.current.addDefaultToolWidgets())})()};m.useEffect(()=>{j&&setTimeout(()=>{M()},200)},[j]);const b=async()=>{if(d.current){const x=d.current.toSVG(),a=x.outerHTML,w=`drawer-${K()}.svg`;let A=Z(x.outerHTML);if(n){const B=i.dataURLtoFile(A,w);A=await n(B)}t==null||t.chain().focus().setDrawer({type:"drawer",src:A,alt:encodeURIComponent(a),width:426,height:212},!!a).run()}S(!1)},_=x=>{const a=d.current.toolController.getPrimaryTools()[2],w=c.current.getWidgetById("pen-1");a&&w&&(a.setColor(x),w.serializeState())},h=x=>{const a=d.current.toolController.getPrimaryTools()[2],w=c.current.getWidgetById("pen-1");a&&w&&(a.setThickness(x),w.serializeState())},u=x=>{const a=d.current.toolController.getPrimaryTools()[3],w=c.current.getWidgetById("pen-2");a&&w&&(a.setColor(x),w.serializeState())},T=x=>{const a=c.current.getWidgetById("shape");a&&a.setShapeType(x)},f=x=>{const a=d.current.toolController.getPrimaryTools()[5],w=c.current.getWidgetById("shape");a&&w&&(a.setColor(x),w.serializeState())},s=x=>{const a=d.current.toolController.getPrimaryTools()[5],w=c.current.getWidgetById("shape");a&&w&&(a.setThickness(x),w.serializeState())},F=x=>{const a=d.current.toolController.getPrimaryTools()[5],w=c.current.getWidgetById("shape");a&&w&&(a.setBorderColor(x),w.serializeState())},z=()=>{if(P){for(;d.current.history.redoStackSize>0;)d.current.history.redo();P=!1;return}d.current.history.undo()},I=()=>{P||d.current.history.redo()},O=()=>{if(!P){for(;d.current.history.undoStackSize>0;)z();P=!0}};return r?e.jsxs(i.Dialog,{onOpenChange:S,open:j,children:[e.jsx(i.DialogTrigger,{asChild:!0,children:e.jsx(i.ActionButton,{disabled:v,action:()=>{v||S(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),e.jsxs(i.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[e.jsx(i.DialogTitle,{children:"Drawer"}),e.jsxs("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[e.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),e.jsx(X,{changeBorderColorShape:F,changeColorShape:f,changeShape:T,onClear:O,onRedo:I,onThicknessChange:s,onUndo:z,refEditor:d,setColorHighlight:u,setColorPen:_,setThicknessPen:h})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{onClick:b,type:"button",children:"Save changes"})})]})]}):e.jsx(e.Fragment,{})}const Q=i.index_default.extend({name:"richTextDrawer",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({t:r,extension:o})=>{var n;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,icon:"PencilRuler",tooltip:r("editor.drawer.tooltip"),upload:(n=o==null?void 0:o.options)==null?void 0:n.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:r=>{const o=r.querySelector("img"),n=o==null?void 0:o.getAttribute("width");return n?Number.parseInt(n,10):320},renderHTML:r=>({width:r.width})},height:{default:null,parseHTML:r=>{const o=r.querySelector("img"),n=o==null?void 0:o.getAttribute("height");return n?Number.parseInt(n,10):212},renderHTML:r=>({height:r.height})},align:{default:"center",parseHTML:r=>r.getAttribute("align"),renderHTML:r=>({align:r.align})}}},addNodeView(){return R.ReactNodeViewRenderer(J)},addCommands(){return{setDrawer:(t,r)=>({commands:o,editor:n})=>r?o.insertContent({type:this.name,attrs:t}):o.insertContentAt(n.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageDrawer:t=>({commands:r})=>r.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:r}=t;return["div",{style:r?`text-align: ${r};`:"",class:"imageDrawer"},["img",R.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageDrawer]",getAttrs:t=>{const r=t.querySelector("img"),o=r==null?void 0:r.getAttribute("width"),n=r==null?void 0:r.getAttribute("height");return{src:r==null?void 0:r.getAttribute("src"),alt:r==null?void 0:r.getAttribute("alt"),width:o?Number.parseInt(o,10):null,height:n?Number.parseInt(n,10):null,align:(r==null?void 0:r.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.ControlDrawer=X;exports.Drawer=Q;exports.RichTextDrawer=Re;exports.i=Z;exports.shortId=K;
|
package/lib/Drawer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");require("./index-BynXHtjJ.cjs");const e=require("./Drawer-DlgdaO_B.cjs");exports.Drawer=e.Drawer;exports.RichTextDrawer=e.RichTextDrawer;
|
package/lib/Drawer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./clsx-
|
|
2
|
-
import "./index-
|
|
3
|
-
import { D as t, R as i } from "./Drawer-
|
|
1
|
+
import "./clsx-BUPZHhq3.js";
|
|
2
|
+
import "./index-CnKgiZFQ.js";
|
|
3
|
+
import { D as t, R as i } from "./Drawer-CayP4Ww4.js";
|
|
4
4
|
export {
|
|
5
5
|
t as Drawer,
|
|
6
6
|
i as RichTextDrawer
|