react-reason-editor 1.0.24 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/{Attachment-DGzsbPZZ.js → Attachment-FN0H4pdR.js} +2 -2
- package/dist/Attachment.js +1 -1
- package/dist/BulletList.cjs +1 -1
- package/dist/{Callout-heY7R-Zu.js → Callout-C6kKHIbW.js} +2 -2
- package/dist/Callout.js +1 -1
- package/dist/{CodeBlock-B7Wklup8.js → CodeBlock-DLhI2Guf.js} +1 -1
- package/dist/{CodeBlock-D2OKvGCF.cjs → CodeBlock-zh4cX5EA.cjs} +1 -1
- package/dist/CodeBlock.cjs +1 -1
- package/dist/CodeBlock.js +1 -1
- package/dist/CodeView.cjs +1 -1
- package/dist/CodeView.js +1 -1
- package/dist/{Color-BxzxtvJH.cjs → Color-D5zLljFV.cjs} +1 -1
- package/dist/Color.cjs +1 -1
- package/dist/{Drawer-DxCO6TBr.cjs → Drawer-B0QvuSOf.cjs} +1 -1
- package/dist/{Drawer-Dunw22Q1.js → Drawer-bqo2XUCW.js} +12 -12
- package/dist/Drawer.cjs +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/{Drawio-eqEGDkwW.js → Drawio-CIXM-WGy.js} +4 -4
- package/dist/Drawio.js +1 -1
- package/dist/{Emoji-BU-itkPp.js → Emoji-CTvSFbHz.js} +3 -3
- package/dist/Emoji.js +1 -1
- package/dist/FontFamily.js +2 -2
- package/dist/{Highlight-BeqLxfbY.cjs → Highlight-DQxtCrNN.cjs} +1 -1
- package/dist/Highlight.cjs +1 -1
- package/dist/{History-C6yBYB2w.js → History-PbMa-usl.js} +1 -1
- package/dist/History.js +1 -1
- package/dist/Image.js +1 -1
- package/dist/{ImageCropper-Dlz4nJQu.js → ImageCropper-CN_GzBBG.js} +5 -5
- package/dist/{ImageGif-D5Qw_Xf-.js → ImageGif-D9goI48J.js} +3 -3
- package/dist/ImageGif.js +1 -1
- package/dist/{ImportWord-BCcs3dYp.js → ImportWord-Bux3L57d.js} +1 -1
- package/dist/ImportWord.js +1 -1
- package/dist/{Indent-DpTPoZMk.js → Indent-fBwkYx_q.js} +1 -1
- package/dist/Indent.js +1 -1
- package/dist/{Katex-D_vF5gsD.cjs → Katex-B1xls7hE.cjs} +1 -1
- package/dist/{Katex-Bo_vfXrd.js → Katex-D2g86C-B.js} +3 -3
- package/dist/Katex.cjs +1 -1
- package/dist/Katex.js +1 -1
- package/dist/LineHeight.js +1 -1
- package/dist/{Link-C0cNnjXo.js → Link-Dpaom2jX.js} +1 -1
- package/dist/Link.js +1 -1
- package/dist/{Mention-DEkbeL04.js → Mention-D0HVk1SC.js} +1 -1
- package/dist/Mention.js +1 -1
- package/dist/{Mermaid-BB15qd24.cjs → Mermaid-3vSlkOlc.cjs} +1 -1
- package/dist/Mermaid-B3KGZMBo.js +5 -0
- package/dist/Mermaid.cjs +1 -1
- package/dist/Mermaid.js +1 -1
- package/dist/MoreMark.js +1 -1
- package/dist/OrderedList.cjs +1 -1
- package/dist/SearchAndReplace.cjs +1 -1
- package/dist/SearchAndReplace.js +1 -1
- package/dist/{SlashCommand-8LkH8bHy.js → SlashCommand-ZFZhrxKb.js} +1 -1
- package/dist/SlashCommand.js +1 -1
- package/dist/{Table-C9t-k9Qu.js → Table-6kM52sUH.js} +2 -2
- package/dist/Table.js +1 -1
- package/dist/TaskList.cjs +1 -1
- package/dist/{TextAlign-C75gn_OM.js → TextAlign-BKo82ocx.js} +1 -1
- package/dist/TextAlign.js +1 -1
- package/dist/TextDirection.js +1 -1
- package/dist/{Twitter-DyrQT0n4.cjs → Twitter-3yCP2UdP.cjs} +1 -1
- package/dist/{Twitter-D5UNfT-K.js → Twitter-D38giVew.js} +2 -2
- package/dist/Twitter.cjs +1 -1
- package/dist/Twitter.js +1 -1
- package/dist/{Video-_YlAC2R_.js → Video-DcfPDZLP.js} +3 -3
- package/dist/Video.js +1 -1
- package/dist/WordCount.js +1 -1
- package/dist/{bubble---c27x7L.js → bubble-4RecyKlX.js} +1 -1
- package/dist/bubble.cjs +1 -1
- package/dist/bubble.js +1 -1
- package/dist/editor-kit.cjs +1 -0
- package/dist/editor-kit.d.ts +13 -0
- package/dist/editor-kit.js +1 -0
- package/dist/editor-views/components/AlignToolbar.d.ts +4 -0
- package/dist/editor-views/components/BubbleMenus.d.ts +4 -0
- package/dist/editor-views/components/EditorContainer.d.ts +10 -0
- package/dist/editor-views/components/Header.d.ts +8 -0
- package/dist/editor-views/components/Toolbar.d.ts +26 -0
- package/dist/editor-views/components/constants.d.ts +14 -0
- package/dist/editor-views/components/extensions.d.ts +8 -0
- package/dist/editor-views/components/index.d.ts +9 -0
- package/dist/editor-views/config/baseKit.d.ts +7 -0
- package/dist/editor-views/config/editorConfig.d.ts +37 -0
- package/dist/editor-views/config/pluginRegistry.d.ts +43 -0
- package/dist/editorConfig-Cgs4P8O5.js +184 -0
- package/dist/editorConfig-CnzPmOCy.cjs +1 -0
- package/dist/html-to-docx.esm-DkztZsL5-BqrjWkoQ.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/reason-docs.cjs +1 -1
- package/dist/reason-docs.js +1 -1
- package/dist/{separator-BHN46aj5.cjs → separator-CXjMk9dM.cjs} +1 -1
- package/dist/src-73l1pSjp.js +463 -0
- package/dist/src-CF0U82SA.cjs +1 -0
- package/package.json +12 -2
- package/dist/Mermaid-DxpFRVu0.js +0 -5
- package/dist/html-to-docx.esm-DkztZsL5-DQYdhD3B.cjs +0 -1
- package/dist/src-C7k3RYxJ.js +0 -646
- package/dist/src-DYbBlAjR.cjs +0 -1
package/dist/Mermaid.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./Mermaid-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./Mermaid-3vSlkOlc.cjs");exports.Mermaid=e.Mermaid,exports.RichTextMermaid=e.RichTextMermaid;
|
package/dist/Mermaid.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as r,t as a}from"./Mermaid-
|
|
1
|
+
import{n as r,t as a}from"./Mermaid-B3KGZMBo.js";export{a as Mermaid,r as RichTextMermaid};
|
package/dist/MoreMark.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as r,t as
|
|
1
|
+
import{n as r,t as o}from"./MoreMark-CXudh2cm.js";export{o as MoreMark,r as RichTextMoreMark};
|
package/dist/OrderedList.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const t=require("./toggle-CRftKzl0.cjs"),e=require("./useButtonProps-D2Hd5DbR.cjs"),o=require("./dist-ICzvPVCE.cjs");let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const t=require("./toggle-CRftKzl0.cjs"),e=require("./useButtonProps-D2Hd5DbR.cjs"),o=require("./dist-ICzvPVCE.cjs");let r=require("react/jsx-runtime");var i=o.OrderedList.extend({addOptions(){return{...this.parent?.(),button:({editor:t,t:e,extension:o})=>({componentProps:{action:()=>t.commands.toggleOrderedList(),isActive:()=>t.isActive("orderedList"),disabled:!1,icon:"ListOrdered",shortcutKeys:o.options.shortcutKeys??["mod","shift","7"],tooltip:e("editor.orderedlist.tooltip")}})}}});exports.OrderedList=i,exports.RichTextOrderedList=function(){const o=e.useButtonProps(i.name),{icon:s,tooltip:n,shortcutKeys:d,tooltipOptions:c={},action:u,isActive:a}=o?.componentProps??{},{dataState:p,disabled:l,update:m}=e.useToggleActive(a);return o?(0,r.jsx)(t.ActionButton,{action:()=>{l||u&&(u(),m())},dataState:p,disabled:l,icon:s,shortcutKeys:d,tooltip:n,tooltipOptions:c}):(0,r.jsx)(r.Fragment,{})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./toggle-CRftKzl0.cjs"),t=require("./locales-Dg9XL0yP.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./toggle-CRftKzl0.cjs"),t=require("./locales-Dg9XL0yP.cjs"),r=require("./Icon-DQdA22_-.cjs"),s=require("./button-CYMsgP3Y.cjs"),c=require("./checkbox-BtMvSk4V.cjs"),a=require("./input-AvqqajGM.cjs"),n=require("./label-DPSH3PiY.cjs"),o=require("./popover-DEGqjF2J.cjs"),i=require("./useButtonProps-D2Hd5DbR.cjs");let l=require("react"),d=require("react/jsx-runtime"),h=require("@tiptap/core"),u=require("@tiptap/pm/state"),x=require("@tiptap/pm/view");var p=(e,t)=>t(e.tr);function m(e,t,{state:r,dispatch:s}){if(!t[0])return;const{from:c,to:a}=t[0];s&&s(r.tr.insertText(e,c,a))}function g(e,t,r,s){const c=t+1;if(!s[c])return null;const{from:a,to:n}=s[t],o=n-a-e.length+r,{from:i,to:l}=s[c];return s[c]={to:l-o,from:i-o},[o,s]}var f=h.Extension.create({name:"searchAndReplace",addOptions(){return{...this.parent?.(),searchTerm:"",replaceTerm:"",results:[],searchResultClass:"search-result",searchResultCurrentClass:"search-result-current",caseSensitive:!1,disableRegex:!0,onChange:()=>{},button:({editor:e,t:t})=>({componentProps:{action:()=>{},icon:"SearchAndReplace",tooltip:t("editor.searchAndReplace.tooltip"),isActive:()=>!0,editor:e}})}},addStorage:()=>({searchTerm:"",replaceTerm:"",results:[],lastSearchTerm:"",caseSensitive:!1,lastCaseSensitive:!1,resultIndex:0,lastResultIndex:0}),addCommands:()=>({setSearchTerm:e=>({editor:t,state:r,dispatch:s})=>(t.storage.searchAndReplace.searchTerm=e,p(r,s),!1),setReplaceTerm:e=>({editor:t,state:r,dispatch:s})=>(t.storage.searchAndReplace.replaceTerm=e,p(r,s),!1),setCaseSensitive:e=>({editor:t,state:r,dispatch:s})=>(t.storage.searchAndReplace.caseSensitive=e,p(r,s),!1),resetIndex:()=>({editor:e,state:t,dispatch:r})=>(e.storage.searchAndReplace.resultIndex=0,p(t,r),!1),nextSearchResult:()=>({editor:e})=>{const{results:t,resultIndex:r}=e.storage.searchAndReplace,s=r+1;return t[s]?e.storage.searchAndReplace.resultIndex=s:e.storage.searchAndReplace.resultIndex=0,!1},previousSearchResult:()=>({editor:e})=>{const{results:t,resultIndex:r}=e.storage.searchAndReplace,s=r-1;return t[s]?e.storage.searchAndReplace.resultIndex=s:e.storage.searchAndReplace.resultIndex=t.length-1,!1},replace:()=>({editor:e,state:t,dispatch:r})=>{const{replaceTerm:s,results:c,resultIndex:a}=e.storage.searchAndReplace,n=c[a];return n?(m(s,[n],{state:t,dispatch:r}),e.storage.searchAndReplace.results.splice(a,1)):(m(s,c,{state:t,dispatch:r}),e.storage.searchAndReplace.results.shift()),p(t,r),!1},replaceAll:()=>({editor:e,tr:t,state:r,dispatch:s})=>{const{replaceTerm:c,results:a}=e.storage.searchAndReplace;return function(e,t,{tr:r,dispatch:s}){let c=0,a=t.slice();if(0!==a.length){for(let t=0;t<a.length;t+=1){const{from:s,to:n}=a[t];r.insertText(e,s,n);const o=g(e,t,c,a);o&&(c=o[0],a=o[1])}s(r)}}(c,a,{tr:t,dispatch:s}),e.storage.searchAndReplace.resultIndex=0,e.storage.searchAndReplace.results=[],p(r,s),!1}}),addProseMirrorPlugins(){const e=this.editor,{searchResultClass:t,disableRegex:r}=this.options;return[new u.Plugin({key:new u.PluginKey(`richtextCustomPlugin${this.name}`),state:{init:()=>x.DecorationSet.empty,apply({doc:s,docChanged:c},a){const{searchTerm:n,lastSearchTerm:o,caseSensitive:i,lastCaseSensitive:l,resultIndex:d,lastResultIndex:h}=e.storage.searchAndReplace;if(!c&&o===n&&l===i&&h===d)return a;var u;if(u=n,e.storage.searchAndReplace.lastSearchTerm=u,(t=>{e.storage.searchAndReplace.lastCaseSensitive=t})(i),(t=>{e.storage.searchAndReplace.lastResultIndex=t})(d),!n)return e.storage.searchAndReplace.results=[],x.DecorationSet.empty;const{decorationsToReturn:p,results:m}=function(e,t,r,s){const c=[],a=[];let n=[],o=0;if(!t)return{decorationsToReturn:x.DecorationSet.empty,results:[]};e?.descendants((e,t)=>{e.isText?n[o]?n[o]={text:n[o].text+e.text,pos:n[o].pos}:n[o]={text:`${e.text}`,pos:t}:o+=1}),n=n.filter(Boolean);for(const i of n){const{text:e,pos:r}=i,s=Array.from(e.matchAll(t)).filter(([e])=>e.trim());for(const t of s){if(""===t[0])break;void 0!==t.index&&a.push({from:r+t.index,to:r+t.index+t[0].length})}}for(const[i,l]of a.entries()){const e=i===s?`${r} ${r}-current`:r,t=x.Decoration.inline(l.from,l.to,{class:e});c.push(t)}return{decorationsToReturn:x.DecorationSet.create(e,c),results:a}}(s,function(e,t,r){return RegExp(t?e.replace(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`):e,r?"gu":"gui")}(n,r,i),t,d);return e.storage.searchAndReplace.results=m,p}},props:{decorations(e){return this.getState(e)}}})]}});exports.RichTextSearchAndReplace=function(){const{t:h}=t.useLocale(),u=i.useEditorInstance(),x=i.useButtonProps(f.name),{icon:p,tooltip:m,shortcutKeys:g,tooltipOptions:R={},action:v,isActive:A}=x?.componentProps??{},{disabled:j}=i.useActive(A),[S,C]=(0,l.useState)(!1),[T,I]=(0,l.useState)(""),[b,w]=(0,l.useState)(""),[q,N]=(0,l.useState)(!1),[y,P]=(0,l.useState)(""),k=()=>{P(`${u?.storage?.searchAndReplace?.resultIndex+1}/${u?.storage?.searchAndReplace?.results.length}`)};(0,l.useEffect)(()=>{u&&k()},[u]);const B=(e=!1)=>{u&&(e&&u?.commands?.resetIndex?.(),u?.commands?.setSearchTerm?.(T),u?.commands?.setReplaceTerm?.(b),u?.commands?.setCaseSensitive?.(q),k())},E=()=>{if(!u)return;const{results:e,resultIndex:t}=u.storage.searchAndReplace,r=e[t];if(!r)return;u?.commands?.setTextSelection?.(r);const{node:s}=u.view.domAtPos(u.state.selection.anchor);s instanceof HTMLElement&&s.scrollIntoView({behavior:"smooth",block:"center"}),k()};(0,l.useEffect)(()=>{T.trim()||$(),T.trim()&&B(!0)},[T]),(0,l.useEffect)(()=>{b.trim()&&B()},[b]),(0,l.useEffect)(()=>{B(!0)},[q]);const $=()=>{I(""),w(""),u?.commands?.resetIndex?.(),k()};return x?(0,d.jsxs)(o.Popover,{onOpenChange:C,open:S,children:[(0,d.jsx)(o.PopoverTrigger,{asChild:!0,disabled:j,children:(0,d.jsx)(e.ActionButton,{action:()=>{j||v&&v()},disabled:j,icon:p,shortcutKeys:g,tooltip:m,tooltipOptions:R})}),(0,d.jsxs)(o.PopoverContent,{align:"start",className:"richtext-w-full",hideWhenDetached:!0,side:"bottom",children:[(0,d.jsxs)("div",{className:"richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between",children:[(0,d.jsx)(n.Label,{children:h("editor.search.dialog.text")}),(0,d.jsx)("span",{className:"richtext-font-semibold",children:y})]}),(0,d.jsxs)("div",{className:"richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:[(0,d.jsx)(a.Input,{autoFocus:!0,className:"richtext-w-full",onChange:e=>I(e.target.value),placeholder:"Text",required:!0,type:"text",value:T}),(0,d.jsx)(s.Button,{className:"richtext-flex-1",onClick:()=>{u?.commands?.previousSearchResult?.(),E()},children:(0,d.jsx)(r.IconComponent,{name:"ChevronUp"})}),(0,d.jsx)(s.Button,{className:"richtext-flex-1",onClick:()=>{u?.commands?.nextSearchResult?.(),E()},children:(0,d.jsx)(r.IconComponent,{name:"ChevronDown"})}),(0,d.jsx)(s.Button,{className:"richtext-flex-1",onClick:$,children:"Clear"})]}),(0,d.jsx)(n.Label,{className:"richtext-mb-[6px]",children:h("editor.replace.dialog.text")}),(0,d.jsx)("div",{className:"richtext-mb-[5px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:(0,d.jsx)("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:(0,d.jsx)(a.Input,{className:"richtext-w-80",onChange:e=>w(e.target.value),placeholder:"Text",required:!0,type:"text",value:b})})}),(0,d.jsxs)("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-1",children:[(0,d.jsx)(c.Checkbox,{checked:q,onCheckedChange:e=>{N(e),u.commands.setCaseSensitive(e)}}),(0,d.jsx)(n.Label,{children:h("editor.replace.caseSensitive")})]}),(0,d.jsxs)("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[(0,d.jsx)(s.Button,{className:"richtext-flex-1",onClick:()=>{u?.commands?.replace?.(),E()},children:h("editor.replace.dialog.text")}),(0,d.jsx)(s.Button,{className:"richtext-flex-1",onClick:()=>{u?.commands?.replaceAll?.(),P("0/0")},children:h("editor.replaceAll.dialog.text")})]})]})]}):(0,d.jsx)(d.Fragment,{})},exports.SearchAndReplace=f;
|
package/dist/SearchAndReplace.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./toggle-BXl_NYYh.js";import{n as t}from"./locales-DfkG6-1b.js";import{t as r}from"./Icon-CJJ9AQtR.js";import{t as s}from"./button-CXcuJkiM.js";import{t as a}from"./checkbox-zfuPZBhD.js";import{t as c}from"./input-CMD6LZFr.js";import{t as n}from"./label-Dx1mMx8l.js";import{n as o,r as i,t as l}from"./popover-DGEv-NbL.js";import{d,s as h,t as m}from"./useButtonProps-DSIajp_B.js";import{useEffect as p,useState as x}from"react";import{Fragment as u,jsx as f,jsxs as g}from"react/jsx-runtime";import{Extension as R}from"@tiptap/core";import{Plugin as v,PluginKey as A}from"@tiptap/pm/state";import{Decoration as C,DecorationSet as T}from"@tiptap/pm/view";function S(){const{t:R}=t(),v=d(),A=m(N.name),{icon:C,tooltip:T,shortcutKeys:S,tooltipOptions:I={},action:b,isActive:w}=A?.componentProps??{},{disabled:
|
|
1
|
+
import{n as e}from"./toggle-BXl_NYYh.js";import{n as t}from"./locales-DfkG6-1b.js";import{t as r}from"./Icon-CJJ9AQtR.js";import{t as s}from"./button-CXcuJkiM.js";import{t as a}from"./checkbox-zfuPZBhD.js";import{t as c}from"./input-CMD6LZFr.js";import{t as n}from"./label-Dx1mMx8l.js";import{n as o,r as i,t as l}from"./popover-DGEv-NbL.js";import{d,s as h,t as m}from"./useButtonProps-DSIajp_B.js";import{useEffect as p,useState as x}from"react";import{Fragment as u,jsx as f,jsxs as g}from"react/jsx-runtime";import{Extension as R}from"@tiptap/core";import{Plugin as v,PluginKey as A}from"@tiptap/pm/state";import{Decoration as C,DecorationSet as T}from"@tiptap/pm/view";function S(){const{t:R}=t(),v=d(),A=m(N.name),{icon:C,tooltip:T,shortcutKeys:S,tooltipOptions:I={},action:b,isActive:w}=A?.componentProps??{},{disabled:j}=h(w),[y,k]=x(!1),[$,P]=x(""),[O,q]=x(""),[B,D]=x(!1),[E,F]=x(""),K=()=>{F(`${v?.storage?.searchAndReplace?.resultIndex+1}/${v?.storage?.searchAndReplace?.results.length}`)};p(()=>{v&&K()},[v]);const M=(e=!1)=>{v&&(e&&v?.commands?.resetIndex?.(),v?.commands?.setSearchTerm?.($),v?.commands?.setReplaceTerm?.(O),v?.commands?.setCaseSensitive?.(B),K())},H=()=>{if(!v)return;const{results:e,resultIndex:t}=v.storage.searchAndReplace,r=e[t];if(!r)return;v?.commands?.setTextSelection?.(r);const{node:s}=v.view.domAtPos(v.state.selection.anchor);s instanceof HTMLElement&&s.scrollIntoView({behavior:"smooth",block:"center"}),K()};p(()=>{$.trim()||L(),$.trim()&&M(!0)},[$]),p(()=>{O.trim()&&M()},[O]),p(()=>{M(!0)},[B]);const L=()=>{P(""),q(""),v?.commands?.resetIndex?.(),K()};return A?/* @__PURE__ */g(l,{onOpenChange:k,open:y,children:[/* @__PURE__ */f(i,{asChild:!0,disabled:j,children:/* @__PURE__ */f(e,{action:()=>{j||b&&b()},disabled:j,icon:C,shortcutKeys:S,tooltip:T,tooltipOptions:I})}),/* @__PURE__ */g(o,{align:"start",className:"richtext-w-full",hideWhenDetached:!0,side:"bottom",children:[
|
|
2
2
|
/* @__PURE__ */g("div",{className:"richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between",children:[/* @__PURE__ */f(n,{children:R("editor.search.dialog.text")}),/* @__PURE__ */f("span",{className:"richtext-font-semibold",children:E})]}),
|
|
3
3
|
/* @__PURE__ */g("div",{className:"richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:[
|
|
4
4
|
/* @__PURE__ */f(c,{autoFocus:!0,className:"richtext-w-full",onChange:e=>P(e.target.value),placeholder:"Text",required:!0,type:"text",value:$}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as t}from"./dist-CsCFCV4K.js";import{n as e}from"./locales-DfkG6-1b.js";import{a as r,n}from"./dist-fiA_WbbM.js";import{t as o}from"./Icon-CJJ9AQtR.js";import{t as i}from"./label-Dx1mMx8l.js";import{n as c,t as a}from"./updatePosition-CBT0mUIB.js";import{n as s,t as m}from"./renderCommandListDefault-CJd5Cd3Q.js";import{ReactRenderer as
|
|
1
|
+
import{o as t}from"./dist-CsCFCV4K.js";import{n as e}from"./locales-DfkG6-1b.js";import{a as r,n}from"./dist-fiA_WbbM.js";import{t as o}from"./Icon-CJJ9AQtR.js";import{t as i}from"./label-Dx1mMx8l.js";import{n as c,t as a}from"./updatePosition-CBT0mUIB.js";import{n as s,t as m}from"./renderCommandListDefault-CJd5Cd3Q.js";import{ReactRenderer as l}from"@tiptap/react";import h,{Fragment as x,forwardRef as d,useEffect as p,useImperativeHandle as u,useRef as f,useState as g}from"react";import{Fragment as v,jsx as b,jsxs as y}from"react/jsx-runtime";import{Extension as w}from"@tiptap/core";import{PluginKey as N}from"@tiptap/pm/state";var j=r([]);function k(){const[t,e]=n(j);return[t,e]}var C=d(function(r,n){const[c]=k(),[a,m]=g(0),[l,h]=g(0),d=f(null),{t:v}=e(),w=s(c,r.query),N=f([]);function j({event:t}){return"ArrowUp"===t.key?(function(){if(0===w.length)return!1;let t=a-1,e=l;t<0&&(e=l-1,t=w[e]?.commands.length-1||0);e<0&&(e=w.length-1,t=w[e].commands.length-1);m(t),h(e)}(),!0):"ArrowDown"===t.key?(function(){if(0===w.length)return!1;const t=w[l].commands;let e=a+1,r=l;t.length-1<e&&(e=0,r=l+1);w.length-1<r&&(r=0);m(e),h(r)}(),!0):"Enter"===t.key&&(function(){if(0===w.length||-1===l||-1===a)return!1;C(l,a)}(),!0)}function C(t,e){const n=w[t].commands[e];r?.command(n)}return u(n,()=>({onKeyDown:j})),p(()=>{if(!d.current)return;const t=1e3*l+a,e=N.current[t];e&&e.scrollIntoView({behavior:"smooth",block:"nearest"})},[a,l]),/* @__PURE__ */b("div",{className:"richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap 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:d,children:/* @__PURE__ */b("div",w?.length?{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:w?.map((e,r)=>/* @__PURE__ */y(x,{children:[/* @__PURE__ */b(i,{className:"richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase",children:e.title}),e.commands.map((e,n)=>/* @__PURE__ */y("button",{onClick:()=>function(t,e){C(t,e)}(r,n),ref:t=>function(t,e,r){N.current[1e3*t+e]=r}(r,n,t),className:t("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":l===r&&a===n}),children:[e.iconUrl&&/* @__PURE__ */b("img",{alt:"",className:"richtext-size-6",src:e.iconUrl}),e.iconName&&/* @__PURE__ */b(o,{className:"!richtext-mr-1 !richtext-text-lg",name:e.iconName}),e.label]},`command-${n}`))]},`slash-${e.title}`))}:{className:"richtext-p-3",children:/* @__PURE__ */b("span",{className:"richtext-text-xs richtext-text-foreground",children:v("editor.slash.empty")})})})});function D({commandList:t}){const[,r]=k(),{t:n}=e();return p(()=>{if(!t?.length){const t=m({t:n});return void r(t)}r(t)},[n,t]),/* @__PURE__ */b(v,{})}var K=w.create({name:"richtextSlashCommand",priority:200,addProseMirrorPlugins(){return[c({pluginKey:new N("richtextSlashCommandPlugin"),editor:this.editor,char:"/",command:({editor:t,range:e,props:r})=>{const{view:n}=t;r.action({editor:t,range:e}),n.focus()},render:()=>{let t;return{onStart:e=>{e.clientRect&&(t=new l(C,{props:e,editor:e.editor}),t.element.style.position="absolute",document.body.appendChild(t.element),a(e.editor,t.element))},onUpdate(e){t.updateProps(e),e.clientRect&&a(e.editor,t.element)},onKeyDown:e=>"Escape"===e.event.key?(t.destroy(),t.element.remove(),!0):t.ref?.onKeyDown(e),onExit(){t&&(t.destroy(),t.element.remove())}}}})]}});export{D as n,K as t};
|
package/dist/SlashCommand.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as a,t as m}from"./renderCommandListDefault-CJd5Cd3Q.js";import{n as s,t as o}from"./SlashCommand-
|
|
1
|
+
import{n as a,t as m}from"./renderCommandListDefault-CJd5Cd3Q.js";import{n as s,t as o}from"./SlashCommand-ZFZhrxKb.js";export{o as SlashCommand,s as SlashCommandList,m as renderCommandListDefault,a as useFilterCommandList};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{n as t}from"./toggle-BXl_NYYh.js";import{n as e,r as o,t as n}from"./popover-DGEv-NbL.js";import{c as r,d as i,t as l}from"./useButtonProps-DSIajp_B.js";import a,{useState as s}from"react";import{Fragment as c,jsx as d,jsxs as h}from"react/jsx-runtime";import{Extension as p,Node as u,callOrReturn as b,findParentNodeClosestToPos as f,getExtensionField as g,mergeAttributes as m}from"@tiptap/core";import{TextSelection as w}from"@tiptap/pm/state";import{CellSelection as x,addColumnAfter as y,addColumnBefore as C,addRowAfter as M,addRowBefore as T,columnResizing as v,deleteColumn as A,deleteRow as H,deleteTable as k,fixTables as L,goToNextCell as R,mergeCells as N,setCellAttr as $,splitCell as S,tableEditing as W,toggleHeader as E,toggleHeaderCell as O}from"@tiptap/pm/tables";function j(t){return"left"===t||"right"===t||"center"===t?t:null}function z(){return{default:null,parseHTML:t=>function(t){const e=(t.style.textAlign||"").trim().toLowerCase(),o=(t.getAttribute("align")||"").trim().toLowerCase();return j(e||o)}(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}function P(t){const e=t.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):function(t){var e;const o=t.parentElement,n=t.closest("table");if(!o||!n)return null;const r=Array.from(o.children).indexOf(t),i=null==(e=n.querySelectorAll("colgroup > col")[r])?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}(t)}var B=/[ \t\r\n\f]+/g;function D(t){var e;return!(t.children.length>0)&&""===(null!=(e=t.textContent)?e:"").replace(B,"")}function V(t){const e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}var I=u.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:P},align:z()}),tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>!!D(t)&&{},getContent:(t,e)=>V(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",m(this.options.HTMLAttributes,t),0]}}),F=u.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:P},align:z()}),tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>!!D(t)&&{},getContent:(t,e)=>V(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",m(this.options.HTMLAttributes,t),0]}}),q=u.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:t}){return["tr",m(this.options.HTMLAttributes,t),0]}});function K(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function _(t,e,o,n,r,i){var l;let a=0,s=!0,c=e.firstChild;const d=t.firstChild;if(null!==d)for(let p=0,u=0;p<d.childCount;p+=1){const{colspan:t,colwidth:o}=d.child(p).attrs;for(let l=0;l<t;l+=1,u+=1){const t=r===u?i:o&&o[l],d=t?`${t}px`:"";if(a+=t||n,t||(s=!1),c){if(c.style.width!==d){const[e,o]=K(n,t);c.style.setProperty(e,o)}c=c.nextSibling}else{const o=document.createElement("col"),[r,i]=K(n,t);o.style.setProperty(r,i),e.appendChild(o)}}}for(;c;){const t=c.nextSibling;null==(l=c.parentNode)||l.removeChild(c),c=t}const h=t.attrs.style&&"string"==typeof t.attrs.style&&/\bwidth\s*:/i.test(t.attrs.style);s&&!h?(o.style.width=`${a}px`,o.style.minWidth=""):(o.style.width="",o.style.minWidth=`${a}px`)}var G=class{constructor(t,e,o,n={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[r,i]of Object.entries(n))null!=i&&("style"===r?this.table.style.cssText=String(i):this.table.setAttribute(r,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),_(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type===this.node.type&&(this.node=t,_(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,o=this.dom.contains(e),n=this.contentDOM.contains(e);return!(!o||n||"attributes"!==t.type&&"childList"!==t.type&&"characterData"!==t.type)}};function J(t,e){return e?t.createChecked(null,e):t.createAndFill()}function Q(t,e,o,n,r){const i=function(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(o=>{const n=t.nodes[o];n.spec.tableRole&&(e[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=e,e}(t),l=[],a=[];for(let c=0;c<o;c+=1){const t=J(i.cell,r);if(t&&a.push(t),n){const t=J(i.header_cell,r);t&&l.push(t)}}const s=[];for(let c=0;c<e;c+=1)s.push(i.row.createChecked(null,n&&0===c?l:a));return i.table.createChecked(null,s)}var U=({editor:t})=>{const{selection:e}=t.state;if(!(e instanceof x))return!1;let o=0;return f(e.ranges[0].$from,t=>"table"===t.type.name)?.node.descendants(t=>{if("table"===t.type.name)return!1;["tableCell","tableHeader"].includes(t.type.name)&&(o+=1)}),o===e.ranges.length&&(t.commands.deleteTable(),!0)};var X=function(t,e,o={}){var n;const r=null!=(n=o.cellLineSeparator)?n:"";if(!t||!t.content||0===t.content.length)return"";const i=[];t.content.forEach(t=>{const o=[];t.content&&t.content.forEach(t=>{let n="";n=t.content&&Array.isArray(t.content)&&t.content.length>1?t.content.map(t=>e.renderChildren(t)).join(r):t.content?e.renderChildren(t.content):"";const i=(n.split(r).join("\n").replace(/[ \t]*\r?\n[ \t]*/g,"<br>")||"").replace(/\s+/g," ").trim();const l="tableHeader"===t.type,a=j(null==(s=t.attrs)?void 0:s.align);var s;o.push({text:i,isHeader:l,align:a})}),i.push(o)});const l=i.reduce((t,e)=>Math.max(t,e.length),0);if(0===l)return"";const a=Array.from({length:l}).fill(0);i.forEach(t=>{var e;for(let o=0;o<l;o+=1){const n=((null==(e=t[o])?void 0:e.text)||"").length;n>a[o]&&(a[o]=n),a[o]<3&&(a[o]=3)}});const s=(t,e)=>t+" ".repeat(Math.max(0,e-t.length)),c=i[0],d=c.some(t=>t.isHeader),h=Array.from({length:l}).fill(null);i.forEach(t=>{var e;for(let o=0;o<l;o+=1)!h[o]&&(null==(e=t[o])?void 0:e.align)&&(h[o]=t[o].align)});let p="\n";const u=Array.from({length:l}).map((t,e)=>d&&c[e]&&c[e].text||"");return p+=`| ${u.map((t,e)=>s(t,a[e])).join(" | ")} |\n`,p+=`| ${a.map((t,e)=>{const o=Math.max(3,t),n=h[e];return"left"===n?`:${"-".repeat(o)}`:"right"===n?`${"-".repeat(o)}:`:"center"===n?`:${"-".repeat(o)}:`:"-".repeat(o)}).join(" | ")} |\n`,(d?i.slice(1):i).forEach(t=>{p+=`| ${Array.from({length:l}).fill(0).map((e,o)=>s(t[o]&&t[o].text||"",a[o])).join(" | ")} |\n`}),p},Y=u.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:G,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:t,HTMLAttributes:e}){const{colgroup:o,tableWidth:n,tableMinWidth:r}=function(t,e,o,n){let r=0,i=!0;const l=[],a=t.firstChild;if(!a)return{};for(let d=0,h=0;d<a.childCount;d+=1){const{colspan:t,colwidth:s}=a.child(d).attrs;for(let a=0;a<t;a+=1,h+=1){const t=o===h?n:s&&s[a];r+=t||e,t||(i=!1);const[c,d]=K(e,t);l.push(["col",{style:`${c}: ${d}`}])}}const s=i?`${r}px`:"",c=i?"":`${r}px`;return{colgroup:["colgroup",{},...l],tableWidth:s,tableMinWidth:c}}(t,this.options.cellMinWidth),i=e.style;const l=["table",m(this.options.HTMLAttributes,e,{style:i||(n?`width: ${n}`:`min-width: ${r}`)}),o,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const o=[],n=Array.isArray(t.align)?t.align:[];if(t.header){const r=[];t.header.forEach((t,o)=>{var i;const l=j(null!=(i=n[o])?i:t.align),a=l?{align:l}:{};r.push(e.createNode("tableHeader",a,[{type:"paragraph",content:e.parseInline(t.tokens)}]))}),o.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(t=>{const r=[];t.forEach((t,o)=>{var i;const l=j(null!=(i=n[o])?i:t.align),a=l?{align:l}:{};r.push(e.createNode("tableCell",a,[{type:"paragraph",content:e.parseInline(t.tokens)}]))}),o.push(e.createNode("tableRow",{},r))}),e.createNode("table",void 0,o)},renderMarkdown:(t,e)=>X(t,e),markdownTokenizer:{name:"table",level:"block",start:t=>{const e=t.split("\n");if(e.length<2)return-1;const o=e[1];return/^[ \t|:]*-[ \t|:-]*$/.test(o)&&o.includes("|")&&e[0].includes("|")?0:-1},tokenize(t,e,o){const n=t.indexOf("\n\n"),r=n>=0?t.slice(0,n):t,i=r.split("\n");if(i.length<2)return;const l=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(l)||!l.includes("|"))return;const a=function(t){return t.split("\n").map(t=>t.includes("|")&&t.includes("`")?function(t){let e="",o=0;for(;o<t.length;){if("\\"===t[o]&&o+1<t.length){e+=t[o]+t[o+1],o+=2;continue}if("`"!==t[o]){e+=t[o++];continue}let n=0;for(;o+n<t.length&&"`"===t[o+n];)n+=1;let r=o+n,i=!1;for(;r<t.length;){if("`"!==t[r]){r+=1;continue}let l=0;for(;r+l<t.length&&"`"===t[r+l];)l+=1;if(l===n){const l=t.slice(o+n,r);e+=t.slice(o,o+n)+l.replace(/(?<!\\)\|/g,"\\|")+t.slice(r,r+n),o=r+n,i=!0;break}r+=l}i||(e+=t.slice(o,o+n),o+=n)}return e}(t):t).join("\n")}(r);if(a===r)return;const s=o.blockTokens(a)[0];if("table"!==(null==s?void 0:s.type)||!s.raw)return;const c=s.raw.split("\n").length,d=t.split("\n").slice(0,c).join("\n");return{...s,raw:d}}},addCommands:()=>({insertTable:({rows:t=3,cols:e=3,withHeaderRow:o=!0}={})=>({tr:n,dispatch:r,editor:i})=>{const l=Q(i.schema,t,e,o);if(r){const t=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(w.near(n.doc.resolve(t)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>C(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>y(t,e),deleteColumn:()=>({state:t,dispatch:e})=>A(t,e),addRowBefore:()=>({state:t,dispatch:e})=>T(t,e),addRowAfter:()=>({state:t,dispatch:e})=>M(t,e),deleteRow:()=>({state:t,dispatch:e})=>H(t,e),deleteTable:()=>({state:t,dispatch:e})=>k(t,e),mergeCells:()=>({state:t,dispatch:e})=>N(t,e),splitCell:()=>({state:t,dispatch:e})=>S(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>E("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>E("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>O(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>!!N(t,e)||S(t,e),setCellAttribute:(t,e)=>({state:o,dispatch:n})=>$(t,e)(o,n),goToNextCell:()=>({state:t,dispatch:e})=>R(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>R(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&L(t),!0),setCellSelection:t=>({tr:e,dispatch:o})=>{if(o){const o=x.create(e.doc,t.anchorCell,t.headCell);e.setSelection(o)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:U,"Mod-Backspace":U,Delete:U,"Mod-Delete":U}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[v({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],W({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:t,view:o,HTMLAttributes:n})=>{const r=m(this.options.HTMLAttributes,n);return new e(t,this.options.cellMinWidth,o,r)}},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:b(g(t,"tableRole",e))}}});p.create({name:"tableKit",addExtensions(){const t=[];return!1!==this.options.table&&t.push(Y.configure(this.options.table)),!1!==this.options.tableCell&&t.push(I.configure(this.options.tableCell)),!1!==this.options.tableHeader&&t.push(F.configure(this.options.tableHeader)),!1!==this.options.tableRow&&t.push(q.configure(this.options.tableRow)),t}});function Z(t,e){return({tr:e,state:o,dispatch:n})=>{const{selection:r}=o;return e=function(t,e,o){const{doc:n,selection:r}=t;return n&&r&&r instanceof x?(r.forEachCell((e,n)=>{t=function(t,e,o){if(!t.doc)return t;const n=t.doc.nodeAt(e);if(!n)return t;if(o===n.attrs.backgroundColor)return t;const r={...n.attrs,backgroundColor:o};return t.setNodeMarkup(e,n.type,r,n.marks)}(t,n,o)}),t):t}(e=e.setSelection(r),0,t),!!e.docChanged&&(n?.(e),!0)}}var tt=p.create({name:"tableCellBackground",addOptions:()=>({types:["tableCell"],HTMLAttributes:{}}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:t=>t.style.backgroundColor||"",renderHTML:t=>t.backgroundColor&&""!==t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setTableCellBackground:t=>Z(t,this.options),unsetTableCellBackground:()=>Z("",this.options)}}}),et=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,ot=/CrOS/,nt=/android|ipad|playbook|silk/i;function rt(t={}){let e=t.ua||"undefined"!=typeof navigator&&navigator.userAgent;return e&&"object"==typeof e&&e.headers&&"string"==typeof e.headers["user-agent"]&&(e=e.headers["user-agent"]),"string"==typeof e&&(!(!et.test(e)||ot.test(e))||(!(!t.tablet||!nt.test(e))||!!(t.tablet&&t.featureDetect&&navigator&&navigator.maxTouchPoints>1&&e.includes("Macintosh")&&e.includes("Safari"))))}var it=t=>Array.from({length:t}).map((t,e)=>e+1);function lt(t){const[r,i]=s(!1),[l,a]=s(!0),[c,p]=s({rows:(rt(),10),cols:(rt(),10)}),[u,b]=s({rows:2,cols:2});function f(e,o){t?.createTable({rows:e,cols:o,withHeaderRow:l}),a(!1),p({rows:10,cols:10}),b({rows:2,cols:2}),i(!1)}/* @__PURE__ */
|
|
1
|
+
import{n as t}from"./toggle-BXl_NYYh.js";import{n as e,r as o,t as n}from"./popover-DGEv-NbL.js";import{c as r,d as i,t as l}from"./useButtonProps-DSIajp_B.js";import a,{useState as s}from"react";import{Fragment as c,jsx as d,jsxs as h}from"react/jsx-runtime";import{Extension as p,Node as u,callOrReturn as b,findParentNodeClosestToPos as f,getExtensionField as g,mergeAttributes as m}from"@tiptap/core";import{TextSelection as w}from"@tiptap/pm/state";import{CellSelection as x,addColumnAfter as y,addColumnBefore as C,addRowAfter as M,addRowBefore as T,columnResizing as v,deleteColumn as A,deleteRow as H,deleteTable as k,fixTables as L,goToNextCell as R,mergeCells as N,setCellAttr as $,splitCell as S,tableEditing as W,toggleHeader as E,toggleHeaderCell as j}from"@tiptap/pm/tables";function O(t){return"left"===t||"right"===t||"center"===t?t:null}function z(){return{default:null,parseHTML:t=>function(t){const e=(t.style.textAlign||"").trim().toLowerCase(),o=(t.getAttribute("align")||"").trim().toLowerCase();return O(e||o)}(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}function P(t){const e=t.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):function(t){var e;const o=t.parentElement,n=t.closest("table");if(!o||!n)return null;const r=Array.from(o.children).indexOf(t),i=null==(e=n.querySelectorAll("colgroup > col")[r])?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}(t)}var B=/[ \t\r\n\f]+/g;function D(t){var e;return!(t.children.length>0)&&""===(null!=(e=t.textContent)?e:"").replace(B,"")}function V(t){const e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}var I=u.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:P},align:z()}),tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>!!D(t)&&{},getContent:(t,e)=>V(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",m(this.options.HTMLAttributes,t),0]}}),F=u.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:P},align:z()}),tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>!!D(t)&&{},getContent:(t,e)=>V(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",m(this.options.HTMLAttributes,t),0]}}),K=u.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:t}){return["tr",m(this.options.HTMLAttributes,t),0]}});function _(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function q(t,e,o,n,r,i){var l;let a=0,s=!0,c=e.firstChild;const d=t.firstChild;if(null!==d)for(let p=0,u=0;p<d.childCount;p+=1){const{colspan:t,colwidth:o}=d.child(p).attrs;for(let l=0;l<t;l+=1,u+=1){const t=r===u?i:o&&o[l],d=t?`${t}px`:"";if(a+=t||n,t||(s=!1),c){if(c.style.width!==d){const[e,o]=_(n,t);c.style.setProperty(e,o)}c=c.nextSibling}else{const o=document.createElement("col"),[r,i]=_(n,t);o.style.setProperty(r,i),e.appendChild(o)}}}for(;c;){const t=c.nextSibling;null==(l=c.parentNode)||l.removeChild(c),c=t}const h=t.attrs.style&&"string"==typeof t.attrs.style&&/\bwidth\s*:/i.test(t.attrs.style);s&&!h?(o.style.width=`${a}px`,o.style.minWidth=""):(o.style.width="",o.style.minWidth=`${a}px`)}var G=class{constructor(t,e,o,n={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[r,i]of Object.entries(n))null!=i&&("style"===r?this.table.style.cssText=String(i):this.table.setAttribute(r,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),q(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type===this.node.type&&(this.node=t,q(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,o=this.dom.contains(e),n=this.contentDOM.contains(e);return!(!o||n||"attributes"!==t.type&&"childList"!==t.type&&"characterData"!==t.type)}};function J(t,e){return e?t.createChecked(null,e):t.createAndFill()}function Q(t,e,o,n,r){const i=function(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(o=>{const n=t.nodes[o];n.spec.tableRole&&(e[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=e,e}(t),l=[],a=[];for(let c=0;c<o;c+=1){const t=J(i.cell,r);if(t&&a.push(t),n){const t=J(i.header_cell,r);t&&l.push(t)}}const s=[];for(let c=0;c<e;c+=1)s.push(i.row.createChecked(null,n&&0===c?l:a));return i.table.createChecked(null,s)}var U=({editor:t})=>{const{selection:e}=t.state;if(!(e instanceof x))return!1;let o=0;return f(e.ranges[0].$from,t=>"table"===t.type.name)?.node.descendants(t=>{if("table"===t.type.name)return!1;["tableCell","tableHeader"].includes(t.type.name)&&(o+=1)}),o===e.ranges.length&&(t.commands.deleteTable(),!0)};var X=function(t,e,o={}){var n;const r=null!=(n=o.cellLineSeparator)?n:"";if(!t||!t.content||0===t.content.length)return"";const i=[];t.content.forEach(t=>{const o=[];t.content&&t.content.forEach(t=>{let n="";n=t.content&&Array.isArray(t.content)&&t.content.length>1?t.content.map(t=>e.renderChildren(t)).join(r):t.content?e.renderChildren(t.content):"";const i=(n.split(r).join("\n").replace(/[ \t]*\r?\n[ \t]*/g,"<br>")||"").replace(/\s+/g," ").trim();const l="tableHeader"===t.type,a=O(null==(s=t.attrs)?void 0:s.align);var s;o.push({text:i,isHeader:l,align:a})}),i.push(o)});const l=i.reduce((t,e)=>Math.max(t,e.length),0);if(0===l)return"";const a=Array.from({length:l}).fill(0);i.forEach(t=>{var e;for(let o=0;o<l;o+=1){const n=((null==(e=t[o])?void 0:e.text)||"").length;n>a[o]&&(a[o]=n),a[o]<3&&(a[o]=3)}});const s=(t,e)=>t+" ".repeat(Math.max(0,e-t.length)),c=i[0],d=c.some(t=>t.isHeader),h=Array.from({length:l}).fill(null);i.forEach(t=>{var e;for(let o=0;o<l;o+=1)!h[o]&&(null==(e=t[o])?void 0:e.align)&&(h[o]=t[o].align)});let p="\n";const u=Array.from({length:l}).map((t,e)=>d&&c[e]&&c[e].text||"");return p+=`| ${u.map((t,e)=>s(t,a[e])).join(" | ")} |\n`,p+=`| ${a.map((t,e)=>{const o=Math.max(3,t),n=h[e];return"left"===n?`:${"-".repeat(o)}`:"right"===n?`${"-".repeat(o)}:`:"center"===n?`:${"-".repeat(o)}:`:"-".repeat(o)}).join(" | ")} |\n`,(d?i.slice(1):i).forEach(t=>{p+=`| ${Array.from({length:l}).fill(0).map((e,o)=>s(t[o]&&t[o].text||"",a[o])).join(" | ")} |\n`}),p},Y=u.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:G,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:t,HTMLAttributes:e}){const{colgroup:o,tableWidth:n,tableMinWidth:r}=function(t,e,o,n){let r=0,i=!0;const l=[],a=t.firstChild;if(!a)return{};for(let d=0,h=0;d<a.childCount;d+=1){const{colspan:t,colwidth:s}=a.child(d).attrs;for(let a=0;a<t;a+=1,h+=1){const t=o===h?n:s&&s[a];r+=t||e,t||(i=!1);const[c,d]=_(e,t);l.push(["col",{style:`${c}: ${d}`}])}}const s=i?`${r}px`:"",c=i?"":`${r}px`;return{colgroup:["colgroup",{},...l],tableWidth:s,tableMinWidth:c}}(t,this.options.cellMinWidth),i=e.style;const l=["table",m(this.options.HTMLAttributes,e,{style:i||(n?`width: ${n}`:`min-width: ${r}`)}),o,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const o=[],n=Array.isArray(t.align)?t.align:[];if(t.header){const r=[];t.header.forEach((t,o)=>{var i;const l=O(null!=(i=n[o])?i:t.align),a=l?{align:l}:{};r.push(e.createNode("tableHeader",a,[{type:"paragraph",content:e.parseInline(t.tokens)}]))}),o.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(t=>{const r=[];t.forEach((t,o)=>{var i;const l=O(null!=(i=n[o])?i:t.align),a=l?{align:l}:{};r.push(e.createNode("tableCell",a,[{type:"paragraph",content:e.parseInline(t.tokens)}]))}),o.push(e.createNode("tableRow",{},r))}),e.createNode("table",void 0,o)},renderMarkdown:(t,e)=>X(t,e),markdownTokenizer:{name:"table",level:"block",start:t=>{const e=t.split("\n");if(e.length<2)return-1;const o=e[1];return/^[ \t|:]*-[ \t|:-]*$/.test(o)&&o.includes("|")&&e[0].includes("|")?0:-1},tokenize(t,e,o){const n=t.indexOf("\n\n"),r=n>=0?t.slice(0,n):t,i=r.split("\n");if(i.length<2)return;const l=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(l)||!l.includes("|"))return;const a=function(t){return t.split("\n").map(t=>t.includes("|")&&t.includes("`")?function(t){let e="",o=0;for(;o<t.length;){if("\\"===t[o]&&o+1<t.length){e+=t[o]+t[o+1],o+=2;continue}if("`"!==t[o]){e+=t[o++];continue}let n=0;for(;o+n<t.length&&"`"===t[o+n];)n+=1;let r=o+n,i=!1;for(;r<t.length;){if("`"!==t[r]){r+=1;continue}let l=0;for(;r+l<t.length&&"`"===t[r+l];)l+=1;if(l===n){const l=t.slice(o+n,r);e+=t.slice(o,o+n)+l.replace(/(?<!\\)\|/g,"\\|")+t.slice(r,r+n),o=r+n,i=!0;break}r+=l}i||(e+=t.slice(o,o+n),o+=n)}return e}(t):t).join("\n")}(r);if(a===r)return;const s=o.blockTokens(a)[0];if("table"!==(null==s?void 0:s.type)||!s.raw)return;const c=s.raw.split("\n").length,d=t.split("\n").slice(0,c).join("\n");return{...s,raw:d}}},addCommands:()=>({insertTable:({rows:t=3,cols:e=3,withHeaderRow:o=!0}={})=>({tr:n,dispatch:r,editor:i})=>{const l=Q(i.schema,t,e,o);if(r){const t=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(w.near(n.doc.resolve(t)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>C(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>y(t,e),deleteColumn:()=>({state:t,dispatch:e})=>A(t,e),addRowBefore:()=>({state:t,dispatch:e})=>T(t,e),addRowAfter:()=>({state:t,dispatch:e})=>M(t,e),deleteRow:()=>({state:t,dispatch:e})=>H(t,e),deleteTable:()=>({state:t,dispatch:e})=>k(t,e),mergeCells:()=>({state:t,dispatch:e})=>N(t,e),splitCell:()=>({state:t,dispatch:e})=>S(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>E("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>E("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>j(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>!!N(t,e)||S(t,e),setCellAttribute:(t,e)=>({state:o,dispatch:n})=>$(t,e)(o,n),goToNextCell:()=>({state:t,dispatch:e})=>R(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>R(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&L(t),!0),setCellSelection:t=>({tr:e,dispatch:o})=>{if(o){const o=x.create(e.doc,t.anchorCell,t.headCell);e.setSelection(o)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:U,"Mod-Backspace":U,Delete:U,"Mod-Delete":U}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[v({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],W({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:t,view:o,HTMLAttributes:n})=>{const r=m(this.options.HTMLAttributes,n);return new e(t,this.options.cellMinWidth,o,r)}},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:b(g(t,"tableRole",e))}}});p.create({name:"tableKit",addExtensions(){const t=[];return!1!==this.options.table&&t.push(Y.configure(this.options.table)),!1!==this.options.tableCell&&t.push(I.configure(this.options.tableCell)),!1!==this.options.tableHeader&&t.push(F.configure(this.options.tableHeader)),!1!==this.options.tableRow&&t.push(K.configure(this.options.tableRow)),t}});function Z(t,e){return({tr:e,state:o,dispatch:n})=>{const{selection:r}=o;return e=function(t,e,o){const{doc:n,selection:r}=t;return n&&r&&r instanceof x?(r.forEachCell((e,n)=>{t=function(t,e,o){if(!t.doc)return t;const n=t.doc.nodeAt(e);if(!n)return t;if(o===n.attrs.backgroundColor)return t;const r={...n.attrs,backgroundColor:o};return t.setNodeMarkup(e,n.type,r,n.marks)}(t,n,o)}),t):t}(e=e.setSelection(r),0,t),!!e.docChanged&&(n?.(e),!0)}}var tt=p.create({name:"tableCellBackground",addOptions:()=>({types:["tableCell"],HTMLAttributes:{}}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:t=>t.style.backgroundColor||"",renderHTML:t=>t.backgroundColor&&""!==t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setTableCellBackground:t=>Z(t,this.options),unsetTableCellBackground:()=>Z("",this.options)}}}),et=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,ot=/CrOS/,nt=/android|ipad|playbook|silk/i;function rt(t={}){let e=t.ua||"undefined"!=typeof navigator&&navigator.userAgent;return e&&"object"==typeof e&&e.headers&&"string"==typeof e.headers["user-agent"]&&(e=e.headers["user-agent"]),"string"==typeof e&&(!(!et.test(e)||ot.test(e))||(!(!t.tablet||!nt.test(e))||!!(t.tablet&&t.featureDetect&&navigator&&navigator.maxTouchPoints>1&&e.includes("Macintosh")&&e.includes("Safari"))))}var it=t=>Array.from({length:t}).map((t,e)=>e+1);function lt(t){const[r,i]=s(!1),[l,a]=s(!0),[c,p]=s({rows:(rt(),10),cols:(rt(),10)}),[u,b]=s({rows:2,cols:2});function f(e,o){t?.createTable({rows:e,cols:o,withHeaderRow:l}),a(!1),p({rows:10,cols:10}),b({rows:2,cols:2}),i(!1)}/* @__PURE__ */
|
|
2
2
|
return h(n,{modal:!0,onOpenChange:i,open:r,children:[/* @__PURE__ */d(o,{asChild:!0,"data-state":t?.dataState?"on":"off",children:t?.children}),/* @__PURE__ */d(e,{align:"start",className:"richtext-w-full !richtext-p-2",side:"bottom",children:/* @__PURE__ */h("div",{className:"table-grid-size-editor richtext-p-0",children:[/* @__PURE__ */d("div",{className:"richtext-flex richtext-flex-col richtext-flex-wrap richtext-justify-between richtext-gap-1",children:it(c?.rows)?.map(t=>/* @__PURE__ */d("div",{className:"richtext-flex richtext-gap-1",children:it(c?.cols)?.map(e=>/* @__PURE__ */d("div",{onMouseDown:()=>f(t,e),onMouseOver:()=>{return n=e,(o=t)===c.rows&&p(t=>({...t,rows:Math.min(o+1,10)})),n===c.cols&&p(t=>({...t,cols:Math.min(n+1,10)})),void b({rows:o,cols:n});var o,n},className:`richtext-cursor-pointer richtext-border-border ${e<=u.cols&&t<=u.rows&&"tableCellActive !richtext-bg-foreground"}`,children:/* @__PURE__ */d("div",{className:"richtext-box-border richtext-size-4 richtext-rounded-[2px] !richtext-border richtext-border-solid !richtext-border-border richtext-p-1"})},`richtext-table-col-${e}`))},`richtext-table-row-${t}`))}),/* @__PURE__ */h("div",{className:"richtext-mt-2 richtext-text-center richtext-text-sm richtext-text-foreground",children:[u.rows,"x",u.cols]})]})})]})}function at(){const e=i(),o=l(st.name),{icon:n,tooltip:a,action:s,isActive:h,color:p}=o?.componentProps??{},{dataState:u,disabled:b}=r(h);if(!o)/* @__PURE__ */return d(c,{});/* @__PURE__ */
|
|
3
|
-
return d(lt,{createTable:function(t){e.chain().focus().insertTable({...t,withHeaderRow:!1}).run()},dataState:u,children:/* @__PURE__ */d(t,{action:s,color:p,dataState:u,icon:n,isActive:h,tooltip:a,disabled:b})})}var st=Y.extend({addOptions(){return{...this.parent?.(),HTMLAttributes:{style:"\n border: 1px solid #000;\n border-collapse: collapse;\n width: 100%;\n "},resizable:!0,lastColumnResizable:!0,allowTableNodeSelection:!1,button:({editor:t,t:e})=>({componentProps:{isActive:()=>t.isActive("table"),icon:"Table",tooltip:e("editor.table.tooltip")}})}},addExtensions(){return[
|
|
3
|
+
return d(lt,{createTable:function(t){e.chain().focus().insertTable({...t,withHeaderRow:!1}).run()},dataState:u,children:/* @__PURE__ */d(t,{action:s,color:p,dataState:u,icon:n,isActive:h,tooltip:a,disabled:b})})}var st=Y.extend({addOptions(){return{...this.parent?.(),HTMLAttributes:{style:"\n border: 1px solid #000;\n border-collapse: collapse;\n width: 100%;\n "},resizable:!0,lastColumnResizable:!0,allowTableNodeSelection:!1,button:({editor:t,t:e})=>({componentProps:{isActive:()=>t.isActive("table"),icon:"Table",tooltip:e("editor.table.tooltip")}})}},addExtensions(){return[K.configure(this.options.tableRow),F.configure(this.options.tableHeader),I.configure(this.options.tableCell),tt.configure(this.options.tableCellBackground)]}});export{at as n,st as t};
|
package/dist/Table.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as a,t as o}from"./Table-
|
|
1
|
+
import{n as a,t as o}from"./Table-6kM52sUH.js";export{a as RichTextTable,o as Table};
|
package/dist/TaskList.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const t=require("./toggle-CRftKzl0.cjs"),s=require("./useButtonProps-D2Hd5DbR.cjs"),e=require("./dist-ICzvPVCE.cjs");let o=require("react/jsx-runtime");var i=e.TaskList.extend({addOptions(){return{...this.parent?.(),HTMLAttributes:{class:"task-list"},taskItem:{HTMLAttributes:{class:"task-list-item"}},button:({editor:t,t:s,extension:e})=>({componentProps:{action:()=>t.commands.toggleTaskList(),isActive:()=>t.isActive("taskList"),disabled:!1,icon:"ListTodo",shortcutKeys:e.options.shortcutKeys??["shift","mod","9"],tooltip:s("editor.tasklist.tooltip")}})}},addExtensions(){return[e.TaskItem.configure(this.options.taskItem)]}});exports.RichTextTaskList=function(){const e=s.useButtonProps(i.name),{icon:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const t=require("./toggle-CRftKzl0.cjs"),s=require("./useButtonProps-D2Hd5DbR.cjs"),e=require("./dist-ICzvPVCE.cjs");let o=require("react/jsx-runtime");var i=e.TaskList.extend({addOptions(){return{...this.parent?.(),HTMLAttributes:{class:"task-list"},taskItem:{HTMLAttributes:{class:"task-list-item"}},button:({editor:t,t:s,extension:e})=>({componentProps:{action:()=>t.commands.toggleTaskList(),isActive:()=>t.isActive("taskList"),disabled:!1,icon:"ListTodo",shortcutKeys:e.options.shortcutKeys??["shift","mod","9"],tooltip:s("editor.tasklist.tooltip")}})}},addExtensions(){return[e.TaskItem.configure(this.options.taskItem)]}});exports.RichTextTaskList=function(){const e=s.useButtonProps(i.name),{icon:r,tooltip:n,shortcutKeys:a,tooltipOptions:c={},action:u,isActive:d}=e?.componentProps??{},{dataState:l,disabled:p,update:m}=s.useToggleActive(d);return e?(0,o.jsx)(t.ActionButton,{action:()=>{p||u&&(u(),m())},dataState:l,disabled:p,icon:r,shortcutKeys:a,tooltip:n,tooltipOptions:c}):(0,o.jsx)(o.Fragment,{})},exports.TaskList=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,i as e,n as i,t as s}from"./tooltip-DC3DBc55.js";import{n,t as o}from"./toggle-BXl_NYYh.js";import{t as r}from"./Icon-CJJ9AQtR.js";import{n as a,r as l,t as c}from"./popover-DGEv-NbL.js";import{s as m,t as d}from"./useButtonProps-DSIajp_B.js";import h,{useMemo as p}from"react";import{Fragment as g,jsx as x,jsxs as u}from"react/jsx-runtime";import{Extension as f}from"@tiptap/core";function A(){const[f,A]=h.useState(!1),b=d(y.name),{icon:
|
|
1
|
+
import{a as t,i as e,n as i,t as s}from"./tooltip-DC3DBc55.js";import{n,t as o}from"./toggle-BXl_NYYh.js";import{t as r}from"./Icon-CJJ9AQtR.js";import{n as a,r as l,t as c}from"./popover-DGEv-NbL.js";import{s as m,t as d}from"./useButtonProps-DSIajp_B.js";import h,{useMemo as p}from"react";import{Fragment as g,jsx as x,jsxs as u}from"react/jsx-runtime";import{Extension as f}from"@tiptap/core";function A(){const[f,A]=h.useState(!1),b=d(y.name),{icon:j,tooltip:T,items:S=[],isActive:v}=b?.componentProps??{},{disabled:K,dataState:C}=m(v),M=p(()=>C?.title||"",[C]),w=p(()=>S?.some(t=>t.title===M),[S,M]);return b?/* @__PURE__ */u(c,{modal:!0,onOpenChange:A,open:f,children:[/* @__PURE__ */x(l,{asChild:!0,className:"hover:richtext-bg-accent data-[state=on]:richtext-bg-accent","data-state":w?"on":"off",disabled:K,children:/* @__PURE__ */x(n,{customClass:"!richtext-w-12 richtext-h-12",disabled:K,icon:j,tooltip:T,children:/* @__PURE__ */x(r,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})})}),/* @__PURE__ */x(a,{align:"start",className:"richtext-flex richtext-w-full richtext-min-w-4 richtext-flex-row richtext-gap-1 !richtext-p-[4px]",side:"bottom",children:S?.map((n,a)=>/* @__PURE__ */u(s,{children:[/* @__PURE__ */x(e,{asChild:!0,children:/* @__PURE__ */x(o,{className:"richtext-size-7 richtext-p-1","data-state":M===n.title?"on":"off",size:"sm",onClick:()=>{n?.action(),A(!1)},children:n?.icon&&/* @__PURE__ */x(r,{name:n.icon})})}),/* @__PURE__ */u(i,{className:"richtext-flex richtext-flex-col richtext-items-center",children:[/* @__PURE__ */x("span",{children:n.title}),!!n.shortcutKeys?.length&&/* @__PURE__ */x("span",{children:n.shortcutKeys?.map(e=>t(e)).join(" ")})]})]},`text-align-${a}`))})]}):/* @__PURE__ */x(g,{})}var y=f.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>!!this.options.alignments.includes(t)&&this.options.types.map(i=>e.updateAttributes(i,{textAlign:t})).some(t=>t),unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(t=>t),toggleTextAlign:t=>({editor:e,commands:i})=>!!this.options.alignments.includes(t)&&(e.isActive({textAlign:t})?i.unsetTextAlign():i.setTextAlign(t))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}).extend({addOptions(){return{...this.parent?.(),types:["heading","paragraph","list_item","title"],button({editor:t,extension:e,t:i}){const s=e.options?.alignments||[],n={left:e.options.shortcutKeys?.[0]??["mod","Shift","L"],center:e.options.shortcutKeys?.[1]??["mod","Shift","E"],right:e.options.shortcutKeys?.[2]??["mod","Shift","R"],justify:e.options.shortcutKeys?.[3]??["mod","Shift","J"]},o={left:"AlignLeft",center:"AlignCenter",right:"AlignRight",justify:"AlignJustify"},r=s.map(e=>({title:i(`editor.textalign.${e}.tooltip`),icon:o[e],shortcutKeys:n[e],isActive:()=>t.isActive({textAlign:e})||!1,action:()=>t.commands?.setTextAlign?.(e),disabled:!t?.can?.()?.setTextAlign?.(e)}));return{componentProps:{icon:"AlignJustify",tooltip:i("editor.textalign.tooltip"),items:r,isActive:()=>r?.find(t=>t.isActive())}}}}}});export{A as n,y as t};
|
package/dist/TextAlign.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as t,t as o}from"./TextAlign-
|
|
1
|
+
import{n as t,t as o}from"./TextAlign-BKo82ocx.js";export{t as RichTextAlign,o as TextAlign};
|
package/dist/TextDirection.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,i as e,n as i,t as o}from"./tooltip-DC3DBc55.js";import{n as r,t as n}from"./toggle-BXl_NYYh.js";import{t as s}from"./Icon-CJJ9AQtR.js";import{n as a,r as c,t as l}from"./popover-DGEv-NbL.js";import{s as m,t as h}from"./useButtonProps-DSIajp_B.js";import p,{useMemo as d}from"react";import{Fragment as x,jsx as u,jsxs as f}from"react/jsx-runtime";import{Extension as g}from"@tiptap/core";function D(){const g=h(
|
|
1
|
+
import{a as t,i as e,n as i,t as o}from"./tooltip-DC3DBc55.js";import{n as r,t as n}from"./toggle-BXl_NYYh.js";import{t as s}from"./Icon-CJJ9AQtR.js";import{n as a,r as c,t as l}from"./popover-DGEv-NbL.js";import{s as m,t as h}from"./useButtonProps-DSIajp_B.js";import p,{useMemo as d}from"react";import{Fragment as x,jsx as u,jsxs as f}from"react/jsx-runtime";import{Extension as g}from"@tiptap/core";function D(){const g=h(j.name),[D,T]=p.useState(!1),{icon:b,tooltip:v,items:w=[],isActive:C}=g?.componentProps??{},{editorDisabled:z,dataState:N}=m(C),A=d(()=>N?.dir||"unset",[N]);return g?/* @__PURE__ */f(l,{open:D,onOpenChange:T,modal:!0,children:[/* @__PURE__ */u(c,{asChild:!0,disabled:z,children:/* @__PURE__ */u(r,{customClass:"!richtext-w-12 richtext-h-12",disabled:z,icon:b,tooltip:v,children:/* @__PURE__ */u(s,{className:"richtext-ml-1 richtext-size-3 richtext-text-zinc-500",name:"MenuDown"})})}),/* @__PURE__ */u(a,{align:"start",className:"richtext-flex richtext-w-full richtext-min-w-4 richtext-flex-row richtext-gap-1 !richtext-p-[4px]",side:"bottom",hideWhenDetached:!0,children:w?.map((r,a)=>/* @__PURE__ */f(o,{children:[/* @__PURE__ */u(e,{"data-state":A===r.value?"on":"off",asChild:!0,children:/* @__PURE__ */u(n,{className:"richtext-size-7 richtext-p-1",onClick:()=>{r?.action(),T(!1)},size:"sm",children:r?.icon&&/* @__PURE__ */u(s,{name:r.icon})})}),/* @__PURE__ */f(i,{className:"richtext-flex richtext-flex-col richtext-items-center",children:[/* @__PURE__ */u("span",{children:r.title}),!!r.shortcutKeys?.length&&/* @__PURE__ */u("span",{children:r.shortcutKeys?.map(e=>t(e)).join(" ")})]})]},`text-direction-${a}`))})]}):/* @__PURE__ */u(x,{})}var j=g.create({name:"richTextTextDirection",addOptions(){return{...this.parent?.(),directions:["auto","ltr","rtl","unset"],defaultDirection:"auto",button({editor:t,extension:e,t:i}){const o=e.options?.directions||[],r={auto:"TextDirection",ltr:"LeftToRight",rtl:"RightToLeft",unset:"X"},n=o.map(e=>({title:i(`editor.textDirection.${e}.tooltip`),value:e,icon:r[e],action:()=>{"unset"!==e?t.commands?.setTextDirection?.(e):t.commands?.unsetTextDirection?.()},disabled:!1}));return{componentProps:{icon:"TextDirection",tooltip:i("editor.textDirection.tooltip"),items:n,isActive:()=>t.getAttributes("paragraph")}}}}}});export{D as RichTextTextDirection,j as TextDirection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require("./rolldown-runtime-BeavJI0R.cjs");const t=require("./toggle-CRftKzl0.cjs"),e=require("./locales-Dg9XL0yP.cjs"),r=require("./Icon-DQdA22_-.cjs"),i=require("./button-CYMsgP3Y.cjs"),n=require("./input-AvqqajGM.cjs"),s=require("./label-DPSH3PiY.cjs"),o=require("./popover-DEGqjF2J.cjs"),c=require("./useButtonProps-D2Hd5DbR.cjs");let a=require("@tiptap/react"),d=require("react"),l=require("react/jsx-runtime"),u=require("@tiptap/core"),p=require("react-tweet");function m({node:t}){const e=(t?.attrs?.src||"")?.split("/").pop();return e?(0,l.jsx)(a.NodeViewWrapper,{children:(0,l.jsx)("div",{"data-twitter":"",children:(0,l.jsx)(p.Tweet,{id:e})})}):null}function x(t){const{t:r}=e.useLocale(),[o,c]=(0,d.useState)("");return(0,d.useEffect)(()=>{if(t?.editor){const{src:e}=t.editor.getAttributes(
|
|
1
|
+
require("./rolldown-runtime-BeavJI0R.cjs");const t=require("./toggle-CRftKzl0.cjs"),e=require("./locales-Dg9XL0yP.cjs"),r=require("./Icon-DQdA22_-.cjs"),i=require("./button-CYMsgP3Y.cjs"),n=require("./input-AvqqajGM.cjs"),s=require("./label-DPSH3PiY.cjs"),o=require("./popover-DEGqjF2J.cjs"),c=require("./useButtonProps-D2Hd5DbR.cjs");let a=require("@tiptap/react"),d=require("react"),l=require("react/jsx-runtime"),u=require("@tiptap/core"),p=require("react-tweet");function m({node:t}){const e=(t?.attrs?.src||"")?.split("/").pop();return e?(0,l.jsx)(a.NodeViewWrapper,{children:(0,l.jsx)("div",{"data-twitter":"",children:(0,l.jsx)(p.Tweet,{id:e})})}):null}function x(t){const{t:r}=e.useLocale(),[o,c]=(0,d.useState)("");return(0,d.useEffect)(()=>{if(t?.editor){const{src:e}=t.editor.getAttributes(g.name);e&&c(e)}},[t?.editor]),(0,l.jsxs)("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:function(e){e.preventDefault(),e.stopPropagation(),t?.onSetLink(o)},children:[(0,l.jsx)(s.Label,{className:"mb-[6px]",children:r("editor.link.dialog.text")}),(0,l.jsx)("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:(0,l.jsx)("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:(0,l.jsx)(n.Input,{className:"richtext-w-80",onChange:t=>c(t.target.value),placeholder:"Text",required:!0,type:"text",value:o})})}),(0,l.jsx)(i.Button,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:r("editor.link.dialog.button.apply")})]})}function h(){const[e,i]=(0,d.useState)(!1),n=c.useEditorInstance(),{icon:s,tooltip:a,tooltipOptions:u={},action:p,isActive:m}=c.useButtonProps(g.name)?.componentProps??{},{editorDisabled:h}=c.useToggleActive(m);return(0,l.jsxs)(o.Popover,{modal:!0,onOpenChange:i,open:e,children:[(0,l.jsx)(o.PopoverTrigger,{asChild:!0,children:(0,l.jsx)(t.ActionButton,{disabled:h,isActive:m,tooltip:a,tooltipOptions:u,children:(0,l.jsx)(r.IconComponent,{name:s})})}),(0,l.jsx)(o.PopoverContent,{align:"start",className:"richtext-w-full",hideWhenDetached:!0,side:"bottom",children:(0,l.jsx)(x,{editor:n,onSetLink:function(t){h||p&&(p(t),i(!1))}})})]})}var w=/(https?:\/\/)?(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?/g,b=/^https?:\/\/(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?$/;function j(t){return t.match(b)}var g=u.Node.create({name:"twitter",draggable:!0,selectable:!0,addOptions:()=>({addPasteHandler:!0,HTMLAttributes:{},inline:!1,origin:"",button:({editor:t,t:e})=>({componentProps:{action:e=>{t.commands.setTweet({src:e})},isActive:()=>!1,disabled:!1,icon:"Twitter",tooltip:e("editor.twitter.tooltip"),editor:t}})}),addNodeView(){return(0,a.ReactNodeViewRenderer)(m,{attrs:this.options.HTMLAttributes})},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},addAttributes:()=>({src:{default:null}}),parseHTML:()=>[{tag:"div[data-twitter]"}],addCommands(){return{setTweet:t=>({commands:e})=>!!j(t.src)&&e.insertContent({type:this.name,attrs:t}),updateTweet:t=>({commands:e})=>!!j(t.src)&&e.updateAttributes(this.name,{src:t.src})}},addPasteRules(){return this.options.addPasteHandler?[(0,u.nodePasteRule)({find:w,type:this.type,getAttributes:t=>({src:t.input})})]:[]},renderHTML:({HTMLAttributes:t})=>["div",(0,u.mergeAttributes)({"data-twitter":""},t)]});Object.defineProperty(exports,"FormEditLinkTwitter",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"RichTextTwitter",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"Twitter",{enumerable:!0,get:function(){return g}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{n as t}from"./toggle-BXl_NYYh.js";import{n as e}from"./locales-DfkG6-1b.js";import{t as i}from"./Icon-CJJ9AQtR.js";import{t as r}from"./button-CXcuJkiM.js";import{t as o}from"./input-CMD6LZFr.js";import{t as s}from"./label-Dx1mMx8l.js";import{n,r as a,t as c}from"./popover-DGEv-NbL.js";import{c as d,d as l,t as m}from"./useButtonProps-DSIajp_B.js";import{NodeViewWrapper as p,ReactNodeViewRenderer as u}from"@tiptap/react";import{useEffect as h,useState as f}from"react";import{jsx as x,jsxs as w}from"react/jsx-runtime";import{Node as b,mergeAttributes as g,nodePasteRule as v}from"@tiptap/core";import{Tweet as
|
|
1
|
+
import{n as t}from"./toggle-BXl_NYYh.js";import{n as e}from"./locales-DfkG6-1b.js";import{t as i}from"./Icon-CJJ9AQtR.js";import{t as r}from"./button-CXcuJkiM.js";import{t as o}from"./input-CMD6LZFr.js";import{t as s}from"./label-Dx1mMx8l.js";import{n,r as a,t as c}from"./popover-DGEv-NbL.js";import{c as d,d as l,t as m}from"./useButtonProps-DSIajp_B.js";import{NodeViewWrapper as p,ReactNodeViewRenderer as u}from"@tiptap/react";import{useEffect as h,useState as f}from"react";import{jsx as x,jsxs as w}from"react/jsx-runtime";import{Node as b,mergeAttributes as g,nodePasteRule as v}from"@tiptap/core";import{Tweet as j}from"react-tweet";function A({node:t}){const e=(t?.attrs?.src||"")?.split("/").pop();return e?/* @__PURE__ */x(p,{children:/* @__PURE__ */x("div",{"data-twitter":"",children:/* @__PURE__ */x(j,{id:e})})}):null}function T(t){const{t:i}=e(),[n,a]=f("");return h(()=>{if(t?.editor){const{src:e}=t.editor.getAttributes(y.name);e&&a(e)}},[t?.editor]),/* @__PURE__ */w("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:function(e){e.preventDefault(),e.stopPropagation(),t?.onSetLink(n)},children:[
|
|
2
2
|
/* @__PURE__ */x(s,{className:"mb-[6px]",children:i("editor.link.dialog.text")}),
|
|
3
3
|
/* @__PURE__ */x("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:/* @__PURE__ */x("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:/* @__PURE__ */x(o,{className:"richtext-w-80",onChange:t=>a(t.target.value),placeholder:"Text",required:!0,type:"text",value:n})})}),
|
|
4
4
|
/* @__PURE__ */x(r,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:i("editor.link.dialog.button.apply")})]})}function N(){const[e,r]=f(!1),o=l(),{icon:s,tooltip:p,tooltipOptions:u={},action:h,isActive:b}=m(y.name)?.componentProps??{},{editorDisabled:g}=d(b);/* @__PURE__ */
|
|
5
|
-
return w(c,{modal:!0,onOpenChange:r,open:e,children:[/* @__PURE__ */x(a,{asChild:!0,children:/* @__PURE__ */x(t,{disabled:g,isActive:b,tooltip:p,tooltipOptions:u,children:/* @__PURE__ */x(i,{name:s})})}),/* @__PURE__ */x(n,{align:"start",className:"richtext-w-full",hideWhenDetached:!0,side:"bottom",children:/* @__PURE__ */x(
|
|
5
|
+
return w(c,{modal:!0,onOpenChange:r,open:e,children:[/* @__PURE__ */x(a,{asChild:!0,children:/* @__PURE__ */x(t,{disabled:g,isActive:b,tooltip:p,tooltipOptions:u,children:/* @__PURE__ */x(i,{name:s})})}),/* @__PURE__ */x(n,{align:"start",className:"richtext-w-full",hideWhenDetached:!0,side:"bottom",children:/* @__PURE__ */x(T,{editor:o,onSetLink:function(t){g||h&&(h(t),r(!1))}})})]})}var H=/(https?:\/\/)?(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?/g,L=/^https?:\/\/(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?$/;function P(t){return t.match(L)}var y=b.create({name:"twitter",draggable:!0,selectable:!0,addOptions:()=>({addPasteHandler:!0,HTMLAttributes:{},inline:!1,origin:"",button:({editor:t,t:e})=>({componentProps:{action:e=>{t.commands.setTweet({src:e})},isActive:()=>!1,disabled:!1,icon:"Twitter",tooltip:e("editor.twitter.tooltip"),editor:t}})}),addNodeView(){return u(A,{attrs:this.options.HTMLAttributes})},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},addAttributes:()=>({src:{default:null}}),parseHTML:()=>[{tag:"div[data-twitter]"}],addCommands(){return{setTweet:t=>({commands:e})=>!!P(t.src)&&e.insertContent({type:this.name,attrs:t}),updateTweet:t=>({commands:e})=>!!P(t.src)&&e.updateAttributes(this.name,{src:t.src})}},addPasteRules(){return this.options.addPasteHandler?[v({find:H,type:this.type,getAttributes:t=>({src:t.input})})]:[]},renderHTML:({HTMLAttributes:t})=>["div",g({"data-twitter":""},t)]});export{N as n,T as r,y as t};
|
package/dist/Twitter.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./Twitter-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./Twitter-3yCP2UdP.cjs");exports.RichTextTwitter=e.RichTextTwitter,exports.Twitter=e.Twitter;
|
package/dist/Twitter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as t,t as r}from"./Twitter-
|
|
1
|
+
import{n as t,t as r}from"./Twitter-D38giVew.js";export{t as RichTextTwitter,r as Twitter};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{n as e}from"./toggle-BXl_NYYh.js";import{n as t,v as i}from"./locales-DfkG6-1b.js";import{t as o}from"./button-CXcuJkiM.js";import{a as r,n as a,o as l,t as d}from"./dialog-DgdVbRUv.js";import{t as s}from"./input-CMD6LZFr.js";import{i as n,n as c,r as p,t as u}from"./tabs-BovAV0Y3.js";import{c as h,d as m,i as v,o as f,t as w}from"./useButtonProps-DSIajp_B.js";import{useMemo as b,useRef as g,useState as x}from"react";import{jsx as y,jsxs as L}from"react/jsx-runtime";import{Node as V}from"@tiptap/core";function M(e,t){let i;try{i=new URL(e)}catch{return!1}return!t?.length||1===t.length&&"."===t[0]||t.some(e=>{if(e.includes("*")){const t=e.replace(/\./g,String.raw`\.`).replace(/\*/g,".*");return new RegExp(`^${t}$`).test(i.hostname)}return i.hostname.includes(e)})}function j(){const{t:i}=t(),v=m(),{icon:V,tooltip:j}=w(
|
|
2
|
-
return L(d,{onOpenChange:R,open:N,children:[/* @__PURE__ */y(l,{asChild:!0,children:/* @__PURE__ */y(e,{disabled:
|
|
1
|
+
import{n as e}from"./toggle-BXl_NYYh.js";import{n as t,v as i}from"./locales-DfkG6-1b.js";import{t as o}from"./button-CXcuJkiM.js";import{a as r,n as a,o as l,t as d}from"./dialog-DgdVbRUv.js";import{t as s}from"./input-CMD6LZFr.js";import{i as n,n as c,r as p,t as u}from"./tabs-BovAV0Y3.js";import{c as h,d as m,i as v,o as f,t as w}from"./useButtonProps-DSIajp_B.js";import{useMemo as b,useRef as g,useState as x}from"react";import{jsx as y,jsxs as L}from"react/jsx-runtime";import{Node as V}from"@tiptap/core";function M(e,t){let i;try{i=new URL(e)}catch{return!1}return!t?.length||1===t.length&&"."===t[0]||t.some(e=>{if(e.includes("*")){const t=e.replace(/\./g,String.raw`\.`).replace(/\*/g,".*");return new RegExp(`^${t}$`).test(i.hostname)}return i.hostname.includes(e)})}function j(){const{t:i}=t(),v=m(),{icon:V,tooltip:j}=w(T.name)?.componentProps??{},{editorDisabled:H}=h(),[k,A]=x(""),$=g(null),[C,P]=x(""),[N,R]=x(!1),z=f(T.name),D=b(()=>z?.options??{},[z]);/* @__PURE__ */
|
|
2
|
+
return L(d,{onOpenChange:R,open:N,children:[/* @__PURE__ */y(l,{asChild:!0,children:/* @__PURE__ */y(e,{disabled:H,icon:V,tooltip:j,action:()=>{H||R(!0)}})}),/* @__PURE__ */L(a,{children:[/* @__PURE__ */y(r,{children:i("editor.video.dialog.title")}),/* @__PURE__ */L(u,{activationMode:"manual",defaultValue:"both"===D?.resourceVideo||"upload"===D?.resourceVideo?"upload":"link",children:[
|
|
3
3
|
/* @__PURE__ */L(p,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[("both"===D?.resourceVideo||"upload"===D?.resourceVideo)&&/* @__PURE__ */y(n,{value:"upload",children:i("editor.video.dialog.tab.upload")}),("both"===D?.resourceVideo||"link"===D?.resourceVideo)&&/* @__PURE__ */y(n,{value:"link",children:i("editor.video.dialog.link")})]}),
|
|
4
4
|
/* @__PURE__ */L(c,{value:"upload",children:[/* @__PURE__ */y("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:/* @__PURE__ */y(o,{className:"richtext-mt-1 richtext-w-full",onClick:function(e){e.preventDefault(),$.current?.click()},size:"sm",children:i("editor.video.dialog.tab.upload")})}),/* @__PURE__ */y("input",{accept:"video/*",multiple:!0,onChange:async function(e){const t=e?.target?.files;if(!v||v.isDestroyed||0===t.length)return;const i=t[0];let o="";o=D.upload?await D.upload(i):URL.createObjectURL(i),v.chain().focus().setVideo({src:o,width:"100%"}).run(),R(!1)},ref:$,type:"file",style:{display:"none"}})]}),
|
|
5
|
-
/* @__PURE__ */L(c,{value:"link",children:[/* @__PURE__ */y("div",{children:/* @__PURE__ */L("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[/* @__PURE__ */y(s,{autoFocus:!0,placeholder:i("editor.video.dialog.placeholder"),required:!0,type:"url",value:
|
|
5
|
+
/* @__PURE__ */L(c,{value:"link",children:[/* @__PURE__ */y("div",{children:/* @__PURE__ */L("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[/* @__PURE__ */y(s,{autoFocus:!0,placeholder:i("editor.video.dialog.placeholder"),required:!0,type:"url",value:k,onBlur:e=>{const t=e.target.value,i=D.videoProviders||["."];t&&!M(t,i)?P("Invalid video URL"):P("")},onChange:e=>{A(e.target.value)}}),/* @__PURE__ */y(o,{onClick:function(e){e.preventDefault(),e.stopPropagation(),k&&(v.chain().focus().setVideo({src:k,width:"100%"}).run(),R(!1),A(""))},type:"button",children:i("editor.video.dialog.button.apply")})]})}),C&&/* @__PURE__ */y("div",{className:"richtext-my-[5px] richtext-text-red-500",children:C})]})]})]})]})}function H(e){const t=(e=e.replace("https://youtu.be/","https://www.youtube.com/watch?v=").replace("watch?v=","embed/")).match(/^https:\/\/www\.youtube\.com\/shorts\/([a-zA-Z0-9_-]+)/);t&&(e=`https://www.youtube.com/embed/${t[1]}`);const i=e.match(/^https:\/\/vimeo\.com\/(\d+)(?:\/([a-zA-Z0-9]+))?/);if(i){const t=i[1],o=i[2];e=o?`https://player.vimeo.com/video/${t}?h=${o}`:`https://player.vimeo.com/video/${t}`}return/^https?:\/\/www.bilibili.com\/video\/.*/i.test(e)&&(e=e.replace(/\?.*$/,"").replace("https://www.bilibili.com/video/","https://player.bilibili.com/player.html?bvid=")),e.includes("drive.google.com")&&(e=e.replace("/view","/preview")),e}var T=V.create({name:"video",group:"block",atom:!0,draggable:!0,addOptions:()=>({divider:!1,spacer:!1,allowFullscreen:!0,upload:void 0,frameborder:!1,resourceVideo:"both",width:i["size-medium"],HTMLAttributes:{class:"iframe-wrapper"},button:({editor:e,t:t})=>({componentProps:{action:()=>{},isActive:()=>e.isActive("video")||!1,disabled:!e.can().setVideo?.({}),icon:"Video",tooltip:t("editor.video.tooltip"),videoProviders:["."],editor:e}})}),addAttributes(){return{src:{default:null,renderHTML:({src:e})=>({src:e?H(e):null})},width:{default:this.options.width,renderHTML:({width:e})=>({width:v(e)})},frameborder:{default:this.options.frameborder?1:0,parseHTML:()=>this.options.frameborder?1:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},align:{default:"center",renderHTML:({align:e})=>({align:e})}}},parseHTML:()=>[{tag:"div[data-video] iframe"}],renderHTML({HTMLAttributes:e}){const{width:t="100%",align:i="center"}=e??{},o=["div",{style:`display: flex; justify-content: ${i};`},["div",{style:`position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${t};`},["div",{style:"flex: 1;padding-bottom: 56.25%;"}],["iframe",{...e,width:"100%",height:"100%"}]]];return["div",{...this.options.HTMLAttributes,class:"iframe-wrapper","data-video":""},o]},addCommands(){return{setVideo:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e}),updateVideo:e=>({commands:t})=>t.updateAttributes(this.name,e)}}});export{j as n,M as r,T as t};
|
package/dist/Video.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as o,t
|
|
1
|
+
import{n as o,t}from"./Video-DcfPDZLP.js";export{o as RichTextVideo,t as Video};
|
package/dist/WordCount.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./toggle-BXl_NYYh.js";import{n as t,r,t as a}from"./popover-DGEv-NbL.js";import{d as s,s as c,t as
|
|
1
|
+
import{n as e}from"./toggle-BXl_NYYh.js";import{n as t,r,t as a}from"./popover-DGEv-NbL.js";import{d as s,s as c,t as o}from"./useButtonProps-DSIajp_B.js";import{useEffect as i,useState as n}from"react";import{Fragment as l,jsx as p,jsxs as h}from"react/jsx-runtime";import{Extension as d}from"@tiptap/core";function m(e){if(!e)return[];const t=e.replace(/\s+/g," ").trim();if(!t)return[];const r=t.replace(/\b(Mr|Mrs|Ms|Dr|Prof|Sr|Jr|St|vs|etc|e\.g|i\.e)\./gi,"$1<dot>").replace(/(\d)\.(\d)/g,"$1<dot>$2").match(/[^.!?…。!?]+(?:[.!?…。!?]+|$)/g);return r?r.map(e=>e.replace(/<dot>/g,".").trim()).filter(e=>e.length>0):[]}var u={words:0,charactersWithSpaces:0,charactersNoSpaces:0,sentences:0,paragraphs:0,links:0,images:0};function x(e){if(!e)return{...u};const t=e.getText({blockSeparator:"\n"})??"",r=(t.match(/[^\s]+/g)??[]).length,a=t.length,s=t.replace(/\s/g,"").length,c=m(t).length;let o=0,i=0,n=0;return e.state.doc.descendants(e=>{e.isTextblock&&e.textContent.trim().length>0&&(o+=1),"image"===e.type.name&&(n+=1),e.isText&&e.marks.some(e=>"link"===e.type.name)&&(i+=1)}),{words:r,charactersWithSpaces:a,charactersNoSpaces:s,sentences:c,paragraphs:o,links:i,images:n}}var g={words:0,charactersWithSpaces:0,charactersNoSpaces:0,sentences:0,paragraphs:0,links:0,images:0};function b(){const d=s(),m=o(f.name),{icon:u,tooltip:b,shortcutKeys:v,tooltipOptions:S={},isActive:N}=m?.componentProps??{},{disabled:k}=c(N),[w,C]=n(!1),[W,y]=n(g);if(i(()=>{if(!d||!w)return;const e=()=>y(x(d));return e(),d.on("update",e),d.on("selectionUpdate",e),()=>{d.off("update",e),d.off("selectionUpdate",e)}},[d,w]),!m)/* @__PURE__ */return p(l,{});const j=[{label:"Words",value:W.words},{label:"Characters (with spaces)",value:W.charactersWithSpaces},{label:"Characters (no spaces)",value:W.charactersNoSpaces},{label:"Sentences",value:W.sentences},{label:"Paragraphs",value:W.paragraphs},{label:"Links",value:W.links},{label:"Images",value:W.images}];/* @__PURE__ */
|
|
2
2
|
return h(a,{onOpenChange:C,open:w,children:[/* @__PURE__ */p(r,{asChild:!0,disabled:k,children:/* @__PURE__ */p(e,{disabled:k,icon:u,shortcutKeys:v,tooltip:b,tooltipOptions:S})}),/* @__PURE__ */h(t,{align:"start",className:"richtext-w-[260px]",hideWhenDetached:!0,side:"bottom",children:[/* @__PURE__ */p("div",{className:"richtext-mb-[10px] richtext-flex richtext-items-center richtext-justify-between",children:/* @__PURE__ */p("span",{className:"richtext-text-sm richtext-font-semibold",children:"Word Count"})}),/* @__PURE__ */p("table",{className:"richtext-w-full richtext-text-sm",children:/* @__PURE__ */p("tbody",{children:j.map(e=>/* @__PURE__ */h("tr",{className:"richtext-border-b richtext-border-border last:richtext-border-b-0",children:[/* @__PURE__ */p("td",{className:"richtext-py-[6px] richtext-pr-2 richtext-text-muted-foreground",children:e.label}),/* @__PURE__ */p("td",{className:"richtext-py-[6px] richtext-text-right richtext-font-semibold richtext-tabular-nums",children:e.value})]},e.label))})})]})]})}var f=d.create({name:"wordCount",addOptions(){return{...this.parent?.(),button:({editor:e})=>({componentProps:{action:()=>{},icon:"WordCount",tooltip:"Word Count",isActive:()=>!0,disabled:!1,editor:e}})}}});export{b as RichTextWordCount,f as WordCount,x as getWordCountStats,m as splitTextToSentences};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as t}from"./toggle-BXl_NYYh.js";import{t as e}from"./separator-CTa6o9S_.js";import{_ as n,n as r,v as i}from"./locales-DfkG6-1b.js";import{t as o}from"./Icon-CJJ9AQtR.js";import{t as s}from"./button-CXcuJkiM.js";import{a as l,d as c,i as a,l as h,n as d,o as u,s as p,t as f,u as g}from"./floating-ui.dom-DledU50u.js";import{a as m,i as y,n as w,o as x,r as b,t as v}from"./dialog-DgdVbRUv.js";import{d as k,f as S,i as C,l as _,o as E,r as O,s as A,t as D,u as T}from"./dropdown-menu-CfGzSpIy.js";import{t as I}from"./input-CMD6LZFr.js";import{t as N}from"./label-Dx1mMx8l.js";import{n as M,r as R,t as z}from"./popover-DGEv-NbL.js";import{a as U,i as P,o as L,r as $,s as j,t as H}from"./Callout-heY7R-Zu.js";import{t as B}from"./textarea-uEPOPNqf.js";import{r as F}from"./ImageCropper-Dlz4nJQu.js";import{r as V,t as J}from"./events.constant-DYciHxmk.js";import{d as W,l as K,o as q}from"./useButtonProps-DSIajp_B.js";import{t as G}from"./file-aBzFF1LO.js";import{t as X}from"./Video-_YlAC2R_.js";import{t as Y}from"./CodeBlock-B7Wklup8.js";import{Clear as Z}from"./Clear.js";import{n as Q}from"./Bold-Ciuvp1pM.js";import{n as tt}from"./Italic-CZkbT3Dd.js";import{n as et}from"./TextUnderline-BaV7bhwo.js";import{n as nt}from"./Highlight-OkaWwhRk.js";import{n as rt}from"./Color-VWGwmpsG.js";import{n as it}from"./Code-B17BQJf-.js";import{i as ot,r as st,t as lt}from"./Indent-DpTPoZMk.js";import{n as ct,t as at}from"./TextAlign-C75gn_OM.js";import{n as ht,r as dt,t as ut}from"./Link-C0cNnjXo.js";import{i as pt,r as ft,t as gt}from"./Katex-Bo_vfXrd.js";import{t as mt}from"./ImageGif-D5Qw_Xf-.js";import{t as yt}from"./Table-C9t-k9Qu.js";import{r as wt}from"./Column-D4FgAp5K.js";import{r as xt,t as bt}from"./Twitter-D5UNfT-K.js";import{n as vt}from"./cdn-loader-w67sLKk9.js";import{t as kt}from"./Mermaid-DxpFRVu0.js";import{n as St,t as Ct}from"./shortId-COE42cHb.js";import{t as _t}from"./Drawio-eqEGDkwW.js";import{r as Et,t as Ot}from"./Drawer-Dunw22Q1.js";import{r as At,t as Dt}from"./Iframe-B-0W9YYq.js";import{t as Tt}from"./renderCommandListDefault-CJd5Cd3Q.js";import{useCurrentEditor as It}from"@tiptap/react";import Nt,{Fragment as Mt,useCallback as Rt,useEffect as zt,useLayoutEffect as Ut,useMemo as Pt,useRef as Lt,useState as $t}from"react";import{Fragment as jt,jsx as Ht,jsxs as Bt}from"react/jsx-runtime";import{Check as Ft,Copy as Vt,Pencil as Jt,Trash2 as Wt}from"lucide-react";import{createPortal as Kt}from"react-dom";import{Extension as qt,MappablePosition as Gt,getText as Xt,getTextSerializersFromSchema as Yt,getUpdatedPosition as Zt,isActive as Qt,isFirefox as te,isTextSelection as ee,posToDOMRect as ne}from"@tiptap/core";import{NodeSelection as re,Plugin as ie,PluginKey as oe,Selection as se,SelectionRange as le,TextSelection as ce}from"@tiptap/pm/state";import{Decoration as ae,DecorationSet as he}from"@tiptap/pm/view";import{NodeRange as de}from"@tiptap/pm/model";import{CellSelection as ue}from"@tiptap/pm/tables";import{deleteSelection as pe}from"@tiptap/pm/commands";import{Editor as fe,makeDropdownToolbar as ge}from"easydrawer";var me=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:i=250,resizeDelay:o=60,shouldShow:s,appendTo:l,getReferencedVirtualElement:c,options:a}){var h;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:t,state:e,from:n,to:r})=>{const{doc:i,selection:o}=e,{empty:s}=o,l=!i.textBetween(n,r).length&&ee(e.selection),c=this.element.contains(document.activeElement);return!(!t.hasFocus()&&!c||s||l||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:t})=>{var e;this.editor.isDestroyed?this.destroy():this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null==(e=this.element.parentNode)?void 0:e.contains(t.relatedTarget))||(null==t?void 0:t.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(t,e)=>{const n=!(null==e?void 0:e.selection.eq(t.state.selection)),r=!(null==e?void 0:e.doc.eq(t.state.doc));(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(t,n,r,e)},this.updateDelay))},this.updateHandler=(t,e,n,r)=>{const{composing:i}=t;i||!e&&!n||(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:t})=>{const e=t.getMeta(this.pluginKey);"updatePosition"===e?this.updatePosition():e&&"object"==typeof e&&"updateOptions"===e.type?this.updateOptions(e.options):"hide"===e?this.hide():"show"===e&&(this.updatePosition(),this.show())},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=o,this.appendTo=l,this.scrollTarget=null!=(h=null==a?void 0:a.scrollTarget)?h:window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(l("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(g("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(h("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(f(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(c("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(d("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(u("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(p("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,i=null==(t=this.getReferencedVirtualElement)?void 0:t.call(this);if(i)return i;if(!(null==(n=null==(e=this.view)?void 0:e.dom)?void 0:n.parentNode))return;const o=ne(this.view,r.from,r.to);let s={getBoundingClientRect:()=>o,getClientRects:()=>[o]};if(r instanceof re){let t=this.view.nodeDOM(r.from);const e=t.dataset.nodeViewWrapper?t:t.querySelector("[data-node-view-wrapper]");e&&(t=e),t&&(s={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(r instanceof ue){const{$anchorCell:t,$headCell:e}=r,n=t?t.pos:e.pos,i=e?e.pos:t.pos,o=this.view.nodeDOM(n),l=this.view.nodeDOM(i);if(!o||!l)return;const c=o===l?o.getBoundingClientRect():function(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-i;return new DOMRect(i,n,o,r-n)}(o.getBoundingClientRect(),l.getBoundingClientRect());s={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return s}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&a(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:e,strategy:n,middlewareData:r})=>{var i,o;this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected&&((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(o=r.hide)?void 0:o.escaped)?this.element.style.visibility="hidden":(this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${e}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()))})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r)return void this.handleDebouncedUpdate(t,e);const i=!(null==e?void 0:e.selection.eq(t.state.selection)),o=!(null==e?void 0:e.doc.eq(t.state.doc));this.updateHandler(t,i,o,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(t=>t.$from.pos)),s=Math.max(...i.map(t=>t.$to.pos));return(null==(e=this.shouldShow)?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:o,to:s}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(t=null!=e?e:this.view.dom.parentElement)||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(void 0!==t.updateDelay&&(this.updateDelay=t.updateDelay),void 0!==t.resizeDelay&&(this.resizeDelay=t.resizeDelay),void 0!==t.appendTo&&(this.appendTo=t.appendTo),void 0!==t.getReferencedVirtualElement&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),void 0!==t.shouldShow&&t.shouldShow&&(this.shouldShow=t.shouldShow),void 0!==t.options){const n=null!=(e=t.options.scrollTarget)?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},ye=t=>new ie({key:"string"==typeof t.pluginKey?new oe(t.pluginKey):t.pluginKey,view:e=>new me({view:e,...t})}),we=(qt.create({name:"bubbleMenu",addOptions:()=>({element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[ye({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}}),class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:i=250,resizeDelay:o=60,options:s,appendTo:l,shouldShow:c}){var a;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:t,state:e})=>{const{selection:n}=e,{$anchor:r,empty:i}=n,o=1===r.depth,s=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&0===r.parent.childCount&&!this.getTextContent(r.parent);return!!(t.hasFocus()&&i&&o&&s&&this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(t,e,n,r)=>{const{composing:i}=t;i||!e&&!n||(this.getShouldShow(r)?(this.updatePosition(),this.show()):this.hide())},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:t})=>{var e;this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null==(e=this.element.parentNode)?void 0:e.contains(t.relatedTarget))||(null==t?void 0:t.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:t})=>{const e=t.getMeta(this.pluginKey);"updatePosition"===e?this.updatePosition():e&&"object"==typeof e&&"updateOptions"===e.type?this.updateOptions(e.options):"hide"===e?this.hide():"show"===e&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=o,this.appendTo=l,this.scrollTarget=null!=(a=null==s?void 0:s.scrollTarget)?a:window,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return Xt(t,{textSerializers:Yt(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(l("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(g("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(h("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(f(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(c("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(d("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(u("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(p("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(t=>t.$from.pos)),s=Math.max(...i.map(t=>t.$to.pos));return null==(e=this.shouldShow)?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:o,to:s})}updateOptions(t){var e;if(void 0!==t.updateDelay&&(this.updateDelay=t.updateDelay),void 0!==t.resizeDelay&&(this.resizeDelay=t.resizeDelay),void 0!==t.appendTo&&(this.appendTo=t.appendTo),void 0!==t.shouldShow&&t.shouldShow&&(this.shouldShow=t.shouldShow),void 0!==t.options){const n=null!=(e=t.options.scrollTarget)?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){var t,e;if(!(null==(e=null==(t=this.view)?void 0:t.dom)?void 0:e.parentNode))return;const{selection:n}=this.editor.state,r=ne(this.view,n.from,n.to);a({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:e,strategy:n,middlewareData:r})=>{var i,o;(null==(i=r.hide)?void 0:i.referenceHidden)||(null==(o=r.hide)?void 0:o.escaped)?this.element.style.visibility="hidden":(this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${e}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate())})}update(t,e){const n=!(null==e?void 0:e.selection.eq(t.state.selection)),r=!(null==e?void 0:e.doc.eq(t.state.doc));this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(t=null!=e?e:this.view.dom.parentElement)||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}}),xe=t=>new ie({key:"string"==typeof t.pluginKey?new oe(t.pluginKey):t.pluginKey,view:e=>new we({view:e,...t})});qt.create({name:"floatingMenu",addOptions:()=>({element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}),addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[xe({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function be(t,e){return null!=t?t:new oe(e)}var ve="undefined"!=typeof window?Ut:zt,ke=/* @__PURE__ */new Set(["left","opacity","position","top","visibility","width"]),Se=/* @__PURE__ */new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),Ce=/* @__PURE__ */new Set(["children","className","style"]),_e=/* @__PURE__ */new Set(["tabIndex"]),Ee=/* @__PURE__ */new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),Oe={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function Ae(t,e){return/^on[A-Z]/.test(t)&&"function"==typeof e}function De(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Te(t){return _e.has(t)}function Ie(t,e,n){"tabIndex"!==e?t[e]=n:t.tabIndex=Number(n)}function Ne(t,e,n){ke.has(e)||t.style.setProperty(De(e),function(t,e){return"number"!=typeof e||0===e||t.startsWith("--")||Se.has(t)?String(e):`${e}px`}(e,n))}function Me(t,e,n){
|
|
1
|
+
import{n as t}from"./toggle-BXl_NYYh.js";import{t as e}from"./separator-CTa6o9S_.js";import{_ as n,n as r,v as i}from"./locales-DfkG6-1b.js";import{t as o}from"./Icon-CJJ9AQtR.js";import{t as s}from"./button-CXcuJkiM.js";import{a as l,d as c,i as a,l as h,n as d,o as u,s as p,t as f,u as g}from"./floating-ui.dom-DledU50u.js";import{a as m,i as y,n as w,o as x,r as b,t as v}from"./dialog-DgdVbRUv.js";import{d as k,f as S,i as C,l as _,o as E,r as O,s as A,t as D,u as T}from"./dropdown-menu-CfGzSpIy.js";import{t as I}from"./input-CMD6LZFr.js";import{t as N}from"./label-Dx1mMx8l.js";import{n as M,r as R,t as z}from"./popover-DGEv-NbL.js";import{a as U,i as P,o as L,r as $,s as j,t as H}from"./Callout-C6kKHIbW.js";import{t as B}from"./textarea-uEPOPNqf.js";import{r as F}from"./ImageCropper-CN_GzBBG.js";import{r as V,t as J}from"./events.constant-DYciHxmk.js";import{d as W,l as K,o as q}from"./useButtonProps-DSIajp_B.js";import{t as G}from"./file-aBzFF1LO.js";import{t as X}from"./Video-DcfPDZLP.js";import{t as Y}from"./CodeBlock-DLhI2Guf.js";import{Clear as Z}from"./Clear.js";import{n as Q}from"./Bold-Ciuvp1pM.js";import{n as tt}from"./Italic-CZkbT3Dd.js";import{n as et}from"./TextUnderline-BaV7bhwo.js";import{n as nt}from"./Highlight-OkaWwhRk.js";import{n as rt}from"./Color-VWGwmpsG.js";import{n as it}from"./Code-B17BQJf-.js";import{i as ot,r as st,t as lt}from"./Indent-fBwkYx_q.js";import{n as ct,t as at}from"./TextAlign-BKo82ocx.js";import{n as ht,r as dt,t as ut}from"./Link-Dpaom2jX.js";import{i as pt,r as ft,t as gt}from"./Katex-D2g86C-B.js";import{t as mt}from"./ImageGif-D9goI48J.js";import{t as yt}from"./Table-6kM52sUH.js";import{r as wt}from"./Column-D4FgAp5K.js";import{r as xt,t as bt}from"./Twitter-D38giVew.js";import{n as vt}from"./cdn-loader-w67sLKk9.js";import{t as kt}from"./Mermaid-B3KGZMBo.js";import{n as St,t as Ct}from"./shortId-COE42cHb.js";import{t as _t}from"./Drawio-CIXM-WGy.js";import{r as Et,t as Ot}from"./Drawer-bqo2XUCW.js";import{r as At,t as Dt}from"./Iframe-B-0W9YYq.js";import{t as Tt}from"./renderCommandListDefault-CJd5Cd3Q.js";import{useCurrentEditor as It}from"@tiptap/react";import Nt,{Fragment as Mt,useCallback as Rt,useEffect as zt,useLayoutEffect as Ut,useMemo as Pt,useRef as Lt,useState as $t}from"react";import{Fragment as jt,jsx as Ht,jsxs as Bt}from"react/jsx-runtime";import{Check as Ft,Copy as Vt,Pencil as Jt,Trash2 as Wt}from"lucide-react";import{createPortal as Kt}from"react-dom";import{Extension as qt,MappablePosition as Gt,getText as Xt,getTextSerializersFromSchema as Yt,getUpdatedPosition as Zt,isActive as Qt,isFirefox as te,isTextSelection as ee,posToDOMRect as ne}from"@tiptap/core";import{NodeSelection as re,Plugin as ie,PluginKey as oe,Selection as se,SelectionRange as le,TextSelection as ce}from"@tiptap/pm/state";import{Decoration as ae,DecorationSet as he}from"@tiptap/pm/view";import{NodeRange as de}from"@tiptap/pm/model";import{CellSelection as ue}from"@tiptap/pm/tables";import{deleteSelection as pe}from"@tiptap/pm/commands";import{Editor as fe,makeDropdownToolbar as ge}from"easydrawer";var me=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:i=250,resizeDelay:o=60,shouldShow:s,appendTo:l,getReferencedVirtualElement:c,options:a}){var h;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:t,state:e,from:n,to:r})=>{const{doc:i,selection:o}=e,{empty:s}=o,l=!i.textBetween(n,r).length&&ee(e.selection),c=this.element.contains(document.activeElement);return!(!t.hasFocus()&&!c||s||l||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:t})=>{var e;this.editor.isDestroyed?this.destroy():this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null==(e=this.element.parentNode)?void 0:e.contains(t.relatedTarget))||(null==t?void 0:t.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(t,e)=>{const n=!(null==e?void 0:e.selection.eq(t.state.selection)),r=!(null==e?void 0:e.doc.eq(t.state.doc));(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(t,n,r,e)},this.updateDelay))},this.updateHandler=(t,e,n,r)=>{const{composing:i}=t;i||!e&&!n||(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:t})=>{const e=t.getMeta(this.pluginKey);"updatePosition"===e?this.updatePosition():e&&"object"==typeof e&&"updateOptions"===e.type?this.updateOptions(e.options):"hide"===e?this.hide():"show"===e&&(this.updatePosition(),this.show())},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=o,this.appendTo=l,this.scrollTarget=null!=(h=null==a?void 0:a.scrollTarget)?h:window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(l("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(g("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(h("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(f(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(c("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(d("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(u("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(p("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,i=null==(t=this.getReferencedVirtualElement)?void 0:t.call(this);if(i)return i;if(!(null==(n=null==(e=this.view)?void 0:e.dom)?void 0:n.parentNode))return;const o=ne(this.view,r.from,r.to);let s={getBoundingClientRect:()=>o,getClientRects:()=>[o]};if(r instanceof re){let t=this.view.nodeDOM(r.from);const e=t.dataset.nodeViewWrapper?t:t.querySelector("[data-node-view-wrapper]");e&&(t=e),t&&(s={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(r instanceof ue){const{$anchorCell:t,$headCell:e}=r,n=t?t.pos:e.pos,i=e?e.pos:t.pos,o=this.view.nodeDOM(n),l=this.view.nodeDOM(i);if(!o||!l)return;const c=o===l?o.getBoundingClientRect():function(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-i;return new DOMRect(i,n,o,r-n)}(o.getBoundingClientRect(),l.getBoundingClientRect());s={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return s}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&a(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:e,strategy:n,middlewareData:r})=>{var i,o;this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected&&((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(o=r.hide)?void 0:o.escaped)?this.element.style.visibility="hidden":(this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${e}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()))})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r)return void this.handleDebouncedUpdate(t,e);const i=!(null==e?void 0:e.selection.eq(t.state.selection)),o=!(null==e?void 0:e.doc.eq(t.state.doc));this.updateHandler(t,i,o,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(t=>t.$from.pos)),s=Math.max(...i.map(t=>t.$to.pos));return(null==(e=this.shouldShow)?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:o,to:s}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(t=null!=e?e:this.view.dom.parentElement)||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(void 0!==t.updateDelay&&(this.updateDelay=t.updateDelay),void 0!==t.resizeDelay&&(this.resizeDelay=t.resizeDelay),void 0!==t.appendTo&&(this.appendTo=t.appendTo),void 0!==t.getReferencedVirtualElement&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),void 0!==t.shouldShow&&t.shouldShow&&(this.shouldShow=t.shouldShow),void 0!==t.options){const n=null!=(e=t.options.scrollTarget)?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},ye=t=>new ie({key:"string"==typeof t.pluginKey?new oe(t.pluginKey):t.pluginKey,view:e=>new me({view:e,...t})}),we=(qt.create({name:"bubbleMenu",addOptions:()=>({element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[ye({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}}),class{constructor({editor:t,element:e,view:n,pluginKey:r="floatingMenu",updateDelay:i=250,resizeDelay:o=60,options:s,appendTo:l,shouldShow:c}){var a;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:t,state:e})=>{const{selection:n}=e,{$anchor:r,empty:i}=n,o=1===r.depth,s=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&0===r.parent.childCount&&!this.getTextContent(r.parent);return!!(t.hasFocus()&&i&&o&&s&&this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(t,e,n,r)=>{const{composing:i}=t;i||!e&&!n||(this.getShouldShow(r)?(this.updatePosition(),this.show()):this.hide())},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:t})=>{var e;this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null==(e=this.element.parentNode)?void 0:e.contains(t.relatedTarget))||(null==t?void 0:t.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:t})=>{const e=t.getMeta(this.pluginKey);"updatePosition"===e?this.updatePosition():e&&"object"==typeof e&&"updateOptions"===e.type?this.updateOptions(e.options):"hide"===e?this.hide():"show"===e&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=o,this.appendTo=l,this.scrollTarget=null!=(a=null==s?void 0:s.scrollTarget)?a:window,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(t){return Xt(t,{textSerializers:Yt(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(l("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(g("boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(h("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(f(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(c("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(d("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(u("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(p("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,o=Math.min(...i.map(t=>t.$from.pos)),s=Math.max(...i.map(t=>t.$to.pos));return null==(e=this.shouldShow)?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:o,to:s})}updateOptions(t){var e;if(void 0!==t.updateDelay&&(this.updateDelay=t.updateDelay),void 0!==t.resizeDelay&&(this.resizeDelay=t.resizeDelay),void 0!==t.appendTo&&(this.appendTo=t.appendTo),void 0!==t.shouldShow&&t.shouldShow&&(this.shouldShow=t.shouldShow),void 0!==t.options){const n=null!=(e=t.options.scrollTarget)?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}updatePosition(){var t,e;if(!(null==(e=null==(t=this.view)?void 0:t.dom)?void 0:e.parentNode))return;const{selection:n}=this.editor.state,r=ne(this.view,n.from,n.to);a({getBoundingClientRect:()=>r,getClientRects:()=>[r]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:e,strategy:n,middlewareData:r})=>{var i,o;(null==(i=r.hide)?void 0:i.referenceHidden)||(null==(o=r.hide)?void 0:o.escaped)?this.element.style.visibility="hidden":(this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${e}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate())})}update(t,e){const n=!(null==e?void 0:e.selection.eq(t.state.selection)),r=!(null==e?void 0:e.doc.eq(t.state.doc));this.updateHandler(t,n,r,e)}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(t=null!=e?e:this.view.dom.parentElement)||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}}),xe=t=>new ie({key:"string"==typeof t.pluginKey?new oe(t.pluginKey):t.pluginKey,view:e=>new we({view:e,...t})});qt.create({name:"floatingMenu",addOptions:()=>({element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}),addCommands(){return{updateFloatingMenuPosition:()=>({tr:t,dispatch:e})=>(e&&t.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[xe({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function be(t,e){return null!=t?t:new oe(e)}var ve="undefined"!=typeof window?Ut:zt,ke=/* @__PURE__ */new Set(["left","opacity","position","top","visibility","width"]),Se=/* @__PURE__ */new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),Ce=/* @__PURE__ */new Set(["children","className","style"]),_e=/* @__PURE__ */new Set(["tabIndex"]),Ee=/* @__PURE__ */new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),Oe={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function Ae(t,e){return/^on[A-Z]/.test(t)&&"function"==typeof e}function De(t){return t.startsWith("--")?t:t.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Te(t){return _e.has(t)}function Ie(t,e,n){"tabIndex"!==e?t[e]=n:t.tabIndex=Number(n)}function Ne(t,e,n){ke.has(e)||t.style.setProperty(De(e),function(t,e){return"number"!=typeof e||0===e||t.startsWith("--")||Se.has(t)?String(e):`${e}px`}(e,n))}function Me(t,e,n){
|
|
2
2
|
/* @__PURE__ */new Set([...Object.keys(e),...Object.keys(n)]).forEach(r=>{if(Ce.has(r)||!function(t){return t.startsWith("aria-")||t.startsWith("data-")||Ee.has(t)}(r)||Ae(r,e[r])||Ae(r,n[r]))return;const i=e[r],o=n[r];if(i===o)return;const s=function(t){return t.startsWith("aria-")||t.startsWith("data-"),t}(r);return null==o||!1===o?(Te(r)&&function(t,e){if("tabIndex"===e)return void t.removeAttribute("tabindex");const n=t[e];t[e]="boolean"!=typeof n&&("number"!=typeof n?"":0)}(t,r),void t.removeAttribute(s)):!0===o?(Te(r)&&Ie(t,r,!0),void t.setAttribute(s,"")):void(Te(r)?Ie(t,r,o):t.setAttribute(s,String(o)))})}function Re(t,e,n){const r=null!=e?e:{},i=null!=n?n:{};
|
|
3
3
|
/* @__PURE__ */new Set([...Object.keys(r),...Object.keys(i)]).forEach(e=>{const n=r[e],o=i[e];n!==o&&(null!=o?Ne(t,e,o):function(t,e){ke.has(e)||t.style.removeProperty(De(e))}(t,e))})}function ze(t,e,n){e.forEach(({eventName:e,listener:n,options:r})=>{t.removeEventListener(e,n,r)});const r=[];return Object.entries(n).forEach(([e,n])=>{if(!Ae(e,n))return;const{eventName:i,options:o}=function(t){var e;const n=t.endsWith("Capture"),r=(n?t.slice(0,-7):t).slice(2);return{eventName:null!=(e=Oe[r])?e:r.toLowerCase(),options:n?{capture:!0}:void 0}}(e),s=e=>{n(function(t,e){let n=e.defaultPrevented,r=!1;const i=Object.create(e);return Object.defineProperties(i,{nativeEvent:{value:e},currentTarget:{value:t},target:{value:e.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,e.preventDefault()}},stopPropagation:{value:()=>{r=!0,e.stopPropagation()}}}),i}(t,e))};t.addEventListener(i,s,o),r.push({eventName:i,listener:s,options:o})}),r}function Ue(t,e){const n=Lt({}),r=Lt([]);ve(()=>{const i=n.current;return function(t,e,n){e!==n&&(n?t.className=n:t.removeAttribute("class"))}(t,i.className,e.className),Re(t,i.style,e.style),Me(t,i,e),r.current=ze(t,r.current,e),n.current=e,()=>{r.current.forEach(({eventName:e,listener:n,options:r})=>{t.removeEventListener(e,n,r)}),r.current=[]}},[t,e])}var Pe=Nt.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:o=null,getReferencedVirtualElement:s,options:l,children:c,...a},h)=>{const d=Lt(document.createElement("div")),u=Lt(be(t,"bubbleMenu")).current;Ue(d.current,a),"function"==typeof h?h(d.current):h&&(h.current=d.current);const{editor:p}=It(),f=e||p,g={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:u,shouldShow:o,getReferencedVirtualElement:s,options:l},m=Lt(g);m.current=g;const[y,w]=$t(!1),x=Lt(!0);return zt(()=>{if(null==f?void 0:f.isDestroyed)return;if(!f)return;const t=d.current;t.style.visibility="hidden",t.style.position="absolute";const e=ye({...m.current,editor:f,element:t});f.registerPlugin(e);const n=m.current.pluginKey;return x.current=!0,w(!0),()=>{w(!1),f.unregisterPlugin(n),window.requestAnimationFrame(()=>{t.parentNode&&t.parentNode.removeChild(t)})}},[f]),zt(()=>{y&&f&&!f.isDestroyed&&(x.current?x.current=!1:f.view.dispatch(f.state.tr.setMeta(u,{type:"updateOptions",options:m.current})))},[y,f,n,r,o,l,i,s,u]),Kt(c,d.current)});Nt.forwardRef(({pluginKey:t,editor:e,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:o=null,options:s,children:l,...c},a)=>{const h=Lt(document.createElement("div")),d=Lt(be(t,"floatingMenu")).current;Ue(h.current,c),"function"==typeof a?a(h.current):a&&(a.current=h.current);const{editor:u}=It(),p=e||u,f={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:o,options:s},g=Lt(f);g.current=f;const[m,y]=$t(!1),w=Lt(!0);return zt(()=>{if(null==p?void 0:p.isDestroyed)return;if(!p)return;const t=h.current;t.style.visibility="hidden",t.style.position="absolute";const e=xe({...g.current,editor:p,element:t});p.registerPlugin(e);const n=g.current.pluginKey;return w.current=!0,y(!0),()=>{y(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{t.parentNode&&t.parentNode.removeChild(t)})}},[p]),zt(()=>{m&&p&&!p.isDestroyed&&(w.current?w.current=!1:p.view.dispatch(p.state.tr.setMeta(d,{type:"updateOptions",options:g.current})))},[m,p,n,r,o,s,i,d]),Kt(l,h.current)});function Le(t,e){const{state:n}=e,r=n.selection.$anchor;let i=!1;if(r.depth)for(let o=r.depth;o>0;o--)r.node(o).type.name===t&&(e.dispatchTransaction&&e.dispatchTransaction(n.tr.delete(r.before(o),r.after(o)).scrollIntoView()),i=!0);else{const r=n.selection.node;r&&r.type.name===t&&(e.chain().deleteSelection().run(),i=!0)}if(!i){const o=r.pos;if(o){const r=n.tr.doc.nodeAt(o);r&&r.type.name===t&&(e.dispatchTransaction&&e.dispatchTransaction(n.tr.delete(o,o+r.nodeSize)),i=!0)}}return i}var $e=[{value:"note",label:"Note",icon:"Info"},{value:"tip",label:"Tip",icon:"Lightbulb"},{value:"important",label:"Important",icon:"AlertCircle"},{value:"warning",label:"Warning",icon:"TriangleAlert"},{value:"caution",label:"Caution",icon:"OctagonAlert"}];function je(){const e=K(),n=W(),{t:i}=r(),{type:o,title:l,body:c}=ft(n,H.name,{type:"note",title:"",body:""}),[a,h]=$t(!1),[d,u]=$t("note"),[p,f]=$t(""),[g,y]=$t("");zt(()=>{a&&(u(o||"note"),f(l||""),y(c||""))},[a,o,l,c]);const k=Rt(()=>{n&&(n.chain().updateAttributes(H.name,{type:d,title:p,body:g}).focus().run(),h(!1))},[n,d,p,g]),S=Rt(()=>{h(!1)},[]),C=Rt(()=>{Le(H.name,n)},[n]),_=Rt(()=>n.isActive(H.name),[n]);return e?/* @__PURE__ */Ht(Pe,{editor:n,options:{placement:"top",offset:8,flip:!0},pluginKey:"RichTextBubbleCallout",shouldShow:_,children:/* @__PURE__ */Bt("div",{className:"richtext-flex richtext-items-center richtext-gap-2 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",children:[/* @__PURE__ */Bt(v,{onOpenChange:h,open:a,children:[/* @__PURE__ */Ht(x,{asChild:!0,children:/* @__PURE__ */Ht(t,{icon:"Pencil",tooltip:i("editor.callout.edit.title")})}),/* @__PURE__ */Bt(w,{children:[
|
|
4
4
|
/* @__PURE__ */Ht(m,{children:i("editor.callout.edit.title")}),
|