reactjs-tiptap-editor 0.3.5 → 0.3.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-DocMG_Xt.cjs → ActionMenuButton-C5YeJ90E.cjs} +1 -1
- package/lib/{ActionMenuButton-D9WfF2ep.js → ActionMenuButton-EAy6-lM0.js} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.d.cts +7 -7
- package/lib/Attachment.d.ts +7 -7
- package/lib/Attachment.js +3 -3
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.d.cts +7 -7
- package/lib/Blockquote.d.ts +7 -7
- package/lib/Blockquote.js +2 -2
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.d.cts +7 -7
- package/lib/Bold.d.ts +7 -7
- package/lib/Bold.js +2 -2
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.d.cts +7 -7
- package/lib/BulletList.d.ts +7 -7
- package/lib/BulletList.js +2 -2
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.d.cts +7 -7
- package/lib/Clear.d.ts +7 -7
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.d.cts +7 -7
- package/lib/Code.d.ts +7 -7
- package/lib/Code.js +2 -2
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.d.cts +7 -7
- package/lib/CodeBlock.d.ts +7 -7
- package/lib/CodeBlock.js +3 -3
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.d.cts +7 -7
- package/lib/CodeView.d.ts +7 -7
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.d.cts +7 -7
- package/lib/Color.d.ts +7 -7
- package/lib/Color.js +3 -3
- package/lib/Document.cjs +1 -1
- package/lib/Document.d.cts +7 -7
- package/lib/Document.d.ts +7 -7
- package/lib/Document.js +1 -1
- package/lib/{Drawer-DdyndCxA.js → Drawer-CrFsNVAD.js} +3 -3
- package/lib/{Drawer-C6yrcHc7.cjs → Drawer-D89IU-M_.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.d.cts +7 -7
- package/lib/Drawer.d.ts +7 -7
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.d.cts +7 -7
- package/lib/Emoji.d.ts +7 -7
- package/lib/Emoji.js +4 -4
- package/lib/{Excalidraw-D5qXWfKq.js → Excalidraw-CEzgggna.js} +3 -3
- package/lib/{Excalidraw-BS6_3xHm.cjs → Excalidraw-Dl-lRpPD.cjs} +1 -1
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.d.cts +7 -7
- package/lib/Excalidraw.d.ts +7 -7
- package/lib/Excalidraw.js +3 -3
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.d.cts +7 -7
- package/lib/ExportPdf.d.ts +7 -7
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.d.cts +7 -7
- package/lib/ExportWord.d.ts +7 -7
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.d.cts +7 -7
- package/lib/FontFamily.d.ts +7 -7
- package/lib/FontFamily.js +4 -4
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.d.cts +7 -7
- package/lib/FontSize.d.ts +7 -7
- package/lib/FontSize.js +3 -3
- package/lib/FormatPainter.cjs +1 -1
- package/lib/FormatPainter.d.cts +7 -7
- package/lib/FormatPainter.d.ts +7 -7
- package/lib/FormatPainter.js +2 -2
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.d.cts +7 -7
- package/lib/Heading.d.ts +7 -7
- package/lib/Heading.js +3 -3
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.d.cts +7 -7
- package/lib/Highlight.d.ts +7 -7
- package/lib/Highlight.js +2 -2
- package/lib/History.cjs +1 -1
- package/lib/History.d.cts +7 -7
- package/lib/History.d.ts +7 -7
- package/lib/History.js +2 -2
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.d.cts +7 -7
- package/lib/HorizontalRule.d.ts +7 -7
- package/lib/HorizontalRule.js +10 -8
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.d.cts +7 -7
- package/lib/Iframe.d.ts +7 -7
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.d.cts +7 -7
- package/lib/Image.d.ts +7 -7
- package/lib/Image.js +3 -3
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.d.cts +7 -7
- package/lib/ImageGif.d.ts +7 -7
- package/lib/ImageGif.js +3 -3
- package/lib/ImportWord.cjs +2 -2
- package/lib/ImportWord.d.cts +7 -7
- package/lib/ImportWord.d.ts +7 -7
- package/lib/ImportWord.js +4 -4
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.d.cts +7 -7
- package/lib/Indent.d.ts +7 -7
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.d.cts +7 -7
- package/lib/Italic.d.ts +7 -7
- package/lib/Italic.js +2 -2
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.d.cts +7 -7
- package/lib/Katex.d.ts +7 -7
- package/lib/Katex.js +4 -4
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.d.cts +7 -7
- package/lib/LineHeight.d.ts +7 -7
- package/lib/LineHeight.js +2 -2
- package/lib/Link.cjs +1 -1
- package/lib/Link.d.cts +7 -7
- package/lib/Link.d.ts +7 -7
- package/lib/Link.js +2 -2
- package/lib/ListItem.cjs +1 -1
- package/lib/ListItem.d.cts +7 -7
- package/lib/ListItem.d.ts +7 -7
- package/lib/ListItem.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.d.cts +7 -7
- package/lib/Mention.d.ts +7 -7
- package/lib/Mention.js +3 -3
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.d.cts +7 -7
- package/lib/Mermaid.d.ts +7 -7
- package/lib/Mermaid.js +16 -16
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.d.cts +7 -7
- package/lib/MoreMark.d.ts +7 -7
- package/lib/MoreMark.js +3 -3
- package/lib/MultiColumn.cjs +1 -1
- package/lib/MultiColumn.d.cts +7 -7
- package/lib/MultiColumn.d.ts +7 -7
- package/lib/MultiColumn.js +2 -2
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.d.cts +7 -7
- package/lib/OrderedList.d.ts +7 -7
- package/lib/OrderedList.js +2 -2
- package/lib/RichTextEditor-DaQRHXru.cjs +137 -0
- package/lib/{RichTextEditor-DS30aD8t.js → RichTextEditor-iSPxjLdO.js} +898 -904
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.d.cts +7 -7
- package/lib/SearchAndReplace.d.ts +7 -7
- package/lib/SearchAndReplace.js +2 -2
- package/lib/Selection.cjs +1 -1
- package/lib/Selection.d.cts +7 -7
- package/lib/Selection.d.ts +7 -7
- package/lib/Selection.js +1 -1
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.d.cts +7 -7
- package/lib/SlashCommand.d.ts +7 -7
- package/lib/SlashCommand.js +4 -4
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.d.cts +7 -7
- package/lib/Strike.d.ts +7 -7
- package/lib/Strike.js +2 -2
- package/lib/SubAndSuperScript.cjs +1 -1
- package/lib/SubAndSuperScript.d.cts +7 -7
- package/lib/SubAndSuperScript.d.ts +7 -7
- package/lib/SubAndSuperScript.js +3 -3
- package/lib/Table.cjs +1 -1
- package/lib/Table.d.cts +7 -7
- package/lib/Table.d.ts +7 -7
- package/lib/Table.js +15 -15
- package/lib/TableOfContent.cjs +1 -1
- package/lib/TableOfContent.d.cts +7 -7
- package/lib/TableOfContent.d.ts +7 -7
- package/lib/TableOfContent.js +3 -3
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.d.cts +7 -7
- package/lib/TaskList.d.ts +7 -7
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.d.cts +7 -7
- package/lib/TextAlign.d.ts +7 -7
- package/lib/TextAlign.js +47 -46
- package/lib/TextBubble.cjs +1 -1
- package/lib/TextBubble.d.cts +7 -7
- package/lib/TextBubble.d.ts +7 -7
- package/lib/TextBubble.js +2 -2
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.d.cts +7 -7
- package/lib/TextDirection.d.ts +7 -7
- package/lib/TextDirection.js +2 -2
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.d.cts +7 -7
- package/lib/TextUnderline.d.ts +7 -7
- package/lib/TextUnderline.js +2 -2
- package/lib/TrailingNode.cjs +1 -1
- package/lib/TrailingNode.d.cts +7 -7
- package/lib/TrailingNode.d.ts +7 -7
- package/lib/TrailingNode.js +1 -1
- package/lib/{Twitter-VKMhfUTN.js → Twitter-Ac3aMied.js} +44 -44
- package/lib/{Twitter-Dwmo5UJ-.cjs → Twitter-D-hJZsaa.cjs} +1 -1
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.d.cts +7 -7
- package/lib/Twitter.d.ts +7 -7
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.d.cts +7 -7
- package/lib/Video.d.ts +7 -7
- package/lib/Video.js +2 -2
- package/lib/bubble-extra.cjs +1 -1
- package/lib/bubble-extra.d.cts +7 -7
- package/lib/bubble-extra.d.ts +7 -7
- package/lib/bubble-extra.js +6 -6
- package/lib/{dom-dataset-pKb7TLlt.js → dom-dataset-2RXYq9wp.js} +397 -376
- package/lib/dom-dataset-DmsCLv1q.cjs +33 -0
- package/lib/{index-BaTWsqZj.js → index-BGwJ0NfQ.js} +1 -1
- package/lib/{index-Dk3tSDmG.js → index-BkoojfPK.js} +1 -1
- package/lib/{index-COecBbaE.cjs → index-CSvnpArE.cjs} +11 -11
- package/lib/{index-DEe_Svay.js → index-CXIIg9Sq.js} +676 -644
- package/lib/{index-DjP7Onch.cjs → index-CrxasX7b.cjs} +1 -1
- package/lib/{index-CySbCeQd.cjs → index-Cyh1yoFk.cjs} +1 -1
- package/lib/{index-DCFzuS5p.js → index-fKx6CYUM.js} +1 -1
- package/lib/{index-ClFtfQ0J.cjs → index-h9_SDuwc.cjs} +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +7 -7
- package/lib/index.d.ts +7 -7
- package/lib/index.js +27 -27
- package/lib/locale-bundle.d.cts +7 -7
- package/lib/locale-bundle.d.ts +7 -7
- package/lib/{textarea-I3qcfzYg.cjs → textarea-DNGemIPu.cjs} +1 -1
- package/lib/{textarea-DITg4shx.js → textarea-DpvZ1MKU.js} +1 -1
- package/package.json +71 -71
- package/lib/RichTextEditor-CFS3E6GK.cjs +0 -137
- package/lib/dom-dataset-CAXnsjYE.cjs +0 -33
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";const D=require("./index-COecBbaE.cjs"),ne=require("tippy.js"),c=require("react"),Y=require("react-dom");class re{constructor({editor:e,element:t,view:n,tippyOptions:r={},updateDelay:o=250,shouldShow:m}){this.preventHide=!1,this.shouldShow=({view:a,state:p,from:l,to:d})=>{const{doc:s,selection:f}=p,{empty:v}=f,y=!s.textBetween(l,d).length&&D.isTextSelection(p.selection),E=this.element.contains(document.activeElement);return!(!(a.hasFocus()||E)||v||y||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:a})=>{var p;if(this.preventHide){this.preventHide=!1;return}a!=null&&a.relatedTarget&&(!((p=this.element.parentNode)===null||p===void 0)&&p.contains(a.relatedTarget))||(a==null?void 0:a.relatedTarget)!==this.editor.view.dom&&this.hide()},this.tippyBlurHandler=a=>{this.blurHandler({event:a})},this.handleDebouncedUpdate=(a,p)=>{const l=!(p!=null&&p.selection.eq(a.state.selection)),d=!(p!=null&&p.doc.eq(a.state.doc));!l&&!d||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(a,l,d,p)},this.updateDelay))},this.updateHandler=(a,p,l,d)=>{var s,f,v;const{state:y,composing:E}=a,{selection:_}=y;if(E||!p&&!l)return;this.createTooltip();const{ranges:C}=_,S=Math.min(...C.map(u=>u.$from.pos)),h=Math.max(...C.map(u=>u.$to.pos));if(!((s=this.shouldShow)===null||s===void 0?void 0:s.call(this,{editor:this.editor,element:this.element,view:a,state:y,oldState:d,from:S,to:h}))){this.hide();return}(f=this.tippy)===null||f===void 0||f.setProps({getReferenceClientRect:((v=this.tippyOptions)===null||v===void 0?void 0:v.getReferenceClientRect)||(()=>{if(D.isNodeSelection(y.selection)){let u=a.nodeDOM(S);if(u){const g=u.dataset.nodeViewWrapper?u:u.querySelector("[data-node-view-wrapper]");if(g&&(u=g.firstChild),u)return u.getBoundingClientRect()}}return D.posToDOMRect(a,S,h)})}),this.show()},this.editor=e,this.element=t,this.view=n,this.updateDelay=o,m&&(this.shouldShow=m),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=r,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;this.tippy||!t||(this.tippy=ne(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,t){const{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}const o=!(t!=null&&t.selection.eq(e.state.selection)),m=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,o,m,t)}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Q=i=>new D.Plugin({key:typeof i.pluginKey=="string"?new D.PluginKey(i.pluginKey):i.pluginKey,view:e=>new re({view:e,...i})});D.Extension.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Q({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});function ie(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var U={exports:{}},H={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* use-sync-external-store-shim.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var W;function oe(){if(W)return H;W=1;var i=c;function e(s,f){return s===f&&(s!==0||1/s===1/f)||s!==s&&f!==f}var t=typeof Object.is=="function"?Object.is:e,n=i.useState,r=i.useEffect,o=i.useLayoutEffect,m=i.useDebugValue;function a(s,f){var v=f(),y=n({inst:{value:v,getSnapshot:f}}),E=y[0].inst,_=y[1];return o(function(){E.value=v,E.getSnapshot=f,p(E)&&_({inst:E})},[s,v,f]),r(function(){return p(E)&&_({inst:E}),s(function(){p(E)&&_({inst:E})})},[s]),m(v),v}function p(s){var f=s.getSnapshot;s=s.value;try{var v=f();return!t(s,v)}catch{return!0}}function l(s,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return H.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:d,H}var B={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* use-sync-external-store-shim.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var z;function se(){return z||(z=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var i=c,e=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(S){{for(var h=arguments.length,b=new Array(h>1?h-1:0),u=1;u<h;u++)b[u-1]=arguments[u];n("error",S,b)}}function n(S,h,b){{var u=e.ReactDebugCurrentFrame,g=u.getStackAddendum();g!==""&&(h+="%s",b=b.concat([g]));var w=b.map(function(O){return String(O)});w.unshift("Warning: "+h),Function.prototype.apply.call(console[S],console,w)}}function r(S,h){return S===h&&(S!==0||1/S===1/h)||S!==S&&h!==h}var o=typeof Object.is=="function"?Object.is:r,m=i.useState,a=i.useEffect,p=i.useLayoutEffect,l=i.useDebugValue,d=!1,s=!1;function f(S,h,b){d||i.startTransition!==void 0&&(d=!0,t("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var u=h();if(!s){var g=h();o(u,g)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),s=!0)}var w=m({inst:{value:u,getSnapshot:h}}),O=w[0].inst,T=w[1];return p(function(){O.value=u,O.getSnapshot=h,v(O)&&T({inst:O})},[S,u,h]),a(function(){v(O)&&T({inst:O});var A=function(){v(O)&&T({inst:O})};return S(A)},[S]),l(u),u}function v(S){var h=S.getSnapshot,b=S.value;try{var u=h();return!o(b,u)}catch{return!0}}function y(S,h,b){return h()}var E=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",_=!E,R=_?y:f,C=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:R;B.useSyncExternalStore=C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),B}process.env.NODE_ENV==="production"?U.exports=oe():U.exports=se();var L=U.exports;const ue=(...i)=>e=>{i.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},ae=({contentComponent:i})=>{const e=L.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getServerSnapshot);return c.createElement(c.Fragment,null,Object.values(e))};function de(){const i=new Set;let e={};return{subscribe(t){return i.add(t),()=>{i.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,n){e={...e,[t]:Y.createPortal(n.reactElement,n.element,t)},i.forEach(r=>r())},removeRenderer(t){const n={...e};delete n[t],e=n,i.forEach(r=>r())}}}class le extends c.Component{constructor(e){var t;super(e),this.editorContentRef=c.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((t=e.editor)===null||t===void 0)&&t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=de(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const e=this.props.editor;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!e.options.element.firstChild))return;const t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){const{editor:e,innerRef:t,...n}=this.props;return c.createElement(c.Fragment,null,c.createElement("div",{ref:ue(t,this.editorContentRef),...n}),(e==null?void 0:e.contentComponent)&&c.createElement(ae,{contentComponent:e.contentComponent}))}}const ce=c.forwardRef((i,e)=>{const t=c.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[i.editor]);return c.createElement(le,{key:t,innerRef:e,...i})}),he=c.memo(ce);var fe=function i(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var n,r,o;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!i(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!i(r[1],t.get(r[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){var m=o[r];if(!(m==="_owner"&&e.$$typeof)&&!i(e[m],t[m]))return!1}return!0}return e!==e&&t!==t},pe=ie(fe),q={exports:{}},P={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* use-sync-external-store-shim/with-selector.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var G;function me(){if(G)return P;G=1;var i=c,e=L;function t(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,o=i.useRef,m=i.useEffect,a=i.useMemo,p=i.useDebugValue;return P.useSyncExternalStoreWithSelector=function(l,d,s,f,v){var y=o(null);if(y.current===null){var E={hasValue:!1,value:null};y.current=E}else E=y.current;y=a(function(){function R(u){if(!C){if(C=!0,S=u,u=f(u),v!==void 0&&E.hasValue){var g=E.value;if(v(g,u))return h=g}return h=u}if(g=h,n(S,u))return g;var w=f(u);return v!==void 0&&v(g,w)?g:(S=u,h=w)}var C=!1,S,h,b=s===void 0?null:s;return[function(){return R(d())},b===null?void 0:function(){return R(b())}]},[d,s,f,v]);var _=r(l,y[0],y[1]);return m(function(){E.hasValue=!0,E.value=_},[_]),p(_),_},P}var j={};/**
|
|
26
|
-
* @license React
|
|
27
|
-
* use-sync-external-store-shim/with-selector.development.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var $;function ve(){return $||($=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var i=c,e=L;function t(d,s){return d===s&&(d!==0||1/d===1/s)||d!==d&&s!==s}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,o=i.useRef,m=i.useEffect,a=i.useMemo,p=i.useDebugValue;function l(d,s,f,v,y){var E=o(null),_;E.current===null?(_={hasValue:!1,value:null},E.current=_):_=E.current;var R=a(function(){var b=!1,u,g,w=function(M){if(!b){b=!0,u=M;var x=v(M);if(y!==void 0&&_.hasValue){var N=_.value;if(y(N,x))return g=N,N}return g=x,x}var te=u,V=g;if(n(te,M))return V;var I=v(M);return y!==void 0&&y(V,I)?V:(u=M,g=I,I)},O=f===void 0?null:f,T=function(){return w(s())},A=O===null?void 0:function(){return w(O())};return[T,A]},[s,f,v,y]),C=R[0],S=R[1],h=r(d,C,S);return m(function(){_.hasValue=!0,_.value=h},[h]),p(h),h}j.useSyncExternalStoreWithSelector=l,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),j}process.env.NODE_ENV==="production"?q.exports=me():q.exports=ve();var Se=q.exports;const Ee=typeof window<"u"?c.useLayoutEffect:c.useEffect;class ye{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",t),()=>{n.off("transaction",t)}}}}function _e(i){var e;const[t]=c.useState(()=>new ye(i.editor)),n=Se.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,i.selector,(e=i.equalityFn)!==null&&e!==void 0?e:pe);return Ee(()=>t.watch(i.editor),[i.editor,t]),c.useDebugValue(n),n}const J=process.env.NODE_ENV!=="production",F=typeof window>"u",ge=F||!!(typeof window<"u"&&window.next);class K{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return F||ge?(J&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&F&&J)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...n)=>{var r,o;return(o=(r=this.options.current).onBeforeCreate)===null||o===void 0?void 0:o.call(r,...n)},onBlur:(...n)=>{var r,o;return(o=(r=this.options.current).onBlur)===null||o===void 0?void 0:o.call(r,...n)},onCreate:(...n)=>{var r,o;return(o=(r=this.options.current).onCreate)===null||o===void 0?void 0:o.call(r,...n)},onDestroy:(...n)=>{var r,o;return(o=(r=this.options.current).onDestroy)===null||o===void 0?void 0:o.call(r,...n)},onFocus:(...n)=>{var r,o;return(o=(r=this.options.current).onFocus)===null||o===void 0?void 0:o.call(r,...n)},onSelectionUpdate:(...n)=>{var r,o;return(o=(r=this.options.current).onSelectionUpdate)===null||o===void 0?void 0:o.call(r,...n)},onTransaction:(...n)=>{var r,o;return(o=(r=this.options.current).onTransaction)===null||o===void 0?void 0:o.call(r,...n)},onUpdate:(...n)=>{var r,o;return(o=(r=this.options.current).onUpdate)===null||o===void 0?void 0:o.call(r,...n)},onContentError:(...n)=>{var r,o;return(o=(r=this.options.current).onContentError)===null||o===void 0?void 0:o.call(r,...n)},onDrop:(...n)=>{var r,o;return(o=(r=this.options.current).onDrop)===null||o===void 0?void 0:o.call(r,...n)},onPaste:(...n)=>{var r,o;return(o=(r=this.options.current).onPaste)===null||o===void 0?void 0:o.call(r,...n)}};return new D.Editor(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)?!0:n==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((r,o)=>{var m;return r===((m=t.extensions)===null||m===void 0?void 0:m[o])}):e[n]===t[n])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?K.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((n,r)=>n===e[r]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function be(i={},e=[]){const t=c.useRef(i);t.current=i;const[n]=c.useState(()=>new K(t)),r=L.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return c.useDebugValue(r),c.useEffect(n.onRender(e)),_e({editor:r,selector:({transactionNumber:o})=>i.shouldRerenderOnTransaction===!1?null:i.immediatelyRender&&o===0?0:o+1}),r}const X=c.createContext({editor:null});X.Consumer;const Oe=()=>c.useContext(X),we=i=>{const[e,t]=c.useState(null),{editor:n}=Oe();return c.useEffect(()=>{var r;if(!e||!((r=i.editor)===null||r===void 0)&&r.isDestroyed||n!=null&&n.isDestroyed)return;const{pluginKey:o="bubbleMenu",editor:m,tippyOptions:a={},updateDelay:p,shouldShow:l=null}=i,d=m||n;if(!d){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const s=Q({updateDelay:p,editor:d,element:e,pluginKey:o,shouldShow:l,tippyOptions:a});return d.registerPlugin(s),()=>{d.unregisterPlugin(o)}},[i.editor,n,e]),c.createElement("div",{ref:t,className:i.className,style:{visibility:"hidden"}},i.children)},Z=c.createContext({onDragStart:void 0}),Ce=()=>c.useContext(Z),De=c.forwardRef((i,e)=>{const{onDragStart:t}=Ce(),n=i.as||"div";return c.createElement(n,{...i,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...i.style}})});function Re(i){return!!(typeof i=="function"&&i.prototype&&i.prototype.isReactComponent)}function Te(i){var e;return typeof i=="object"&&((e=i.$$typeof)===null||e===void 0?void 0:e.toString())==="Symbol(react.forward_ref)"}class k{constructor(e,{editor:t,props:n={},as:r="div",className:o=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isInitialized?Y.flushSync(()=>{this.render()}):this.render()}render(){var e;const t=this.component,n=this.props,r=this.editor;(Re(t)||Te(t))&&(n.ref=o=>{this.ref=o}),this.reactElement=c.createElement(t,{...n}),(e=r==null?void 0:r.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const t=this.editor;(e=t==null?void 0:t.contentComponent)===null||e===void 0||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}}class Me extends D.NodeView{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode()};if(!this.component.displayName){const l=d=>d.charAt(0).toUpperCase()+d.substring(1);this.component.displayName=l(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:l=>{l&&this.contentDOMElement&&l.firstChild!==this.contentDOMElement&&l.appendChild(this.contentDOMElement)}},o=this.component,m=c.memo(l=>c.createElement(Z.Provider,{value:r},c.createElement(o,l)));m.displayName="ReactNodeView",this.node.isLeaf?this.contentDOMElement=null:this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.style.whiteSpace="inherit");let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:p=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new k(m,{editor:this.editor,props:e,as:a,className:`node-${this.node.type.name} ${p}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:t}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t,n){const r=o=>{this.renderer.updateProps(o),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const o=this.node,m=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.options.update({oldNode:o,oldDecorations:m,newNode:e,newDecorations:t,oldInnerDecorations:a,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n})})}return e===this.node&&this.decorations===t&&this.innerDecorations===n||(this.node=e,this.decorations=t,this.innerDecorations=n,r({node:e,decorations:t,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){const t=this.editor.extensionManager.attributes,n=D.getRenderedAttributes(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function Le(i,e){return t=>t.editor.contentComponent?new Me(i,t,e):{}}function ee(i){var e,t,n="";if(typeof i=="string"||typeof i=="number")n+=i;else if(typeof i=="object")if(Array.isArray(i)){var r=i.length;for(e=0;e<r;e++)i[e]&&(t=ee(i[e]))&&(n&&(n+=" "),n+=t)}else for(t in i)i[t]&&(n&&(n+=" "),n+=t);return n}function Ae(){for(var i,e,t=0,n="",r=arguments.length;t<r;t++)(i=arguments[t])&&(e=ee(i))&&(n&&(n+=" "),n+=e);return n}function xe(i){try{return JSON.stringify(i)}catch{return JSON.stringify({})}}function Ne(i,e=!1){return t=>{const n=i.startsWith("data-")?i:`data-${i}`;let r=decodeURIComponent(t.getAttribute(n));if(r==null||typeof r=="string"&&r==="null")try{const a=t.outerHTML.match(/([\S\s])+?="([\S\s])+?"/g);a&&a.length>0&&(r=(a.map(l=>l.trim()).reduce((l,d)=>{const s=d.indexOf("="),f=[d.slice(0,s),d.slice(s+1).slice(1,-1)];return l[f[0]]=f[1],l},{})[i.toLowerCase()]||"").replaceAll(""",'"'))}catch(m){console.error("Error getDatasetAttribute ",m.message,t)}if(e)try{return JSON.parse(r)}catch{return{}}if(r.includes("%")||r.includes("auto"))return r;const o=Number.parseInt(r);return o!==o?r:o}}function Ve(i){const{attrs:e}=i;return Object.keys(e).reduce((t,n)=>{const r=e[n];if(r==null)return t;let o="";return typeof r=="object"?o=xe(r):o=r,t[n]=o,t},Object.create(null))}exports.BubbleMenu=we;exports.EditorContent=he;exports.NodeViewWrapper=De;exports.ReactNodeViewRenderer=Le;exports.ReactRenderer=k;exports.clsx=Ae;exports.getDatasetAttribute=Ne;exports.nodeAttrsToDataset=Ve;exports.useEditor=be;
|