reactjs-tiptap-editor 1.0.23 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{ActionMenuButton-Da0H9Beu.cjs → ActionMenuButton-B8NhVw5m.cjs} +1 -1
- package/lib/{ActionMenuButton-C53IYt_R.js → ActionMenuButton-HYlhmRvw.js} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +3 -3
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.js +2 -2
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +2 -2
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +2 -2
- package/lib/{Callout-CdXbDkZ6.cjs → Callout-B-S2f0Qo.cjs} +1 -1
- package/lib/{Callout-igc-a1lj.js → Callout-CF7Y9yJ7.js} +3 -3
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +4 -4
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +6 -6
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +27 -27
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +3 -3
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +7 -7
- package/lib/{Drawer-DzroBQds.js → Drawer-CaXVhxo4.js} +20 -20
- package/lib/{Drawer-CrMuQNbZ.cjs → Drawer-Was4hxYH.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +4311 -1859
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +3 -3
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +4 -4
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +4 -4
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +4 -4
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +69 -46
- package/lib/History.cjs +1 -1
- package/lib/History.js +556 -418
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +2 -2
- package/lib/{Iframe-DVLx3H0m.cjs → Iframe-BI0sq6pd.cjs} +1 -1
- package/lib/{Iframe-Dt2Styg8.js → Iframe-Bp986fj0.js} +3 -3
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +3 -3
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +4 -4
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +2 -2
- package/lib/{Indent-BCZFJKcN.js → Indent-E6B8DkyN.js} +4 -4
- package/lib/{Indent-CQCn1r9U.cjs → Indent-FvM52kjA.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +2 -2
- package/lib/{Katex-By61XteD.cjs → Katex-DP6EjdKz.cjs} +1 -1
- package/lib/{Katex--VT0zcjU.js → Katex-pzwyyiFJ.js} +4 -4
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +3 -3
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +3 -3
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/LinkEditBlock-Cmkmp2fW.cjs +5 -0
- package/lib/{LinkEditBlock-C_F9zWEj.js → LinkEditBlock-OjN4F2rM.js} +222 -224
- package/lib/MarkdownPaste.cjs +1 -1
- package/lib/MarkdownPaste.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +8 -8
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +27 -27
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +3 -3
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +2 -2
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +3 -3
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/{SlashCommandNodeView-Aqc77oRC.cjs → SlashCommandNodeView-DarAytvt.cjs} +1 -1
- package/lib/{SlashCommandNodeView-DxlBPKPV.js → SlashCommandNodeView-o323V8li.js} +1 -1
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +2 -2
- package/lib/Table-CC9uNHPL.js +1984 -0
- package/lib/Table-Clnz-i4l.cjs +9 -0
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +3 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +3 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +2 -2
- package/lib/{Twitter-f-oMDZuV.cjs → Twitter-0kmrijjL.cjs} +1 -1
- package/lib/{Twitter-DP_9V0zb.js → Twitter-BVnXL8we.js} +4 -4
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +2 -2
- package/lib/bubble.cjs +6 -6
- package/lib/bubble.js +1573 -1561
- package/lib/{clsx-Bg-2aTKh.js → clsx-0OU6n9va.js} +379 -353
- package/lib/clsx-D6gYQn3o.cjs +33 -0
- package/lib/{dropdown-menu-DeBV2h9-.cjs → dropdown-menu-BIGvxqiu.cjs} +1 -1
- package/lib/{dropdown-menu-uIj8M0jD.js → dropdown-menu-BW2M6saA.js} +1 -1
- package/lib/index-BAb_UADw.cjs +1 -0
- package/lib/index-BF3EVCB1.cjs +2 -0
- package/lib/{index-D0EmqTpe.js → index-BblvcbTH.js} +1130 -1064
- package/lib/index-Bcj8cyOO.cjs +24 -0
- package/lib/{index-BVtsbzV8.js → index-BrsJsbds.js} +2 -2
- package/lib/index-CGjT-a9h.js +1377 -0
- package/lib/index-CPTpXLfX.cjs +11 -0
- package/lib/{index-C3dgmjIF.cjs → index-CUvjYuRp.cjs} +1 -1
- package/lib/{index-DXtVL0al.js → index-Cal5SPfB.js} +189 -134
- package/lib/{index-CjLxMm5d.js → index-D-Ouz0vF.js} +1 -1
- package/lib/{index-ezTXvA7H.cjs → index-deubsx3z.cjs} +1 -1
- package/lib/{index-CbkpBnTX.js → index-zw-Kd38i.js} +47 -50
- package/lib/index.cjs +1 -1
- package/lib/index.js +2 -2
- package/lib/{popover-mlZeH-7I.js → popover-BIVHT1W9.js} +1 -1
- package/lib/{popover-Cq1iLY7i.cjs → popover-DoSfJsFS.cjs} +1 -1
- package/lib/{renderNodeView-CbxCTni3.js → renderNodeView-CfWJK4rG.js} +2 -2
- package/lib/{renderNodeView-DFVrJy0l.cjs → renderNodeView-D--fDFov.cjs} +1 -1
- package/lib/{separator-DvAvl5_5.cjs → separator-SRbPfmGa.cjs} +1 -1
- package/lib/{separator-Bh_ttGZg.js → separator-b-qOPJmp.js} +2 -2
- package/lib/{textarea-MU5imD7D.js → textarea-CpxXPky_.js} +1 -1
- package/lib/{textarea-CKXzGwId.cjs → textarea-DbGw9oCU.cjs} +1 -1
- package/lib/updatePosition-BwzAsiY0.js +16 -0
- package/lib/{updatePosition-CQE1ct18.cjs → updatePosition-DGPtRfWN.cjs} +1 -1
- package/package.json +60 -60
- package/lib/LinkEditBlock-BLkA2CYZ.cjs +0 -5
- package/lib/Table-DqXkwJAY.cjs +0 -9
- package/lib/Table-r09L4PvT.js +0 -1945
- package/lib/clsx-DSAWW32g.cjs +0 -33
- package/lib/index-C4WLt4NA.cjs +0 -24
- package/lib/index-DlxZt4_j.cjs +0 -1
- package/lib/index-P5_MyY0i.js +0 -1362
- package/lib/index-TcJ2UKnv.cjs +0 -1
- package/lib/index-fbGGohBT.cjs +0 -12
- package/lib/updatePosition-BGD41Hbg.js +0 -16
package/lib/Excalidraw.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var z=Object.create;var M=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var U=(e,s,i,d)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of V(s))!$.call(e,o)&&o!==i&&M(e,o,{get:()=>s[o],enumerable:!(d=P(s,o))||d.enumerable});return e};var R=(e,s,i)=>(i=e!=null?z(B(e)):{},U(s||!e||!e.__esModule?M(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./index-
|
|
1
|
+
"use strict";var z=Object.create;var M=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var U=(e,s,i,d)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of V(s))!$.call(e,o)&&o!==i&&M(e,o,{get:()=>s[o],enumerable:!(d=P(s,o))||d.enumerable});return e};var R=(e,s,i)=>(i=e!=null?z(B(e)):{},U(s||!e||!e.__esModule?M(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./index-Bcj8cyOO.cjs"),y=require("./clsx-D6gYQn3o.cjs"),t=require("react/jsx-runtime"),F=require("re-resizable"),r=require("react"),a=require("./index-deubsx3z.cjs"),v=require("./dom-dataset-BqoJhJXt.cjs"),X="_wrap_dra8y_1",Y="_renderWrap_dra8y_7",G="_handlerWrap_dra8y_30",J="_disabled_dra8y_40",T={wrap:X,renderWrap:Y,handlerWrap:G,disabled:J},K=10,Q=200,O=15,W={width:"100%",height:"100%",maxWidth:"100%"};function ee({editor:e,node:s,updateAttributes:i}){const d=r.useRef(null),o=a.useEditableEditor(),x=e.isActive(_.name),{data:p,width:c,height:A}=s.attrs,[m,I]=r.useState(null),[b,D]=r.useState(!0),[u,g]=r.useState(null),[E,S]=r.useState(100),f=r.useCallback(n=>()=>{S(h=>a.clamp(n==="minus"?h-O:h+O,K,Q))},[]);r.useEffect(()=>{let n=!1;return import("@excalidraw/excalidraw").then(h=>{n||(d.current=h.exportToSvg)}).catch(h=>!n&&g(h)).finally(()=>!n&&D(!1)),()=>{n=!0}},[p]),r.useEffect(()=>{let n=!1;return(async()=>{if(!d.current||n||b||u||!p)return;const w=await d.current(p);n||(w.setAttribute("width","100%"),w.setAttribute("height","100%"),w.setAttribute("display","block"),I(w))})(),()=>{n=!0}},[p,b,u]);const L=n=>{i({width:n.width,height:n.height})};return t.jsx(y.NodeViewWrapper,{className:y.clsx(T.wrap,{[T.active]:x,[T.disabled]:!o}),children:t.jsx(F.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(A)},onResizeStop:(n,h,w,j)=>{L({width:Number.parseInt(c)+j.width,height:Number.parseInt(A)+j.height})},children:t.jsxs("div",{className:y.clsx(T.renderWrap,"render-wrapper"),style:{...W,overflow:"hidden"},children:[u&&t.jsx("div",{style:W,children:t.jsx("p",{children:u.message||u})}),b&&t.jsx("p",{children:"Loading..."}),!b&&!u&&m&&t.jsx("div",{dangerouslySetInnerHTML:{__html:(m==null?void 0:m.outerHTML)??""},style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${E/100})`,transition:"all ease-in-out .3s"}}),t.jsxs("div",{className:T.handlerWrap,children:[t.jsx(a.ActionButton,{action:f("minus"),disabled:!o,icon:"ZoomOut",tooltip:"Zoom Out"}),t.jsx(a.ActionButton,{action:f("plus"),disabled:!o,icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})}function te(){const e=a.useEditorInstance(),s=a.useButtonProps(_.name),i=a.useExtension(_.name),{tooltipOptions:d={},isActive:o=void 0}=(s==null?void 0:s.componentProps)??{},{editorDisabled:x}=a.useToggleActive(o),p=r.useMemo(()=>(i==null?void 0:i.options)||{},[i]),[c,A]=r.useState(null),[m,I]=r.useState({}),[b,D]=r.useState({elements:[],appState:{isLoading:!1},files:null}),[u,g]=r.useState(!1),[E,S]=r.useState(!0),[f,L]=r.useState(null),n=r.useCallback(l=>{l&&import("@excalidraw/excalidraw").then(C=>{A(C.Excalidraw)}).catch(L).finally(()=>S(!1))},[S]),h=r.useCallback(l=>{setTimeout(()=>{l.refresh()})},[]),w=r.useCallback((l,C,q)=>{I({elements:l,appState:{isLoading:!1},files:q})},[]),j=r.useCallback(()=>{if(!c){g(!1);return}e.chain().focus().setExcalidraw({data:m}).run(),g(!1)},[c,e,m,g]),k=l=>{g(!0),l!=null&&l.data&&D(l==null?void 0:l.data)},Z=a.EVENTS.EXCALIDRAW(e.id);return a.useListener(k,[Z]),r.useEffect(()=>{!E&&c&&u&&setTimeout(()=>{window.dispatchEvent(new Event("resize"))},400)},[E,c,u]),t.jsxs(a.Dialog,{onOpenChange:g,open:u,children:[t.jsx(a.DialogTrigger,{asChild:!0,children:t.jsx(a.ActionButton,{disabled:x,icon:"Excalidraw",tooltip:"Excalidraw",tooltipOptions:d,action:()=>{x||g(!0)}})}),t.jsxs(a.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[t.jsx(a.DialogTitle,{children:"Excalidraw"}),t.jsxs("div",{style:{height:"100%",borderWidth:1},children:[E&&t.jsx("p",{children:"Loading..."}),f&&t.jsx("p",{children:f&&f.message||"Error"}),t.jsx("div",{ref:n,style:{width:"100%",height:600},children:!E&&!f&&c?t.jsx(c,{initialData:b,langCode:"en",onChange:w,ref:h,...p.excalidrawProps}):null})]}),t.jsx(a.DialogFooter,{children:t.jsx(a.Button,{disabled:!c,onClick:j,type:"button",children:"Save changes"})})]})]})}const H={elements:[]},_=N.Node3.create({name:"excalidraw",group:"block",selectable:!0,atom:!0,draggable:!0,inline:!1,addAttributes(){return{defaultShowPicker:{default:!1},createUser:{default:null},width:{default:"100%",parseHTML:v.getDatasetAttribute("width")},height:{default:240,parseHTML:v.getDatasetAttribute("height")},data:{default:H,parseHTML:v.getDatasetAttribute("data",!0)}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"excalidraw"},excalidrawProps:{},button:()=>({componentProps:{}})}},parseHTML(){return[{tag:"div[class=excalidraw]"}]},renderHTML({HTMLAttributes:e,node:s}){return["div",N.mergeAttributes(this.options.HTMLAttributes,e,v.nodeAttrsToDataset(s))]},addCommands(){return{setExcalidraw:e=>({tr:s,commands:i,chain:d})=>{var o,x,p;return e=e||{},e.data=e.data||H,((p=(x=(o=s.selection)==null?void 0:o.node)==null?void 0:x.type)==null?void 0:p.name)==this.name?i.updateAttributes(this.name,e):d().insertContent({type:this.name,attrs:e}).run()}}},addNodeView(){return y.ReactNodeViewRenderer(ee)},addInputRules(){return[N.nodeInputRule({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});exports.Excalidraw=_;exports.RichTextExcalidraw=te;
|
package/lib/Excalidraw.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { N as k, n as $, m as B } from "./index-
|
|
2
|
-
import { N as U, c as R, a as j } from "./clsx-
|
|
1
|
+
import { N as k, n as $, m as B } from "./index-BblvcbTH.js";
|
|
2
|
+
import { N as U, c as R, a as j } from "./clsx-0OU6n9va.js";
|
|
3
3
|
import { jsx as t, jsxs as T } from "react/jsx-runtime";
|
|
4
4
|
import { Resizable as F } from "re-resizable";
|
|
5
5
|
import { useRef as X, useState as o, useCallback as v, useEffect as M, useMemo as q } from "react";
|
|
6
|
-
import { F as G, q as Y, A as S, h as J, u as K, m as Q, d as ee, E as te, G as re, D as ae, r as ne, s as ie, v as se, w as oe, B as le } from "./index-
|
|
6
|
+
import { F as G, q as Y, A as S, h as J, u as K, m as Q, d as ee, E as te, G as re, D as ae, r as ne, s as ie, v as se, w as oe, B as le } from "./index-BrsJsbds.js";
|
|
7
7
|
import { n as de, g as D } from "./dom-dataset-CIEeltF6.js";
|
|
8
8
|
const ce = "_wrap_dra8y_1", ue = "_renderWrap_dra8y_7", he = "_handlerWrap_dra8y_30", pe = "_disabled_dra8y_40", x = {
|
|
9
9
|
wrap: ce,
|
package/lib/ExportPdf.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-Bcj8cyOO.cjs"),l=require("react/jsx-runtime"),m=require("./index-deubsx3z.cjs");require("react");require("./theme.cjs");function y(e,n){var u;const t=document.createElement("iframe");t.setAttribute("style","position: absolute; width: 0; height: 0; top: 0; left: 0;"),document.body.appendChild(t);const o=t.contentDocument||((u=t.contentWindow)==null?void 0:u.document);if(!o)return;const{paperSize:d,title:i="React Tiptap Editor",margins:{top:s,right:a,bottom:r,left:c}}=n,p=`
|
|
2
2
|
<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
package/lib/ExportPdf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as b } from "./index-
|
|
1
|
+
import { E as b } from "./index-BblvcbTH.js";
|
|
2
2
|
import { jsx as f, Fragment as v } from "react/jsx-runtime";
|
|
3
|
-
import { u as y, d as x, A as E } from "./index-
|
|
3
|
+
import { u as y, d as x, A as E } from "./index-BrsJsbds.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "./theme.js";
|
|
6
6
|
function P(o, i) {
|
package/lib/ExportWord.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-Bcj8cyOO.cjs"),u=require("docx"),n=require("prosemirror-docx"),i=require("react/jsx-runtime"),y=require("react"),a=require("./index-deubsx3z.cjs");require("./theme.cjs");const g=typeof window<"u";function v(o,e){if(g){const r=window.URL.createObjectURL(o),t=document.createElement("a");return t.href=r,t.download=e,t.click(),window.URL.revokeObjectURL(r),Promise.resolve()}return console.error("Download is not supported in Node.js"),Promise.resolve()}function B(){const o=a.useButtonProps(p.name),[e,r]=y.useState(!1),{icon:t=void 0,tooltip:c=void 0,shortcutKeys:s=void 0,tooltipOptions:f={},action:d=void 0,isActive:m=void 0}=(o==null?void 0:o.componentProps)??{},{dataState:x,disabled:l,update:w}=a.useToggleActive(m),b=async()=>{l||e||d&&(r(!0),await d(),w(),r(!1))};return o?i.jsx(a.ActionButton,{action:b,dataState:x,disabled:l||e,icon:e?"Loader":t,shortcutKeys:s,tooltip:c,tooltipOptions:f}):i.jsx(i.Fragment,{})}const E={...n.defaultNodes,hardBreak:n.defaultNodes.hard_break,codeBlock:n.defaultNodes.code_block,orderedList:n.defaultNodes.ordered_list,listItem:n.defaultNodes.list_item,bulletList:n.defaultNodes.bullet_list,horizontalRule:n.defaultNodes.horizontal_rule,image(o,e){o.renderInline(e),o.closeBlock(e)},table(o,e){o.table(e,{tableOptions:{width:{size:100,type:u.WidthType.PERCENTAGE}}})}},W=new n.DocxSerializer(E,n.defaultMarks),p=h.Extension.create({name:"exportWord",addOptions(){var o;return{...(o=this.parent)==null?void 0:o.call(this),button:({editor:e,t:r})=>({componentProps:{icon:"ExportWord",action:()=>{var t;return e==null?void 0:e.commands.exportToWord((t=e==null?void 0:e.state)==null?void 0:t.doc)},tooltip:r("editor.exportWord.tooltip"),isActive:()=>!1,disabled:!1}})}},addCommands(){return{exportToWord:o=>async()=>{try{const e={getImageBuffer:async t=>{const s=await(await fetch(t)).arrayBuffer();return new Uint8Array(s)}},r=W.serialize(o,e);return u.Packer.toBlob(r).then(t=>v(new Blob([t]),"richtext-export-document.docx")),!0}catch(e){return console.error("Error exporting to Word:",e),!1}}}}});exports.ExportWord=p;exports.RichTextExportWord=B;
|
package/lib/ExportWord.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as w } from "./index-
|
|
1
|
+
import { E as w } from "./index-BblvcbTH.js";
|
|
2
2
|
import { Packer as x, WidthType as b } from "docx";
|
|
3
3
|
import { defaultNodes as n, DocxSerializer as h, defaultMarks as B } from "prosemirror-docx";
|
|
4
4
|
import { jsx as d, Fragment as v } from "react/jsx-runtime";
|
|
5
5
|
import { useState as y } from "react";
|
|
6
|
-
import { u as E, d as g, A as k } from "./index-
|
|
6
|
+
import { u as E, d as g, A as k } from "./index-BrsJsbds.js";
|
|
7
7
|
import "./theme.js";
|
|
8
8
|
const W = typeof window < "u";
|
|
9
9
|
function A(e, o) {
|
package/lib/FontFamily.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-BAb_UADw.cjs"),F=require("./index-CWw4s87s.cjs"),f=require("./index-deubsx3z.cjs"),e=require("react/jsx-runtime"),m=require("react"),x=require("./ActionMenuButton-B8NhVw5m.cjs");require("./theme.cjs");const d=require("./dropdown-menu-BIGvxqiu.cjs");function M(){const{t:l}=F.useLocale(),o=f.useButtonProps(p.name),{icon:a=void 0,tooltip:u=void 0,items:r=[],isActive:s=void 0}=(o==null?void 0:o.componentProps)??{},{disabled:c,dataState:t}=f.useActive(s),n=m.useMemo(()=>(t==null?void 0:t.font)||l("editor.fontFamily.default.tooltip"),[t]);return o?e.jsxs(d.DropdownMenu,{children:[e.jsx(d.DropdownMenuTrigger,{asChild:!0,disabled:c,children:e.jsx(x.ActionMenuButton,{disabled:c,icon:a,title:(n==null?void 0:n.length)>12?`${n==null?void 0:n.slice(0,12)}...`:n,tooltip:u})}),e.jsx(d.DropdownMenuContent,{className:"richtext-w-full",children:r==null?void 0:r.map((i,y)=>{const h=i.font===l("editor.fontFamily.default.tooltip")?{}:{fontFamily:i.font};return e.jsxs(m.Fragment,{children:[e.jsx(d.DropdownMenuCheckboxItem,{checked:n===i.font,onClick:i.action,children:e.jsx("div",{className:"richtext-ml-1 richtext-h-full",style:h,children:i.font})}),i.font===l("editor.fontFamily.default.tooltip")&&e.jsx(d.DropdownMenuSeparator,{})]},`font-family-${y}`)})})]}):e.jsx(e.Fragment,{})}const p=v.FontFamily.extend({addOptions(){var l;return{...(l=this.parent)==null?void 0:l.call(this),fontFamilyList:F.DEFAULT_FONT_FAMILY_LIST,button({editor:o,extension:a,t:u}){var c;const r=f.ensureNameValueOptions(((c=a==null?void 0:a.options)==null?void 0:c.fontFamilyList)||[]),s=r.map(t=>({action:()=>{if(t.value==="Default"){o.chain().focus().unsetFontFamily().run();return}o.chain().focus().setFontFamily(t.value).run()},isActive:()=>o.isActive("textStyle",{fontFamily:t.value})||!1,title:t.name,font:t.value,default:t.value==="Default"}));return{componentProps:{tooltip:u("editor.fontFamily.tooltip"),disabled:!1,items:s,isActive:()=>{const t=s==null?void 0:s.find(i=>i.isActive());return t&&!t.default?t:{title:u("editor.fontFamily.default.tooltip"),font:u("editor.fontFamily.default.tooltip"),isActive:()=>!1,disabled:!1}},icon:"MenuDown",fontFamilyList:r}}}}}});exports.FontFamily=p;exports.RichTextFontFamily=M;
|
package/lib/FontFamily.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { F as p } from "./index-
|
|
1
|
+
import { F as p } from "./index-zw-Kd38i.js";
|
|
2
2
|
import { u as F, D as y } from "./index-oj858lQO.js";
|
|
3
|
-
import { u as h, e as v, f as A } from "./index-
|
|
3
|
+
import { u as h, e as v, f as A } from "./index-BrsJsbds.js";
|
|
4
4
|
import { jsx as i, Fragment as D, jsxs as f } from "react/jsx-runtime";
|
|
5
5
|
import { useMemo as M, Fragment as w } from "react";
|
|
6
|
-
import { A as L } from "./ActionMenuButton-
|
|
6
|
+
import { A as L } from "./ActionMenuButton-HYlhmRvw.js";
|
|
7
7
|
import "./theme.js";
|
|
8
|
-
import { D as g, a as x, b, c as T, d as C } from "./dropdown-menu-
|
|
8
|
+
import { D as g, a as x, b, c as T, d as C } from "./dropdown-menu-BW2M6saA.js";
|
|
9
9
|
function S() {
|
|
10
10
|
const { t: a } = F(), n = h(N.name), {
|
|
11
11
|
icon: s = void 0,
|
package/lib/FontSize.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index-Bcj8cyOO.cjs"),x=require("./index-CWw4s87s.cjs"),S=require("./index-deubsx3z.cjs"),o=require("react/jsx-runtime"),p=require("react"),h=require("./ActionMenuButton-B8NhVw5m.cjs");require("./theme.cjs");const l=require("./dropdown-menu-BIGvxqiu.cjs");function v(){const{t}=x.useLocale(),n=S.useButtonProps(z.name),{icon:d=void 0,tooltip:s=void 0,items:c=[],isActive:a=void 0}=(n==null?void 0:n.componentProps)??{},{disabled:u,dataState:e}=S.useActive(a),r=p.useMemo(()=>(e==null?void 0:e.title)||t("editor.fontSize.default.tooltip"),[e]);return n?o.jsxs(l.DropdownMenu,{children:[o.jsx(l.DropdownMenuTrigger,{asChild:!0,disabled:u,children:o.jsx(h.ActionMenuButton,{disabled:u,icon:d,title:r,tooltip:s})}),o.jsx(l.DropdownMenuContent,{className:"richtext-max-h-96 richtext-w-32 richtext-overflow-y-auto",children:c==null?void 0:c.map((i,f)=>o.jsxs(p.Fragment,{children:[o.jsx(l.DropdownMenuCheckboxItem,{checked:r===i.title,onClick:i.action,children:o.jsx("div",{className:"richtext-ml-1 richtext-h-full",children:i.title})}),i.title===t("editor.fontSize.default.tooltip")&&o.jsx(l.DropdownMenuSeparator,{})]},`font-size-${f}`))})]}):o.jsx(o.Fragment,{})}const z=m.Extension.create({name:"fontSize",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),types:["textStyle"],fontSizes:x.DEFAULT_FONT_SIZE_LIST,button({editor:n,extension:d,t:s}){var u;const a=S.ensureNameValueOptions((u=d.options)==null?void 0:u.fontSizes).map(e=>({title:e.value==="Default"?s("editor.fontSize.default.tooltip"):String(e.name),isActive:()=>{const{fontSize:r}=n.getAttributes("textStyle"),i=e.value==="Default",f=r==null||r==="";return i&&f?!0:n.isActive({fontSize:String(e.value)})||!1},action:()=>{if(e.value==="Default"){n.commands.unsetFontSize();return}n.commands.setFontSize(String(e.value))},default:e.value==="Default"||!1}));return{componentProps:{editor:n,tooltip:s("editor.fontSize.tooltip"),disabled:!1,items:a,maxHeight:280,icon:"MenuDown",isActive:()=>{const e=(a||[]).find(i=>i.isActive());return e&&!e.default?e:{title:s("editor.fontSize.default.tooltip"),isActive:()=>!1}}}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize.replaceAll(/["']+/g,""),renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:n})=>n().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}});exports.FontSize=z;exports.RichTextFontSize=v;
|
package/lib/FontSize.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { E as m } from "./index-
|
|
1
|
+
import { E as m } from "./index-BblvcbTH.js";
|
|
2
2
|
import { u as p, h as S } from "./index-oj858lQO.js";
|
|
3
|
-
import { u as z, e as h, f as v } from "./index-
|
|
3
|
+
import { u as z, e as h, f as v } from "./index-BrsJsbds.js";
|
|
4
4
|
import { jsx as r, Fragment as x, jsxs as d } from "react/jsx-runtime";
|
|
5
5
|
import { useMemo as A, Fragment as D } from "react";
|
|
6
|
-
import { A as y } from "./ActionMenuButton-
|
|
6
|
+
import { A as y } from "./ActionMenuButton-HYlhmRvw.js";
|
|
7
7
|
import "./theme.js";
|
|
8
|
-
import { D as F, a as M, b as g, c as w, d as T } from "./dropdown-menu-
|
|
8
|
+
import { D as F, a as M, b as g, c as w, d as T } from "./dropdown-menu-BW2M6saA.js";
|
|
9
9
|
function $() {
|
|
10
10
|
const { t: e } = p(), n = z(b.name), {
|
|
11
11
|
icon: f = void 0,
|
package/lib/Heading.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index-Bcj8cyOO.cjs"),M=require("./index-CWw4s87s.cjs"),s=require("react/jsx-runtime"),x=require("react"),b=require("./ActionMenuButton-B8NhVw5m.cjs"),v=require("./index-deubsx3z.cjs");require("./theme.cjs");const h=require("./dropdown-menu-BIGvxqiu.cjs");var j=f.Node3.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,f.mergeAttributes(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var l;const i=(l=e.attrs)!=null&&l.level?parseInt(e.attrs.level,10):1,a="#".repeat(i);return e.content?`${a} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>f.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});function m(){const{t:e}=M.useLocale(),t=v.useButtonProps(A.name),{icon:l=void 0,tooltip:i=void 0,isActive:a=void 0,items:o=[]}=(t==null?void 0:t.componentProps)??{},{disabled:p,dataState:d}=v.useActive(a),r=x.useMemo(()=>(d==null?void 0:d.title)||e("editor.paragraph.tooltip"),[d]);return t?s.jsxs(h.DropdownMenu,{children:[s.jsx(h.DropdownMenuTrigger,{asChild:!0,disabled:p,children:s.jsx(b.ActionMenuButton,{disabled:p,icon:l,title:r,tooltip:i})}),s.jsx(h.DropdownMenuContent,{className:"richtext-w-full",children:o==null?void 0:o.map((n,c)=>{var u,g;return s.jsxs(x.Fragment,{children:[s.jsxs(h.DropdownMenuCheckboxItem,{checked:r===n.title,onClick:n.action,children:[s.jsx("div",{className:v.cn("richtext-ml-1 richtext-h-full",{"":n.level==="Paragraph","heading-1":n.level===1,"heading-2":n.level===2,"heading-3":n.level===3,"heading-4":n.level===4,"heading-5":n.level===5,"heading-6":n.level===6}),children:n.title}),!!((u=n==null?void 0:n.shortcutKeys)!=null&&u.length)&&s.jsx(h.DropdownMenuShortcut,{className:"richtext-pl-4",children:(g=n==null?void 0:n.shortcutKeys)==null?void 0:g.map(H=>v.getShortcutKey(H)).join(" ")})]}),n.level==="Paragraph"&&s.jsx(h.DropdownMenuSeparator,{})]},`heading-k-${c}`)})})]}):s.jsx(s.Fragment,{})}const A=j.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),levels:M.HEADINGS,button({editor:t,extension:l,t:i}){var d;const a=((d=l.options)==null?void 0:d.levels)||[],o=a.map(r=>{var c;const n=r==="Paragraph";return{action:()=>{if(n){const u=a.find(g=>t.isActive("heading",{level:g}));u&&u!=="Paragraph"&&t.commands.toggleHeading({level:u});return}t.commands.toggleHeading({level:r})},isActive:()=>n?!1:t.isActive("heading",{level:r})||!1,disabled:!t.can().toggleHeading({level:r}),title:i(n?"editor.paragraph.tooltip":`editor.heading.h${r}.tooltip`),level:r,shortcutKeys:((c=l.options.shortcutKeys)==null?void 0:c[r])??["alt","mod",`${r}`],default:n}}),p=o.filter(r=>r.disabled).length===o.length;return{componentProps:{tooltip:i("editor.heading.tooltip"),disabled:p,items:o,icon:"MenuDown",isActive:()=>{const r=o==null?void 0:o.find(c=>c.isActive());return r&&!r.default?r:{title:i("editor.paragraph.tooltip"),level:0,isActive:()=>!1}},levels:a}}}}}});exports.Heading=A;exports.RichTextHeading=m;
|
package/lib/Heading.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { N as f, t as m, m as A } from "./index-
|
|
1
|
+
import { N as f, t as m, m as A } from "./index-BblvcbTH.js";
|
|
2
2
|
import { u as M, H } from "./index-oj858lQO.js";
|
|
3
3
|
import { jsx as d, Fragment as $, jsxs as g } from "react/jsx-runtime";
|
|
4
4
|
import { useMemo as b, Fragment as w } from "react";
|
|
5
|
-
import { A as x } from "./ActionMenuButton-
|
|
6
|
-
import { u as D, e as y, c as N, l as k } from "./index-
|
|
5
|
+
import { A as x } from "./ActionMenuButton-HYlhmRvw.js";
|
|
6
|
+
import { u as D, e as y, c as N, l as k } from "./index-BrsJsbds.js";
|
|
7
7
|
import "./theme.js";
|
|
8
|
-
import { D as L, a as C, b as T, c as I, e as K, d as P } from "./dropdown-menu-
|
|
8
|
+
import { D as L, a as C, b as T, c as I, e as K, d as P } from "./dropdown-menu-BW2M6saA.js";
|
|
9
9
|
var R = f.create({
|
|
10
10
|
name: "heading",
|
|
11
11
|
addOptions() {
|
package/lib/Highlight.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-Bcj8cyOO.cjs"),r=require("react/jsx-runtime"),x=require("react"),h=require("./index-deubsx3z.cjs"),C=require("./separator-SRbPfmGa.cjs");require("./theme.cjs");var m=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,L=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,k=l.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||l.getStyleProperty(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",l.mergeAttributes(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,s){const i=/^(==)([^=]+)(==)/.exec(t);if(i){const n=i[2].trim(),a=s.inlineTokens(n);return{type:"highlight",raw:i[0],text:n,tokens:a}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[l.markInputRule({find:m,type:this.type})]},addPasteRules(){return[l.markPasteRule({find:L,type:this.type})]}});function v({fill:t}){return r.jsx("svg",{height:"18px",version:"1.1",viewBox:"0 0 256 256",width:"18px",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("g",{fill:"none",fillRule:"evenodd",stroke:"none",strokeWidth:1,children:r.jsxs("g",{id:"icon/背景颜色",children:[r.jsx("g",{fill:"currentColor",children:r.jsxs("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",children:[r.jsx("path",{d:"M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z",fillRule:"nonzero"}),r.jsx("path",{d:"M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z",fillRule:"evenodd"}),r.jsx("path",{d:"M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z",fillRule:"nonzero"})]})}),r.jsx("path",{d:"M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z",fill:typeof t=="string"?t:"none",id:"矩形"})]})})})}function H(){const t=h.useButtonProps(g.name),{tooltip:e=void 0,isActive:s=void 0,defaultColor:o=void 0,colors:i,action:n,shortcutKeys:a}=(t==null?void 0:t.componentProps)??{},{editorDisabled:u}=h.useActive(s),[c,p]=x.useState(o);function f(d){u||n&&(n==null||n(d),p(d))}return t?r.jsx(C.ColorPicker,{colors:i,disabled:u,highlight:!0,onChange:f,value:c,children:r.jsx(h.ActionButton,{disabled:u,tooltip:e,shortcutKeys:a,children:r.jsxs("span",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[4px] richtext-text-sm",children:[r.jsx(v,{fill:c}),r.jsx(h.IconComponent,{className:"!richtext-h-3 !richtext-w-3 richtext-text-zinc-500",name:"MenuDown"})]})})}):r.jsx(r.Fragment,{})}const g=k.extend({addStorage(){return{currentColor:this.options.defaultColor||void 0}},addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),multicolor:!0,button:({editor:e,t:s,extension:o})=>({componentProps:{action:i=>{if(typeof i=="string"){e.storage.highlight.currentColor=i,e.chain().focus().setHighlight({color:i}).run();return}e.chain().focus().unsetHighlight().run()},isActive:()=>e.isActive("highlight")||!1,disabled:!1,shortcutKeys:o.options.shortcutKeys??["⇧","mod","H"],tooltip:s("editor.highlight.tooltip"),defaultColor:o.options.defaultColor}})}},addKeyboardShortcuts(){var t;return{...(t=this.parent)==null?void 0:t.call(this),"Mod-Shift-h":()=>{const e=this.storage.currentColor||this.options.defaultColor;if(!e){const{color:o}=this.editor.getAttributes("highlight");return o?this.editor.chain().focus().unsetHighlight().run():!1}return this.editor.isActive("highlight",{color:e})?this.editor.chain().focus().unsetHighlight().run():this.editor.chain().focus().setHighlight({color:e}).run()}}}});exports.Highlight=g;exports.RichTextHighlight=H;
|
package/lib/Highlight.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { M as
|
|
2
|
-
import { jsx as r, jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { u as
|
|
5
|
-
import { C as
|
|
1
|
+
import { M as p, h as f, j as m, m as C, g as L } from "./index-BblvcbTH.js";
|
|
2
|
+
import { jsx as r, jsxs as a, Fragment as x } from "react/jsx-runtime";
|
|
3
|
+
import { useState as k } from "react";
|
|
4
|
+
import { u as M, e as v, A as H, I as y } from "./index-BrsJsbds.js";
|
|
5
|
+
import { C as A } from "./separator-b-qOPJmp.js";
|
|
6
6
|
import "./theme.js";
|
|
7
|
-
|
|
7
|
+
var b = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, w = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g, R = p.create({
|
|
8
8
|
name: "highlight",
|
|
9
9
|
addOptions() {
|
|
10
10
|
return {
|
|
@@ -16,7 +16,11 @@ const k = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, b = /(?:^|\s)(==(?!\s+
|
|
|
16
16
|
return this.options.multicolor ? {
|
|
17
17
|
color: {
|
|
18
18
|
default: null,
|
|
19
|
-
|
|
19
|
+
// Prefer `data-color` (set by our own `renderHTML`) for lossless
|
|
20
|
+
// round-trips. Otherwise parse the raw inline `style` attribute so
|
|
21
|
+
// the original color format (e.g. `#rrggbb`) is preserved instead of
|
|
22
|
+
// the canonicalized `rgb(...)` value from `element.style.backgroundColor`.
|
|
23
|
+
parseHTML: (t) => t.getAttribute("data-color") || L(t, "background-color") || t.style.backgroundColor,
|
|
20
24
|
renderHTML: (t) => t.color ? {
|
|
21
25
|
"data-color": t.color,
|
|
22
26
|
style: `background-color: ${t.color}; color: inherit`
|
|
@@ -34,6 +38,25 @@ const k = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, b = /(?:^|\s)(==(?!\s+
|
|
|
34
38
|
renderHTML({ HTMLAttributes: t }) {
|
|
35
39
|
return ["mark", C(this.options.HTMLAttributes, t), 0];
|
|
36
40
|
},
|
|
41
|
+
renderMarkdown: (t, e) => `==${e.renderChildren(t)}==`,
|
|
42
|
+
parseMarkdown: (t, e) => e.applyMark("highlight", e.parseInline(t.tokens || [])),
|
|
43
|
+
markdownTokenizer: {
|
|
44
|
+
name: "highlight",
|
|
45
|
+
level: "inline",
|
|
46
|
+
start: (t) => t.indexOf("=="),
|
|
47
|
+
tokenize(t, e, s) {
|
|
48
|
+
const i = /^(==)([^=]+)(==)/.exec(t);
|
|
49
|
+
if (i) {
|
|
50
|
+
const n = i[2].trim(), l = s.inlineTokens(n);
|
|
51
|
+
return {
|
|
52
|
+
type: "highlight",
|
|
53
|
+
raw: i[0],
|
|
54
|
+
text: n,
|
|
55
|
+
tokens: l
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
37
60
|
addCommands() {
|
|
38
61
|
return {
|
|
39
62
|
setHighlight: (t) => ({ commands: e }) => e.setMark(this.name, t),
|
|
@@ -49,21 +72,21 @@ const k = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, b = /(?:^|\s)(==(?!\s+
|
|
|
49
72
|
addInputRules() {
|
|
50
73
|
return [
|
|
51
74
|
m({
|
|
52
|
-
find:
|
|
75
|
+
find: b,
|
|
53
76
|
type: this.type
|
|
54
77
|
})
|
|
55
78
|
];
|
|
56
79
|
},
|
|
57
80
|
addPasteRules() {
|
|
58
81
|
return [
|
|
59
|
-
|
|
60
|
-
find:
|
|
82
|
+
f({
|
|
83
|
+
find: w,
|
|
61
84
|
type: this.type
|
|
62
85
|
})
|
|
63
86
|
];
|
|
64
87
|
}
|
|
65
88
|
});
|
|
66
|
-
function
|
|
89
|
+
function T({ fill: t }) {
|
|
67
90
|
return /* @__PURE__ */ r(
|
|
68
91
|
"svg",
|
|
69
92
|
{
|
|
@@ -72,8 +95,8 @@ function w({ fill: t }) {
|
|
|
72
95
|
viewBox: "0 0 256 256",
|
|
73
96
|
width: "18px",
|
|
74
97
|
xmlns: "http://www.w3.org/2000/svg",
|
|
75
|
-
children: /* @__PURE__ */ r("g", { fill: "none", fillRule: "evenodd", stroke: "none", strokeWidth: 1, children: /* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */ r("g", { fill: "currentColor", children: /* @__PURE__ */
|
|
98
|
+
children: /* @__PURE__ */ r("g", { fill: "none", fillRule: "evenodd", stroke: "none", strokeWidth: 1, children: /* @__PURE__ */ a("g", { id: "icon/背景颜色", children: [
|
|
99
|
+
/* @__PURE__ */ r("g", { fill: "currentColor", children: /* @__PURE__ */ a("g", { transform: "translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)", children: [
|
|
77
100
|
/* @__PURE__ */ r(
|
|
78
101
|
"path",
|
|
79
102
|
{
|
|
@@ -108,36 +131,36 @@ function w({ fill: t }) {
|
|
|
108
131
|
}
|
|
109
132
|
);
|
|
110
133
|
}
|
|
111
|
-
function
|
|
112
|
-
const t =
|
|
134
|
+
function $() {
|
|
135
|
+
const t = M(S.name), {
|
|
113
136
|
tooltip: e = void 0,
|
|
114
|
-
isActive:
|
|
115
|
-
defaultColor:
|
|
116
|
-
colors:
|
|
117
|
-
action:
|
|
118
|
-
shortcutKeys:
|
|
119
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled:
|
|
120
|
-
function g(
|
|
121
|
-
|
|
137
|
+
isActive: s = void 0,
|
|
138
|
+
defaultColor: o = void 0,
|
|
139
|
+
colors: i,
|
|
140
|
+
action: n,
|
|
141
|
+
shortcutKeys: l
|
|
142
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: h } = v(s), [u, d] = k(o);
|
|
143
|
+
function g(c) {
|
|
144
|
+
h || n && (n == null || n(c), d(c));
|
|
122
145
|
}
|
|
123
146
|
return t ? /* @__PURE__ */ r(
|
|
124
|
-
|
|
147
|
+
A,
|
|
125
148
|
{
|
|
126
|
-
colors:
|
|
127
|
-
disabled:
|
|
149
|
+
colors: i,
|
|
150
|
+
disabled: h,
|
|
128
151
|
highlight: !0,
|
|
129
152
|
onChange: g,
|
|
130
|
-
value:
|
|
153
|
+
value: u,
|
|
131
154
|
children: /* @__PURE__ */ r(
|
|
132
|
-
|
|
155
|
+
H,
|
|
133
156
|
{
|
|
134
|
-
disabled:
|
|
157
|
+
disabled: h,
|
|
135
158
|
tooltip: e,
|
|
136
|
-
shortcutKeys:
|
|
137
|
-
children: /* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */ r(
|
|
159
|
+
shortcutKeys: l,
|
|
160
|
+
children: /* @__PURE__ */ a("span", { className: "richtext-flex richtext-items-center richtext-justify-center richtext-gap-[4px] richtext-text-sm", children: [
|
|
161
|
+
/* @__PURE__ */ r(T, { fill: u }),
|
|
139
162
|
/* @__PURE__ */ r(
|
|
140
|
-
|
|
163
|
+
y,
|
|
141
164
|
{
|
|
142
165
|
className: "!richtext-h-3 !richtext-w-3 richtext-text-zinc-500",
|
|
143
166
|
name: "MenuDown"
|
|
@@ -147,9 +170,9 @@ function z() {
|
|
|
147
170
|
}
|
|
148
171
|
)
|
|
149
172
|
}
|
|
150
|
-
) : /* @__PURE__ */ r(
|
|
173
|
+
) : /* @__PURE__ */ r(x, {});
|
|
151
174
|
}
|
|
152
|
-
const
|
|
175
|
+
const S = /* @__PURE__ */ R.extend({
|
|
153
176
|
addStorage() {
|
|
154
177
|
return {
|
|
155
178
|
// Stores the currently selected highlight color; undefined indicates "No Fill".
|
|
@@ -162,20 +185,20 @@ const T = /* @__PURE__ */ R.extend({
|
|
|
162
185
|
return {
|
|
163
186
|
...(t = this.parent) == null ? void 0 : t.call(this),
|
|
164
187
|
multicolor: !0,
|
|
165
|
-
button: ({ editor: e, t:
|
|
188
|
+
button: ({ editor: e, t: s, extension: o }) => ({
|
|
166
189
|
componentProps: {
|
|
167
|
-
action: (
|
|
168
|
-
if (typeof
|
|
169
|
-
e.storage.highlight.currentColor =
|
|
190
|
+
action: (i) => {
|
|
191
|
+
if (typeof i == "string") {
|
|
192
|
+
e.storage.highlight.currentColor = i, e.chain().focus().setHighlight({ color: i }).run();
|
|
170
193
|
return;
|
|
171
194
|
}
|
|
172
195
|
e.chain().focus().unsetHighlight().run();
|
|
173
196
|
},
|
|
174
197
|
isActive: () => e.isActive("highlight") || !1,
|
|
175
198
|
disabled: !1,
|
|
176
|
-
shortcutKeys:
|
|
177
|
-
tooltip:
|
|
178
|
-
defaultColor:
|
|
199
|
+
shortcutKeys: o.options.shortcutKeys ?? ["⇧", "mod", "H"],
|
|
200
|
+
tooltip: s("editor.highlight.tooltip"),
|
|
201
|
+
defaultColor: o.options.defaultColor
|
|
179
202
|
}
|
|
180
203
|
})
|
|
181
204
|
};
|
|
@@ -187,8 +210,8 @@ const T = /* @__PURE__ */ R.extend({
|
|
|
187
210
|
"Mod-Shift-h": () => {
|
|
188
211
|
const e = this.storage.currentColor || this.options.defaultColor;
|
|
189
212
|
if (!e) {
|
|
190
|
-
const { color:
|
|
191
|
-
return
|
|
213
|
+
const { color: o } = this.editor.getAttributes("highlight");
|
|
214
|
+
return o ? this.editor.chain().focus().unsetHighlight().run() : !1;
|
|
192
215
|
}
|
|
193
216
|
return this.editor.isActive("highlight", {
|
|
194
217
|
color: e
|
|
@@ -198,6 +221,6 @@ const T = /* @__PURE__ */ R.extend({
|
|
|
198
221
|
}
|
|
199
222
|
});
|
|
200
223
|
export {
|
|
201
|
-
|
|
202
|
-
|
|
224
|
+
S as Highlight,
|
|
225
|
+
$ as RichTextHighlight
|
|
203
226
|
};
|
package/lib/History.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-C4WLt4NA.cjs"),C=require("@tiptap/pm/state"),E=require("@tiptap/pm/view"),R=require("./index-C3dgmjIF.cjs"),I=require("react/jsx-runtime"),x=require("./index-ezTXvA7H.cjs");require("react");require("./theme.cjs");function U(n={}){return new h.Plugin({view(e){return new W(e,n)}})}class W{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let c=e.nodeBefore,p=e.nodeAfter;if(c||p){let m=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(m){let v=m.getBoundingClientRect(),A=c?v.bottom:v.top;c&&p&&(A=(A+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let M=this.width/2*l;r={left:v.left,right:v.right,top:A-M,bottom:A+M}}}}if(!r){let c=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:c.left-p,right:c.left+p,top:c.top,bottom:c.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")d=-pageXOffset,u=-pageYOffset;else{let c=a.getBoundingClientRect(),p=c.width/a.offsetWidth,m=c.height/a.offsetHeight;d=c.left-a.scrollLeft*p,u=c.top-a.scrollTop*m}this.element.style.left=(r.left-d)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=h.dropPoint(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class f extends h.Selection{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return f.valid(r)?new f(r):h.Selection.near(r)}content(){return h.Slice.empty}eq(e){return e instanceof f&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new f(e.resolve(t.pos))}getBookmark(){return new z(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!q(e)||!X(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&f.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(f.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!h.NodeSelection.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(f.valid(l))return l}return null}}}f.prototype.visible=!1;f.findFrom=f.findGapCursorFrom;h.Selection.jsonID("gapcursor",f);class z{constructor(e){this.pos=e}map(e){return new z(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return f.valid(t)?new f(t):h.Selection.near(t)}}function B(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function q(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function X(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Y(){return new h.Plugin({props:{decorations:$,createSelectionBetween(n,e,t){return e.pos==t.pos&&f.valid(t)?new f(t):null},handleClick:J,handleKeyDown:Z,handleDOMEvents:{beforeinput:Q}}})}const Z=R.keydownHandler({ArrowLeft:S("horiz",-1),ArrowRight:S("horiz",1),ArrowUp:S("vert",-1),ArrowDown:S("vert",1)});function S(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof h.TextSelection){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let d=f.findGapCursorFrom(l,e,a);return d?(i&&i(r.tr.setSelection(new f(d))),!0):!1}}function J(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!f.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&h.NodeSelection.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new f(r))),!0)}function Q(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof f))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=h.Fragment.empty;for(let s=r.length-1;s>=0;s--)i=h.Fragment.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new h.Slice(i,0,0));return o.setSelection(h.TextSelection.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function $(n){if(!(n.selection instanceof f))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",R.DecorationSet.create(n.doc,[R.Decoration.widget(n.selection.head,e,{key:"gapcursor"})])}var O=200,g=function(){};g.prototype.append=function(e){return e.length?(e=g.from(e),!this.length&&e||e.length<O&&this.leafAppend(e)||this.length<O&&e.leafPrepend(this)||this.appendInner(e)):this};g.prototype.prepend=function(e){return e.length?g.from(e).append(this):this};g.prototype.appendInner=function(e){return new ee(this,e)};g.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?g.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};g.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};g.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};g.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};g.from=function(e){return e instanceof g?e:e&&e.length?new j(e):g.empty};var j=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=O)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=O)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(g);g.empty=new j([]);var ee=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(g);const te=500;class w{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,d=[],u=[];return this.items.forEach((c,p)=>{if(!c.step){i||(i=this.remapping(r,p+1),o=i.maps.length),o--,u.push(c);return}if(i){u.push(new y(c.map));let m=c.step.map(i.slice(o)),v;m&&s.maybeStep(m).doc&&(v=s.mapping.maps[s.mapping.maps.length-1],d.push(new y(v,void 0,void 0,d.length+u.length))),o--,v&&i.appendMap(v,o)}else s.maybeStep(c.step);if(c.selection)return l=i?c.selection.map(i.slice(o)):c.selection,a=new w(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let c=e.steps[u].invert(e.docs[u]),p=new y(e.mapping.maps[u],c,t),m;(m=a&&a.merge(p))&&(p=m,u?o.pop():l=l.slice(0,l.length-1)),o.push(p),t&&(s++,t=void 0),i||(a=p)}let d=s-r.depth;return d>ie&&(l=ne(l,d),s-=d),new w(l.append(o),s)}remapping(e,t){let r=new h.Mapping;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new w(this.items.append(e.map(t=>new y(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let a=t;this.items.forEach(p=>{let m=o.getMirror(--a);if(m==null)return;s=Math.min(s,m);let v=o.maps[m];if(p.step){let A=e.steps[m].invert(e.docs[m]),M=p.selection&&p.selection.map(o.slice(a+1,m));M&&l++,r.push(new y(v,A,M))}else r.push(new y(v))},i);let d=[];for(let p=t;p<s;p++)d.push(new y(o.maps[p]));let u=this.items.slice(0,i).append(d).append(r),c=new w(u,l);return c.emptyItemCount()>te&&(c=c.compress(this.items.length-r.length)),c}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),d=a&&a.getMap();if(r--,d&&t.appendMap(d,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&o++;let c=new y(d.invert(),a,u),p,m=i.length-1;(p=i.length&&i[m].merge(c))?i[m]=p:i.push(c)}}else s.map&&r--},this.items.length,0),new w(g.from(i.reverse()),o)}}w.empty=new w(g.empty,0);function ne(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class y{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new y(t.getMap().invert(),t,this.selection)}}}class P{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const ie=20;function re(n,e,t,r){let i=t.getMeta(b),o;if(i)return i.historyState;t.getMeta(le)&&(n=new P(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(b))return s.getMeta(b).redo?new P(n.done.addTransform(t,void 0,r,T(e)),n.undone,F(t.mapping.maps),n.prevTime,n.prevComposition):new P(n.done,n.undone.addTransform(t,void 0,r,T(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!oe(t,n.prevRanges)),d=s?D(n.prevRanges,t.mapping):F(t.mapping.maps);return new P(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,T(e)),w.empty,d,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new P(n.done.rebased(t,o),n.undone.rebased(t,o),D(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new P(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),D(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function oe(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function F(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function D(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),o=e.map(n[r+1],-1);i<=o&&t.push(i,o)}return t}function se(n,e,t){let r=T(e),i=b.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),a=new P(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(b,{redo:t,historyState:a})}let k=!1,L=null;function T(n){let e=n.plugins;if(L!=e){k=!1,L=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){k=!0;break}}return k}const b=new h.PluginKey("history"),le=new h.PluginKey("closeHistory");function ae(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new h.Plugin({key:b,state:{init(){return new P(w.empty,w.empty,null,0,-1)},apply(e,t,r){return re(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?H:r=="historyRedo"?G:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function _(n,e){return(t,r)=>{let i=b.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=se(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const H=_(!1,!0),G=_(!0,!0);h.Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new C.Plugin({key:new C.PluginKey("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit;if(i==null||i===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const s=o-i,l=0,a=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const d=r.tr.deleteRange(l,a);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||i>r&&o>r&&o<=i)return!0;if(i>r&&o>r&&o>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,d=l-a,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>r)}})]}});h.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[U(this.options)]}});h.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,o=[];if(!t||!r)return E.DecorationSet.create(n,[]);let s=0;this.options.mode==="deepest"&&n.descendants((a,d)=>{if(a.isText)return;if(!(i>=d&&i<=d+a.nodeSize-1))return!1;s+=1});let l=0;return n.descendants((a,d)=>{if(a.isText||!(i>=d&&i<=d+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(E.Decoration.node(d,d+a.nodeSize,{class:this.options.className}))}),E.DecorationSet.create(n,o)}}})]}});h.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Y()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=h.callOrReturn(h.getExtensionField(n,"allowGapCursor",t)))!=null?e:null}}});var V="placeholder";function de(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}h.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:V,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${de(this.options.dataAttribute)}`:`data-${V}`;return[new C.Plugin({key:new C.PluginKey("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=t,o=[];if(!r)return null;const s=this.editor.isEmpty;return e.descendants((l,a)=>{const d=i>=a&&i<=a+l.nodeSize,u=!l.isLeaf&&h.isNodeEmpty(l);if(!l.type.isTextblock)return this.options.includeChildren;if((d||!this.options.showOnlyCurrent)&&u){const c=[this.options.emptyNodeClass];s&&c.push(this.options.emptyEditorClass);const p=E.Decoration.node(a,a+l.nodeSize,{class:c.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:d}):this.options.placeholder});o.push(p)}return this.options.includeChildren}),E.DecorationSet.create(e,o)}}})]}});h.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new C.Plugin({key:new C.PluginKey("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||h.isNodeSelection(t.selection)||n.view.dragging?null:E.DecorationSet.create(t.doc,[E.Decoration.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function K({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}h.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new C.PluginKey(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new C.Plugin({key:e,appendTransaction:(i,o,s)=>{const{doc:l,tr:a,schema:d}=s,u=e.getState(s),c=l.content.size,p=d.nodes[t];if(u)return a.insert(c,p.create())},state:{init:(i,o)=>{const s=o.tr.doc.lastChild;return!K({node:s,types:r})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const s=i.doc.lastChild;return!K({node:s,types:r})}}})]}});var ce=h.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>H(n,e),redo:()=>({state:n,dispatch:e})=>G(n,e)}},addProseMirrorPlugins(){return[ae(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});function ue(){var u;const n=x.useButtonProps(N.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:r=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((u=n==null?void 0:n.componentProps)==null?void 0:u.undo)??{},{disabled:l}=x.useActive(s),a=x.icons[e],d=()=>{l||o&&o()};return!n||!a?I.jsx(I.Fragment,{}):I.jsx(x.ActionButton,{action:d,disabled:l,icon:e,shortcutKeys:r,tooltip:t,tooltipOptions:i})}function pe(){var d;const n=x.useButtonProps(N.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:r=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((d=n==null?void 0:n.componentProps)==null?void 0:d.redo)??{},{disabled:l}=x.useActive(s),a=()=>{l||o&&o()};return n?I.jsx(x.ActionButton,{action:a,disabled:l,icon:e,shortcutKeys:r,tooltip:t,tooltipOptions:i}):I.jsx(I.Fragment,{})}const N=ce.extend({addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),depth:100,newGroupDelay:500,button:({editor:e,t,extension:r})=>{var i,o;return{componentProps:{undo:{action:()=>{e.chain().focus().undo().run()},shortcutKeys:((i=r.options.shortcutKeys)==null?void 0:i[0])??["mod","Z"],isActive:()=>e.can().undo(),icon:"Undo2",tooltip:t("editor.undo.tooltip")},redo:{action:()=>{e.chain().focus().redo().run()},shortcutKeys:((o=r.options.shortcutKeys)==null?void 0:o[1])??["shift","mod","Z"],isActive:()=>e.can().redo(),icon:"Redo2",tooltip:t("editor.redo.tooltip")}}}}}}});exports.History=N;exports.RichTextRedo=pe;exports.RichTextUndo=ue;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-Bcj8cyOO.cjs"),C=require("@tiptap/pm/state"),S=require("@tiptap/pm/view"),z=require("./index-CUvjYuRp.cjs"),T=require("react/jsx-runtime"),x=require("./index-deubsx3z.cjs");require("react");require("./theme.cjs");function X(o={}){return new h.Plugin({view(e){return new q(e,o)}})}class q{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let r=s=>{this[i](s)};return e.dom.addEventListener(i,r),{name:i,handler:r}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,i=this.editorView.dom,r=i.getBoundingClientRect(),s=r.width/i.offsetWidth,l=r.height/i.offsetHeight;if(t){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let g=f.getBoundingClientRect(),P=d?g.bottom:g.top;d&&p&&(P=(P+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let E=this.width/2*l;n={left:g.left,right:g.right,top:P-E,bottom:P+E}}}}if(!n){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;n={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),p=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*f}this.element.style.left=(n.left-c)/s+"px",this.element.style.top=(n.top-u)/l+"px",this.element.style.width=(n.right-n.left)/s+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,r=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!r){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=h.dropPoint(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class m extends h.Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return m.valid(n)?new m(n):h.Selection.near(n)}content(){return h.Slice.empty}eq(e){return e instanceof m&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new m(e.resolve(t.pos))}getBookmark(){return new k(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Z(e)||!J(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&m.valid(e))return e;let i=e.pos,r=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){r=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(m.valid(a))return a}for(;;){let s=t>0?r.firstChild:r.lastChild;if(!s){if(r.isAtom&&!r.isText&&!h.NodeSelection.isSelectable(r)){e=e.doc.resolve(i+r.nodeSize*t),n=!1;continue e}break}r=s,i+=t;let l=e.doc.resolve(i);if(m.valid(l))return l}return null}}}m.prototype.visible=!1;m.findFrom=m.findGapCursorFrom;h.Selection.jsonID("gapcursor",m);class k{constructor(e){this.pos=e}map(e){return new k(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return m.valid(t)?new m(t):h.Selection.near(t)}}function H(o){return o.isAtom||o.spec.isolating||o.spec.createGapCursor}function Z(o){for(let e=o.depth;e>=0;e--){let t=o.index(e),n=o.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||H(i.type))return!0;if(i.inlineContent)return!1}}return!0}function J(o){for(let e=o.depth;e>=0;e--){let t=o.indexAfter(e),n=o.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||H(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Q(){return new h.Plugin({props:{decorations:ne,createSelectionBetween(o,e,t){return e.pos==t.pos&&m.valid(t)?new m(t):null},handleClick:ee,handleKeyDown:$,handleDOMEvents:{beforeinput:te}}})}const $=z.keydownHandler({ArrowLeft:I("horiz",-1),ArrowRight:I("horiz",1),ArrowUp:I("vert",-1),ArrowDown:I("vert",1)});function I(o,e){const t=o=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,r){let s=n.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof h.TextSelection){if(!r.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=m.findGapCursorFrom(l,e,a);return c?(i&&i(n.tr.setSelection(new m(c))),!0):!1}}function ee(o,e,t){if(!o||!o.editable)return!1;let n=o.state.doc.resolve(e);if(!m.valid(n))return!1;let i=o.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&h.NodeSelection.isSelectable(o.state.doc.nodeAt(i.inside))?!1:(o.dispatch(o.state.tr.setSelection(new m(n))),!0)}function te(o,e){if(e.inputType!="insertCompositionText"||!(o.state.selection instanceof m))return!1;let{$from:t}=o.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(o.state.schema.nodes.text);if(!n)return!1;let i=h.Fragment.empty;for(let s=n.length-1;s>=0;s--)i=h.Fragment.from(n[s].createAndFill(null,i));let r=o.state.tr.replace(t.pos,t.pos,new h.Slice(i,0,0));return r.setSelection(h.TextSelection.near(r.doc.resolve(t.pos+1))),o.dispatch(r),!1}function ne(o){if(!(o.selection instanceof m))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",z.DecorationSet.create(o.doc,[z.Decoration.widget(o.selection.head,e,{key:"gapcursor"})])}var R=200,v=function(){};v.prototype.append=function(e){return e.length?(e=v.from(e),!this.length&&e||e.length<R&&this.leafAppend(e)||this.length<R&&e.leafPrepend(this)||this.appendInner(e)):this};v.prototype.prepend=function(e){return e.length?v.from(e).append(this):this};v.prototype.appendInner=function(e){return new oe(this,e)};v.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?v.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};v.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};v.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};v.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(r,s){return i.push(e(r,s))},t,n),i};v.from=function(e){return e instanceof v?e:e&&e.length?new j(e):v.empty};var j=(function(o){function e(n){o.call(this),this.values=n}o&&(e.__proto__=o),e.prototype=Object.create(o&&o.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,r){return i==0&&r==this.length?this:new e(this.values.slice(i,r))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,r,s,l){for(var a=r;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,s,l){for(var a=r-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=R)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=R)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(v);v.empty=new j([]);var oe=(function(o){function e(t,n){o.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return o&&(e.__proto__=o),e.prototype=Object.create(o&&o.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,r,s){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(r,l),s)===!1||r>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,r)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,r,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(r,l)-l,s+l)===!1||r<l&&this.left.forEachInvertedInner(n,Math.min(i,l),r,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var r=this.left.length;return i<=r?this.left.slice(n,i):n>=r?this.right.slice(n-r,i-r):this.left.slice(n,r).append(this.right.slice(0,i-r))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(v);const ie=500;class y{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,r;t&&(i=this.remapping(n,this.items.length),r=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,p)=>{if(!d.step){i||(i=this.remapping(n,p+1),r=i.maps.length),r--,u.push(d);return}if(i){u.push(new w(d.map));let f=d.step.map(i.slice(r)),g;f&&s.maybeStep(f).doc&&(g=s.mapping.maps[s.mapping.maps.length-1],c.push(new w(g,void 0,void 0,c.length+u.length))),r--,g&&i.appendMap(g,r)}else s.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(r)):d.selection,a=new y(this.items.slice(0,n).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,i){let r=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),p=new w(e.mapping.maps[u],d,t),f;(f=a&&a.merge(p))&&(p=f,u?r.pop():l=l.slice(0,l.length-1)),r.push(p),t&&(s++,t=void 0),i||(a=p)}let c=s-n.depth;return c>se&&(l=re(l,c),s-=c),new y(l.append(r),s)}remapping(e,t){let n=new h.Mapping;return this.items.forEach((i,r)=>{let s=i.mirrorOffset!=null&&r-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,s)},e,t),n}addMaps(e){return this.eventCount==0?this:new y(this.items.append(e.map(t=>new w(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),r=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let a=t;this.items.forEach(p=>{let f=r.getMirror(--a);if(f==null)return;s=Math.min(s,f);let g=r.maps[f];if(p.step){let P=e.steps[f].invert(e.docs[f]),E=p.selection&&p.selection.map(r.slice(a+1,f));E&&l++,n.push(new w(g,P,E))}else n.push(new w(g))},i);let c=[];for(let p=t;p<s;p++)c.push(new w(r.maps[p]));let u=this.items.slice(0,i).append(c).append(n),d=new y(u,l);return d.emptyItemCount()>ie&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],r=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&r++;else if(s.step){let a=s.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let u=s.selection&&s.selection.map(t.slice(n));u&&r++;let d=new w(c.invert(),a,u),p,f=i.length-1;(p=i.length&&i[f].merge(d))?i[f]=p:i.push(d)}}else s.map&&n--},this.items.length,0),new y(v.from(i.reverse()),r)}}y.empty=new y(v.empty,0);function re(o,e){let t;return o.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),o.slice(t)}class w{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new w(t.getMap().invert(),t,this.selection)}}}class b{constructor(e,t,n,i,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=r}}const se=20;function le(o,e,t,n){let i=t.getMeta(M),r;if(i)return i.historyState;t.getMeta(de)&&(o=new b(o.done,o.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return o;if(s&&s.getMeta(M))return s.getMeta(M).redo?new b(o.done.addTransform(t,void 0,n,O(e)),o.undone,B(t.mapping.maps),o.prevTime,o.prevComposition):new b(o.done,o.undone.addTransform(t,void 0,n,O(e)),null,o.prevTime,o.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=o.prevTime==0||!s&&o.prevComposition!=l&&(o.prevTime<(t.time||0)-n.newGroupDelay||!ae(t,o.prevRanges)),c=s?D(o.prevRanges,t.mapping):B(t.mapping.maps);return new b(o.done.addTransform(t,a?e.selection.getBookmark():void 0,n,O(e)),y.empty,c,t.time,l??o.prevComposition)}else return(r=t.getMeta("rebased"))?new b(o.done.rebased(t,r),o.undone.rebased(t,r),D(o.prevRanges,t.mapping),o.prevTime,o.prevComposition):new b(o.done.addMaps(t.mapping.maps),o.undone.addMaps(t.mapping.maps),D(o.prevRanges,t.mapping),o.prevTime,o.prevComposition)}function ae(o,e){if(!e)return!1;if(!o.docChanged)return!0;let t=!1;return o.mapping.maps[0].forEach((n,i)=>{for(let r=0;r<e.length;r+=2)n<=e[r+1]&&i>=e[r]&&(t=!0)}),t}function B(o){let e=[];for(let t=o.length-1;t>=0&&e.length==0;t--)o[t].forEach((n,i,r,s)=>e.push(r,s));return e}function D(o,e){if(!o)return null;let t=[];for(let n=0;n<o.length;n+=2){let i=e.map(o[n],1),r=e.map(o[n+1],-1);i<=r&&t.push(i,r)}return t}function ce(o,e,t){let n=O(e),i=M.get(e).spec.config,r=(t?o.undone:o.done).popEvent(e,n);if(!r)return null;let s=r.selection.resolve(r.transform.doc),l=(t?o.done:o.undone).addTransform(r.transform,e.selection.getBookmark(),i,n),a=new b(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(s).setMeta(M,{redo:t,historyState:a})}let N=!1,F=null;function O(o){let e=o.plugins;if(F!=e){N=!1,F=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){N=!0;break}}return N}const M=new h.PluginKey("history"),de=new h.PluginKey("closeHistory");function ue(o={}){return o={depth:o.depth||100,newGroupDelay:o.newGroupDelay||500},new h.Plugin({key:M,state:{init(){return new b(y.empty,y.empty,null,0,-1)},apply(e,t,n){return le(t,n,e,o)}},config:o,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?U:n=="historyRedo"?W:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function G(o,e){return(t,n)=>{let i=M.getState(t);if(!i||(o?i.undone:i.done).eventCount==0)return!1;if(n){let r=ce(i,t,o);r&&n(e?r.scrollIntoView():r)}return!0}}const U=G(!1,!0),W=G(!0,!0);h.Extension.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:o=>o.length,wordCounter:o=>o.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=o=>{const e=(o==null?void 0:o.node)||this.editor.state.doc;if(((o==null?void 0:o.mode)||this.options.mode)==="textSize"){const n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=o=>{const e=(o==null?void 0:o.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let o=!1;return[new C.Plugin({key:new C.PluginKey("characterCount"),appendTransaction:(e,t,n)=>{if(o)return;const i=this.options.limit,r=this.options.autoTrim;if(i==null||i===0||r===!1){o=!0;return}const s=this.storage.characters({node:n.doc});if(s>i){const l=s-i,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=n.tr.deleteRange(a,c);return o=!0,u}o=!0},filterTransaction:(e,t)=>{const n=this.options.limit;if(!e.docChanged||n===0||n===null||n===void 0)return!0;const i=this.storage.characters({node:t.doc}),r=this.storage.characters({node:e.doc});if(r<=n||i>n&&r>n&&r<=i)return!0;if(i>n&&r>n&&r>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=r-n,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>n)}})]}});h.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[X(this.options)]}});h.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("focus"),props:{decorations:({doc:o,selection:e})=>{const{isEditable:t,isFocused:n}=this.editor,{anchor:i}=e,r=[];if(!t||!n)return S.DecorationSet.create(o,[]);let s=0;this.options.mode==="deepest"&&o.descendants((a,c)=>{if(a.isText)return;if(!(i>=c&&i<=c+a.nodeSize-1))return!1;s+=1});let l=0;return o.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";r.push(S.Decoration.node(c,c+a.nodeSize,{class:this.options.className}))}),S.DecorationSet.create(o,r)}}})]}});h.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Q()]},extendNodeSchema(o){var e;const t={name:o.name,options:o.options,storage:o.storage};return{allowGapCursor:(e=h.callOrReturn(h.getExtensionField(o,"allowGapCursor",t)))!=null?e:null}}});function _(o){const{editor:e,placeholder:t,dataAttribute:n,pos:i,node:r,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=o,u=[a];return s&&u.push(c),S.Decoration.node(i,i+r.nodeSize,{class:u.join(" "),[n]:typeof t=="function"?t({editor:e,node:r,pos:i,hasAnchor:l}):t})}function pe(o){const e=getComputedStyle(o),t=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(t)}function he(o){let e=o;for(;e;){if(pe(e))return e;const t=e.parentElement;if(!t){const n=e.getRootNode();if(n instanceof ShadowRoot){e=n.host;continue}return window}e=t}return window}function fe(o){return o===window?{top:0,bottom:window.innerHeight}:o.getBoundingClientRect()}function me({doc:o,view:e,scrollContainer:t}){const n=e.dom.getBoundingClientRect(),i=t?fe(t):{top:0,bottom:window.innerHeight},r=Math.max(n.top,i.top),s=Math.min(n.bottom,i.bottom);if(r>=s)return{top:0,bottom:o.content.size};const a=getComputedStyle(e.dom).direction==="rtl"?Math.max(n.right-2,n.left+2):n.left+2,c=e.posAtCoords({left:a,top:r+2}),u=e.posAtCoords({left:a,top:s-2});return{top:c?c.pos:0,bottom:u?u.pos:o.content.size}}function ge(o,e){let t=null;return{call:((...r)=>{t||(o(...r),t=setTimeout(()=>{t=null},e))}),cancel:()=>{t&&(clearTimeout(t),t=null)}}}var V="placeholder";function ve(o){return o.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var A=new C.PluginKey("tiptap__placeholder");h.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:V,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const o=this.options.dataAttribute?`data-${ve(this.options.dataAttribute)}`:`data-${V}`;return[new C.Plugin({state:{init(){return{topPos:null,bottomPos:null}},apply(e,t){const n=e.getMeta(A);return n!=null&&n.positions?{topPos:n.positions.top,bottomPos:n.positions.bottom}:e.docChanged?{topPos:t.topPos!==null?e.mapping.map(t.topPos):null,bottomPos:t.bottomPos!==null?e.mapping.map(t.bottomPos):null}:t}},key:A,view(e){const t=he(e.dom),n=()=>{const l=me({view:e,doc:e.state.doc,scrollContainer:t}),a=A.getState(e.state);if(a.topPos===l.top&&a.bottomPos===l.bottom)return;const c=e.state.tr.setMeta(A,{positions:l}).setMeta("tiptap__viewportUpdate",!0);e.dispatch(c)},{call:i,cancel:r}=ge(n,250),s=t;return s.addEventListener("scroll",i,{passive:!0}),n(),{update(l,a){e.state.doc.content.size!==a.doc.content.size&&n()},destroy:()=>{r(),s.removeEventListener("scroll",i)}}},props:{decorations:({doc:e,selection:t})=>{var n,i;if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:s}=t,l=[],a=this.editor.isEmpty;if(this.options.showOnlyCurrent&&!this.options.includeChildren){const u=e.resolve(s);if(u.depth>0){const d=u.node(1),p=u.before(1);if(d.type.isTextblock&&h.isNodeEmpty(d)){const f=s>=p&&s<=p+d.nodeSize,g=_({node:d,dataAttribute:o,hasAnchor:f,placeholder:this.options.placeholder,classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:a,pos:u.before(1)});l.push(g)}}}else{const u=A.getState(this.editor.state),d=(n=u.topPos)!=null?n:0,p=(i=u.bottomPos)!=null?i:e.content.size;e.nodesBetween(d,p,(f,g)=>{const P=s>=g&&s<=g+f.nodeSize,E=!f.isLeaf&&h.isNodeEmpty(f);if(!f.type.isTextblock)return this.options.includeChildren;if((P||!this.options.showOnlyCurrent)&&E){const Y=_({classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:a,dataAttribute:o,hasAnchor:P,placeholder:this.options.placeholder,node:f,pos:g});l.push(Y)}return this.options.includeChildren})}return S.DecorationSet.create(e,l)}}})]}});h.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:o,options:e}=this;return[new C.Plugin({key:new C.PluginKey("selection"),props:{decorations(t){return t.selection.empty||o.isFocused||!o.isEditable||h.isNodeSelection(t.selection)||o.view.dragging?null:S.DecorationSet.create(t.doc,[S.Decoration.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});var ye="skipTrailingNode";function K({types:o,node:e}){return e&&Array.isArray(o)&&o.includes(e.type)||(e==null?void 0:e.type)===o}h.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var o;const e=new C.PluginKey(this.name),t=this.options.node||((o=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:o.name)||"paragraph",n=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new C.Plugin({key:e,appendTransaction:(i,r,s)=>{const{doc:l,tr:a,schema:c}=s,u=e.getState(s),d=l.content.size,p=c.nodes[t];if(!i.some(f=>f.getMeta(ye))&&u)return a.insert(d,p.create())},state:{init:(i,r)=>{const s=r.tr.doc.lastChild;return!K({node:s,types:n})},apply:(i,r)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return r;const s=i.doc.lastChild;return!K({node:s,types:n})}}})]}});var we=h.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:o,dispatch:e})=>U(o,e),redo:()=>({state:o,dispatch:e})=>W(o,e)}},addProseMirrorPlugins(){return[ue(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});function Ce(){var u;const o=x.useButtonProps(L.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:r=void 0,isActive:s=void 0}=((u=o==null?void 0:o.componentProps)==null?void 0:u.undo)??{},{disabled:l}=x.useActive(s),a=x.icons[e],c=()=>{l||r&&r()};return!o||!a?T.jsx(T.Fragment,{}):T.jsx(x.ActionButton,{action:c,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i})}function Pe(){var c;const o=x.useButtonProps(L.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:r=void 0,isActive:s=void 0}=((c=o==null?void 0:o.componentProps)==null?void 0:c.redo)??{},{disabled:l}=x.useActive(s),a=()=>{l||r&&r()};return o?T.jsx(x.ActionButton,{action:a,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i}):T.jsx(T.Fragment,{})}const L=we.extend({addOptions(){var o;return{...(o=this.parent)==null?void 0:o.call(this),depth:100,newGroupDelay:500,button:({editor:e,t,extension:n})=>{var i,r;return{componentProps:{undo:{action:()=>{e.chain().focus().undo().run()},shortcutKeys:((i=n.options.shortcutKeys)==null?void 0:i[0])??["mod","Z"],isActive:()=>e.can().undo(),icon:"Undo2",tooltip:t("editor.undo.tooltip")},redo:{action:()=>{e.chain().focus().redo().run()},shortcutKeys:((r=n.options.shortcutKeys)==null?void 0:r[1])??["shift","mod","Z"],isActive:()=>e.can().redo(),icon:"Redo2",tooltip:t("editor.redo.tooltip")}}}}}}});exports.History=L;exports.RichTextRedo=Pe;exports.RichTextUndo=Ce;
|