reactjs-tiptap-editor 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{ActionMenuButton-BS1m0efQ.cjs → ActionMenuButton-DYT5chmX.cjs} +1 -1
- package/lib/{ActionMenuButton-CmYQziyT.js → ActionMenuButton-htJNI0Fa.js} +6 -6
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +1 -1
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.js +1 -1
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +1 -1
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +1 -1
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +1 -1
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +1 -1
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +2 -2
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +1 -1
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +6 -6
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +1 -1
- package/lib/{Drawer-BCMlTDss.js → Drawer-1211urKj.js} +1 -1
- package/lib/{Drawer-DPVStAKs.cjs → Drawer-DUFUd5BW.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +1 -1
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +1 -1
- package/lib/{Excalidraw-BP-xjF6S.cjs → Excalidraw-CajgZDjU.cjs} +1 -1
- package/lib/{Excalidraw-1dKmqI-3.js → Excalidraw-Du3hBR8t.js} +1 -1
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +1 -1
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +1 -1
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +1 -1
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +1 -1
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +1 -1
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +1 -1
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +6 -6
- package/lib/History.cjs +1 -1
- package/lib/History.js +2 -2
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +1 -1
- package/lib/{Iframe-CeasogsD.cjs → Iframe-CM6mRQmv.cjs} +1 -1
- package/lib/{Iframe-B_GAN9lj.js → Iframe-DTYTLQE6.js} +1 -1
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +1 -1
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +2 -2
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +1 -1
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +1 -1
- package/lib/{Indent-BGmFt7Dc.cjs → Indent-BmhiEb0S.cjs} +1 -1
- package/lib/{Indent-DCTAYr8i.js → Indent-jOPn3eUM.js} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +1 -1
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +1 -1
- package/lib/{Katex-CxEAc1xw.js → Katex-CERSrcTP.js} +1 -1
- package/lib/{Katex-CFZB-dZq.cjs → Katex-CUd3LxLh.cjs} +1 -1
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +1 -1
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +12 -12
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +1 -1
- package/lib/{LinkEditBlock-C8rPUoNH.js → LinkEditBlock-B5SdhOfa.js} +2 -2
- package/lib/{LinkEditBlock-DiSXJpTN.cjs → LinkEditBlock-DaxljgJC.cjs} +1 -1
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +1 -1
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +14 -14
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +1 -1
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +7 -7
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +43 -41
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +1 -1
- package/lib/{Table-B9w1GsCg.js → Table-39OkCQbu.js} +1 -1
- package/lib/{Table-B4s9CpR4.cjs → Table-3VstSlg4.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +1 -1
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +2 -2
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +2 -2
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +1 -1
- package/lib/{Twitter-B-GTNq1g.js → Twitter-D7PhLycr.js} +18 -18
- package/lib/{Twitter-BVlF0vEs.cjs → Twitter-DuHPeVW1.cjs} +1 -1
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +1 -1
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +1 -1
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +267 -254
- package/lib/{toggle-Bo07J-M7.cjs → toggle-DVCNvcqp.cjs} +1 -1
- package/lib/{toggle-MUGlaI1L.js → toggle-xchtz-Kf.js} +9 -9
- package/package.json +1 -1
package/lib/Emoji.js
CHANGED
|
@@ -5,7 +5,7 @@ import { jsx as p, jsxs as h, Fragment as I } from "react/jsx-runtime";
|
|
|
5
5
|
import { forwardRef as K, useRef as V, useState as E, useMemo as $, useEffect as D, useImperativeHandle as U } from "react";
|
|
6
6
|
import W from "scroll-into-view-if-needed";
|
|
7
7
|
import { u as Z } from "./index-0OnGZkVF.js";
|
|
8
|
-
import { A as J } from "./toggle-
|
|
8
|
+
import { A as J } from "./toggle-xchtz-Kf.js";
|
|
9
9
|
import { c as b } from "./index-DuZCJJSp.js";
|
|
10
10
|
import { EmojiPicker as d } from "frimousse";
|
|
11
11
|
import { SearchIcon as Y, LoaderIcon as X } from "lucide-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var B=Object.create;var H=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var F=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of V(t))!X.call(e,a)&&a!==r&&H(e,a,{get:()=>t[a],enumerable:!(n=$(t,a))||n.enumerable});return e};var q=(e,t,r)=>(r=e!=null?B(U(e)):{},F(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e));const E=require("./index-DLqogznp.cjs"),s=require("react/jsx-runtime"),i=require("react"),C=require("./toggle-
|
|
1
|
+
"use strict";var B=Object.create;var H=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var F=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of V(t))!X.call(e,a)&&a!==r&&H(e,a,{get:()=>t[a],enumerable:!(n=$(t,a))||n.enumerable});return e};var q=(e,t,r)=>(r=e!=null?B(U(e)):{},F(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e));const E=require("./index-DLqogznp.cjs"),s=require("react/jsx-runtime"),i=require("react"),C=require("./toggle-DVCNvcqp.cjs"),A=require("./dialog-DaHBd2zw.cjs"),T=require("./useButtonProps-bei1vI37.cjs"),G=require("re-resizable"),Y=require("./index-CNzHZDls.cjs"),I=require("./dom-dataset-BqoJhJXt.cjs"),J=require("./button-xNppt_aK.cjs");function K(e){return e=e||new Map,{all:e,on(t,r){const n=e.get(t);n?n.push(r):e.set(t,[r])},off(t,r){const n=e.get(t);n&&(r?n.splice(n.indexOf(r)>>>0,1):e.set(t,[]))},emit(t,r){let n=e.get(t);n&&[...n].map(a=>{a(r)}),n=e.get("*"),n&&[...n].map(a=>{a(t,r)})}}}let O;function W(){try{return O||(O=K()),O}catch{throw new Error("Error EventEmitter")}}const R="OPEN_EXCALIDRAW_SETTING_MODAL";function Q(e,t){W().on(e,t)}function ee(e,t){W().off(e,t)}function te(e){W().emit(R,e)}function re(){const e=T.useEditorInstance(),t=T.useButtonProps(L.name),r=T.useExtension(L.name),{tooltipOptions:n={},isActive:a=void 0}=(t==null?void 0:t.componentProps)??{},{editorDisabled:f}=T.useToggleActive(a),u=i.useMemo(()=>(r==null?void 0:r.options)||{},[r]),[c,_]=i.useState(null),[x,M]=i.useState({}),[b,y]=i.useState({elements:[],appState:{isLoading:!1},files:null}),[d,h]=i.useState(!1),[v,j]=i.useState(!0),[m,N]=i.useState(null),o=i.useCallback(p=>{p&&import("@excalidraw/excalidraw").then(g=>{_(g.Excalidraw)}).catch(N).finally(()=>j(!1))},[j]),l=i.useCallback(p=>{setTimeout(()=>{p.refresh()})},[]),w=i.useCallback((p,g,z)=>{M({elements:p,appState:{isLoading:!1},files:z})},[]),D=i.useCallback(()=>{if(!c){h(!1);return}e.chain().focus().setExcalidraw({data:x}).run(),h(!1)},[c,e,x,h]);return i.useEffect(()=>{const p=g=>{(g==null?void 0:g.editor)===e&&(h(!0),g&&y(g.data))};return Q(R,p),()=>{ee(R,p)}},[e,h]),i.useEffect(()=>{!v&&c&&d&&setTimeout(()=>{window.dispatchEvent(new Event("resize"))},400)},[v,c,d]),s.jsxs(A.Dialog,{onOpenChange:h,open:d,children:[s.jsx(A.DialogTrigger,{asChild:!0,children:s.jsx(C.ActionButton,{disabled:f,icon:"Excalidraw",tooltip:"Excalidraw",tooltipOptions:n,action:()=>{f||h(!0)}})}),s.jsxs(A.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[s.jsx(A.DialogTitle,{children:"Excalidraw"}),s.jsxs("div",{style:{height:"100%",borderWidth:1},children:[v&&s.jsx("p",{children:"Loading..."}),m&&s.jsx("p",{children:m&&m.message||"Error"}),s.jsx("div",{ref:o,style:{width:"100%",height:600},children:!v&&!m&&c?s.jsx(c,{initialData:b,langCode:"en",onChange:w,ref:l,...u.excalidrawProps}):null})]}),s.jsx(A.DialogFooter,{children:s.jsx(J.Button,{disabled:!c,onClick:D,type:"button",children:"Save changes"})})]})]})}const ne="_wrap_dra8y_1",se="_renderWrap_dra8y_7",ie="_handlerWrap_dra8y_30",ae="_disabled_dra8y_40",S={wrap:ne,renderWrap:se,handlerWrap:ie,disabled:ae},oe=10,ce=200,k=15,P={width:"100%",height:"100%",maxWidth:"100%"};function de({editor:e,node:t,updateAttributes:r}){const n=i.useRef(null),a=Y.useEditableEditor(),f=e.isActive(L.name),{data:u,width:c,height:_}=t.attrs,[x,M]=i.useState(null),[b,y]=i.useState(!0),[d,h]=i.useState(null),[v,j]=i.useState(100),m=i.useCallback(o=>()=>{j(l=>T.clamp(o==="minus"?l-k:l+k,oe,ce))},[]);i.useEffect(()=>{let o=!1;return import("@excalidraw/excalidraw").then(l=>{o||(n.current=l.exportToSvg)}).catch(l=>!o&&h(l)).finally(()=>!o&&y(!1)),()=>{o=!0}},[u]),i.useEffect(()=>{let o=!1;return(async()=>{if(!n.current||o||b||d||!u)return;const w=await n.current(u);o||(w.setAttribute("width","100%"),w.setAttribute("height","100%"),w.setAttribute("display","block"),M(w))})(),()=>{o=!0}},[u,b,d]);const N=o=>{r({width:o.width,height:o.height})};return s.jsx(E.NodeViewWrapper,{className:E.clsx(S.wrap,{[S.active]:f,[S.disabled]:!a}),children:s.jsx(G.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(_)},onResizeStop:(o,l,w,D)=>{N({width:Number.parseInt(c)+D.width,height:Number.parseInt(_)+D.height})},children:s.jsxs("div",{className:E.clsx(S.renderWrap,"render-wrapper"),style:{...P,overflow:"hidden"},children:[d&&s.jsx("div",{style:P,children:s.jsx("p",{children:d.message||d})}),b&&s.jsx("p",{children:"Loading..."}),!b&&!d&&x&&s.jsx("div",{dangerouslySetInnerHTML:{__html:(x==null?void 0:x.outerHTML)??""},style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${v/100})`,transition:"all ease-in-out .3s"}}),s.jsxs("div",{className:S.handlerWrap,children:[s.jsx(C.ActionButton,{action:m("minus"),disabled:!a,icon:"ZoomOut",tooltip:"Zoom Out"}),s.jsx(C.ActionButton,{action:m("plus"),disabled:!a,icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})}const Z={elements:[]},L=E.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:I.getDatasetAttribute("width")},height:{default:240,parseHTML:I.getDatasetAttribute("height")},data:{default:Z,parseHTML:I.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:t}){return["div",E.mergeAttributes(this.options.HTMLAttributes,e,I.nodeAttrsToDataset(t))]},addCommands(){return{setExcalidraw:e=>({tr:t,commands:r,chain:n})=>{var a,f,u;return e=e||{},e.data=e.data||Z,((u=(f=(a=t.selection)==null?void 0:a.node)==null?void 0:f.type)==null?void 0:u.name)==this.name?r.updateAttributes(this.name,e):n().insertContent({type:this.name,attrs:e}).run()}}},addNodeView(){return E.ReactNodeViewRenderer(de)},addInputRules(){return[E.nodeInputRule({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});exports.Excalidraw=L;exports.RichTextExcalidraw=re;exports.triggerOpenExcalidrawSettingModal=te;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { s as V, C as Z, N as $, n as B, R as U, m as X } from "./index-nFjllrEl.js";
|
|
2
2
|
import { jsxs as T, jsx as i } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo as F, useState as l, useCallback as A, useEffect as N, useRef as G } from "react";
|
|
4
|
-
import { A as C } from "./toggle-
|
|
4
|
+
import { A as C } from "./toggle-xchtz-Kf.js";
|
|
5
5
|
import { D as Y, a as q, b as J, c as K, d as Q } from "./dialog-Ce9Cjfft.js";
|
|
6
6
|
import { c as ee, u as te, d as re, a as ne, i as ie } from "./useButtonProps-D0SrPzuG.js";
|
|
7
7
|
import { Resizable as ae } from "re-resizable";
|
package/lib/Excalidraw.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-DLqogznp.cjs");const e=require("./Excalidraw-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-DLqogznp.cjs");const e=require("./Excalidraw-CajgZDjU.cjs");require("./dom-dataset-BqoJhJXt.cjs");exports.Excalidraw=e.Excalidraw;exports.RichTextExcalidraw=e.RichTextExcalidraw;
|
package/lib/Excalidraw.js
CHANGED
package/lib/ExportPdf.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-DLqogznp.cjs"),l=require("react/jsx-runtime"),y=require("./toggle-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-DLqogznp.cjs"),l=require("react/jsx-runtime"),y=require("./toggle-DVCNvcqp.cjs");require("react");require("./index-CNzHZDls.cjs");const h=require("./useButtonProps-bei1vI37.cjs");function E(e,n){var m;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||((m=t.contentWindow)==null?void 0:m.document);if(!o)return;const{paperSize:s,title:i="Echo Editor",margins:{top:d,right:c,bottom:r,left:a}}=n,p=`
|
|
2
2
|
<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
package/lib/ExportPdf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { E as b } from "./index-nFjllrEl.js";
|
|
2
2
|
import { jsx as u, Fragment as v } from "react/jsx-runtime";
|
|
3
|
-
import { A as y } from "./toggle-
|
|
3
|
+
import { A as y } from "./toggle-xchtz-Kf.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "./index-DuZCJJSp.js";
|
|
6
6
|
import { u as E, a as x } from "./useButtonProps-D0SrPzuG.js";
|
package/lib/ExportWord.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-DLqogznp.cjs"),u=require("docx"),n=require("prosemirror-docx"),i=require("react/jsx-runtime"),g=require("./toggle-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-DLqogznp.cjs"),u=require("docx"),n=require("prosemirror-docx"),i=require("react/jsx-runtime"),g=require("./toggle-DVCNvcqp.cjs"),y=require("react");require("./index-CNzHZDls.cjs");const l=require("./useButtonProps-bei1vI37.cjs"),B=typeof window<"u";function v(o,e){if(B){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 E(){const o=l.useButtonProps(p.name),[e,r]=y.useState(!1),{icon:t=void 0,tooltip:a=void 0,shortcutKeys:s=void 0,tooltipOptions:f={},action:c=void 0,isActive:x=void 0}=(o==null?void 0:o.componentProps)??{},{dataState:m,disabled:d,update:w}=l.useToggleActive(x),b=async()=>{d||e||c&&(r(!0),await c(),w(),r(!1))};return o?i.jsx(g.ActionButton,{action:b,dataState:m,disabled:d||e,icon:e?"Loader":t,shortcutKeys:s,tooltip:a,tooltipOptions:f}):i.jsx(i.Fragment,{})}const W={...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}}})}},R=new n.DocxSerializer(W,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=R.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=E;
|
package/lib/ExportWord.js
CHANGED
|
@@ -2,7 +2,7 @@ import { E as w } from "./index-nFjllrEl.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
|
-
import { A as y } from "./toggle-
|
|
5
|
+
import { A as y } from "./toggle-xchtz-Kf.js";
|
|
6
6
|
import { useState as E } from "react";
|
|
7
7
|
import "./index-DuZCJJSp.js";
|
|
8
8
|
import { u as g, a as k } from "./useButtonProps-D0SrPzuG.js";
|
package/lib/FontFamily.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-DylewabB.cjs"),F=require("./index-FSRjMsxW.cjs"),f=require("./useButtonProps-bei1vI37.cjs"),e=require("react/jsx-runtime"),m=require("react"),x=require("./ActionMenuButton-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-DylewabB.cjs"),F=require("./index-FSRjMsxW.cjs"),f=require("./useButtonProps-bei1vI37.cjs"),e=require("react/jsx-runtime"),m=require("react"),x=require("./ActionMenuButton-DYT5chmX.cjs");require("./index-CNzHZDls.cjs");const d=require("./dropdown-menu-CSCDQtq0.cjs");function M(){const{t:l}=F.useLocale(),n=f.useButtonProps(p.name),{icon:u=void 0,tooltip:a=void 0,items:r=[],isActive:s=void 0}=(n==null?void 0:n.componentProps)??{},{disabled:c,dataState:t}=f.useActive(s),o=m.useMemo(()=>(t==null?void 0:t.font)||l("editor.fontFamily.default.tooltip"),[t]);return n?e.jsxs(d.DropdownMenu,{children:[e.jsx(d.DropdownMenuTrigger,{asChild:!0,disabled:c,children:e.jsx(x.ActionMenuButton,{disabled:c,icon:u,title:(o==null?void 0:o.length)>12?`${o==null?void 0:o.slice(0,12)}...`:o,tooltip:a})}),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:o===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:n,extension:u,t:a}){var c;const r=f.ensureNameValueOptions(((c=u==null?void 0:u.options)==null?void 0:c.fontFamilyList)||[]),s=r.map(t=>({action:()=>{if(t.value==="Default"){n.chain().focus().unsetFontFamily().run();return}n.chain().focus().setFontFamily(t.value).run()},isActive:()=>n.isActive("textStyle",{fontFamily:t.value})||!1,title:t.name,font:t.value,default:t.value==="Default"}));return{componentProps:{tooltip:a("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:a("editor.fontFamily.default.tooltip"),font:a("editor.fontFamily.default.tooltip"),isActive:()=>!1,disabled:!1}},icon:"MenuDown",fontFamilyList:r}}}}}});exports.FontFamily=p;exports.RichTextFontFamily=M;
|
package/lib/FontFamily.js
CHANGED
|
@@ -3,7 +3,7 @@ import { u as F, D as y } from "./index-0OnGZkVF.js";
|
|
|
3
3
|
import { u as h, b as v, e as A } from "./useButtonProps-D0SrPzuG.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-htJNI0Fa.js";
|
|
7
7
|
import "./index-DuZCJJSp.js";
|
|
8
8
|
import { D as b, a as g, b as x, c as T, d as C } from "./dropdown-menu-CQykJhBs.js";
|
|
9
9
|
function S() {
|
package/lib/FontSize.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index-DLqogznp.cjs"),x=require("./index-FSRjMsxW.cjs"),S=require("./useButtonProps-bei1vI37.cjs"),o=require("react/jsx-runtime"),p=require("react"),h=require("./ActionMenuButton-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index-DLqogznp.cjs"),x=require("./index-FSRjMsxW.cjs"),S=require("./useButtonProps-bei1vI37.cjs"),o=require("react/jsx-runtime"),p=require("react"),h=require("./ActionMenuButton-DYT5chmX.cjs");require("./index-CNzHZDls.cjs");const l=require("./dropdown-menu-CSCDQtq0.cjs");function v(){const{t:e}=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:t}=S.useActive(a),r=p.useMemo(()=>(t==null?void 0:t.title)||e("editor.fontSize.default.tooltip"),[t]);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===e("editor.fontSize.default.tooltip")&&o.jsx(l.DropdownMenuSeparator,{})]},`font-size-${f}`))})]}):o.jsx(o.Fragment,{})}const z=m.Extension.create({name:"fontSize",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.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(t=>({title:t.value==="Default"?s("editor.fontSize.default.tooltip"):String(t.name),isActive:()=>{const{fontSize:r}=n.getAttributes("textStyle"),i=t.value==="Default",f=r==null||r==="";return i&&f?!0:n.isActive({fontSize:String(t.value)})||!1},action:()=>{if(t.value==="Default"){n.commands.unsetFontSize();return}n.commands.setFontSize(String(t.value))},default:t.value==="Default"||!1}));return{componentProps:{editor:n,tooltip:s("editor.fontSize.tooltip"),disabled:!1,items:a,maxHeight:280,icon:"MenuDown",isActive:()=>{const t=(a||[]).find(i=>i.isActive());return t&&!t.default?t:{title:s("editor.fontSize.default.tooltip"),isActive:()=>!1}}}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replaceAll(/["']+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:n})=>n().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}});exports.FontSize=z;exports.RichTextFontSize=v;
|
package/lib/FontSize.js
CHANGED
|
@@ -3,7 +3,7 @@ import { u as p, h as S } from "./index-0OnGZkVF.js";
|
|
|
3
3
|
import { u as z, b as h, e as v } from "./useButtonProps-D0SrPzuG.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-htJNI0Fa.js";
|
|
7
7
|
import "./index-DuZCJJSp.js";
|
|
8
8
|
import { D as F, a as M, b as g, c as b, d as w } from "./dropdown-menu-CQykJhBs.js";
|
|
9
9
|
function $() {
|
package/lib/Heading.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-DLqogznp.cjs"),M=require("./index-FSRjMsxW.cjs"),s=require("react/jsx-runtime"),x=require("react"),$=require("./ActionMenuButton-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-DLqogznp.cjs"),M=require("./index-FSRjMsxW.cjs"),s=require("react/jsx-runtime"),x=require("react"),$=require("./ActionMenuButton-DYT5chmX.cjs"),b=require("./index-CNzHZDls.cjs"),f=require("./useButtonProps-bei1vI37.cjs"),h=require("./dropdown-menu-CSCDQtq0.cjs");var j=v.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]}`,v.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=>v.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=f.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}=f.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($.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:b.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=>f.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
|
@@ -2,7 +2,7 @@ import { N as f, t as m, m as A } from "./index-nFjllrEl.js";
|
|
|
2
2
|
import { u as M, H } from "./index-0OnGZkVF.js";
|
|
3
3
|
import { jsx as d, Fragment as b, jsxs as g } from "react/jsx-runtime";
|
|
4
4
|
import { useMemo as $, Fragment as w } from "react";
|
|
5
|
-
import { A as x } from "./ActionMenuButton-
|
|
5
|
+
import { A as x } from "./ActionMenuButton-htJNI0Fa.js";
|
|
6
6
|
import { c as D } from "./index-DuZCJJSp.js";
|
|
7
7
|
import { u as y, b as N, h as k } from "./useButtonProps-D0SrPzuG.js";
|
|
8
8
|
import { D as L, a as C, b as T, c as I, e as K, d as P } from "./dropdown-menu-CQykJhBs.js";
|
package/lib/Highlight.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-DLqogznp.cjs"),e=require("react/jsx-runtime"),x=require("react"),C=require("./toggle-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-DLqogznp.cjs"),e=require("react/jsx-runtime"),x=require("react"),C=require("./toggle-DVCNvcqp.cjs"),m=require("./separator-DCQD8P6s.cjs");require("./index-CNzHZDls.cjs");const a=require("./useButtonProps-bei1vI37.cjs"),L=require("./Icon-BjR_or8V.cjs"),H=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,M=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,v=l.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-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]},addCommands(){return{setHighlight:t=>({commands:r})=>r.setMark(this.name,t),toggleHighlight:t=>({commands:r})=>r.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:H,type:this.type})]},addPasteRules(){return[l.markPasteRule({find:M,type:this.type})]}});function j({fill:t}){return e.jsx("svg",{height:"18px",version:"1.1",viewBox:"0 0 256 256",width:"18px",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("g",{fill:"none",fillRule:"evenodd",stroke:"none",strokeWidth:1,children:e.jsxs("g",{id:"icon/背景颜色",children:[e.jsx("g",{fill:"currentColor",children:e.jsxs("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",children:[e.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"}),e.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"}),e.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"})]})}),e.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 y(){const t=a.useButtonProps(d.name),{tooltip:r=void 0,isActive:s=void 0,defaultColor:i=void 0,colors:o,action:n,shortcutKeys:g}=(t==null?void 0:t.componentProps)??{},{editorDisabled:h}=a.useActive(s),[u,f]=x.useState(i);function p(c){h||n&&(n==null||n(c),f(c))}return t?e.jsx(m.ColorPicker,{colors:o,disabled:h,highlight:!0,onChange:p,value:u,children:e.jsx(C.ActionButton,{disabled:h,tooltip:r,shortcutKeys:g,children:e.jsxs("span",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[4px] richtext-text-sm",children:[e.jsx(j,{fill:u}),e.jsx(L.IconComponent,{className:"!richtext-h-3 !richtext-w-3 richtext-text-zinc-500",name:"MenuDown"})]})})}):e.jsx(e.Fragment,{})}const d=v.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:r,t:s,extension:i})=>({componentProps:{action:o=>{if(typeof o=="string"){r.storage.highlight.currentColor=o,r.chain().focus().setHighlight({color:o}).run();return}r.chain().focus().unsetHighlight().run()},isActive:()=>r.isActive("highlight")||!1,disabled:!1,shortcutKeys:i.options.shortcutKeys??["⇧","mod","H"],tooltip:s("editor.highlight.tooltip"),defaultColor:i.options.defaultColor}})}},addKeyboardShortcuts(){var t;return{...(t=this.parent)==null?void 0:t.call(this),"Mod-Shift-h":()=>{const r=this.storage.currentColor||this.options.defaultColor;if(!r){const{color:i}=this.editor.getAttributes("highlight");return i?this.editor.chain().focus().unsetHighlight().run():!1}return this.editor.isActive("highlight",{color:r})?this.editor.chain().focus().unsetHighlight().run():this.editor.chain().focus().setHighlight({color:r}).run()}}}});exports.Highlight=d;exports.RichTextHighlight=y;
|
package/lib/Highlight.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { M as f, h as p, j as m, m as C } from "./index-nFjllrEl.js";
|
|
2
2
|
import { jsx as r, jsxs as h, Fragment as L } from "react/jsx-runtime";
|
|
3
3
|
import { useState as x } from "react";
|
|
4
|
-
import { A as H } from "./toggle-
|
|
4
|
+
import { A as H } from "./toggle-xchtz-Kf.js";
|
|
5
5
|
import { C as M } from "./separator-6SnwzytZ.js";
|
|
6
6
|
import "./index-DuZCJJSp.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { u as v, b as A } from "./useButtonProps-D0SrPzuG.js";
|
|
8
|
+
import { I as y } from "./Icon-C-qYUAS1.js";
|
|
9
9
|
const b = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, k = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g, R = f.create({
|
|
10
10
|
name: "highlight",
|
|
11
11
|
addOptions() {
|
|
@@ -126,14 +126,14 @@ function w({ fill: t }) {
|
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
function $() {
|
|
129
|
-
const t =
|
|
129
|
+
const t = v(T.name), {
|
|
130
130
|
tooltip: e = void 0,
|
|
131
131
|
isActive: n = void 0,
|
|
132
132
|
defaultColor: o = void 0,
|
|
133
133
|
colors: i,
|
|
134
134
|
action: s,
|
|
135
135
|
shortcutKeys: c
|
|
136
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: l } =
|
|
136
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: l } = A(n), [a, d] = x(o);
|
|
137
137
|
function g(u) {
|
|
138
138
|
l || s && (s == null || s(u), d(u));
|
|
139
139
|
}
|
|
@@ -154,7 +154,7 @@ function $() {
|
|
|
154
154
|
children: /* @__PURE__ */ h("span", { className: "richtext-flex richtext-items-center richtext-justify-center richtext-gap-[4px] richtext-text-sm", children: [
|
|
155
155
|
/* @__PURE__ */ r(w, { fill: a }),
|
|
156
156
|
/* @__PURE__ */ r(
|
|
157
|
-
|
|
157
|
+
y,
|
|
158
158
|
{
|
|
159
159
|
className: "!richtext-h-3 !richtext-w-3 richtext-text-zinc-500",
|
|
160
160
|
name: "MenuDown"
|
package/lib/History.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./index-DLqogznp.cjs"),C=require("@tiptap/pm/state"),x=require("@tiptap/pm/view"),R=require("./index-DCJheRBq.cjs"),S=require("react/jsx-runtime"),L=require("./toggle-Bo07J-M7.cjs");require("react");require("./index-CNzHZDls.cjs");const W=require("./index-DmOTQudI.cjs"),A=require("./useButtonProps-bei1vI37.cjs");function q(r={}){return new p.Plugin({view(e){return new U(e,r)}})}class U{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 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,n,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let c=e.nodeBefore,h=e.nodeAfter;if(c||h){let m=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(m){let v=m.getBoundingClientRect(),M=c?v.bottom:v.top;c&&h&&(M=(M+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;n={left:v.left,right:v.right,top:M-b,bottom:M+b}}}}if(!n){let c=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;n={left:c.left-h,right:c.left+h,top:c.top,bottom:c.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")d=-pageXOffset,u=-pageYOffset;else{let c=a.getBoundingClientRect(),h=c.width/a.offsetWidth,m=c.height/a.offsetHeight;d=c.left-a.scrollLeft*h,u=c.top-a.scrollTop*m}this.element.style.left=(n.left-d)/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,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=p.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 p.Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return f.valid(n)?new f(n):p.Selection.near(n)}content(){return p.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.isTextblock||!X(e)||!Y(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&&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&&!p.NodeSelection.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),n=!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;p.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):p.Selection.near(t)}}function B(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function X(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.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||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Y(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.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||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function J(){return new p.Plugin({props:{decorations:ee,createSelectionBetween(r,e,t){return e.pos==t.pos&&f.valid(t)?new f(t):null},handleClick:Q,handleKeyDown:Z,handleDOMEvents:{beforeinput:$}}})}const Z=R.keydownHandler({ArrowLeft:I("horiz",-1),ArrowRight:I("horiz",1),ArrowUp:I("vert",-1),ArrowDown:I("vert",1)});function I(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,o){let s=n.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof p.TextSelection){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let d=f.findGapCursorFrom(l,e,a);return d?(i&&i(n.tr.setSelection(new f(d))),!0):!1}}function Q(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!f.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&p.NodeSelection.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new f(n))),!0)}function $(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof f))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=p.Fragment.empty;for(let s=n.length-1;s>=0;s--)i=p.Fragment.from(n[s].createAndFill(null,i));let o=r.state.tr.replace(t.pos,t.pos,new p.Slice(i,0,0));return o.setSelection(p.TextSelection.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function ee(r){if(!(r.selection instanceof f))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",R.DecorationSet.create(r.doc,[R.Decoration.widget(r.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 te(this,e)};g.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?g.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};g.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};g.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};g.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};g.from=function(e){return e instanceof g?e:e&&e.length?new j(e):g.empty};var j=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.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 te=(function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.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,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},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})(g);const ne=500;class w{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,o;t&&(i=this.remapping(n,this.items.length),o=i.maps.length);let s=e.tr,l,a,d=[],u=[];return this.items.forEach((c,h)=>{if(!c.step){i||(i=this.remapping(n,h+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,n).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,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]),h=new y(e.mapping.maps[u],c,t),m;(m=a&&a.merge(h))&&(h=m,u?o.pop():l=l.slice(0,l.length-1)),o.push(h),t&&(s++,t=void 0),i||(a=h)}let d=s-n.depth;return d>re&&(l=ie(l,d),s-=d),new w(l.append(o),s)}remapping(e,t){let n=new p.Mapping;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-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 w(this.items.append(e.map(t=>new y(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},i);let a=t;this.items.forEach(h=>{let m=o.getMirror(--a);if(m==null)return;s=Math.min(s,m);let v=o.maps[m];if(h.step){let M=e.steps[m].invert(e.docs[m]),b=h.selection&&h.selection.map(o.slice(a+1,m));b&&l++,n.push(new y(v,M,b))}else n.push(new y(v))},i);let d=[];for(let h=t;h<s;h++)d.push(new y(o.maps[h]));let u=this.items.slice(0,i).append(d).append(n),c=new w(u,l);return c.emptyItemCount()>ne&&(c=c.compress(this.items.length-n.length)),c}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,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(n)),d=a&&a.getMap();if(n--,d&&t.appendMap(d,n),a){let u=s.selection&&s.selection.map(t.slice(n));u&&o++;let c=new y(d.invert(),a,u),h,m=i.length-1;(h=i.length&&i[m].merge(c))?i[m]=h:i.push(c)}}else s.map&&n--},this.items.length,0),new w(g.from(i.reverse()),o)}}w.empty=new w(g.empty,0);function ie(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class y{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 y(t.getMap().invert(),t,this.selection)}}}class P{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}}const re=20;function oe(r,e,t,n){let i=t.getMeta(E),o;if(i)return i.historyState;t.getMeta(ae)&&(r=new P(r.done,r.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(s&&s.getMeta(E))return s.getMeta(E).redo?new P(r.done.addTransform(t,void 0,n,T(e)),r.undone,F(t.mapping.maps),r.prevTime,r.prevComposition):new P(r.done,r.undone.addTransform(t,void 0,n,T(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!s&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!se(t,r.prevRanges)),d=s?D(r.prevRanges,t.mapping):F(t.mapping.maps);return new P(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,T(e)),w.empty,d,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new P(r.done.rebased(t,o),r.undone.rebased(t,o),D(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new P(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),D(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function se(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function F(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,o,s)=>e.push(o,s));return e}function D(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),o=e.map(r[n+1],-1);i<=o&&t.push(i,o)}return t}function le(r,e,t){let n=T(e),i=E.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),i,n),a=new P(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(E,{redo:t,historyState:a})}let k=!1,V=null;function T(r){let e=r.plugins;if(V!=e){k=!1,V=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){k=!0;break}}return k}const E=new p.PluginKey("history"),ae=new p.PluginKey("closeHistory");function de(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new p.Plugin({key:E,state:{init(){return new P(w.empty,w.empty,null,0,-1)},apply(e,t,n){return oe(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?G:n=="historyRedo"?_:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function H(r,e){return(t,n)=>{let i=E.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let o=le(i,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const G=H(!1,!0),_=H(!0,!0);p.Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:r=>r.length,wordCounter:r=>r.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=r=>{const e=(r==null?void 0:r.node)||this.editor.state.doc;if(((r==null?void 0:r.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=r=>{const e=(r==null?void 0:r.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let r=!1;return[new C.Plugin({key:new C.PluginKey("characterCount"),appendTransaction:(e,t,n)=>{if(r)return;const i=this.options.limit;if(i==null||i===0){r=!0;return}const o=this.storage.characters({node:n.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=n.tr.deleteRange(l,a);return r=!0,d}r=!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}),o=this.storage.characters({node:e.doc});if(o<=n||i>n&&o>n&&o<=i)return!0;if(i>n&&o>n&&o>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-n,d=l-a,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>n)}})]}});p.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[q(this.options)]}});p.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("focus"),props:{decorations:({doc:r,selection:e})=>{const{isEditable:t,isFocused:n}=this.editor,{anchor:i}=e,o=[];if(!t||!n)return x.DecorationSet.create(r,[]);let s=0;this.options.mode==="deepest"&&r.descendants((a,d)=>{if(a.isText)return;if(!(i>=d&&i<=d+a.nodeSize-1))return!1;s+=1});let l=0;return r.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(x.Decoration.node(d,d+a.nodeSize,{class:this.options.className}))}),x.DecorationSet.create(r,o)}}})]}});p.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[J()]},extendNodeSchema(r){var e;const t={name:r.name,options:r.options,storage:r.storage};return{allowGapCursor:(e=p.callOrReturn(p.getExtensionField(r,"allowGapCursor",t)))!=null?e:null}}});p.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("placeholder"),props:{decorations:({doc:r,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:n}=e,i=[];if(!t)return null;const o=this.editor.isEmpty;return r.descendants((s,l)=>{const a=n>=l&&n<=l+s.nodeSize,d=!s.isLeaf&&p.isNodeEmpty(s);if((a||!this.options.showOnlyCurrent)&&d){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const c=x.Decoration.node(l,l+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});i.push(c)}return this.options.includeChildren}),x.DecorationSet.create(r,i)}}})]}});p.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:r,options:e}=this;return[new C.Plugin({key:new C.PluginKey("selection"),props:{decorations(t){return t.selection.empty||r.isFocused||!r.isEditable||p.isNodeSelection(t.selection)||r.view.dragging?null:x.DecorationSet.create(t.doc,[x.Decoration.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function K({types:r,node:e}){return e&&Array.isArray(r)&&r.includes(e.type)||(e==null?void 0:e.type)===r}p.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var r;const e=new C.PluginKey(this.name),t=this.options.node||((r=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:r.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,o,s)=>{const{doc:l,tr:a,schema:d}=s,u=e.getState(s),c=l.content.size,h=d.nodes[t];if(u)return a.insert(c,h.create())},state:{init:(i,o)=>{const s=o.tr.doc.lastChild;return!K({node:s,types:n})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const s=i.doc.lastChild;return!K({node:s,types:n})}}})]}});var ce=p.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:r,dispatch:e})=>G(r,e),redo:()=>({state:r,dispatch:e})=>_(r,e)}},addProseMirrorPlugins(){return[de(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 r=A.useButtonProps(N.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((u=r==null?void 0:r.componentProps)==null?void 0:u.undo)??{},{disabled:l}=A.useActive(s),a=W.icons[e],d=()=>{l||o&&o()};return!r||!a?S.jsx(S.Fragment,{}):S.jsx(L.ActionButton,{action:d,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i})}function pe(){var d;const r=A.useButtonProps(N.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((d=r==null?void 0:r.componentProps)==null?void 0:d.redo)??{},{disabled:l}=A.useActive(s),a=()=>{l||o&&o()};return r?S.jsx(L.ActionButton,{action:a,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i}):S.jsx(S.Fragment,{})}const N=ce.extend({addOptions(){var r;return{...(r=this.parent)==null?void 0:r.call(this),depth:100,newGroupDelay:500,button:({editor:e,t,extension:n})=>{var i,o;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:((o=n.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 p=require("./index-DLqogznp.cjs"),C=require("@tiptap/pm/state"),x=require("@tiptap/pm/view"),R=require("./index-DCJheRBq.cjs"),S=require("react/jsx-runtime"),L=require("./toggle-DVCNvcqp.cjs");require("react");require("./index-CNzHZDls.cjs");const A=require("./useButtonProps-bei1vI37.cjs"),W=require("./index-DmOTQudI.cjs");function q(r={}){return new p.Plugin({view(e){return new U(e,r)}})}class U{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 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,n,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let c=e.nodeBefore,h=e.nodeAfter;if(c||h){let m=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(m){let v=m.getBoundingClientRect(),M=c?v.bottom:v.top;c&&h&&(M=(M+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;n={left:v.left,right:v.right,top:M-b,bottom:M+b}}}}if(!n){let c=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;n={left:c.left-h,right:c.left+h,top:c.top,bottom:c.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")d=-pageXOffset,u=-pageYOffset;else{let c=a.getBoundingClientRect(),h=c.width/a.offsetWidth,m=c.height/a.offsetHeight;d=c.left-a.scrollLeft*h,u=c.top-a.scrollTop*m}this.element.style.left=(n.left-d)/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,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=p.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 p.Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return f.valid(n)?new f(n):p.Selection.near(n)}content(){return p.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.isTextblock||!X(e)||!Y(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&&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&&!p.NodeSelection.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),n=!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;p.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):p.Selection.near(t)}}function B(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function X(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.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||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Y(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.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||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function J(){return new p.Plugin({props:{decorations:ee,createSelectionBetween(r,e,t){return e.pos==t.pos&&f.valid(t)?new f(t):null},handleClick:Q,handleKeyDown:Z,handleDOMEvents:{beforeinput:$}}})}const Z=R.keydownHandler({ArrowLeft:I("horiz",-1),ArrowRight:I("horiz",1),ArrowUp:I("vert",-1),ArrowDown:I("vert",1)});function I(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,o){let s=n.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof p.TextSelection){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let d=f.findGapCursorFrom(l,e,a);return d?(i&&i(n.tr.setSelection(new f(d))),!0):!1}}function Q(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!f.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&p.NodeSelection.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new f(n))),!0)}function $(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof f))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=p.Fragment.empty;for(let s=n.length-1;s>=0;s--)i=p.Fragment.from(n[s].createAndFill(null,i));let o=r.state.tr.replace(t.pos,t.pos,new p.Slice(i,0,0));return o.setSelection(p.TextSelection.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function ee(r){if(!(r.selection instanceof f))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",R.DecorationSet.create(r.doc,[R.Decoration.widget(r.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 te(this,e)};g.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?g.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};g.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};g.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};g.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};g.from=function(e){return e instanceof g?e:e&&e.length?new j(e):g.empty};var j=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.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 te=(function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.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,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},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})(g);const ne=500;class w{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,o;t&&(i=this.remapping(n,this.items.length),o=i.maps.length);let s=e.tr,l,a,d=[],u=[];return this.items.forEach((c,h)=>{if(!c.step){i||(i=this.remapping(n,h+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,n).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,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]),h=new y(e.mapping.maps[u],c,t),m;(m=a&&a.merge(h))&&(h=m,u?o.pop():l=l.slice(0,l.length-1)),o.push(h),t&&(s++,t=void 0),i||(a=h)}let d=s-n.depth;return d>re&&(l=ie(l,d),s-=d),new w(l.append(o),s)}remapping(e,t){let n=new p.Mapping;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-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 w(this.items.append(e.map(t=>new y(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},i);let a=t;this.items.forEach(h=>{let m=o.getMirror(--a);if(m==null)return;s=Math.min(s,m);let v=o.maps[m];if(h.step){let M=e.steps[m].invert(e.docs[m]),b=h.selection&&h.selection.map(o.slice(a+1,m));b&&l++,n.push(new y(v,M,b))}else n.push(new y(v))},i);let d=[];for(let h=t;h<s;h++)d.push(new y(o.maps[h]));let u=this.items.slice(0,i).append(d).append(n),c=new w(u,l);return c.emptyItemCount()>ne&&(c=c.compress(this.items.length-n.length)),c}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,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(n)),d=a&&a.getMap();if(n--,d&&t.appendMap(d,n),a){let u=s.selection&&s.selection.map(t.slice(n));u&&o++;let c=new y(d.invert(),a,u),h,m=i.length-1;(h=i.length&&i[m].merge(c))?i[m]=h:i.push(c)}}else s.map&&n--},this.items.length,0),new w(g.from(i.reverse()),o)}}w.empty=new w(g.empty,0);function ie(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class y{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 y(t.getMap().invert(),t,this.selection)}}}class P{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}}const re=20;function oe(r,e,t,n){let i=t.getMeta(E),o;if(i)return i.historyState;t.getMeta(ae)&&(r=new P(r.done,r.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(s&&s.getMeta(E))return s.getMeta(E).redo?new P(r.done.addTransform(t,void 0,n,T(e)),r.undone,F(t.mapping.maps),r.prevTime,r.prevComposition):new P(r.done,r.undone.addTransform(t,void 0,n,T(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!s&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!se(t,r.prevRanges)),d=s?D(r.prevRanges,t.mapping):F(t.mapping.maps);return new P(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,T(e)),w.empty,d,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new P(r.done.rebased(t,o),r.undone.rebased(t,o),D(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new P(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),D(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function se(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function F(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,o,s)=>e.push(o,s));return e}function D(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),o=e.map(r[n+1],-1);i<=o&&t.push(i,o)}return t}function le(r,e,t){let n=T(e),i=E.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),i,n),a=new P(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(E,{redo:t,historyState:a})}let k=!1,V=null;function T(r){let e=r.plugins;if(V!=e){k=!1,V=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){k=!0;break}}return k}const E=new p.PluginKey("history"),ae=new p.PluginKey("closeHistory");function de(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new p.Plugin({key:E,state:{init(){return new P(w.empty,w.empty,null,0,-1)},apply(e,t,n){return oe(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?G:n=="historyRedo"?_:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function H(r,e){return(t,n)=>{let i=E.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let o=le(i,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const G=H(!1,!0),_=H(!0,!0);p.Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:r=>r.length,wordCounter:r=>r.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=r=>{const e=(r==null?void 0:r.node)||this.editor.state.doc;if(((r==null?void 0:r.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=r=>{const e=(r==null?void 0:r.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let r=!1;return[new C.Plugin({key:new C.PluginKey("characterCount"),appendTransaction:(e,t,n)=>{if(r)return;const i=this.options.limit;if(i==null||i===0){r=!0;return}const o=this.storage.characters({node:n.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=n.tr.deleteRange(l,a);return r=!0,d}r=!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}),o=this.storage.characters({node:e.doc});if(o<=n||i>n&&o>n&&o<=i)return!0;if(i>n&&o>n&&o>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-n,d=l-a,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>n)}})]}});p.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[q(this.options)]}});p.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("focus"),props:{decorations:({doc:r,selection:e})=>{const{isEditable:t,isFocused:n}=this.editor,{anchor:i}=e,o=[];if(!t||!n)return x.DecorationSet.create(r,[]);let s=0;this.options.mode==="deepest"&&r.descendants((a,d)=>{if(a.isText)return;if(!(i>=d&&i<=d+a.nodeSize-1))return!1;s+=1});let l=0;return r.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(x.Decoration.node(d,d+a.nodeSize,{class:this.options.className}))}),x.DecorationSet.create(r,o)}}})]}});p.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[J()]},extendNodeSchema(r){var e;const t={name:r.name,options:r.options,storage:r.storage};return{allowGapCursor:(e=p.callOrReturn(p.getExtensionField(r,"allowGapCursor",t)))!=null?e:null}}});p.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("placeholder"),props:{decorations:({doc:r,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:n}=e,i=[];if(!t)return null;const o=this.editor.isEmpty;return r.descendants((s,l)=>{const a=n>=l&&n<=l+s.nodeSize,d=!s.isLeaf&&p.isNodeEmpty(s);if((a||!this.options.showOnlyCurrent)&&d){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const c=x.Decoration.node(l,l+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});i.push(c)}return this.options.includeChildren}),x.DecorationSet.create(r,i)}}})]}});p.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:r,options:e}=this;return[new C.Plugin({key:new C.PluginKey("selection"),props:{decorations(t){return t.selection.empty||r.isFocused||!r.isEditable||p.isNodeSelection(t.selection)||r.view.dragging?null:x.DecorationSet.create(t.doc,[x.Decoration.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function K({types:r,node:e}){return e&&Array.isArray(r)&&r.includes(e.type)||(e==null?void 0:e.type)===r}p.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var r;const e=new C.PluginKey(this.name),t=this.options.node||((r=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:r.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,o,s)=>{const{doc:l,tr:a,schema:d}=s,u=e.getState(s),c=l.content.size,h=d.nodes[t];if(u)return a.insert(c,h.create())},state:{init:(i,o)=>{const s=o.tr.doc.lastChild;return!K({node:s,types:n})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const s=i.doc.lastChild;return!K({node:s,types:n})}}})]}});var ce=p.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:r,dispatch:e})=>G(r,e),redo:()=>({state:r,dispatch:e})=>_(r,e)}},addProseMirrorPlugins(){return[de(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 r=A.useButtonProps(N.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((u=r==null?void 0:r.componentProps)==null?void 0:u.undo)??{},{disabled:l}=A.useActive(s),a=W.icons[e],d=()=>{l||o&&o()};return!r||!a?S.jsx(S.Fragment,{}):S.jsx(L.ActionButton,{action:d,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i})}function pe(){var d;const r=A.useButtonProps(N.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((d=r==null?void 0:r.componentProps)==null?void 0:d.redo)??{},{disabled:l}=A.useActive(s),a=()=>{l||o&&o()};return r?S.jsx(L.ActionButton,{action:a,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i}):S.jsx(S.Fragment,{})}const N=ce.extend({addOptions(){var r;return{...(r=this.parent)==null?void 0:r.call(this),depth:100,newGroupDelay:500,button:({editor:e,t,extension:n})=>{var i,o;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:((o=n.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;
|
package/lib/History.js
CHANGED
|
@@ -3,11 +3,11 @@ import { Plugin as I, PluginKey as b } from "@tiptap/pm/state";
|
|
|
3
3
|
import { DecorationSet as O, Decoration as R } from "@tiptap/pm/view";
|
|
4
4
|
import { k as le, D as ae, a as de } from "./index-BeUrdBxf.js";
|
|
5
5
|
import { jsx as T, Fragment as j } from "react/jsx-runtime";
|
|
6
|
-
import { A as U } from "./toggle-
|
|
6
|
+
import { A as U } from "./toggle-xchtz-Kf.js";
|
|
7
7
|
import "react";
|
|
8
8
|
import "./index-DuZCJJSp.js";
|
|
9
|
-
import { i as ce } from "./index-BQ17A_37.js";
|
|
10
9
|
import { u as X, b as Y } from "./useButtonProps-D0SrPzuG.js";
|
|
10
|
+
import { i as ce } from "./index-BQ17A_37.js";
|
|
11
11
|
function ue(i = {}) {
|
|
12
12
|
return new N({
|
|
13
13
|
view(e) {
|
package/lib/HorizontalRule.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-DLqogznp.cjs"),l=require("@tiptap/pm/state"),f=require("./toggle-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-DLqogznp.cjs"),l=require("@tiptap/pm/state"),f=require("./toggle-DVCNvcqp.cjs"),h=require("react/jsx-runtime");require("react");require("./index-CNzHZDls.cjs");const T=require("./useButtonProps-bei1vI37.cjs");var A=i.Node3.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",i.mergeAttributes(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,n)=>n.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:n})=>{if(!i.canInsertNode(n,n.schema.nodes[this.name]))return!1;const{selection:r}=n,{$to:s}=r,c=t();return i.isNodeSelection(r)?c.insertContentAt(s.pos,{type:this.name}):c.insertContent({type:this.name}),c.command(({state:a,tr:e,dispatch:p})=>{if(p){const{$to:o}=e.selection,u=o.end();if(o.nodeAfter)o.nodeAfter.isTextblock?e.setSelection(l.TextSelection.create(e.doc,o.pos+1)):o.nodeAfter.isBlock?e.setSelection(l.NodeSelection.create(e.doc,o.pos)):e.setSelection(l.TextSelection.create(e.doc,o.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||o.parent.type.contentMatch.defaultType,m=d==null?void 0:d.create();m&&(e.insert(u,m),e.setSelection(l.TextSelection.create(e.doc,u+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[i.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});function R(){const t=T.useButtonProps(y.name),{icon:n=void 0,tooltip:r=void 0,shortcutKeys:s=void 0,tooltipOptions:c={},action:a=void 0,isActive:e=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:o,update:u}=T.useToggleActive(e),d=()=>{o||a&&(a(),u())};return t?h.jsx(f.ActionButton,{action:d,dataState:p,disabled:o,icon:n,shortcutKeys:s,tooltip:r,tooltipOptions:c}):h.jsx(h.Fragment,{})}const y=A.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:n,t:r,extension:s})=>({component:f.ActionButton,componentProps:{action:()=>n.commands.setHorizontalRule(),disabled:!n.can().setHorizontalRule(),icon:"Minus",shortcutKeys:s.options.shortcutKeys??["mod","alt","S"],tooltip:r("editor.horizontalrule.tooltip")}})}},addKeyboardShortcuts(){return{"Mod-Alt-s":()=>this.editor.commands.setHorizontalRule()}},renderHTML(){return["div",i.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}});exports.HorizontalRule=y;exports.RichTextHorizontalRule=R;
|
package/lib/HorizontalRule.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { N as T, n as A, l as y, o as H, m as h } from "./index-nFjllrEl.js";
|
|
2
2
|
import { TextSelection as u, NodeSelection as R } from "@tiptap/pm/state";
|
|
3
|
-
import { A as f } from "./toggle-
|
|
3
|
+
import { A as f } from "./toggle-xchtz-Kf.js";
|
|
4
4
|
import { jsx as m, Fragment as M } from "react/jsx-runtime";
|
|
5
5
|
import "react";
|
|
6
6
|
import "./index-DuZCJJSp.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("./index-DLqogznp.cjs"),s=require("react/jsx-runtime"),b=require("react"),y=require("re-resizable"),h=require("./dom-dataset-BqoJhJXt.cjs"),S=require("./toggle-
|
|
1
|
+
"use strict";const u=require("./index-DLqogznp.cjs"),s=require("react/jsx-runtime"),b=require("react"),y=require("re-resizable"),h=require("./dom-dataset-BqoJhJXt.cjs"),S=require("./toggle-DVCNvcqp.cjs"),I=require("./index-CNzHZDls.cjs"),g=require("./useButtonProps-bei1vI37.cjs"),P=require("./input-tU3H__39.cjs"),R=require("./button-xNppt_aK.cjs"),m={youtube:{example:"https://www.youtube.com/watch?v=I4sMhHbHYXM",src:"https://www.youtube.com/embed/I4sMhHbHYXM",srcPrefix:"https://www.youtube.com/embed",linkRule:[/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\s/]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[&?]v=)|youtu\.be\/)([\w-]{11})/]},youku:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html?spm=a2h0c.8166622.PhoneSokuUgc_4.dtitle",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"https://player.youku.com/embed",linkRule:[String.raw`v.youku.com\/v_show\/id_\w+\=*`],idRule:String.raw`id_\w+\=*`},bilibili:{example:"https://www.bilibili.com/video/BV1EJ411u7DN",src:"https://player.bilibili.com/player.html?bvid=BV1EJ411u7DN",srcPrefix:"https://player.bilibili.com/player.html?bvid",linkRule:[String.raw`www.bilibili.com\/video\/\w+`]},qqvideo:{example:"https://v.qq.com/x/cover/mzc0020006aw1mn/u0033nvzb5v.html",src:"https://v.qq.com/txp/iframe/player.html?vid=u0033nvzb5v",srcPrefix:"https://v.qq.com/txp/iframe/player.html?vid",linkRule:[String.raw`v.qq.com\/x\/cover\/\w+\/\w+`]},amap:{example:"https://ditu.amap.com/",src:"https://www.amap.com/place/B000A45467",srcPrefix:"",linkRule:[String.raw`\.amap\.com`]},baidu_map:{example:"https://j.map.baidu.com/15/fo",src:"https://j.map.baidu.com/15/fo",srcPrefix:"",linkRule:[String.raw`map\.baidu\.com`]},modao:{example:"https://free.modao.cc/app/2cd26580a6717a147454df7470e7ec464093cba3/embed/v2#screen=sk71k6d1dfxulzx",src:"https://free.modao.cc/app/6UkpAxcGE3nPz52GLqhnOZgC7MATBSy/embed/v2",srcPrefix:"",linkRule:[String.raw`https:\/\/\w+.modao.cc\/app\/\w+\/embed\/v2`],tips:"Modao > More > Share > Embed > COPY"},lanhu:{example:"https://lanhuapp.com/link/#/invite?sid=evP7L",src:"https://lanhuapp.com/url/evP7L",srcPrefix:"",linkRule:[String.raw`https:\/\/lanhuapp.com\/url\/\w+`],tips:"Lanhu > Project > Share > Copy Link"},figma:{example:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",src:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",srcPrefix:"https://www.figma.com/embed?embed_host=share&url",linkRule:[String.raw`https:\/\/www.figma.com\/file\/\w+`]},canva:{example:"https://www.canva.cn/design/DAD61-t29UI/view",src:"https://www.canva.cn/design/DAD61-t29UI/view",srcPrefix:"",linkRule:[String.raw`https:\/\/www.canva.cn\/design\/.+\/view`]},processon:{example:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",src:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",srcPrefix:"",linkRule:[String.raw`https:\/\/www.processon.com\/embed\/\w+`]},codepen:{example:"https://codepen.io/mekery/embed/YzyrKOJ",src:"https://codepen.io/mekery/embed/YzyrKOJ",srcPrefix:"",linkRule:[String.raw`https:\/\/codepen.io\/.+\/embed\/\w+`]},jinshuju:{example:"https://jinshuju.net/f/q9YvVf",src:"https://jinshuju.net/f/q9YvVf",srcPrefix:"",linkRule:[String.raw`https:\/\/jinshuju.net\/f\/\w+`]},iframe:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"",linkRule:[".+"]},googlemaps:{example:"https://goo.gl/maps/8Ys8b4K1ZJY2",src:"https://www.google.com/maps/embed?pb=https://goo.gl/maps/8Ys8b4K1ZJY2",srcPrefix:"",linkRule:[String.raw`https:\/\/goo.gl\/maps\/\w+`]}};function j(e){const t=m.youtube,i=e.matchedUrl;e.validLink=!0;const r=i.split("="),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}/${c}`,e.validId=!0}return e}function M(e){const t=m.youku,i=e.matchedUrl,r=t.idRule,n=new RegExp(r),c=i.match(n);if(c&&c.length>0){const o=c[0].slice(3);e.validId=!0,e.src=`${t.srcPrefix}/${o}`}else e.validId=!1;return e}function q(e){const t=m.bilibili,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function N(e){const t=m.qqvideo,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function U(e,t){return t.src=e,t.validId=!0,t}function A(e,t){return t.src=e,t.validId=!0,t}function D(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function L(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function $(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function _(e){const t=m.figma;return e.src=`${t.srcPrefix}=${encodeURIComponent(e.matchedUrl)}`,e.validId=!0,e.originalLink=e.matchedUrl,e}function T(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function z(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function Y(e){return e.src=`${e.matchedUrl}`,e.validId=!0,e.originalLink=e.src,e}function C(e,t){return t.src=`${t.matchedUrl}?background=white&banner=show&embedded=true`,t.validId=!0,t.originalLink=e,t}function E(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function H(e,t,i){if(e==="googlemaps")return i.validLink=!0,i.matchedUrl=t,i;const n=m[e].linkRule;for(const c of n){const o=new RegExp(c),a=t.match(o);if(a&&a.length>0)return i.validLink=!0,i.matchedUrl=e==="youtube"?a[1]:a[0],i}return i}function B(e){var i,r;let t="iframe";return((i=e.includes)!=null&&i.call(e,"youtube")||(r=e.includes)!=null&&r.call(e,"youtu.be"))&&(t="youtube"),e.includes("youku")&&(t="youku"),e.includes("bilibili")&&(t="bilibili"),e.includes("qq")&&(t="qqvideo"),e.includes("amap")&&(t="amap"),e.includes("map.baidu")&&(t="baidu_map"),(e.includes("google.com/maps")||e.includes("maps.app.goo.gl"))&&(t="googlemaps"),e.includes("modao")&&(t="modao"),e.includes("lanhuapp")&&(t="lanhu"),e.includes("figma")&&(t="figma"),e.includes("canva")&&(t="canva"),e.includes("processon")&&(t="processon"),e.includes("codepen")&&(t="codepen"),e.includes("jinshuju")&&(t="jinshuju"),e.includes("iframe")&&(t="iframe"),t}function x(e){let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const i=B(e);if(t=H(i,e,t),!t.validLink)return t;switch(i){case"youtube":return j(t);case"youku":return M(t);case"bilibili":return q(t);case"qqvideo":return N(t);case"amap":return U(e,t);case"baidu_map":return A(e,t);case"googlemaps":return D(e,t);case"modao":return L(t);case"lanhu":return $(t);case"figma":return _(t);case"canva":return T(e,t);case"processon":return z(e,t);case"codepen":return Y(t);case"jinshuju":return C(e,t);case"iframe":return E(e,t);default:return e}}const V="_wrap_5y04w_1",K="_innerWrap_5y04w_15",v={wrap:V,innerWrap:K};function O({editor:e,node:t,updateAttributes:i}){const r=I.useEditableEditor(),{src:n,width:c,height:o}=t.attrs,[a,p]=b.useState("");function l(){if(!a)return;const d=x(a);e.chain().updateAttributes(f.name,{src:(d==null?void 0:d.src)||a}).setNodeSelection(e.state.selection.from).focus().run()}const k=b.useCallback(d=>{i({width:d.width,height:d.height})},[i]);return s.jsxs(u.NodeViewWrapper,{children:[!n&&s.jsxs("div",{className:"richtext-mx-auto richtext-my-[12px] richtext-flex richtext-max-w-[600px] richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-rounded-[12px] richtext-border richtext-border-solid richtext-border-border richtext-p-[10px]",children:[s.jsx(P.Input,{autoFocus:!0,className:"richtext-flex-1",onInput:d=>p(d.target.value),placeholder:"Enter link",type:"url",value:a}),s.jsx(R.Button,{className:"richtext-w-[60px]",onClick:l,children:"OK"})]}),n&&s.jsx(y.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(o)},onResizeStop:(d,J,W,w)=>{k({width:Number.parseInt(c)+w.width,height:Number.parseInt(o)+w.height})},children:s.jsx("div",{className:u.clsx(v.wrap,"render-wrapper"),children:s.jsx("div",{className:v.innerWrap,style:{pointerEvents:r?"none":"auto"},children:s.jsx("iframe",{className:"richtext-my-[12px] ",src:n})})})})]})}function X(){const e=g.useButtonProps(f.name),{icon:t=void 0,tooltip:i=void 0,shortcutKeys:r=void 0,tooltipOptions:n={},action:c=void 0,isActive:o=void 0}=(e==null?void 0:e.componentProps)??{},{editorDisabled:a,update:p}=g.useToggleActive(o),l=()=>{a||c&&(c(),p())};return e?s.jsx(S.ActionButton,{action:l,disabled:a,icon:t,shortcutKeys:r,tooltip:i,tooltipOptions:n}):s.jsx(s.Fragment,{})}const f=u.Node3.create({name:"iframe",content:"",marks:"",group:"block",selectable:!0,atom:!0,draggable:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"iframe"},button:({editor:t,extension:i,t:r})=>({componentProps:{action:n=>t.commands.setIframe(n),upload:i.options.upload,icon:"Iframe",tooltip:r("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:h.getDatasetAttribute("width")},height:{default:300,parseHTML:h.getDatasetAttribute("height")},src:{default:null,parseHTML:h.getDatasetAttribute("src")},defaultShowPicker:{default:!1},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["iframe",u.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:t,commands:i,chain:r})=>{var c,o,a;if(((a=(o=(c=t.selection)==null?void 0:c.node)==null?void 0:o.type)==null?void 0:a.name)==this.name)return i.updateAttributes(this.name,e);const n=e||{url:""};return r().insertContent({type:this.name,attrs:n}).run()}}},addInputRules(){return[u.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return u.ReactNodeViewRenderer(O)}});exports.Iframe=f;exports.RichTextIframe=X;exports.getServiceSrc=x;
|
|
@@ -3,7 +3,7 @@ import { jsxs as f, jsx as d, Fragment as P } from "react/jsx-runtime";
|
|
|
3
3
|
import { useState as R, useCallback as M } from "react";
|
|
4
4
|
import { Resizable as N } from "re-resizable";
|
|
5
5
|
import { g as l } from "./dom-dataset-CIEeltF6.js";
|
|
6
|
-
import { A as j } from "./toggle-
|
|
6
|
+
import { A as j } from "./toggle-xchtz-Kf.js";
|
|
7
7
|
import { b as U } from "./index-DuZCJJSp.js";
|
|
8
8
|
import { u as q, a as A } from "./useButtonProps-D0SrPzuG.js";
|
|
9
9
|
import { I as L } from "./input-DfqFAyKo.js";
|
package/lib/Iframe.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-DLqogznp.cjs");const e=require("./Iframe-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-DLqogznp.cjs");const e=require("./Iframe-CM6mRQmv.cjs");require("./dom-dataset-BqoJhJXt.cjs");exports.Iframe=e.Iframe;exports.RichTextIframe=e.RichTextIframe;
|
package/lib/Iframe.js
CHANGED