reactjs-tiptap-editor 1.0.7 → 1.0.9
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-fTe9ka2F.js → ActionMenuButton-C4aNFFa8.js} +2 -2
- package/lib/{ActionMenuButton-wU6jxKJv.cjs → ActionMenuButton-CmDopTWt.cjs} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +3 -3
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.js +3 -3
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +3 -3
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +3 -3
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +3 -3
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +3 -3
- package/lib/CodeBlock.cjs +39 -39
- package/lib/CodeBlock.js +945 -837
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +3 -3
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +8 -8
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +3 -3
- package/lib/{Drawer-BGSwHoka.cjs → Drawer-CTr2snNd.cjs} +1 -1
- package/lib/{Drawer-DmtILKW4.js → Drawer-DG0gPU_U.js} +14 -14
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +15 -15
- package/lib/{Excalidraw-CrG8fW-7.js → Excalidraw-DpgdxOsc.js} +18 -18
- package/lib/{Excalidraw-BG2U9i30.cjs → Excalidraw-DtezFdjR.cjs} +1 -1
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +2 -2
- package/lib/ExportPdf.cjs +2 -2
- package/lib/ExportPdf.js +26 -26
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +3 -3
- 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 +13 -13
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +8 -8
- package/lib/History.cjs +1 -1
- package/lib/History.js +4 -4
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +3 -3
- package/lib/{Icon-CysGlJkv.js → Icon-C_buGjWy.js} +1 -1
- package/lib/{Icon-C3j4ls73.cjs → Icon-b6HQAURz.cjs} +1 -1
- package/lib/{Iframe-CXDghI6m.cjs → Iframe-CUrXCDxj.cjs} +1 -1
- package/lib/{Iframe-BmqguWbj.js → Iframe-De88TYvj.js} +11 -11
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +46 -46
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +9 -9
- package/lib/ImportWord.cjs +2 -2
- package/lib/ImportWord.js +8 -8
- package/lib/{Indent-BhnGkEaY.js → Indent-Bensb2nf.js} +3 -3
- package/lib/{Indent-B1glTHHl.cjs → Indent-D_KtZNHW.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 +3 -3
- package/lib/{Katex-D4eBjS34.js → Katex-C0dtqznb.js} +974 -941
- package/lib/Katex-NqelWRoi.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 +13 -13
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-DW17TyCA.cjs → LinkEditBlock-BSZ-vgNB.cjs} +2 -2
- package/lib/{LinkEditBlock-D1eSM0kn.js → LinkEditBlock-Bv12sKvW.js} +29 -29
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +138 -132
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +20 -20
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +12 -12
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +3 -3
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +20 -20
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +14 -14
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +3 -3
- package/lib/{Table-BIZppoiY.js → Table-D9ckv6Tb.js} +5 -5
- package/lib/{Table-CIzgfvr9.cjs → Table-cy1mUM2X.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +3 -3
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +10 -10
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +10 -10
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +3 -3
- package/lib/Twitter-Bvs3sW8F.cjs +1 -0
- package/lib/{Twitter-DhczYjbR.js → Twitter-KUvyySA0.js} +566 -524
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +22 -22
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +1342 -1314
- package/lib/{button-C81t4pb1.js → button-D8SI-g7p.js} +1 -1
- package/lib/{button-B6ukqDUf.cjs → button-U6XpZt2X.cjs} +1 -1
- package/lib/{checkbox-ZdxysUFa.cjs → checkbox-DaIBNthL.cjs} +1 -1
- package/lib/{checkbox-CUE9ex4D.js → checkbox-xrY2c5yo.js} +1 -1
- package/lib/{dialog-Cfx8yjkr.cjs → dialog-DgnnVCfv.cjs} +1 -1
- package/lib/{dialog-DMJStzBb.js → dialog-DjnkASYP.js} +1 -1
- package/lib/{dropdown-menu-Busg3FNn.cjs → dropdown-menu-BvVMltdB.cjs} +1 -1
- package/lib/{dropdown-menu-B8iyTZcP.js → dropdown-menu-bI14Gyw4.js} +1 -1
- package/lib/extensions/Katex/Katex.d.ts +1 -1
- package/lib/extensions/Mention/Mention.d.ts +3 -1
- package/lib/extensions/Mention/components/NodeViewMentionList.d.ts +7 -1
- package/lib/{index-DCJheRBq.cjs → index--nUS7Y66.cjs} +1 -1
- package/lib/{index--knBGB61.js → index-4pRt5Vqu.js} +680 -791
- package/lib/{index-DLqogznp.cjs → index-BBNITgNi.cjs} +7 -7
- package/lib/{index-ccgHvIfu.js → index-BQ6ZdLsu.js} +1 -1
- package/lib/{index-DylewabB.cjs → index-BZ6DfR2r.cjs} +1 -1
- package/lib/{index-Dwt9--mS.js → index-BimeTI7q.js} +1 -1
- package/lib/{index-TMqmkmT6.cjs → index-CApXPpjF.cjs} +1 -1
- package/lib/{index-BvYjBPF9.js → index-CbIQPoF6.js} +12 -11
- package/lib/index-DvvMf6Wu.cjs +7 -0
- package/lib/{index-RKufd2EL.js → index-EKFybgpP.js} +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.js +2 -2
- package/lib/{input-BxzQAIRv.cjs → input-BtDj0NeF.cjs} +1 -1
- package/lib/{input-DR_5pbuA.js → input-C5zU49Q1.js} +1 -1
- package/lib/{isNumber-1y3eeW-y.js → isNumber-8HKEgTkA.js} +1 -1
- package/lib/{isNumber-C2saEiG2.cjs → isNumber-Bv1Qhmw8.cjs} +1 -1
- package/lib/{label-D-0oXKCn.js → label-BEUVs-IA.js} +1 -1
- package/lib/{label-BfWfLggp.cjs → label-C8BonzOY.cjs} +1 -1
- package/lib/{popover-D3spkemr.js → popover-CPY5lMCj.js} +1 -1
- package/lib/{popover-sP8CwbV-.cjs → popover-DjL0De8d.cjs} +1 -1
- package/lib/{separator-rM48NeAo.js → separator-BlIlS7LP.js} +18 -18
- package/lib/{separator-yycaNdlI.cjs → separator-BzMkiI_c.cjs} +1 -1
- package/lib/{store-BajRl43v.cjs → store-BSCjQxMK.cjs} +1 -1
- package/lib/{store-NKeQOve_.js → store-D_GvIPxo.js} +1 -1
- package/lib/style.css +1 -1
- package/lib/{tabs-D2nCIOVL.cjs → tabs-CHy82_rs.cjs} +1 -1
- package/lib/{tabs-Cb6Bmpbb.js → tabs-tQpXIzfV.js} +1 -1
- package/lib/{textarea-Cbwi_h4h.cjs → textarea-B-qfanCT.cjs} +1 -1
- package/lib/{textarea-BYZu1lUC.js → textarea-CMDYVXYo.js} +1 -1
- package/lib/{throttle-CjwXmkIY.js → throttle-BIkZV3Y_.js} +1 -1
- package/lib/{throttle-DXN-aiH5.cjs → throttle-BM3Bmbf_.cjs} +1 -1
- package/lib/{updatePosition-BAGpT34H.js → updatePosition-GLTrgcib.js} +1 -1
- package/lib/{updatePosition-C17CDdjq.cjs → updatePosition-u2mTh3mG.cjs} +1 -1
- package/lib/{useButtonProps-TfmRCM9r.cjs → useButtonProps-BqBGuqoP.cjs} +1 -1
- package/lib/{useButtonProps-BIH_9bXT.js → useButtonProps-DTngjZge.js} +2 -2
- package/package.json +55 -55
- package/lib/Katex-BKL_6NWF.cjs +0 -4
- package/lib/Twitter-DwWVNAV5.cjs +0 -1
- package/lib/index-D42xFOzI.cjs +0 -7
package/lib/Mention.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index-BBNITgNi.cjs"),v=require("@tiptap/pm/model"),p=require("./updatePosition-u2mTh3mG.cjs"),w=require("@tiptap/pm/state"),m=require("react/jsx-runtime"),h=require("react"),T=require("scroll-into-view-if-needed");function M({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r="@"}){const o=new w.PluginKey;return{editor:e,char:r,pluginKey:o,command:({editor:s,range:a,props:l})=>{var c,i,d;const g=s.view.state.selection.$to.nodeAfter;((c=g==null?void 0:g.text)==null?void 0:c.startsWith(" "))&&(a.to+=1),s.chain().focus().insertContentAt(a,[{type:n,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(d=(i=s.view.dom.ownerDocument.defaultView)==null?void 0:i.getSelection())==null||d.collapseToEnd()},allow:({state:s,range:a})=>{const l=s.doc.resolve(a.from),c=s.schema.nodes[n];return!!l.parent.type.contentMatch.matchType(c)},...t}}function y(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>M({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function x(e,t){const n=y(e),r=n.find(o=>o.char===t);return r||(n.length?n[0]:null)}var L=u.Node3.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:e,suggestion:t}){var n,r;return`${(n=t==null?void 0:t.char)!=null?n:"@"}${(r=e.attrs.label)!=null?r:e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t,suggestion:n}){var r,o;return["span",u.mergeAttributes(this.HTMLAttributes,e.HTMLAttributes),`${(r=n==null?void 0:n.char)!=null?r:"@"}${(o=t.attrs.label)!=null?o:t.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:e=>e.getAttribute("data-mention-suggestion-char"),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){const n=x(this,e.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",u.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e,suggestion:n})];const r={...this.options};r.HTMLAttributes=u.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,t);const o=this.options.renderHTML({options:r,node:e,suggestion:n});return typeof o=="string"?["span",u.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,t),o]:o},...u.createInlineMarkdownSpec({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:e=>{const t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(e);for(;r!==null;){const[,o,s,a]=r,l=s??a;t[o==="char"?"mentionSuggestionChar":o]=l,r=n.exec(e)}return t},serializeAttributes:e=>Object.entries(e).filter(([,t])=>t!=null).map(([t,n])=>`${t==="mentionSuggestionChar"?"char":t}="${n}"`).join(" ")}),renderText({node:e}){const t={options:this.options,node:e,suggestion:x(this,e.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(t)):this.options.renderText(t)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1;const{selection:r}=t,{empty:o,anchor:s}=r;if(!o)return!1;let a=new v.Node,l=0;return t.doc.nodesBetween(s-1,s,(c,i)=>{if(c.type.name===this.name)return n=!0,a=c,l=i,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?"":a.attrs.mentionSuggestionChar,l,l+a.nodeSize),n})}},addProseMirrorPlugins(){return y(this).map(p.Suggestion)}}),S=L;const A=h.forwardRef((e,t)=>{const n=h.useRef(null),[r,o]=h.useState(0),s=i=>{const d=e.items[i];d&&e.command(d)},a=()=>{o((r+e.items.length-1)%e.items.length)},l=()=>{o((r+1)%e.items.length)},c=()=>{s(r)};return h.useEffect(()=>o(0),[e.items]),h.useEffect(()=>{if(Number.isNaN(r+1))return;const i=n.current.querySelector(`span:nth-of-type(${r+1})`);i&&T(i,{behavior:"smooth",scrollMode:"if-needed"})},[r]),h.useImperativeHandle(t,()=>({onKeyDown:({event:i})=>i.key==="ArrowUp"?(a(),!0):i.key==="ArrowDown"?(l(),!0):i.key==="Enter"?(c(),!0):!1})),m.jsx("div",{className:" !richtext-max-h-[320px] !richtext-w-[160px] richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none","data-richtext-portal":!0,ref:n,children:m.jsx("div",{children:e.items.length>0?e.items.map((i,d)=>{var g;return m.jsxs("span",{className:u.clsx("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent ",{"bg-item-active":d===r}),onClick:f=>{f.preventDefault(),s(d)},children:[((g=i==null?void 0:i.avatar)==null?void 0:g.src)&&m.jsx("img",{alt:i.label,className:"richtext-size-5 richtext-rounded-full",src:i.avatar.src}),i==null?void 0:i.label]},`mention-item-${i.id}`)}):m.jsx("div",{className:u.clsx("itemUserEmpty, richtext-text-foreground"),children:"Empty"})})})});function b(){let e;return{onStart:t=>{t.clientRect&&(e=new u.ReactRenderer(A,{props:t,editor:t.editor}),e.element.style.position="absolute",document.body.appendChild(e.element),p.updatePosition(t.editor,e.element))},onUpdate(t){e.updateProps(t),t.clientRect&&p.updatePosition(t.editor,e.element)},onKeyDown(t){var n;return t.event.key==="Escape"?(e.destroy(),e.element.remove(),!0):(n=e.ref)==null?void 0:n.onKeyDown(t)},onExit(){e.destroy(),e.element.remove()}}}const H=u.Extension.create({name:"richTextMentionWrapper",addExtensions(){var t,n,r,o;const e={...this.options};return(t=this.options)!=null&&t.suggestion&&(e.suggestion={render:b,...this.options.suggestion}),(r=(n=this.options)==null?void 0:n.suggestions)!=null&&r.length&&(e.suggestions=(o=this.options.suggestions)==null?void 0:o.map(s=>({render:b,...s}))),[S.configure({HTMLAttributes:{class:"mention"},...e})]}});exports.Mention=H;
|
package/lib/Mention.js
CHANGED
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
import { N as w, B as
|
|
2
|
-
import { Node as
|
|
3
|
-
import { S as
|
|
4
|
-
import { PluginKey as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { forwardRef as
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
function k({
|
|
1
|
+
import { N as w, B as T, m as h, C as p, E as M, G as L } from "./index-CbIQPoF6.js";
|
|
2
|
+
import { Node as S } from "@tiptap/pm/model";
|
|
3
|
+
import { S as H, u as f } from "./updatePosition-GLTrgcib.js";
|
|
4
|
+
import { PluginKey as A } from "@tiptap/pm/state";
|
|
5
|
+
import { jsx as g, jsxs as C } from "react/jsx-runtime";
|
|
6
|
+
import { forwardRef as N, useRef as $, useState as k, useEffect as x, useImperativeHandle as E } from "react";
|
|
7
|
+
import K from "scroll-into-view-if-needed";
|
|
8
|
+
function _({
|
|
10
9
|
editor: e,
|
|
11
10
|
overrideSuggestionOptions: t,
|
|
12
|
-
extensionName:
|
|
13
|
-
char:
|
|
11
|
+
extensionName: n,
|
|
12
|
+
char: r = "@"
|
|
14
13
|
}) {
|
|
15
|
-
const
|
|
14
|
+
const o = new A();
|
|
16
15
|
return {
|
|
17
16
|
editor: e,
|
|
18
|
-
char:
|
|
19
|
-
pluginKey:
|
|
17
|
+
char: r,
|
|
18
|
+
pluginKey: o,
|
|
20
19
|
command: ({ editor: s, range: a, props: l }) => {
|
|
21
|
-
var u,
|
|
22
|
-
const
|
|
23
|
-
((u =
|
|
20
|
+
var u, i, d;
|
|
21
|
+
const c = s.view.state.selection.$to.nodeAfter;
|
|
22
|
+
((u = c == null ? void 0 : c.text) == null ? void 0 : u.startsWith(" ")) && (a.to += 1), s.chain().focus().insertContentAt(a, [
|
|
24
23
|
{
|
|
25
|
-
type:
|
|
26
|
-
attrs: { ...l, mentionSuggestionChar:
|
|
24
|
+
type: n,
|
|
25
|
+
attrs: { ...l, mentionSuggestionChar: r }
|
|
27
26
|
},
|
|
28
27
|
{
|
|
29
28
|
type: "text",
|
|
30
29
|
text: " "
|
|
31
30
|
}
|
|
32
|
-
]).run(), (d = (
|
|
31
|
+
]).run(), (d = (i = s.view.dom.ownerDocument.defaultView) == null ? void 0 : i.getSelection()) == null || d.collapseToEnd();
|
|
33
32
|
},
|
|
34
33
|
allow: ({ state: s, range: a }) => {
|
|
35
|
-
const l = s.doc.resolve(a.from), u = s.schema.nodes[
|
|
34
|
+
const l = s.doc.resolve(a.from), u = s.schema.nodes[n];
|
|
36
35
|
return !!l.parent.type.contentMatch.matchType(u);
|
|
37
36
|
},
|
|
38
37
|
...t
|
|
@@ -40,7 +39,7 @@ function k({
|
|
|
40
39
|
}
|
|
41
40
|
function y(e) {
|
|
42
41
|
return (e.options.suggestions.length ? e.options.suggestions : [e.options.suggestion]).map(
|
|
43
|
-
(t) =>
|
|
42
|
+
(t) => _({
|
|
44
43
|
// @ts-ignore `editor` can be `undefined` when converting the document to HTML with the HTML utility
|
|
45
44
|
editor: e.editor,
|
|
46
45
|
overrideSuggestionOptions: t,
|
|
@@ -50,8 +49,8 @@ function y(e) {
|
|
|
50
49
|
);
|
|
51
50
|
}
|
|
52
51
|
function b(e, t) {
|
|
53
|
-
const
|
|
54
|
-
return
|
|
52
|
+
const n = y(e), r = n.find((o) => o.char === t);
|
|
53
|
+
return r || (n.length ? n[0] : null);
|
|
55
54
|
}
|
|
56
55
|
var D = w.create({
|
|
57
56
|
name: "mention",
|
|
@@ -60,16 +59,16 @@ var D = w.create({
|
|
|
60
59
|
return {
|
|
61
60
|
HTMLAttributes: {},
|
|
62
61
|
renderText({ node: e, suggestion: t }) {
|
|
63
|
-
var
|
|
64
|
-
return `${(
|
|
62
|
+
var n, r;
|
|
63
|
+
return `${(n = t == null ? void 0 : t.char) != null ? n : "@"}${(r = e.attrs.label) != null ? r : e.attrs.id}`;
|
|
65
64
|
},
|
|
66
65
|
deleteTriggerWithBackspace: !1,
|
|
67
|
-
renderHTML({ options: e, node: t, suggestion:
|
|
68
|
-
var
|
|
66
|
+
renderHTML({ options: e, node: t, suggestion: n }) {
|
|
67
|
+
var r, o;
|
|
69
68
|
return [
|
|
70
69
|
"span",
|
|
71
|
-
|
|
72
|
-
`${(
|
|
70
|
+
h(this.HTMLAttributes, e.HTMLAttributes),
|
|
71
|
+
`${(r = n == null ? void 0 : n.char) != null ? r : "@"}${(o = t.attrs.label) != null ? o : t.attrs.id}`
|
|
73
72
|
];
|
|
74
73
|
},
|
|
75
74
|
suggestions: [],
|
|
@@ -114,45 +113,45 @@ var D = w.create({
|
|
|
114
113
|
];
|
|
115
114
|
},
|
|
116
115
|
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
117
|
-
const
|
|
116
|
+
const n = b(this, e.attrs.mentionSuggestionChar);
|
|
118
117
|
if (this.options.renderLabel !== void 0)
|
|
119
118
|
return console.warn("renderLabel is deprecated use renderText and renderHTML instead"), [
|
|
120
119
|
"span",
|
|
121
|
-
|
|
120
|
+
h({ "data-type": this.name }, this.options.HTMLAttributes, t),
|
|
122
121
|
this.options.renderLabel({
|
|
123
122
|
options: this.options,
|
|
124
123
|
node: e,
|
|
125
|
-
suggestion:
|
|
124
|
+
suggestion: n
|
|
126
125
|
})
|
|
127
126
|
];
|
|
128
|
-
const
|
|
129
|
-
|
|
127
|
+
const r = { ...this.options };
|
|
128
|
+
r.HTMLAttributes = h(
|
|
130
129
|
{ "data-type": this.name },
|
|
131
130
|
this.options.HTMLAttributes,
|
|
132
131
|
t
|
|
133
132
|
);
|
|
134
|
-
const
|
|
135
|
-
options:
|
|
133
|
+
const o = this.options.renderHTML({
|
|
134
|
+
options: r,
|
|
136
135
|
node: e,
|
|
137
|
-
suggestion:
|
|
136
|
+
suggestion: n
|
|
138
137
|
});
|
|
139
|
-
return typeof
|
|
138
|
+
return typeof o == "string" ? ["span", h({ "data-type": this.name }, this.options.HTMLAttributes, t), o] : o;
|
|
140
139
|
},
|
|
141
|
-
...
|
|
140
|
+
...T({
|
|
142
141
|
nodeName: "mention",
|
|
143
142
|
name: "@",
|
|
144
143
|
selfClosing: !0,
|
|
145
144
|
allowedAttributes: ["id", "label", { name: "mentionSuggestionChar", skipIfDefault: "@" }],
|
|
146
145
|
parseAttributes: (e) => {
|
|
147
|
-
const t = {},
|
|
148
|
-
let
|
|
149
|
-
for (;
|
|
150
|
-
const [,
|
|
151
|
-
t[
|
|
146
|
+
const t = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
|
|
147
|
+
let r = n.exec(e);
|
|
148
|
+
for (; r !== null; ) {
|
|
149
|
+
const [, o, s, a] = r, l = s ?? a;
|
|
150
|
+
t[o === "char" ? "mentionSuggestionChar" : o] = l, r = n.exec(e);
|
|
152
151
|
}
|
|
153
152
|
return t;
|
|
154
153
|
},
|
|
155
|
-
serializeAttributes: (e) => Object.entries(e).filter(([, t]) => t != null).map(([t,
|
|
154
|
+
serializeAttributes: (e) => Object.entries(e).filter(([, t]) => t != null).map(([t, n]) => `${t === "mentionSuggestionChar" ? "char" : t}="${n}"`).join(" ")
|
|
156
155
|
}),
|
|
157
156
|
renderText({ node: e }) {
|
|
158
157
|
const t = {
|
|
@@ -165,110 +164,117 @@ var D = w.create({
|
|
|
165
164
|
addKeyboardShortcuts() {
|
|
166
165
|
return {
|
|
167
166
|
Backspace: () => this.editor.commands.command(({ tr: e, state: t }) => {
|
|
168
|
-
let
|
|
169
|
-
const { selection:
|
|
170
|
-
if (!
|
|
167
|
+
let n = !1;
|
|
168
|
+
const { selection: r } = t, { empty: o, anchor: s } = r;
|
|
169
|
+
if (!o)
|
|
171
170
|
return !1;
|
|
172
|
-
let a = new
|
|
173
|
-
return t.doc.nodesBetween(s - 1, s, (u,
|
|
171
|
+
let a = new S(), l = 0;
|
|
172
|
+
return t.doc.nodesBetween(s - 1, s, (u, i) => {
|
|
174
173
|
if (u.type.name === this.name)
|
|
175
|
-
return
|
|
176
|
-
}),
|
|
174
|
+
return n = !0, a = u, l = i, !1;
|
|
175
|
+
}), n && e.insertText(
|
|
177
176
|
this.options.deleteTriggerWithBackspace ? "" : a.attrs.mentionSuggestionChar,
|
|
178
177
|
l,
|
|
179
178
|
l + a.nodeSize
|
|
180
|
-
),
|
|
179
|
+
), n;
|
|
181
180
|
})
|
|
182
181
|
};
|
|
183
182
|
},
|
|
184
183
|
addProseMirrorPlugins() {
|
|
185
|
-
return y(this).map(
|
|
184
|
+
return y(this).map(H);
|
|
186
185
|
}
|
|
187
|
-
}),
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const d = e.items[
|
|
191
|
-
d && e.command(
|
|
186
|
+
}), I = D;
|
|
187
|
+
const R = N((e, t) => {
|
|
188
|
+
const n = $(null), [r, o] = k(0), s = (i) => {
|
|
189
|
+
const d = e.items[i];
|
|
190
|
+
d && e.command(d);
|
|
192
191
|
}, a = () => {
|
|
193
|
-
|
|
192
|
+
o((r + e.items.length - 1) % e.items.length);
|
|
194
193
|
}, l = () => {
|
|
195
|
-
|
|
194
|
+
o((r + 1) % e.items.length);
|
|
196
195
|
}, u = () => {
|
|
197
|
-
s(
|
|
196
|
+
s(r);
|
|
198
197
|
};
|
|
199
|
-
return
|
|
200
|
-
if (Number.isNaN(
|
|
198
|
+
return x(() => o(0), [e.items]), x(() => {
|
|
199
|
+
if (Number.isNaN(r + 1))
|
|
201
200
|
return;
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
}, [
|
|
205
|
-
onKeyDown: ({ event:
|
|
206
|
-
})), /* @__PURE__ */
|
|
207
|
-
"
|
|
201
|
+
const i = n.current.querySelector(`span:nth-of-type(${r + 1})`);
|
|
202
|
+
i && K(i, { behavior: "smooth", scrollMode: "if-needed" });
|
|
203
|
+
}, [r]), E(t, () => ({
|
|
204
|
+
onKeyDown: ({ event: i }) => i.key === "ArrowUp" ? (a(), !0) : i.key === "ArrowDown" ? (l(), !0) : i.key === "Enter" ? (u(), !0) : !1
|
|
205
|
+
})), /* @__PURE__ */ g(
|
|
206
|
+
"div",
|
|
208
207
|
{
|
|
209
|
-
className:
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
className: " !richtext-max-h-[320px] !richtext-w-[160px] richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",
|
|
209
|
+
"data-richtext-portal": !0,
|
|
210
|
+
ref: n,
|
|
211
|
+
children: /* @__PURE__ */ g("div", { children: e.items.length > 0 ? e.items.map((i, d) => {
|
|
212
|
+
var c;
|
|
213
|
+
return /* @__PURE__ */ C(
|
|
214
|
+
"span",
|
|
215
|
+
{
|
|
216
|
+
className: p("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent ", { "bg-item-active": d === r }),
|
|
217
|
+
onClick: (m) => {
|
|
218
|
+
m.preventDefault(), s(d);
|
|
219
|
+
},
|
|
220
|
+
children: [
|
|
221
|
+
((c = i == null ? void 0 : i.avatar) == null ? void 0 : c.src) && /* @__PURE__ */ g(
|
|
222
|
+
"img",
|
|
223
|
+
{
|
|
224
|
+
alt: i.label,
|
|
225
|
+
className: "richtext-size-5 richtext-rounded-full",
|
|
226
|
+
src: i.avatar.src
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
i == null ? void 0 : i.label
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
`mention-item-${i.id}`
|
|
233
|
+
);
|
|
234
|
+
}) : /* @__PURE__ */ g("div", { className: p("itemUserEmpty, richtext-text-foreground"), children: "Empty" }) })
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
});
|
|
238
|
+
function v() {
|
|
239
|
+
let e;
|
|
240
|
+
return {
|
|
241
|
+
onStart: (t) => {
|
|
242
|
+
t.clientRect && (e = new L(R, {
|
|
243
|
+
props: t,
|
|
244
|
+
editor: t.editor
|
|
245
|
+
}), e.element.style.position = "absolute", document.body.appendChild(e.element), f(t.editor, e.element));
|
|
212
246
|
},
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
name: "Jane Doe"
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
id: "3",
|
|
226
|
-
name: "Alice"
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
id: "4",
|
|
230
|
-
name: "Bob"
|
|
231
|
-
}
|
|
232
|
-
], V = /* @__PURE__ */ K.extend({
|
|
233
|
-
addAttributes() {
|
|
234
|
-
return {
|
|
235
|
-
id: {
|
|
236
|
-
default: "",
|
|
237
|
-
parseHTML: x("id")
|
|
238
|
-
},
|
|
239
|
-
label: {
|
|
240
|
-
default: "",
|
|
241
|
-
parseHTML: x("label")
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
}).configure({
|
|
246
|
-
HTMLAttributes: {
|
|
247
|
-
class: "mention"
|
|
248
|
-
},
|
|
249
|
-
suggestion: {
|
|
250
|
-
items: async ({ query: e }) => E.map((r) => r.name).filter((r) => r.toLowerCase().startsWith(e.toLowerCase())),
|
|
251
|
-
render: () => {
|
|
252
|
-
let e;
|
|
253
|
-
return {
|
|
254
|
-
onStart: (t) => {
|
|
255
|
-
t.clientRect && (e = new T(_, {
|
|
256
|
-
props: t,
|
|
257
|
-
editor: t.editor
|
|
258
|
-
}), e.element.style.position = "absolute", document.body.appendChild(e.element), f(t.editor, e.element));
|
|
259
|
-
},
|
|
260
|
-
onUpdate(t) {
|
|
261
|
-
e.updateProps(t), t.clientRect && f(t.editor, e.element);
|
|
262
|
-
},
|
|
263
|
-
onKeyDown(t) {
|
|
264
|
-
var r;
|
|
265
|
-
return t.event.key === "Escape" ? (e.destroy(), e.element.remove(), !0) : (r = e.ref) == null ? void 0 : r.onKeyDown(t);
|
|
266
|
-
},
|
|
267
|
-
onExit() {
|
|
268
|
-
e.destroy(), e.element.remove();
|
|
269
|
-
}
|
|
270
|
-
};
|
|
247
|
+
onUpdate(t) {
|
|
248
|
+
e.updateProps(t), t.clientRect && f(t.editor, e.element);
|
|
249
|
+
},
|
|
250
|
+
onKeyDown(t) {
|
|
251
|
+
var n;
|
|
252
|
+
return t.event.key === "Escape" ? (e.destroy(), e.element.remove(), !0) : (n = e.ref) == null ? void 0 : n.onKeyDown(t);
|
|
253
|
+
},
|
|
254
|
+
onExit() {
|
|
255
|
+
e.destroy(), e.element.remove();
|
|
271
256
|
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const V = /* @__PURE__ */ M.create({
|
|
260
|
+
name: "richTextMentionWrapper",
|
|
261
|
+
addExtensions() {
|
|
262
|
+
var t, n, r, o;
|
|
263
|
+
const e = {
|
|
264
|
+
...this.options
|
|
265
|
+
};
|
|
266
|
+
return (t = this.options) != null && t.suggestion && (e.suggestion = {
|
|
267
|
+
render: v,
|
|
268
|
+
...this.options.suggestion
|
|
269
|
+
}), (r = (n = this.options) == null ? void 0 : n.suggestions) != null && r.length && (e.suggestions = (o = this.options.suggestions) == null ? void 0 : o.map((s) => ({
|
|
270
|
+
render: v,
|
|
271
|
+
...s
|
|
272
|
+
}))), [I.configure({
|
|
273
|
+
HTMLAttributes: {
|
|
274
|
+
class: "mention"
|
|
275
|
+
},
|
|
276
|
+
...e
|
|
277
|
+
})];
|
|
272
278
|
}
|
|
273
279
|
});
|
|
274
280
|
export {
|
package/lib/Mermaid.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var X=Object.create;var G=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Z(e))!J.call(t,l)&&l!==r&&G(t,l,{get:()=>e[l],enumerable:!(a=U(e,l))||a.enumerable});return t};var Q=(t,e,r)=>(r=t!=null?X(Y(t)):{},K(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./index-
|
|
2
|
-
a-->b`;function ae(){const t=z.useEditorInstance(),e=z.useButtonProps(W.name),{tooltipOptions:r={},isActive:a=void 0,upload:l}=(e==null?void 0:e.componentProps)??{},{editorDisabled:T}=z.useToggleActive(a),[d,C]=s.useState(se),[q,y]=s.useState(""),[c,_]=s.useState(!1),S=s.useRef(null),[h,k]=s.useState(null),[f,O]=s.useState(!0),D=s.useCallback(u=>{u&&import("mermaid").then(g=>{k(g.default)}).finally(()=>O(!1))},[]),I=async u=>{try{const{svg:g}=await h.render("mermaid-svg",u);y(g)}catch{y("")}},R=()=>{h.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),I(d)};s.useEffect(()=>{!f&&h&&c&&R()},[h,c]),s.useEffect(()=>{!f&&h&&c&&I(d)},[h&&d]);const P=async()=>{if(d!==""){if(d){const u=S.current.querySelector("svg"),{width:g,height:j}=u.getBoundingClientRect(),A=`mermaid-${F.shortId()}.svg`;let b=F.i(u.outerHTML);if(l){const i=
|
|
1
|
+
"use strict";var X=Object.create;var G=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Z(e))!J.call(t,l)&&l!==r&&G(t,l,{get:()=>e[l],enumerable:!(a=U(e,l))||a.enumerable});return t};var Q=(t,e,r)=>(r=t!=null?X(Y(t)):{},K(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./index-BBNITgNi.cjs"),$=require("./throttle-BM3Bmbf_.cjs"),o=require("react/jsx-runtime"),s=require("react"),F=require("./shortId-Bfj8TyNr.cjs"),ee=require("./index-DvvMf6Wu.cjs"),E=require("./dialog-DgnnVCfv.cjs"),te=require("./textarea-B-qfanCT.cjs"),L=require("./index-FSRjMsxW.cjs"),z=require("./useButtonProps-BqBGuqoP.cjs"),re=require("./file-i7e4nQY2.cjs"),ie=require("./button-U6XpZt2X.cjs"),se=`graph TB
|
|
2
|
+
a-->b`;function ae(){const t=z.useEditorInstance(),e=z.useButtonProps(W.name),{tooltipOptions:r={},isActive:a=void 0,upload:l}=(e==null?void 0:e.componentProps)??{},{editorDisabled:T}=z.useToggleActive(a),[d,C]=s.useState(se),[q,y]=s.useState(""),[c,_]=s.useState(!1),S=s.useRef(null),[h,k]=s.useState(null),[f,O]=s.useState(!0),D=s.useCallback(u=>{u&&import("mermaid").then(g=>{k(g.default)}).finally(()=>O(!1))},[]),I=async u=>{try{const{svg:g}=await h.render("mermaid-svg",u);y(g)}catch{y("")}},R=()=>{h.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),I(d)};s.useEffect(()=>{!f&&h&&c&&R()},[h,c]),s.useEffect(()=>{!f&&h&&c&&I(d)},[h&&d]);const P=async()=>{if(d!==""){if(d){const u=S.current.querySelector("svg"),{width:g,height:j}=u.getBoundingClientRect(),A=`mermaid-${F.shortId()}.svg`;let b=F.i(u.outerHTML);if(l){const i=re.dataURLtoFile(b,A);b=await l(i)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:b,alt:encodeURIComponent(d),width:g,height:j},!!d).run()}_(!1)}};return o.jsxs(E.Dialog,{onOpenChange:_,open:c,children:[o.jsx(E.DialogTrigger,{asChild:!0,children:o.jsx(ee.ActionButton,{disabled:T,icon:"Mermaid",tooltip:"Mermaid",tooltipOptions:r,action:()=>{T||_(!0)}})}),o.jsxs(E.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(E.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:D,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:f?o.jsx("p",{children:"Loading..."}):o.jsx(o.Fragment,{children:o.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[o.jsx(te.Textarea,{autoFocus:!0,className:"richtext-flex-1",onChange:u=>C(u.target.value),placeholder:"Text",required:!0,rows:10,value:d,style:{color:"hsl(var(--foreground))"}}),o.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:q},ref:S,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})})}),o.jsx(E.DialogFooter,{children:o.jsx(ie.Button,{disabled:!h,onClick:P,type:"button",children:"Save changes"})})]})]})}const H={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function ne({editor:t,node:e,updateAttributes:r,getPos:a,selected:l}){const[T,d]=s.useState({width:L.IMAGE_MAX_SIZE,height:L.IMAGE_MAX_SIZE}),[C,q]=s.useState({width:0,height:0}),[y]=s.useState([H.TOP_LEFT,H.TOP_RIGHT,H.BOTTOM_LEFT,H.BOTTOM_RIGHT]),[c,_]=s.useState(!1),[S,h]=s.useState({x:0,y:0,w:0,h:0,dir:""}),{align:k}=e==null?void 0:e.attrs,f=s.useMemo(()=>{const{src:i,alt:p,width:x,height:v}=e==null?void 0:e.attrs,w=N.isNumber(x)?`${x}px`:x,n=N.isNumber(v)?`${v}px`:v;return{src:i||void 0,alt:p||void 0,style:{width:w||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),O=s.useMemo(()=>{const{style:{width:i}}=f;return{width:i==="100%"?i:void 0}},[f]);function D(i){q({width:i.target.width,height:i.target.height})}function I(){t.commands.setNodeSelection(a())}const R=s.useCallback($.throttle(()=>{const{width:i}=getComputedStyle(t.view.dom);d(p=>({...p,width:Number.parseInt(i,10)}))},L.IMAGE_THROTTLE_WAIT_TIME),[t]);function P(i,p){i.preventDefault(),i.stopPropagation();const x=C.width,v=C.height,w=x/v;let n=Number(e.attrs.width),M=Number(e.attrs.height);const m=T.width;n&&!M?(n=n>m?m:n,M=Math.round(n/w)):M&&!n?(n=Math.round(M*w),n=n>m?m:n):!n&&!M?(n=x>m?m:x,M=Math.round(n/w)):n=n>m?m:n,_(!0),h({x:i.clientX,y:i.clientY,w:n,h:M,dir:p})}const u=s.useCallback($.throttle(i=>{if(i.preventDefault(),i.stopPropagation(),!c)return;const{x:p,w:x,dir:v}=S,w=(i.clientX-p)*(/l/.test(v)?-1:1),{width:n,height:M}=e==null?void 0:e.attrs,m=n/M,B=z.clamp(x+w,L.IMAGE_MIN_SIZE,T.width),V=Math.round(B/m);r({width:B,height:V})},L.IMAGE_THROTTLE_WAIT_TIME),[c,S,T,r,e==null?void 0:e.attrs]),g=s.useCallback(i=>{i.preventDefault(),i.stopPropagation(),c&&(h({x:0,y:0,w:0,h:0,dir:""}),_(!1),I())},[c,I]),j=s.useCallback(()=>{document==null||document.addEventListener("mousemove",u,!0),document==null||document.addEventListener("mouseup",g,!0)},[u,g]),A=s.useCallback(()=>{document==null||document.removeEventListener("mousemove",u,!0),document==null||document.removeEventListener("mouseup",g,!0)},[u,g]);s.useEffect(()=>(c?j():A(),()=>{A()}),[c,j,A]);const b=s.useMemo(()=>new ResizeObserver(()=>R()),[R]);return s.useEffect(()=>(b.observe(t.view.dom),()=>{b.disconnect()}),[t.view.dom,b]),o.jsx(N.NodeViewWrapper,{className:"image-view",style:{...O,width:"100%",textAlign:k},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...O,background:"#fff"},className:`image-view__body ${l?"image-view__body--focused":""} ${c?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:D,src:f.src,style:f.style}),t.view.editable&&(l||c)&&o.jsx("div",{className:"image-resizer",children:y==null?void 0:y.map(i=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${i}`,onMouseDown:p=>P(p,i)},`image-dir-${i}`))})]})})}const W=$.index_default.extend({name:"mermaid",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:"mermaid"},button:({editor:e,t:r,extension:a})=>{var l;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:r("editor.mermaid.tooltip"),upload:(l=a==null?void 0:a.options)==null?void 0:l.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("width");return a?Number.parseInt(a,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("height");return a?Number.parseInt(a,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return N.ReactNodeViewRenderer(ne)},addCommands(){return{setMermaid:(t,e)=>({commands:r,editor:a})=>e?r.insertContent({type:this.name,attrs:t}):r.insertContentAt(a.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageMermaid:t=>({commands:e})=>e.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:e}=t;return["div",{style:e?`text-align: ${e};`:"",class:"imageMermaid"},["img",N.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:t=>{const e=t.querySelector("img"),r=e==null?void 0:e.getAttribute("width"),a=e==null?void 0:e.getAttribute("height");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),width:r?Number.parseInt(r,10):null,height:a?Number.parseInt(a,10):null,align:(e==null?void 0:e.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.Mermaid=W;exports.RichTextMermaid=ae;
|
package/lib/Mermaid.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { s as U, u as G, m as X, R as Z } from "./index-
|
|
2
|
-
import { a as q, c as Y } from "./throttle-
|
|
1
|
+
import { s as U, u as G, m as X, R as Z } from "./index-CbIQPoF6.js";
|
|
2
|
+
import { a as q, c as Y } from "./throttle-BIkZV3Y_.js";
|
|
3
3
|
import { jsxs as C, jsx as n, Fragment as J } from "react/jsx-runtime";
|
|
4
4
|
import { useState as m, useRef as K, useCallback as A, useEffect as H, useMemo as P } from "react";
|
|
5
5
|
import { s as Q, i as tt } from "./shortId-WJVkrvml.js";
|
|
6
|
-
import { A as et } from "./index
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
6
|
+
import { A as et } from "./index-4pRt5Vqu.js";
|
|
7
|
+
import { D as rt, a as it, b as at, c as st, d as nt } from "./dialog-DjnkASYP.js";
|
|
8
|
+
import { T as ot } from "./textarea-CMDYVXYo.js";
|
|
9
|
+
import { I as V, j as W, k as lt } from "./index-0OnGZkVF.js";
|
|
10
|
+
import { c as ct, u as dt, a as ut, f as ht } from "./useButtonProps-DTngjZge.js";
|
|
11
|
+
import { d as mt } from "./file-BLas99n7.js";
|
|
12
|
+
import { B as gt } from "./button-D8SI-g7p.js";
|
|
13
13
|
const pt = `graph TB
|
|
14
14
|
a-->b`;
|
|
15
15
|
function Ot() {
|
|
16
|
-
const e =
|
|
16
|
+
const e = ct(), t = dt(vt.name), {
|
|
17
17
|
tooltipOptions: i = {},
|
|
18
18
|
isActive: s = void 0,
|
|
19
19
|
upload: w
|
|
20
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: T } =
|
|
20
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: T } = ut(s), [c, S] = m(pt), [D, y] = m(""), [o, _] = m(!1), L = K(null), [d, k] = m(null), [g, O] = m(!0), B = A(
|
|
21
21
|
(l) => {
|
|
22
22
|
l && import("mermaid").then((u) => {
|
|
23
23
|
k(u.default);
|
|
@@ -45,12 +45,12 @@ function Ot() {
|
|
|
45
45
|
}, [d, o]), H(() => {
|
|
46
46
|
!g && d && o && I(c);
|
|
47
47
|
}, [d && c]), /* @__PURE__ */ C(
|
|
48
|
-
|
|
48
|
+
rt,
|
|
49
49
|
{
|
|
50
50
|
onOpenChange: _,
|
|
51
51
|
open: o,
|
|
52
52
|
children: [
|
|
53
|
-
/* @__PURE__ */ n(
|
|
53
|
+
/* @__PURE__ */ n(it, { asChild: !0, children: /* @__PURE__ */ n(
|
|
54
54
|
et,
|
|
55
55
|
{
|
|
56
56
|
disabled: T,
|
|
@@ -62,8 +62,8 @@ function Ot() {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
) }),
|
|
65
|
-
/* @__PURE__ */ C(
|
|
66
|
-
/* @__PURE__ */ n(
|
|
65
|
+
/* @__PURE__ */ C(at, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
|
|
66
|
+
/* @__PURE__ */ n(st, { children: "Mermaid" }),
|
|
67
67
|
/* @__PURE__ */ n(
|
|
68
68
|
"div",
|
|
69
69
|
{
|
|
@@ -71,7 +71,7 @@ function Ot() {
|
|
|
71
71
|
style: { height: "100%", border: "1px solid hsl(var(--border))" },
|
|
72
72
|
children: g ? /* @__PURE__ */ n("p", { children: "Loading..." }) : /* @__PURE__ */ n(J, { children: /* @__PURE__ */ C("div", { className: "richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]", children: [
|
|
73
73
|
/* @__PURE__ */ n(
|
|
74
|
-
|
|
74
|
+
ot,
|
|
75
75
|
{
|
|
76
76
|
autoFocus: !0,
|
|
77
77
|
className: "richtext-flex-1",
|
|
@@ -97,8 +97,8 @@ function Ot() {
|
|
|
97
97
|
] }) })
|
|
98
98
|
}
|
|
99
99
|
),
|
|
100
|
-
/* @__PURE__ */ n(
|
|
101
|
-
|
|
100
|
+
/* @__PURE__ */ n(nt, { children: /* @__PURE__ */ n(
|
|
101
|
+
gt,
|
|
102
102
|
{
|
|
103
103
|
disabled: !d,
|
|
104
104
|
onClick: async () => {
|
|
@@ -107,7 +107,7 @@ function Ot() {
|
|
|
107
107
|
const l = L.current.querySelector("svg"), { width: u, height: R } = l.getBoundingClientRect(), N = `mermaid-${Q()}.svg`;
|
|
108
108
|
let M = tt(l.outerHTML);
|
|
109
109
|
if (w) {
|
|
110
|
-
const r =
|
|
110
|
+
const r = mt(M, N);
|
|
111
111
|
M = await w(r);
|
|
112
112
|
}
|
|
113
113
|
e == null || e.chain().focus().setMermaid(
|
|
@@ -209,7 +209,7 @@ function ft({ editor: e, node: t, updateAttributes: i, getPos: s, selected: w })
|
|
|
209
209
|
q((r) => {
|
|
210
210
|
if (r.preventDefault(), r.stopPropagation(), !o)
|
|
211
211
|
return;
|
|
212
|
-
const { x: p, w: f, dir: b } = L, x = (r.clientX - p) * (/l/.test(b) ? -1 : 1), { width: a, height: v } = t == null ? void 0 : t.attrs, h = a / v, $ =
|
|
212
|
+
const { x: p, w: f, dir: b } = L, x = (r.clientX - p) * (/l/.test(b) ? -1 : 1), { width: a, height: v } = t == null ? void 0 : t.attrs, h = a / v, $ = ht(f + x, lt, T.width), j = Math.round($ / h);
|
|
213
213
|
i({
|
|
214
214
|
width: $,
|
|
215
215
|
height: j
|
package/lib/MoreMark.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-BBNITgNi.cjs"),r=require("react/jsx-runtime"),x=require("react"),h=require("./index-DvvMf6Wu.cjs"),b=require("./useButtonProps-BqBGuqoP.cjs"),p=require("./dropdown-menu-BvVMltdB.cjs"),f=require("./Icon-b6HQAURz.cjs");var S=c.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),k=c.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",c.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function A(){const t=b.useButtonProps(m.name),{icon:s=void 0,tooltip:n=void 0,items:i=[],isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{disabled:u,dataState:o}=b.useActive(l),d=x.useMemo(()=>(o==null?void 0:o.title)||"",[o]);return t?r.jsxs(p.DropdownMenu,{children:[r.jsx(p.DropdownMenuTrigger,{asChild:!0,disabled:u,children:r.jsx(h.ActionButton,{customClass:"!richtext-w-12 richtext-h-12",disabled:u,icon:s,tooltip:n,children:r.jsx(h.MenuDown,{className:"richtext-size-3 richtext-text-gray-500"})})}),r.jsx(p.DropdownMenuContent,{className:"w-full",children:i==null?void 0:i.map((e,a)=>r.jsxs(p.DropdownMenuCheckboxItem,{checked:d===e.title,className:"richtext-flex richtext-items-center richtext-gap-3",onClick:e.action,children:[r.jsx(f.IconComponent,{name:e==null?void 0:e.icon}),r.jsx("span",{className:"richtext-ml-1",children:e.title}),!!(e!=null&&e.shortcutKeys)&&r.jsx("span",{className:"richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",children:h.getShortcutKeys(e.shortcutKeys)})]},`more-mark-${a}`))})]}):r.jsx(r.Fragment,{})}const m=c.Extension.create({name:"moreMark",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:s,extension:n,t:i}){var a,g;const l=n.options.subscript,u=n.options.superscript,o={action:()=>s.commands.toggleSubscript(),isActive:()=>s.isActive("subscript")||!1,disabled:!s.can().toggleSubscript(),icon:"Subscript",title:i("editor.subscript.tooltip"),shortcutKeys:((a=n.options.shortcutKeys)==null?void 0:a[0])??["mod","."]},d={action:()=>s.commands.toggleSuperscript(),isActive:()=>s.isActive("superscript")||!1,disabled:!s.can().toggleSuperscript(),icon:"Superscript",title:i("editor.superscript.tooltip"),shortcutKeys:((g=n.options.shortcutKeys)==null?void 0:g[1])??["mod",","]},e=[];return l!==!1&&e.push(o),u!==!1&&e.push(d),{componentProps:{icon:"Type",tooltip:i("editor.moremark"),disabled:!s.isEditable,items:e,isActive:()=>e==null?void 0:e.find(M=>M.isActive())}}}}},addExtensions(){const t=[];return this.options.subscript!==!1&&t.push(S.configure(this.options.subscript)),this.options.superscript!==!1&&t.push(k.configure(this.options.superscript)),t}});exports.MoreMark=m;exports.RichTextMoreMark=A;
|
package/lib/MoreMark.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { M as h, m, E as b } from "./index-
|
|
1
|
+
import { M as h, m, E as b } from "./index-CbIQPoF6.js";
|
|
2
2
|
import { jsx as e, Fragment as f, jsxs as d } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo as M } from "react";
|
|
4
|
-
import { A as x, M as A, g as S } from "./index
|
|
5
|
-
import {
|
|
6
|
-
import { D as
|
|
7
|
-
import {
|
|
4
|
+
import { A as x, M as A, g as S } from "./index-4pRt5Vqu.js";
|
|
5
|
+
import { u as k, b as v } from "./useButtonProps-DTngjZge.js";
|
|
6
|
+
import { D as y, a as T, b as K, c as w } from "./dropdown-menu-bI14Gyw4.js";
|
|
7
|
+
import { I as C } from "./Icon-C_buGjWy.js";
|
|
8
8
|
var H = h.create({
|
|
9
9
|
name: "subscript",
|
|
10
10
|
addOptions() {
|
|
@@ -77,15 +77,15 @@ var H = h.create({
|
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
function F() {
|
|
80
|
-
const t =
|
|
80
|
+
const t = k(D.name), {
|
|
81
81
|
icon: s = void 0,
|
|
82
82
|
tooltip: n = void 0,
|
|
83
83
|
items: i = [],
|
|
84
84
|
isActive: a = void 0
|
|
85
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState: o } =
|
|
86
|
-
return t ? /* @__PURE__ */ d(
|
|
85
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: c, dataState: o } = v(a), p = M(() => (o == null ? void 0 : o.title) || "", [o]);
|
|
86
|
+
return t ? /* @__PURE__ */ d(y, { children: [
|
|
87
87
|
/* @__PURE__ */ e(
|
|
88
|
-
|
|
88
|
+
T,
|
|
89
89
|
{
|
|
90
90
|
asChild: !0,
|
|
91
91
|
disabled: c,
|
|
@@ -101,14 +101,14 @@ function F() {
|
|
|
101
101
|
)
|
|
102
102
|
}
|
|
103
103
|
),
|
|
104
|
-
/* @__PURE__ */ e(
|
|
105
|
-
|
|
104
|
+
/* @__PURE__ */ e(K, { className: "w-full", children: i == null ? void 0 : i.map((r, u) => /* @__PURE__ */ d(
|
|
105
|
+
w,
|
|
106
106
|
{
|
|
107
107
|
checked: p === r.title,
|
|
108
108
|
className: "richtext-flex richtext-items-center richtext-gap-3",
|
|
109
109
|
onClick: r.action,
|
|
110
110
|
children: [
|
|
111
|
-
/* @__PURE__ */ e(
|
|
111
|
+
/* @__PURE__ */ e(C, { name: r == null ? void 0 : r.icon }),
|
|
112
112
|
/* @__PURE__ */ e("span", { className: "richtext-ml-1", children: r.title }),
|
|
113
113
|
!!(r != null && r.shortcutKeys) && /* @__PURE__ */ e("span", { className: "richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60", children: S(r.shortcutKeys) })
|
|
114
114
|
]
|