reactjs-tiptap-editor 1.0.25 → 1.0.28
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-8cTG45Ft.js → ActionMenuButton-BhiGvRJ7.js} +1 -1
- package/lib/{ActionMenuButton-CXeFhner.cjs → ActionMenuButton-qUxkZlQg.cjs} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +14 -14
- package/lib/Blockquote.cjs +5 -5
- package/lib/Blockquote.js +1497 -53
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +3 -3
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +2 -2
- package/lib/{Callout-ZlPQrMEt.js → Callout-B9uXfbP3.js} +20 -20
- package/lib/{Callout-DWOMZPiP.cjs → Callout-C_TXsss3.cjs} +1 -1
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +4 -4
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +56 -39
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +8 -4
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +3 -3
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +2 -2
- package/lib/{Drawer-TJY4NuHx.cjs → Drawer-D3B4lQJF.cjs} +1 -1
- package/lib/{Drawer-C-EO1uoK.js → Drawer-h401Yy6Y.js} +4 -4
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +1797 -268
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +10 -10
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +5 -5
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +5 -5
- package/lib/FormatPainter.cjs +1 -0
- package/lib/FormatPainter.js +133 -0
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +15 -11
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +3 -3
- package/lib/History.cjs +7 -1
- package/lib/History.js +663 -569
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +2 -2
- package/lib/{Iframe-CGb6-2LD.js → Iframe-Dhn40BXx.js} +7 -7
- package/lib/{Iframe-5zx43DL4.cjs → Iframe-bvGuzYwC.cjs} +1 -1
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +9 -6
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +33 -33
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +5 -5
- package/lib/{Indent-CdMYsDNS.js → Indent-BK9DvCL7.js} +2 -2
- package/lib/{Indent-DuwV8s1t.cjs → Indent-IOByomps.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +2 -2
- package/lib/{Katex-CCP_ZQz2.js → Katex-C_Ah9G9w.js} +5 -5
- package/lib/{Katex-D9FP7EUE.cjs → Katex-oLGrtLTf.cjs} +1 -1
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +3 -3
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +4 -4
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-DQ8-iufJ.cjs → LinkEditBlock-BojxdGTm.cjs} +2 -2
- package/lib/{LinkEditBlock-B1m-TVMu.js → LinkEditBlock-DRdKXffy.js} +88 -57
- package/lib/MarkdownPaste.cjs +1 -1
- package/lib/MarkdownPaste.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +9 -5
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +14 -14
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +3 -3
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +2 -2
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +10 -10
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +7 -7
- package/lib/{SlashCommandNodeView-DNixmQGa.cjs → SlashCommandNodeView-Dai-O3aD.cjs} +1 -1
- package/lib/{SlashCommandNodeView-Dt6n1SP9.js → SlashCommandNodeView-qwW9cuYt.js} +10 -10
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +2 -2
- package/lib/{Table-DdEgaUwa.js → Table-BKM8SvVj.js} +115 -97
- package/lib/{Table-C5JxBXef.cjs → Table-CWI7tKme.cjs} +5 -5
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +11 -11
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +3 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +2 -2
- package/lib/Twitter-BfsPzA8_.cjs +1 -0
- package/lib/{Twitter-Dnz9qyW0.js → Twitter-CofLQ-zj.js} +191 -191
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +3 -3
- package/lib/bubble.cjs +6 -6
- package/lib/bubble.js +2504 -2152
- package/lib/{clsx-D6gYQn3o.cjs → clsx-DJURdKPs.cjs} +2 -2
- package/lib/{clsx-0OU6n9va.js → clsx-b_2OwHLk.js} +28 -18
- package/lib/components/Bubble/RichTextBubbleCallout.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleCodeBlock.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleColumns.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleDrawer.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleExcalidraw.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleIframe.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleKatex.d.ts +2 -1
- package/lib/components/Bubble/RichTextBubbleLink.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleMedia.d.ts +3 -3
- package/lib/components/Bubble/RichTextBubbleMenuDragHandle.d.ts +2 -1
- package/lib/components/Bubble/RichTextBubbleMermaid.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleTable.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleText.d.ts +1 -1
- package/lib/components/Bubble/RichTextBubbleTwitter.d.ts +1 -1
- package/lib/components/ColorPicker.d.ts +1 -1
- package/lib/components/ReactBus.d.ts +1 -1
- package/lib/components/RichTextProvider.d.ts +1 -1
- package/lib/components/SlashDialogTrigger/RenderDialogUploadImage.d.ts +1 -1
- package/lib/components/SlashDialogTrigger/RenderDialogUploadVideo.d.ts +1 -1
- package/lib/components/SlashDialogTrigger/SlashDialogTrigger.d.ts +2 -1
- package/lib/components/icons/Activity.d.ts +2 -1
- package/lib/components/icons/Animas.d.ts +2 -1
- package/lib/components/icons/AspectRatio.d.ts +1 -1
- package/lib/components/icons/Blockquote.d.ts +1 -1
- package/lib/components/icons/CodeView.d.ts +1 -1
- package/lib/components/icons/ColumnAddLeft.d.ts +1 -1
- package/lib/components/icons/ColumnAddRight.d.ts +1 -1
- package/lib/components/icons/DeleteColumn.d.ts +1 -1
- package/lib/components/icons/DeleteRow.d.ts +1 -1
- package/lib/components/icons/Direction.d.ts +1 -1
- package/lib/components/icons/Excalidraw.d.ts +1 -1
- package/lib/components/icons/ExportPdf.d.ts +1 -1
- package/lib/components/icons/ExportWord.d.ts +2 -1
- package/lib/components/icons/FileWordOutline.d.ts +1 -1
- package/lib/components/icons/Flag.d.ts +2 -1
- package/lib/components/icons/Food.d.ts +2 -1
- package/lib/components/icons/GIfIcon.d.ts +1 -1
- package/lib/components/icons/Html.d.ts +1 -1
- package/lib/components/icons/Icon.d.ts +1 -1
- package/lib/components/icons/IconColorFill.d.ts +1 -1
- package/lib/components/icons/IconHighlightFill.d.ts +1 -1
- package/lib/components/icons/ImportWord.d.ts +2 -1
- package/lib/components/icons/LeftToRight.d.ts +1 -1
- package/lib/components/icons/LineHeight.d.ts +1 -1
- package/lib/components/icons/MenuDown.d.ts +1 -1
- package/lib/components/icons/Mermaid.d.ts +1 -1
- package/lib/components/icons/NoFill.d.ts +1 -1
- package/lib/components/icons/Object.d.ts +2 -1
- package/lib/components/icons/RightToLeft.d.ts +1 -1
- package/lib/components/icons/SizeL.d.ts +1 -1
- package/lib/components/icons/SizeM.d.ts +1 -1
- package/lib/components/icons/SizeS.d.ts +1 -1
- package/lib/components/icons/Symbol.d.ts +2 -1
- package/lib/components/icons/Travel.d.ts +2 -1
- package/lib/components/icons/Twitter.d.ts +1 -1
- package/lib/components/ui/dialog.d.ts +2 -2
- package/lib/components/ui/dropdown-menu.d.ts +1 -1
- package/lib/components/ui/emoji-picker.d.ts +4 -4
- package/lib/components/ui/toaster.d.ts +1 -1
- package/lib/{dropdown-menu-yQ-sQ1k4.cjs → dropdown-menu-CEMxzgnU.cjs} +1 -1
- package/lib/{dropdown-menu-ROihzXsP.js → dropdown-menu-CKAKsyqu.js} +1 -1
- package/lib/extensions/Attachment/components/NodeViewAttachment/FileIcon.d.ts +1 -1
- package/lib/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.d.ts +1 -1
- package/lib/extensions/Attachment/components/RichTextAttachment.d.ts +1 -1
- package/lib/extensions/Blockquote/components/RichTextBlockquote.d.ts +1 -1
- package/lib/extensions/Bold/components/RichTextBold.d.ts +1 -1
- package/lib/extensions/BulletList/components/RichTextBulletList.d.ts +1 -1
- package/lib/extensions/Callout/components/NodeViewCallout/NodeViewCallout.d.ts +1 -1
- package/lib/extensions/Callout/components/RichTextCallout.d.ts +1 -1
- package/lib/extensions/Clear/components/RichTextClear.d.ts +1 -1
- package/lib/extensions/Code/components/RichTextCode.d.ts +1 -1
- package/lib/extensions/CodeBlock/components/RichTextCodeBlock.d.ts +2 -1
- package/lib/extensions/CodeView/components/RichTextCodeView.d.ts +1 -1
- package/lib/extensions/Color/components/RichTextColor.d.ts +1 -1
- package/lib/extensions/Column/Column.d.ts +10 -2
- package/lib/extensions/Column/components/RichTextColumn.d.ts +1 -1
- package/lib/extensions/Drawer/components/ControlDrawer/ControlDrawer.d.ts +2 -1
- package/lib/extensions/Drawer/components/ControlDrawer/icon.d.ts +27 -27
- package/lib/extensions/Drawer/components/EditDrawerBlock.d.ts +1 -1
- package/lib/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.d.ts +2 -1
- package/lib/extensions/Drawer/components/RichTextDrawer.d.ts +1 -1
- package/lib/extensions/Emoji/components/RichTextEmoji.d.ts +2 -1
- package/lib/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.d.ts +2 -1
- package/lib/extensions/Excalidraw/components/RichTextExcalidraw.d.ts +1 -1
- package/lib/extensions/ExportPdf/components/RichTextExportPdf.d.ts +1 -1
- package/lib/extensions/ExportWord/components/RichTextExportWord.d.ts +1 -1
- package/lib/extensions/FontFamily/components/RichTextFontFamily.d.ts +1 -1
- package/lib/extensions/FontSize/components/RichTextFontSize.d.ts +1 -1
- package/lib/extensions/FormatPainter/FormatPainter.d.ts +17 -0
- package/lib/extensions/FormatPainter/components/RichTextFormatPainter.d.ts +1 -0
- package/lib/extensions/FormatPainter/index.d.ts +1 -0
- package/lib/extensions/Heading/components/RichTextHeading.d.ts +1 -1
- package/lib/extensions/Highlight/components/RichTextHighlight.d.ts +2 -1
- package/lib/extensions/History/components/RichTextHistory.d.ts +3 -2
- package/lib/extensions/HorizontalRule/components/RichTextHorizontalRule.d.ts +1 -1
- package/lib/extensions/Iframe/components/IframeNodeView.d.ts +1 -1
- package/lib/extensions/Iframe/components/RichTextIframe.d.ts +1 -1
- package/lib/extensions/Image/Image.d.ts +13 -1
- package/lib/extensions/Image/components/ImageCropper.d.ts +2 -1
- package/lib/extensions/Image/components/ImageView.d.ts +2 -1
- package/lib/extensions/Image/components/RichTextImage.d.ts +1 -1
- package/lib/extensions/ImageGif/components/ImageGifView.d.ts +2 -1
- package/lib/extensions/ImageGif/components/RichTextImageGif.d.ts +2 -1
- package/lib/extensions/ImportWord/components/RichTextImportWord.d.ts +1 -1
- package/lib/extensions/Indent/components/RichTextIndent.d.ts +1 -1
- package/lib/extensions/Italic/components/RichTextItalic.d.ts +1 -1
- package/lib/extensions/Katex/components/KatexWrapper.d.ts +1 -1
- package/lib/extensions/Katex/components/RichTextKatex.d.ts +1 -1
- package/lib/extensions/LineHeight/components/RichTextLightHeight.d.ts +1 -1
- package/lib/extensions/Link/components/LinkEditBlock.d.ts +1 -1
- package/lib/extensions/Link/components/LinkViewBlock.d.ts +2 -1
- package/lib/extensions/Link/components/RichTextLink.d.ts +1 -1
- package/lib/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.d.ts +2 -1
- package/lib/extensions/Mermaid/components/RichTextMermaid.d.ts +1 -1
- package/lib/extensions/MoreMark/components/RichTextMoreMark.d.ts +1 -1
- package/lib/extensions/OrderedList/components/RichTextOrderedList.d.ts +1 -1
- package/lib/extensions/SearchAndReplace/components/RichTextSearchAndReplace.d.ts +1 -1
- package/lib/extensions/SlashCommand/components/SlashCommandList.d.ts +1 -1
- package/lib/extensions/Strike/components/RichTextStrike.d.ts +1 -1
- package/lib/extensions/Table/components/CreateTablePopover.d.ts +2 -1
- package/lib/extensions/Table/components/RichTextTable.d.ts +2 -1
- package/lib/extensions/TaskList/components/RichTextTaskList.d.ts +1 -1
- package/lib/extensions/TextAlign/components/RichTextAlign.d.ts +1 -1
- package/lib/extensions/TextDirection/components/RichTextTextDirection.d.ts +1 -1
- package/lib/extensions/TextUnderline/components/RichTextUnderline.d.ts +1 -1
- package/lib/extensions/Twitter/components/FormEditLinkTwitter.d.ts +1 -1
- package/lib/extensions/Twitter/components/NodeViewTweet.d.ts +1 -1
- package/lib/extensions/Twitter/components/RichTextTwitter.d.ts +1 -1
- package/lib/extensions/Video/components/RichTextVideo.d.ts +1 -1
- package/lib/index-BJQ1G8B1.js +311 -0
- package/lib/index-BO82_0q8.cjs +1 -0
- package/lib/{index-D-Ouz0vF.js → index-Bn_WPziX.js} +1 -1
- package/lib/index-CwbGrQFa.cjs +1 -0
- package/lib/{index-oj858lQO.js → index-DKruDABV.js} +209 -209
- package/lib/{index-BAb_UADw.cjs → index-DN-IR-K0.cjs} +1 -1
- package/lib/{index-X6WZUM9O.js → index-DRcwHivm.js} +1702 -1486
- package/lib/index-DUeBQoIA.cjs +1 -0
- package/lib/index-DeoYYWEA.js +1756 -0
- package/lib/{index-CUvjYuRp.cjs → index-Dgs2thVL.cjs} +1 -1
- package/lib/index-DjB2kNdz.js +1120 -0
- package/lib/{index-zw-Kd38i.js → index-DuWMq-Qs.js} +1 -1
- package/lib/index-EoGU7W4e.cjs +26 -0
- package/lib/index-MDz4NZcT.cjs +12 -0
- package/lib/{index-BblvcbTH.js → index-n4kM0Ll-.js} +1527 -1406
- package/lib/index-qZURFC5Q.cjs +2 -0
- package/lib/index.cjs +1 -1
- package/lib/index.js +2 -2
- package/lib/{jsx-runtime-CT7Pcg-t.js → jsx-runtime-DE8oVoME.js} +3 -1
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +1 -1
- package/lib/locales/index.d.ts +1 -1
- package/lib/{popover-BfWFqCIs.js → popover-Beieacfy.js} +1 -1
- package/lib/{popover-BPzkMuyi.cjs → popover-Bl1kxRJX.cjs} +1 -1
- package/lib/{renderNodeView-D--fDFov.cjs → renderNodeView-BIgT6Ghg.cjs} +1 -1
- package/lib/{renderNodeView-CfWJK4rG.js → renderNodeView-Bi58v3DZ.js} +2 -2
- package/lib/{separator-DpaS43Gt.cjs → separator-DMLtkcoo.cjs} +1 -1
- package/lib/{separator-CBPrZizK.js → separator-DfvK668q.js} +11 -11
- package/lib/store/EditorEditableReactive.d.ts +1 -1
- package/lib/store/ThemeColorReactive.d.ts +1 -1
- package/lib/style.css +1 -1
- package/lib/{textarea-wvARZKyA.cjs → textarea-DV9Fw3y1.cjs} +1 -1
- package/lib/{textarea-Bl64keav.js → textarea-GXaWJbm9.js} +1 -1
- package/lib/theme.cjs +1 -1
- package/lib/theme.js +1 -1
- package/lib/types.d.ts +2 -2
- package/lib/{updatePosition-BwzAsiY0.js → updatePosition-DY1jI7qb.js} +2 -2
- package/lib/{updatePosition-DGPtRfWN.cjs → updatePosition-D_D-TbEu.cjs} +1 -1
- package/package.json +86 -72
- package/lib/Twitter--tfifMt1.cjs +0 -1
- package/lib/index-BF3EVCB1.cjs +0 -2
- package/lib/index-BG0kQamI.js +0 -285
- package/lib/index-Bcj8cyOO.cjs +0 -24
- package/lib/index-CGjT-a9h.js +0 -1377
- package/lib/index-CPTpXLfX.cjs +0 -11
- package/lib/index-CWw4s87s.cjs +0 -1
- package/lib/index-Cal5SPfB.js +0 -779
- package/lib/index-Gi752TMk.cjs +0 -1
- package/lib/index-NsYff_Ni.cjs +0 -1
package/lib/History.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Plugin as
|
|
3
|
-
import { DecorationSet as
|
|
4
|
-
import { k as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { u as J, e as Q, A as $, i as
|
|
1
|
+
import { Q as F, x as de, F as B, v as W, T as j, u as U, S as R, R as Y, U as ue, E as C, V as pe, W as fe, X as he, o as me, Y as X, C as ge } from "./index-n4kM0Ll-.js";
|
|
2
|
+
import { Plugin as x, PluginKey as I } from "@tiptap/pm/state";
|
|
3
|
+
import { DecorationSet as P, Decoration as L } from "@tiptap/pm/view";
|
|
4
|
+
import { k as ve, D as ye, a as we } from "./index-Bn_WPziX.js";
|
|
5
|
+
import { jsx as z, Fragment as Z } from "react/jsx-runtime";
|
|
6
|
+
import { u as J, e as Q, A as $, i as Ce } from "./index-DRcwHivm.js";
|
|
7
7
|
import "react";
|
|
8
8
|
import "./theme.js";
|
|
9
|
-
function
|
|
10
|
-
return new
|
|
9
|
+
function Ee(n = {}) {
|
|
10
|
+
return new F({
|
|
11
11
|
view(e) {
|
|
12
|
-
return new
|
|
12
|
+
return new Pe(e, n);
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class Pe {
|
|
17
17
|
constructor(e, t) {
|
|
18
|
-
var
|
|
19
|
-
this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (
|
|
18
|
+
var r;
|
|
19
|
+
this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (r = t.width) !== null && r !== void 0 ? r : 1, this.color = t.color === !1 ? void 0 : t.color || "black", this.class = t.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((o) => {
|
|
20
20
|
let i = (s) => {
|
|
21
|
-
this[
|
|
21
|
+
this[o](s);
|
|
22
22
|
};
|
|
23
|
-
return e.dom.addEventListener(
|
|
23
|
+
return e.dom.addEventListener(o, i), { name: o, handler: i };
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
destroy() {
|
|
@@ -33,33 +33,33 @@ class ge {
|
|
|
33
33
|
e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
|
|
34
34
|
}
|
|
35
35
|
updateOverlay() {
|
|
36
|
-
let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent,
|
|
36
|
+
let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent, r, o = this.editorView.dom, i = o.getBoundingClientRect(), s = i.width / o.offsetWidth, l = i.height / o.offsetHeight;
|
|
37
37
|
if (t) {
|
|
38
|
-
let
|
|
39
|
-
if (
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
let
|
|
45
|
-
|
|
38
|
+
let c = e.nodeBefore, p = e.nodeAfter;
|
|
39
|
+
if (c || p) {
|
|
40
|
+
let f = this.editorView.nodeDOM(this.cursorPos - (c ? c.nodeSize : 0));
|
|
41
|
+
if (f) {
|
|
42
|
+
let g = f.getBoundingClientRect(), M = c ? g.bottom : g.top;
|
|
43
|
+
c && p && (M = (M + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
|
|
44
|
+
let b = this.width / 2 * l;
|
|
45
|
+
r = { left: g.left, right: g.right, top: M - b, bottom: M + b };
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
if (!
|
|
50
|
-
let
|
|
51
|
-
|
|
49
|
+
if (!r) {
|
|
50
|
+
let c = this.editorView.coordsAtPos(this.cursorPos), p = this.width / 2 * s;
|
|
51
|
+
r = { left: c.left - p, right: c.left + p, top: c.top, bottom: c.bottom };
|
|
52
52
|
}
|
|
53
53
|
let a = this.editorView.dom.offsetParent;
|
|
54
54
|
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);
|
|
55
|
-
let
|
|
55
|
+
let d, u;
|
|
56
56
|
if (!a || a == document.body && getComputedStyle(a).position == "static")
|
|
57
|
-
|
|
57
|
+
d = -pageXOffset, u = -pageYOffset;
|
|
58
58
|
else {
|
|
59
|
-
let
|
|
60
|
-
|
|
59
|
+
let c = a.getBoundingClientRect(), p = c.width / a.offsetWidth, f = c.height / a.offsetHeight;
|
|
60
|
+
d = c.left - a.scrollLeft * p, u = c.top - a.scrollTop * f;
|
|
61
61
|
}
|
|
62
|
-
this.element.style.left = (
|
|
62
|
+
this.element.style.left = (r.left - d) / s + "px", this.element.style.top = (r.top - u) / l + "px", this.element.style.width = (r.right - r.left) / s + "px", this.element.style.height = (r.bottom - r.top) / l + "px";
|
|
63
63
|
}
|
|
64
64
|
scheduleRemoval(e) {
|
|
65
65
|
clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
|
|
@@ -67,11 +67,11 @@ class ge {
|
|
|
67
67
|
dragover(e) {
|
|
68
68
|
if (!this.editorView.editable)
|
|
69
69
|
return;
|
|
70
|
-
let t = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }),
|
|
70
|
+
let t = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), r = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), o = r && r.type.spec.disableDropCursor, i = typeof o == "function" ? o(this.editorView, t, e) : o;
|
|
71
71
|
if (t && !i) {
|
|
72
72
|
let s = t.pos;
|
|
73
73
|
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
74
|
-
let l =
|
|
74
|
+
let l = de(this.editorView.state.doc, s, this.editorView.dragging.slice);
|
|
75
75
|
l != null && (s = l);
|
|
76
76
|
}
|
|
77
77
|
this.setCursor(s), this.scheduleRemoval(5e3);
|
|
@@ -87,7 +87,7 @@ class ge {
|
|
|
87
87
|
this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
class
|
|
90
|
+
class h extends R {
|
|
91
91
|
/**
|
|
92
92
|
Create a gap cursor.
|
|
93
93
|
*/
|
|
@@ -95,14 +95,14 @@ class f extends x {
|
|
|
95
95
|
super(e, e);
|
|
96
96
|
}
|
|
97
97
|
map(e, t) {
|
|
98
|
-
let
|
|
99
|
-
return
|
|
98
|
+
let r = e.resolve(t.map(this.head));
|
|
99
|
+
return h.valid(r) ? new h(r) : R.near(r);
|
|
100
100
|
}
|
|
101
101
|
content() {
|
|
102
102
|
return W.empty;
|
|
103
103
|
}
|
|
104
104
|
eq(e) {
|
|
105
|
-
return e instanceof
|
|
105
|
+
return e instanceof h && e.head == this.head;
|
|
106
106
|
}
|
|
107
107
|
toJSON() {
|
|
108
108
|
return { type: "gapcursor", pos: this.head };
|
|
@@ -113,35 +113,35 @@ class f extends x {
|
|
|
113
113
|
static fromJSON(e, t) {
|
|
114
114
|
if (typeof t.pos != "number")
|
|
115
115
|
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
116
|
-
return new
|
|
116
|
+
return new h(e.resolve(t.pos));
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
@internal
|
|
120
120
|
*/
|
|
121
121
|
getBookmark() {
|
|
122
|
-
return new
|
|
122
|
+
return new V(this.anchor);
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
@internal
|
|
126
126
|
*/
|
|
127
127
|
static valid(e) {
|
|
128
128
|
let t = e.parent;
|
|
129
|
-
if (t.inlineContent || !
|
|
129
|
+
if (t.inlineContent || !Me(e) || !be(e))
|
|
130
130
|
return !1;
|
|
131
|
-
let
|
|
132
|
-
if (
|
|
133
|
-
return
|
|
134
|
-
let
|
|
135
|
-
return
|
|
131
|
+
let r = t.type.spec.allowGapCursor;
|
|
132
|
+
if (r != null)
|
|
133
|
+
return r;
|
|
134
|
+
let o = t.contentMatchAt(e.index()).defaultType;
|
|
135
|
+
return o && o.isTextblock;
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
@internal
|
|
139
139
|
*/
|
|
140
|
-
static findGapCursorFrom(e, t,
|
|
140
|
+
static findGapCursorFrom(e, t, r = !1) {
|
|
141
141
|
e: for (; ; ) {
|
|
142
|
-
if (!
|
|
142
|
+
if (!r && h.valid(e))
|
|
143
143
|
return e;
|
|
144
|
-
let
|
|
144
|
+
let o = e.pos, i = null;
|
|
145
145
|
for (let s = e.depth; ; s--) {
|
|
146
146
|
let l = e.node(s);
|
|
147
147
|
if (t > 0 ? e.indexAfter(s) < l.childCount : e.index(s) > 0) {
|
|
@@ -149,238 +149,238 @@ class f extends x {
|
|
|
149
149
|
break;
|
|
150
150
|
} else if (s == 0)
|
|
151
151
|
return null;
|
|
152
|
-
|
|
153
|
-
let a = e.doc.resolve(
|
|
154
|
-
if (
|
|
152
|
+
o += t;
|
|
153
|
+
let a = e.doc.resolve(o);
|
|
154
|
+
if (h.valid(a))
|
|
155
155
|
return a;
|
|
156
156
|
}
|
|
157
157
|
for (; ; ) {
|
|
158
158
|
let s = t > 0 ? i.firstChild : i.lastChild;
|
|
159
159
|
if (!s) {
|
|
160
|
-
if (i.isAtom && !i.isText && !
|
|
161
|
-
e = e.doc.resolve(
|
|
160
|
+
if (i.isAtom && !i.isText && !U.isSelectable(i)) {
|
|
161
|
+
e = e.doc.resolve(o + i.nodeSize * t), r = !1;
|
|
162
162
|
continue e;
|
|
163
163
|
}
|
|
164
164
|
break;
|
|
165
165
|
}
|
|
166
|
-
i = s,
|
|
167
|
-
let l = e.doc.resolve(
|
|
168
|
-
if (
|
|
166
|
+
i = s, o += t;
|
|
167
|
+
let l = e.doc.resolve(o);
|
|
168
|
+
if (h.valid(l))
|
|
169
169
|
return l;
|
|
170
170
|
}
|
|
171
171
|
return null;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
class
|
|
175
|
+
h.prototype.visible = !1;
|
|
176
|
+
h.findFrom = h.findGapCursorFrom;
|
|
177
|
+
R.jsonID("gapcursor", h);
|
|
178
|
+
class V {
|
|
179
179
|
constructor(e) {
|
|
180
180
|
this.pos = e;
|
|
181
181
|
}
|
|
182
182
|
map(e) {
|
|
183
|
-
return new
|
|
183
|
+
return new V(e.map(this.pos));
|
|
184
184
|
}
|
|
185
185
|
resolve(e) {
|
|
186
186
|
let t = e.resolve(this.pos);
|
|
187
|
-
return
|
|
187
|
+
return h.valid(t) ? new h(t) : R.near(t);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
function q(
|
|
191
|
-
return
|
|
190
|
+
function q(n) {
|
|
191
|
+
return n.isAtom || n.spec.isolating || n.spec.createGapCursor;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
for (let e =
|
|
195
|
-
let t =
|
|
193
|
+
function Me(n) {
|
|
194
|
+
for (let e = n.depth; e >= 0; e--) {
|
|
195
|
+
let t = n.index(e), r = n.node(e);
|
|
196
196
|
if (t == 0) {
|
|
197
|
-
if (
|
|
197
|
+
if (r.type.spec.isolating)
|
|
198
198
|
return !0;
|
|
199
199
|
continue;
|
|
200
200
|
}
|
|
201
|
-
for (let
|
|
202
|
-
if (
|
|
201
|
+
for (let o = r.child(t - 1); ; o = o.lastChild) {
|
|
202
|
+
if (o.childCount == 0 && !o.inlineContent || q(o.type))
|
|
203
203
|
return !0;
|
|
204
|
-
if (
|
|
204
|
+
if (o.inlineContent)
|
|
205
205
|
return !1;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
return !0;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
211
|
-
for (let e =
|
|
212
|
-
let t =
|
|
213
|
-
if (t ==
|
|
214
|
-
if (
|
|
210
|
+
function be(n) {
|
|
211
|
+
for (let e = n.depth; e >= 0; e--) {
|
|
212
|
+
let t = n.indexAfter(e), r = n.node(e);
|
|
213
|
+
if (t == r.childCount) {
|
|
214
|
+
if (r.type.spec.isolating)
|
|
215
215
|
return !0;
|
|
216
216
|
continue;
|
|
217
217
|
}
|
|
218
|
-
for (let
|
|
219
|
-
if (
|
|
218
|
+
for (let o = r.child(t); ; o = o.firstChild) {
|
|
219
|
+
if (o.childCount == 0 && !o.inlineContent || q(o.type))
|
|
220
220
|
return !0;
|
|
221
|
-
if (
|
|
221
|
+
if (o.inlineContent)
|
|
222
222
|
return !1;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
return !0;
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
return new
|
|
227
|
+
function Ae() {
|
|
228
|
+
return new F({
|
|
229
229
|
props: {
|
|
230
|
-
decorations:
|
|
231
|
-
createSelectionBetween(
|
|
232
|
-
return e.pos == t.pos &&
|
|
230
|
+
decorations: Se,
|
|
231
|
+
createSelectionBetween(n, e, t) {
|
|
232
|
+
return e.pos == t.pos && h.valid(t) ? new h(t) : null;
|
|
233
233
|
},
|
|
234
|
-
handleClick:
|
|
235
|
-
handleKeyDown:
|
|
236
|
-
handleDOMEvents: { beforeinput:
|
|
234
|
+
handleClick: xe,
|
|
235
|
+
handleKeyDown: Te,
|
|
236
|
+
handleDOMEvents: { beforeinput: Ie }
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
|
-
const
|
|
241
|
-
ArrowLeft:
|
|
242
|
-
ArrowRight:
|
|
243
|
-
ArrowUp:
|
|
244
|
-
ArrowDown:
|
|
240
|
+
const Te = ve({
|
|
241
|
+
ArrowLeft: S("horiz", -1),
|
|
242
|
+
ArrowRight: S("horiz", 1),
|
|
243
|
+
ArrowUp: S("vert", -1),
|
|
244
|
+
ArrowDown: S("vert", 1)
|
|
245
245
|
});
|
|
246
|
-
function
|
|
247
|
-
const t =
|
|
248
|
-
return function(
|
|
249
|
-
let s =
|
|
246
|
+
function S(n, e) {
|
|
247
|
+
const t = n == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
|
|
248
|
+
return function(r, o, i) {
|
|
249
|
+
let s = r.selection, l = e > 0 ? s.$to : s.$from, a = s.empty;
|
|
250
250
|
if (s instanceof j) {
|
|
251
251
|
if (!i.endOfTextblock(t) || l.depth == 0)
|
|
252
252
|
return !1;
|
|
253
|
-
a = !1, l =
|
|
253
|
+
a = !1, l = r.doc.resolve(e > 0 ? l.after() : l.before());
|
|
254
254
|
}
|
|
255
|
-
let
|
|
256
|
-
return
|
|
255
|
+
let d = h.findGapCursorFrom(l, e, a);
|
|
256
|
+
return d ? (o && o(r.tr.setSelection(new h(d))), !0) : !1;
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
if (!
|
|
259
|
+
function xe(n, e, t) {
|
|
260
|
+
if (!n || !n.editable)
|
|
261
261
|
return !1;
|
|
262
|
-
let
|
|
263
|
-
if (!
|
|
262
|
+
let r = n.state.doc.resolve(e);
|
|
263
|
+
if (!h.valid(r))
|
|
264
264
|
return !1;
|
|
265
|
-
let
|
|
266
|
-
return
|
|
265
|
+
let o = n.posAtCoords({ left: t.clientX, top: t.clientY });
|
|
266
|
+
return o && o.inside > -1 && U.isSelectable(n.state.doc.nodeAt(o.inside)) ? !1 : (n.dispatch(n.state.tr.setSelection(new h(r))), !0);
|
|
267
267
|
}
|
|
268
|
-
function
|
|
269
|
-
if (e.inputType != "insertCompositionText" || !(
|
|
268
|
+
function Ie(n, e) {
|
|
269
|
+
if (e.inputType != "insertCompositionText" || !(n.state.selection instanceof h))
|
|
270
270
|
return !1;
|
|
271
|
-
let { $from: t } =
|
|
272
|
-
if (!
|
|
271
|
+
let { $from: t } = n.state.selection, r = t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);
|
|
272
|
+
if (!r)
|
|
273
273
|
return !1;
|
|
274
|
-
let
|
|
275
|
-
for (let s =
|
|
276
|
-
|
|
277
|
-
let i =
|
|
278
|
-
return i.setSelection(j.near(i.doc.resolve(t.pos + 1))),
|
|
274
|
+
let o = B.empty;
|
|
275
|
+
for (let s = r.length - 1; s >= 0; s--)
|
|
276
|
+
o = B.from(r[s].createAndFill(null, o));
|
|
277
|
+
let i = n.state.tr.replace(t.pos, t.pos, new W(o, 0, 0));
|
|
278
|
+
return i.setSelection(j.near(i.doc.resolve(t.pos + 1))), n.dispatch(i), !1;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
281
|
-
if (!(
|
|
280
|
+
function Se(n) {
|
|
281
|
+
if (!(n.selection instanceof h))
|
|
282
282
|
return null;
|
|
283
283
|
let e = document.createElement("div");
|
|
284
|
-
return e.className = "ProseMirror-gapcursor",
|
|
284
|
+
return e.className = "ProseMirror-gapcursor", ye.create(n.doc, [we.widget(n.selection.head, e, { key: "gapcursor" })]);
|
|
285
285
|
}
|
|
286
|
-
var D = 200,
|
|
286
|
+
var D = 200, m = function() {
|
|
287
287
|
};
|
|
288
|
-
|
|
289
|
-
return e.length ? (e =
|
|
288
|
+
m.prototype.append = function(e) {
|
|
289
|
+
return e.length ? (e = m.from(e), !this.length && e || e.length < D && this.leafAppend(e) || this.length < D && e.leafPrepend(this) || this.appendInner(e)) : this;
|
|
290
290
|
};
|
|
291
|
-
|
|
292
|
-
return e.length ?
|
|
291
|
+
m.prototype.prepend = function(e) {
|
|
292
|
+
return e.length ? m.from(e).append(this) : this;
|
|
293
293
|
};
|
|
294
|
-
|
|
295
|
-
return new
|
|
294
|
+
m.prototype.appendInner = function(e) {
|
|
295
|
+
return new Oe(this, e);
|
|
296
296
|
};
|
|
297
|
-
|
|
298
|
-
return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ?
|
|
297
|
+
m.prototype.slice = function(e, t) {
|
|
298
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? m.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
|
|
299
299
|
};
|
|
300
|
-
|
|
300
|
+
m.prototype.get = function(e) {
|
|
301
301
|
if (!(e < 0 || e >= this.length))
|
|
302
302
|
return this.getInner(e);
|
|
303
303
|
};
|
|
304
|
-
|
|
305
|
-
t === void 0 && (t = 0),
|
|
304
|
+
m.prototype.forEach = function(e, t, r) {
|
|
305
|
+
t === void 0 && (t = 0), r === void 0 && (r = this.length), t <= r ? this.forEachInner(e, t, r, 0) : this.forEachInvertedInner(e, t, r, 0);
|
|
306
306
|
};
|
|
307
|
-
|
|
308
|
-
t === void 0 && (t = 0),
|
|
309
|
-
var
|
|
307
|
+
m.prototype.map = function(e, t, r) {
|
|
308
|
+
t === void 0 && (t = 0), r === void 0 && (r = this.length);
|
|
309
|
+
var o = [];
|
|
310
310
|
return this.forEach(function(i, s) {
|
|
311
|
-
return
|
|
312
|
-
}, t,
|
|
311
|
+
return o.push(e(i, s));
|
|
312
|
+
}, t, r), o;
|
|
313
313
|
};
|
|
314
|
-
|
|
315
|
-
return e instanceof
|
|
314
|
+
m.from = function(e) {
|
|
315
|
+
return e instanceof m ? e : e && e.length ? new ee(e) : m.empty;
|
|
316
316
|
};
|
|
317
|
-
var ee = /* @__PURE__ */ (function(
|
|
318
|
-
function e(
|
|
319
|
-
|
|
317
|
+
var ee = /* @__PURE__ */ (function(n) {
|
|
318
|
+
function e(r) {
|
|
319
|
+
n.call(this), this.values = r;
|
|
320
320
|
}
|
|
321
|
-
|
|
321
|
+
n && (e.__proto__ = n), e.prototype = Object.create(n && n.prototype), e.prototype.constructor = e;
|
|
322
322
|
var t = { length: { configurable: !0 }, depth: { configurable: !0 } };
|
|
323
323
|
return e.prototype.flatten = function() {
|
|
324
324
|
return this.values;
|
|
325
|
-
}, e.prototype.sliceInner = function(
|
|
326
|
-
return
|
|
327
|
-
}, e.prototype.getInner = function(
|
|
328
|
-
return this.values[
|
|
329
|
-
}, e.prototype.forEachInner = function(
|
|
325
|
+
}, e.prototype.sliceInner = function(o, i) {
|
|
326
|
+
return o == 0 && i == this.length ? this : new e(this.values.slice(o, i));
|
|
327
|
+
}, e.prototype.getInner = function(o) {
|
|
328
|
+
return this.values[o];
|
|
329
|
+
}, e.prototype.forEachInner = function(o, i, s, l) {
|
|
330
330
|
for (var a = i; a < s; a++)
|
|
331
|
-
if (
|
|
331
|
+
if (o(this.values[a], l + a) === !1)
|
|
332
332
|
return !1;
|
|
333
|
-
}, e.prototype.forEachInvertedInner = function(
|
|
333
|
+
}, e.prototype.forEachInvertedInner = function(o, i, s, l) {
|
|
334
334
|
for (var a = i - 1; a >= s; a--)
|
|
335
|
-
if (
|
|
335
|
+
if (o(this.values[a], l + a) === !1)
|
|
336
336
|
return !1;
|
|
337
|
-
}, e.prototype.leafAppend = function(
|
|
338
|
-
if (this.length +
|
|
339
|
-
return new e(this.values.concat(
|
|
340
|
-
}, e.prototype.leafPrepend = function(
|
|
341
|
-
if (this.length +
|
|
342
|
-
return new e(
|
|
337
|
+
}, e.prototype.leafAppend = function(o) {
|
|
338
|
+
if (this.length + o.length <= D)
|
|
339
|
+
return new e(this.values.concat(o.flatten()));
|
|
340
|
+
}, e.prototype.leafPrepend = function(o) {
|
|
341
|
+
if (this.length + o.length <= D)
|
|
342
|
+
return new e(o.flatten().concat(this.values));
|
|
343
343
|
}, t.length.get = function() {
|
|
344
344
|
return this.values.length;
|
|
345
345
|
}, t.depth.get = function() {
|
|
346
346
|
return 0;
|
|
347
347
|
}, Object.defineProperties(e.prototype, t), e;
|
|
348
|
-
})(
|
|
349
|
-
|
|
350
|
-
var
|
|
351
|
-
function e(t,
|
|
352
|
-
|
|
348
|
+
})(m);
|
|
349
|
+
m.empty = new ee([]);
|
|
350
|
+
var Oe = /* @__PURE__ */ (function(n) {
|
|
351
|
+
function e(t, r) {
|
|
352
|
+
n.call(this), this.left = t, this.right = r, this.length = t.length + r.length, this.depth = Math.max(t.depth, r.depth) + 1;
|
|
353
353
|
}
|
|
354
|
-
return
|
|
354
|
+
return n && (e.__proto__ = n), e.prototype = Object.create(n && n.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
|
|
355
355
|
return this.left.flatten().concat(this.right.flatten());
|
|
356
|
-
}, e.prototype.getInner = function(
|
|
357
|
-
return
|
|
358
|
-
}, e.prototype.forEachInner = function(
|
|
356
|
+
}, e.prototype.getInner = function(r) {
|
|
357
|
+
return r < this.left.length ? this.left.get(r) : this.right.get(r - this.left.length);
|
|
358
|
+
}, e.prototype.forEachInner = function(r, o, i, s) {
|
|
359
359
|
var l = this.left.length;
|
|
360
|
-
if (
|
|
360
|
+
if (o < l && this.left.forEachInner(r, o, Math.min(i, l), s) === !1 || i > l && this.right.forEachInner(r, Math.max(o - l, 0), Math.min(this.length, i) - l, s + l) === !1)
|
|
361
361
|
return !1;
|
|
362
|
-
}, e.prototype.forEachInvertedInner = function(
|
|
362
|
+
}, e.prototype.forEachInvertedInner = function(r, o, i, s) {
|
|
363
363
|
var l = this.left.length;
|
|
364
|
-
if (
|
|
364
|
+
if (o > l && this.right.forEachInvertedInner(r, o - l, Math.max(i, l) - l, s + l) === !1 || i < l && this.left.forEachInvertedInner(r, Math.min(o, l), i, s) === !1)
|
|
365
365
|
return !1;
|
|
366
|
-
}, e.prototype.sliceInner = function(
|
|
367
|
-
if (
|
|
366
|
+
}, e.prototype.sliceInner = function(r, o) {
|
|
367
|
+
if (r == 0 && o == this.length)
|
|
368
368
|
return this;
|
|
369
369
|
var i = this.left.length;
|
|
370
|
-
return
|
|
371
|
-
}, e.prototype.leafAppend = function(
|
|
372
|
-
var
|
|
373
|
-
if (
|
|
374
|
-
return new e(this.left,
|
|
375
|
-
}, e.prototype.leafPrepend = function(
|
|
376
|
-
var
|
|
377
|
-
if (
|
|
378
|
-
return new e(
|
|
379
|
-
}, e.prototype.appendInner = function(
|
|
380
|
-
return this.left.depth >= Math.max(this.right.depth,
|
|
370
|
+
return o <= i ? this.left.slice(r, o) : r >= i ? this.right.slice(r - i, o - i) : this.left.slice(r, i).append(this.right.slice(0, o - i));
|
|
371
|
+
}, e.prototype.leafAppend = function(r) {
|
|
372
|
+
var o = this.right.leafAppend(r);
|
|
373
|
+
if (o)
|
|
374
|
+
return new e(this.left, o);
|
|
375
|
+
}, e.prototype.leafPrepend = function(r) {
|
|
376
|
+
var o = this.left.leafPrepend(r);
|
|
377
|
+
if (o)
|
|
378
|
+
return new e(o, this.right);
|
|
379
|
+
}, e.prototype.appendInner = function(r) {
|
|
380
|
+
return this.left.depth >= Math.max(this.right.depth, r.depth) + 1 ? new e(this.left, new e(this.right, r)) : new e(this, r);
|
|
381
381
|
}, e;
|
|
382
|
-
})(
|
|
383
|
-
const
|
|
382
|
+
})(m);
|
|
383
|
+
const Re = 500;
|
|
384
384
|
class v {
|
|
385
385
|
constructor(e, t) {
|
|
386
386
|
this.items = e, this.eventCount = t;
|
|
@@ -390,49 +390,49 @@ class v {
|
|
|
390
390
|
popEvent(e, t) {
|
|
391
391
|
if (this.eventCount == 0)
|
|
392
392
|
return null;
|
|
393
|
-
let
|
|
394
|
-
for (; ;
|
|
395
|
-
if (this.items.get(
|
|
396
|
-
--
|
|
393
|
+
let r = this.items.length;
|
|
394
|
+
for (; ; r--)
|
|
395
|
+
if (this.items.get(r - 1).selection) {
|
|
396
|
+
--r;
|
|
397
397
|
break;
|
|
398
398
|
}
|
|
399
|
-
let
|
|
400
|
-
t && (
|
|
401
|
-
let s = e.tr, l, a,
|
|
402
|
-
return this.items.forEach((
|
|
403
|
-
if (!
|
|
404
|
-
|
|
399
|
+
let o, i;
|
|
400
|
+
t && (o = this.remapping(r, this.items.length), i = o.maps.length);
|
|
401
|
+
let s = e.tr, l, a, d = [], u = [];
|
|
402
|
+
return this.items.forEach((c, p) => {
|
|
403
|
+
if (!c.step) {
|
|
404
|
+
o || (o = this.remapping(r, p + 1), i = o.maps.length), i--, u.push(c);
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
let
|
|
410
|
-
|
|
407
|
+
if (o) {
|
|
408
|
+
u.push(new y(c.map));
|
|
409
|
+
let f = c.step.map(o.slice(i)), g;
|
|
410
|
+
f && s.maybeStep(f).doc && (g = s.mapping.maps[s.mapping.maps.length - 1], d.push(new y(g, void 0, void 0, d.length + u.length))), i--, g && o.appendMap(g, i);
|
|
411
411
|
} else
|
|
412
|
-
s.maybeStep(
|
|
413
|
-
if (
|
|
414
|
-
return l =
|
|
412
|
+
s.maybeStep(c.step);
|
|
413
|
+
if (c.selection)
|
|
414
|
+
return l = o ? c.selection.map(o.slice(i)) : c.selection, a = new v(this.items.slice(0, r).append(u.reverse().concat(d)), this.eventCount - 1), !1;
|
|
415
415
|
}, this.items.length, 0), { remaining: a, transform: s, selection: l };
|
|
416
416
|
}
|
|
417
417
|
// Create a new branch with the given transform added.
|
|
418
|
-
addTransform(e, t,
|
|
419
|
-
let i = [], s = this.eventCount, l = this.items, a = !
|
|
420
|
-
for (let
|
|
421
|
-
let
|
|
422
|
-
(
|
|
418
|
+
addTransform(e, t, r, o) {
|
|
419
|
+
let i = [], s = this.eventCount, l = this.items, a = !o && l.length ? l.get(l.length - 1) : null;
|
|
420
|
+
for (let u = 0; u < e.steps.length; u++) {
|
|
421
|
+
let c = e.steps[u].invert(e.docs[u]), p = new y(e.mapping.maps[u], c, t), f;
|
|
422
|
+
(f = a && a.merge(p)) && (p = f, u ? i.pop() : l = l.slice(0, l.length - 1)), i.push(p), t && (s++, t = void 0), o || (a = p);
|
|
423
423
|
}
|
|
424
|
-
let
|
|
425
|
-
return
|
|
424
|
+
let d = s - r.depth;
|
|
425
|
+
return d > De && (l = ze(l, d), s -= d), new v(l.append(i), s);
|
|
426
426
|
}
|
|
427
427
|
remapping(e, t) {
|
|
428
|
-
let
|
|
429
|
-
return this.items.forEach((
|
|
430
|
-
let s =
|
|
431
|
-
|
|
432
|
-
}, e, t),
|
|
428
|
+
let r = new ue();
|
|
429
|
+
return this.items.forEach((o, i) => {
|
|
430
|
+
let s = o.mirrorOffset != null && i - o.mirrorOffset >= e ? r.maps.length - o.mirrorOffset : void 0;
|
|
431
|
+
r.appendMap(o.map, s);
|
|
432
|
+
}, e, t), r;
|
|
433
433
|
}
|
|
434
434
|
addMaps(e) {
|
|
435
|
-
return this.eventCount == 0 ? this : new v(this.items.append(e.map((t) => new
|
|
435
|
+
return this.eventCount == 0 ? this : new v(this.items.append(e.map((t) => new y(t))), this.eventCount);
|
|
436
436
|
}
|
|
437
437
|
// When the collab module receives remote changes, the history has
|
|
438
438
|
// to know about those, so that it can adjust the steps that were
|
|
@@ -441,28 +441,28 @@ class v {
|
|
|
441
441
|
rebased(e, t) {
|
|
442
442
|
if (!this.eventCount)
|
|
443
443
|
return this;
|
|
444
|
-
let
|
|
445
|
-
this.items.forEach((
|
|
446
|
-
|
|
447
|
-
},
|
|
444
|
+
let r = [], o = Math.max(0, this.items.length - t), i = e.mapping, s = e.steps.length, l = this.eventCount;
|
|
445
|
+
this.items.forEach((p) => {
|
|
446
|
+
p.selection && l--;
|
|
447
|
+
}, o);
|
|
448
448
|
let a = t;
|
|
449
|
-
this.items.forEach((
|
|
450
|
-
let
|
|
451
|
-
if (
|
|
449
|
+
this.items.forEach((p) => {
|
|
450
|
+
let f = i.getMirror(--a);
|
|
451
|
+
if (f == null)
|
|
452
452
|
return;
|
|
453
|
-
s = Math.min(s,
|
|
454
|
-
let
|
|
455
|
-
if (
|
|
456
|
-
let
|
|
457
|
-
|
|
453
|
+
s = Math.min(s, f);
|
|
454
|
+
let g = i.maps[f];
|
|
455
|
+
if (p.step) {
|
|
456
|
+
let M = e.steps[f].invert(e.docs[f]), b = p.selection && p.selection.map(i.slice(a + 1, f));
|
|
457
|
+
b && l++, r.push(new y(g, M, b));
|
|
458
458
|
} else
|
|
459
|
-
|
|
460
|
-
},
|
|
461
|
-
let
|
|
462
|
-
for (let
|
|
463
|
-
|
|
464
|
-
let
|
|
465
|
-
return
|
|
459
|
+
r.push(new y(g));
|
|
460
|
+
}, o);
|
|
461
|
+
let d = [];
|
|
462
|
+
for (let p = t; p < s; p++)
|
|
463
|
+
d.push(new y(i.maps[p]));
|
|
464
|
+
let u = this.items.slice(0, o).append(d).append(r), c = new v(u, l);
|
|
465
|
+
return c.emptyItemCount() > Re && (c = c.compress(this.items.length - r.length)), c;
|
|
466
466
|
}
|
|
467
467
|
emptyItemCount() {
|
|
468
468
|
let e = 0;
|
|
@@ -477,158 +477,158 @@ class v {
|
|
|
477
477
|
// because `rebased` relies on a clean, untouched set of items in
|
|
478
478
|
// order to associate old items with rebased steps.
|
|
479
479
|
compress(e = this.items.length) {
|
|
480
|
-
let t = this.remapping(0, e),
|
|
480
|
+
let t = this.remapping(0, e), r = t.maps.length, o = [], i = 0;
|
|
481
481
|
return this.items.forEach((s, l) => {
|
|
482
482
|
if (l >= e)
|
|
483
|
-
|
|
483
|
+
o.push(s), s.selection && i++;
|
|
484
484
|
else if (s.step) {
|
|
485
|
-
let a = s.step.map(t.slice(
|
|
486
|
-
if (
|
|
487
|
-
let
|
|
488
|
-
|
|
489
|
-
let
|
|
490
|
-
(
|
|
485
|
+
let a = s.step.map(t.slice(r)), d = a && a.getMap();
|
|
486
|
+
if (r--, d && t.appendMap(d, r), a) {
|
|
487
|
+
let u = s.selection && s.selection.map(t.slice(r));
|
|
488
|
+
u && i++;
|
|
489
|
+
let c = new y(d.invert(), a, u), p, f = o.length - 1;
|
|
490
|
+
(p = o.length && o[f].merge(c)) ? o[f] = p : o.push(c);
|
|
491
491
|
}
|
|
492
|
-
} else s.map &&
|
|
493
|
-
}, this.items.length, 0), new v(
|
|
492
|
+
} else s.map && r--;
|
|
493
|
+
}, this.items.length, 0), new v(m.from(o.reverse()), i);
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
v.empty = new v(
|
|
497
|
-
function
|
|
496
|
+
v.empty = new v(m.empty, 0);
|
|
497
|
+
function ze(n, e) {
|
|
498
498
|
let t;
|
|
499
|
-
return
|
|
500
|
-
if (
|
|
501
|
-
return t =
|
|
502
|
-
}),
|
|
499
|
+
return n.forEach((r, o) => {
|
|
500
|
+
if (r.selection && e-- == 0)
|
|
501
|
+
return t = o, !1;
|
|
502
|
+
}), n.slice(t);
|
|
503
503
|
}
|
|
504
|
-
class
|
|
505
|
-
constructor(e, t,
|
|
506
|
-
this.map = e, this.step = t, this.selection =
|
|
504
|
+
class y {
|
|
505
|
+
constructor(e, t, r, o) {
|
|
506
|
+
this.map = e, this.step = t, this.selection = r, this.mirrorOffset = o;
|
|
507
507
|
}
|
|
508
508
|
merge(e) {
|
|
509
509
|
if (this.step && e.step && !e.selection) {
|
|
510
510
|
let t = e.step.merge(this.step);
|
|
511
511
|
if (t)
|
|
512
|
-
return new
|
|
512
|
+
return new y(t.getMap().invert(), t, this.selection);
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
-
class
|
|
517
|
-
constructor(e, t,
|
|
518
|
-
this.done = e, this.undone = t, this.prevRanges =
|
|
516
|
+
class w {
|
|
517
|
+
constructor(e, t, r, o, i) {
|
|
518
|
+
this.done = e, this.undone = t, this.prevRanges = r, this.prevTime = o, this.prevComposition = i;
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
|
-
const
|
|
522
|
-
function
|
|
523
|
-
let
|
|
524
|
-
if (
|
|
525
|
-
return
|
|
526
|
-
t.getMeta(
|
|
521
|
+
const De = 20;
|
|
522
|
+
function ke(n, e, t, r) {
|
|
523
|
+
let o = t.getMeta(E), i;
|
|
524
|
+
if (o)
|
|
525
|
+
return o.historyState;
|
|
526
|
+
t.getMeta(Le) && (n = new w(n.done, n.undone, null, 0, -1));
|
|
527
527
|
let s = t.getMeta("appendedTransaction");
|
|
528
528
|
if (t.steps.length == 0)
|
|
529
|
-
return
|
|
529
|
+
return n;
|
|
530
530
|
if (s && s.getMeta(E))
|
|
531
|
-
return s.getMeta(E).redo ? new
|
|
531
|
+
return s.getMeta(E).redo ? new w(n.done.addTransform(t, void 0, r, O(e)), n.undone, _(t.mapping.maps), n.prevTime, n.prevComposition) : new w(n.done, n.undone.addTransform(t, void 0, r, O(e)), null, n.prevTime, n.prevComposition);
|
|
532
532
|
if (t.getMeta("addToHistory") !== !1 && !(s && s.getMeta("addToHistory") === !1)) {
|
|
533
|
-
let l = t.getMeta("composition"), a =
|
|
534
|
-
return new
|
|
535
|
-
} else return (i = t.getMeta("rebased")) ? new
|
|
533
|
+
let l = t.getMeta("composition"), a = n.prevTime == 0 || !s && n.prevComposition != l && (n.prevTime < (t.time || 0) - r.newGroupDelay || !Ne(t, n.prevRanges)), d = s ? k(n.prevRanges, t.mapping) : _(t.mapping.maps);
|
|
534
|
+
return new w(n.done.addTransform(t, a ? e.selection.getBookmark() : void 0, r, O(e)), v.empty, d, t.time, l ?? n.prevComposition);
|
|
535
|
+
} else return (i = t.getMeta("rebased")) ? new w(n.done.rebased(t, i), n.undone.rebased(t, i), k(n.prevRanges, t.mapping), n.prevTime, n.prevComposition) : new w(n.done.addMaps(t.mapping.maps), n.undone.addMaps(t.mapping.maps), k(n.prevRanges, t.mapping), n.prevTime, n.prevComposition);
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function Ne(n, e) {
|
|
538
538
|
if (!e)
|
|
539
539
|
return !1;
|
|
540
|
-
if (!
|
|
540
|
+
if (!n.docChanged)
|
|
541
541
|
return !0;
|
|
542
542
|
let t = !1;
|
|
543
|
-
return
|
|
543
|
+
return n.mapping.maps[0].forEach((r, o) => {
|
|
544
544
|
for (let i = 0; i < e.length; i += 2)
|
|
545
|
-
|
|
545
|
+
r <= e[i + 1] && o >= e[i] && (t = !0);
|
|
546
546
|
}), t;
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function _(n) {
|
|
549
549
|
let e = [];
|
|
550
|
-
for (let t =
|
|
551
|
-
|
|
550
|
+
for (let t = n.length - 1; t >= 0 && e.length == 0; t--)
|
|
551
|
+
n[t].forEach((r, o, i, s) => e.push(i, s));
|
|
552
552
|
return e;
|
|
553
553
|
}
|
|
554
|
-
function k(
|
|
555
|
-
if (!
|
|
554
|
+
function k(n, e) {
|
|
555
|
+
if (!n)
|
|
556
556
|
return null;
|
|
557
557
|
let t = [];
|
|
558
|
-
for (let
|
|
559
|
-
let
|
|
560
|
-
|
|
558
|
+
for (let r = 0; r < n.length; r += 2) {
|
|
559
|
+
let o = e.map(n[r], 1), i = e.map(n[r + 1], -1);
|
|
560
|
+
o <= i && t.push(o, i);
|
|
561
561
|
}
|
|
562
562
|
return t;
|
|
563
563
|
}
|
|
564
|
-
function
|
|
565
|
-
let
|
|
564
|
+
function Fe(n, e, t) {
|
|
565
|
+
let r = O(e), o = E.get(e).spec.config, i = (t ? n.undone : n.done).popEvent(e, r);
|
|
566
566
|
if (!i)
|
|
567
567
|
return null;
|
|
568
|
-
let s = i.selection.resolve(i.transform.doc), l = (t ?
|
|
568
|
+
let s = i.selection.resolve(i.transform.doc), l = (t ? n.done : n.undone).addTransform(i.transform, e.selection.getBookmark(), o, r), a = new w(t ? l : i.remaining, t ? i.remaining : l, null, 0, -1);
|
|
569
569
|
return i.transform.setSelection(s).setMeta(E, { redo: t, historyState: a });
|
|
570
570
|
}
|
|
571
|
-
let
|
|
572
|
-
function
|
|
573
|
-
let e =
|
|
571
|
+
let N = !1, K = null;
|
|
572
|
+
function O(n) {
|
|
573
|
+
let e = n.plugins;
|
|
574
574
|
if (K != e) {
|
|
575
|
-
|
|
575
|
+
N = !1, K = e;
|
|
576
576
|
for (let t = 0; t < e.length; t++)
|
|
577
577
|
if (e[t].spec.historyPreserveItems) {
|
|
578
|
-
|
|
578
|
+
N = !0;
|
|
579
579
|
break;
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
return
|
|
582
|
+
return N;
|
|
583
583
|
}
|
|
584
|
-
const E = new
|
|
585
|
-
function
|
|
586
|
-
return
|
|
587
|
-
depth:
|
|
588
|
-
newGroupDelay:
|
|
589
|
-
}, new
|
|
584
|
+
const E = new Y("history"), Le = new Y("closeHistory");
|
|
585
|
+
function Ve(n = {}) {
|
|
586
|
+
return n = {
|
|
587
|
+
depth: n.depth || 100,
|
|
588
|
+
newGroupDelay: n.newGroupDelay || 500
|
|
589
|
+
}, new F({
|
|
590
590
|
key: E,
|
|
591
591
|
state: {
|
|
592
592
|
init() {
|
|
593
|
-
return new
|
|
593
|
+
return new w(v.empty, v.empty, null, 0, -1);
|
|
594
594
|
},
|
|
595
|
-
apply(e, t,
|
|
596
|
-
return
|
|
595
|
+
apply(e, t, r) {
|
|
596
|
+
return ke(t, r, e, n);
|
|
597
597
|
}
|
|
598
598
|
},
|
|
599
|
-
config:
|
|
599
|
+
config: n,
|
|
600
600
|
props: {
|
|
601
601
|
handleDOMEvents: {
|
|
602
602
|
beforeinput(e, t) {
|
|
603
|
-
let
|
|
604
|
-
return !
|
|
603
|
+
let r = t.inputType, o = r == "historyUndo" ? ne : r == "historyRedo" ? re : null;
|
|
604
|
+
return !o || !e.editable ? !1 : (t.preventDefault(), o(e.state, e.dispatch));
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
608
|
});
|
|
609
609
|
}
|
|
610
|
-
function te(
|
|
611
|
-
return (t,
|
|
612
|
-
let
|
|
613
|
-
if (!
|
|
610
|
+
function te(n, e) {
|
|
611
|
+
return (t, r) => {
|
|
612
|
+
let o = E.getState(t);
|
|
613
|
+
if (!o || (n ? o.undone : o.done).eventCount == 0)
|
|
614
614
|
return !1;
|
|
615
|
-
if (
|
|
616
|
-
let i =
|
|
617
|
-
i &&
|
|
615
|
+
if (r) {
|
|
616
|
+
let i = Fe(o, t, n);
|
|
617
|
+
i && r(e ? i.scrollIntoView() : i);
|
|
618
618
|
}
|
|
619
619
|
return !0;
|
|
620
620
|
};
|
|
621
621
|
}
|
|
622
|
-
const ne = te(!1, !0),
|
|
623
|
-
|
|
622
|
+
const ne = te(!1, !0), re = te(!0, !0);
|
|
623
|
+
C.create({
|
|
624
624
|
name: "characterCount",
|
|
625
625
|
addOptions() {
|
|
626
626
|
return {
|
|
627
627
|
limit: null,
|
|
628
628
|
autoTrim: !0,
|
|
629
629
|
mode: "textSize",
|
|
630
|
-
textCounter: (
|
|
631
|
-
wordCounter: (
|
|
630
|
+
textCounter: (n) => n.length,
|
|
631
|
+
wordCounter: (n) => n.split(" ").filter((e) => e !== "").length
|
|
632
632
|
};
|
|
633
633
|
},
|
|
634
634
|
addStorage() {
|
|
@@ -638,59 +638,59 @@ b.create({
|
|
|
638
638
|
};
|
|
639
639
|
},
|
|
640
640
|
onBeforeCreate() {
|
|
641
|
-
this.storage.characters = (
|
|
642
|
-
const e = (
|
|
643
|
-
if (((
|
|
644
|
-
const
|
|
645
|
-
return this.options.textCounter(
|
|
641
|
+
this.storage.characters = (n) => {
|
|
642
|
+
const e = (n == null ? void 0 : n.node) || this.editor.state.doc;
|
|
643
|
+
if (((n == null ? void 0 : n.mode) || this.options.mode) === "textSize") {
|
|
644
|
+
const r = e.textBetween(0, e.content.size, void 0, " ");
|
|
645
|
+
return this.options.textCounter(r);
|
|
646
646
|
}
|
|
647
647
|
return e.nodeSize;
|
|
648
|
-
}, this.storage.words = (
|
|
649
|
-
const e = (
|
|
648
|
+
}, this.storage.words = (n) => {
|
|
649
|
+
const e = (n == null ? void 0 : n.node) || this.editor.state.doc, t = e.textBetween(0, e.content.size, " ", " ");
|
|
650
650
|
return this.options.wordCounter(t);
|
|
651
651
|
};
|
|
652
652
|
},
|
|
653
653
|
addProseMirrorPlugins() {
|
|
654
|
-
let
|
|
654
|
+
let n = !1;
|
|
655
655
|
return [
|
|
656
|
-
new
|
|
657
|
-
key: new
|
|
658
|
-
appendTransaction: (e, t,
|
|
659
|
-
if (
|
|
656
|
+
new x({
|
|
657
|
+
key: new I("characterCount"),
|
|
658
|
+
appendTransaction: (e, t, r) => {
|
|
659
|
+
if (n)
|
|
660
660
|
return;
|
|
661
|
-
const
|
|
662
|
-
if (
|
|
663
|
-
|
|
661
|
+
const o = this.options.limit, i = this.options.autoTrim;
|
|
662
|
+
if (o == null || o === 0 || i === !1) {
|
|
663
|
+
n = !0;
|
|
664
664
|
return;
|
|
665
665
|
}
|
|
666
|
-
const s = this.storage.characters({ node:
|
|
667
|
-
if (s >
|
|
668
|
-
const l = s -
|
|
666
|
+
const s = this.storage.characters({ node: r.doc });
|
|
667
|
+
if (s > o) {
|
|
668
|
+
const l = s - o, a = 0, d = l;
|
|
669
669
|
console.warn(
|
|
670
|
-
`[CharacterCount] Initial content exceeded limit of ${
|
|
670
|
+
`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`
|
|
671
671
|
);
|
|
672
|
-
const
|
|
673
|
-
return
|
|
672
|
+
const u = r.tr.deleteRange(a, d);
|
|
673
|
+
return n = !0, u;
|
|
674
674
|
}
|
|
675
|
-
|
|
675
|
+
n = !0;
|
|
676
676
|
},
|
|
677
677
|
filterTransaction: (e, t) => {
|
|
678
|
-
const
|
|
679
|
-
if (!e.docChanged ||
|
|
678
|
+
const r = this.options.limit;
|
|
679
|
+
if (!e.docChanged || r === 0 || r === null || r === void 0)
|
|
680
680
|
return !0;
|
|
681
|
-
const
|
|
682
|
-
if (i <=
|
|
681
|
+
const o = this.storage.characters({ node: t.doc }), i = this.storage.characters({ node: e.doc });
|
|
682
|
+
if (i <= r || o > r && i > r && i <= o)
|
|
683
683
|
return !0;
|
|
684
|
-
if (
|
|
684
|
+
if (o > r && i > r && i > o || !e.getMeta("paste"))
|
|
685
685
|
return !1;
|
|
686
|
-
const l = e.selection.$head.pos, a = i -
|
|
687
|
-
return e.deleteRange(
|
|
686
|
+
const l = e.selection.$head.pos, a = i - r, d = l - a, u = l;
|
|
687
|
+
return e.deleteRange(d, u), !(this.storage.characters({ node: e.doc }) > r);
|
|
688
688
|
}
|
|
689
689
|
})
|
|
690
690
|
];
|
|
691
691
|
}
|
|
692
692
|
});
|
|
693
|
-
|
|
693
|
+
C.create({
|
|
694
694
|
name: "dropCursor",
|
|
695
695
|
addOptions() {
|
|
696
696
|
return {
|
|
@@ -700,10 +700,10 @@ b.create({
|
|
|
700
700
|
};
|
|
701
701
|
},
|
|
702
702
|
addProseMirrorPlugins() {
|
|
703
|
-
return [
|
|
703
|
+
return [Ee(this.options)];
|
|
704
704
|
}
|
|
705
705
|
});
|
|
706
|
-
|
|
706
|
+
C.create({
|
|
707
707
|
name: "focus",
|
|
708
708
|
addOptions() {
|
|
709
709
|
return {
|
|
@@ -713,138 +713,320 @@ b.create({
|
|
|
713
713
|
},
|
|
714
714
|
addProseMirrorPlugins() {
|
|
715
715
|
return [
|
|
716
|
-
new
|
|
717
|
-
key: new
|
|
716
|
+
new x({
|
|
717
|
+
key: new I("focus"),
|
|
718
718
|
props: {
|
|
719
|
-
decorations: ({ doc:
|
|
720
|
-
const { isEditable: t, isFocused:
|
|
721
|
-
if (!t || !
|
|
722
|
-
return
|
|
719
|
+
decorations: ({ doc: n, selection: e }) => {
|
|
720
|
+
const { isEditable: t, isFocused: r } = this.editor, { anchor: o } = e, i = [];
|
|
721
|
+
if (!t || !r)
|
|
722
|
+
return P.create(n, []);
|
|
723
723
|
let s = 0;
|
|
724
|
-
this.options.mode === "deepest" &&
|
|
724
|
+
this.options.mode === "deepest" && n.descendants((a, d) => {
|
|
725
725
|
if (a.isText)
|
|
726
726
|
return;
|
|
727
|
-
if (!(
|
|
727
|
+
if (!(o >= d && o <= d + a.nodeSize - 1))
|
|
728
728
|
return !1;
|
|
729
729
|
s += 1;
|
|
730
730
|
});
|
|
731
731
|
let l = 0;
|
|
732
|
-
return
|
|
733
|
-
if (a.isText || !(
|
|
732
|
+
return n.descendants((a, d) => {
|
|
733
|
+
if (a.isText || !(o >= d && o <= d + a.nodeSize - 1))
|
|
734
734
|
return !1;
|
|
735
735
|
if (l += 1, this.options.mode === "deepest" && s - l > 0 || this.options.mode === "shallowest" && l > 1)
|
|
736
736
|
return this.options.mode === "deepest";
|
|
737
737
|
i.push(
|
|
738
|
-
L.node(
|
|
738
|
+
L.node(d, d + a.nodeSize, {
|
|
739
739
|
class: this.options.className
|
|
740
740
|
})
|
|
741
741
|
);
|
|
742
|
-
}),
|
|
742
|
+
}), P.create(n, i);
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
745
|
})
|
|
746
746
|
];
|
|
747
747
|
}
|
|
748
748
|
});
|
|
749
|
-
|
|
749
|
+
C.create({
|
|
750
750
|
name: "gapCursor",
|
|
751
751
|
addProseMirrorPlugins() {
|
|
752
|
-
return [
|
|
752
|
+
return [Ae()];
|
|
753
753
|
},
|
|
754
|
-
extendNodeSchema(
|
|
754
|
+
extendNodeSchema(n) {
|
|
755
755
|
var e;
|
|
756
756
|
const t = {
|
|
757
|
-
name:
|
|
758
|
-
options:
|
|
759
|
-
storage:
|
|
757
|
+
name: n.name,
|
|
758
|
+
options: n.options,
|
|
759
|
+
storage: n.storage
|
|
760
760
|
};
|
|
761
761
|
return {
|
|
762
|
-
allowGapCursor: (e =
|
|
762
|
+
allowGapCursor: (e = pe(fe(n, "allowGapCursor", t))) != null ? e : null
|
|
763
763
|
};
|
|
764
764
|
}
|
|
765
765
|
});
|
|
766
|
-
|
|
766
|
+
var oe = "placeholder", G = new I("tiptap__placeholder");
|
|
767
|
+
function ie(n) {
|
|
767
768
|
const {
|
|
768
769
|
editor: e,
|
|
769
770
|
placeholder: t,
|
|
770
|
-
dataAttribute:
|
|
771
|
-
pos:
|
|
771
|
+
dataAttribute: r,
|
|
772
|
+
pos: o,
|
|
772
773
|
node: i,
|
|
773
774
|
isEmptyDoc: s,
|
|
774
775
|
hasAnchor: l,
|
|
775
|
-
classes: { emptyNode: a, emptyEditor:
|
|
776
|
-
} =
|
|
777
|
-
return s &&
|
|
778
|
-
class:
|
|
779
|
-
[
|
|
776
|
+
classes: { emptyNode: a, emptyEditor: d }
|
|
777
|
+
} = n, u = [a];
|
|
778
|
+
return s && u.push(d), L.node(o, o + i.nodeSize, {
|
|
779
|
+
class: u.join(" "),
|
|
780
|
+
[r]: typeof t == "function" ? t({
|
|
780
781
|
editor: e,
|
|
781
782
|
node: i,
|
|
782
|
-
pos:
|
|
783
|
+
pos: o,
|
|
783
784
|
hasAnchor: l
|
|
784
785
|
}) : t
|
|
785
786
|
});
|
|
786
787
|
}
|
|
787
|
-
function
|
|
788
|
-
|
|
789
|
-
return /auto|scroll|overlay/.test(t);
|
|
788
|
+
function se(n, e) {
|
|
789
|
+
return typeof n == "function" ? n(e) : n;
|
|
790
790
|
}
|
|
791
|
-
function
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
791
|
+
function le({
|
|
792
|
+
editor: n,
|
|
793
|
+
options: e,
|
|
794
|
+
dataAttribute: t,
|
|
795
|
+
doc: r,
|
|
796
|
+
selection: o,
|
|
797
|
+
from: i,
|
|
798
|
+
to: s
|
|
799
|
+
}) {
|
|
800
|
+
const { anchor: l } = o, a = [], d = n.isEmpty;
|
|
801
|
+
return r.nodesBetween(i, s, (u, c) => {
|
|
802
|
+
const p = l >= c && l <= c + u.nodeSize, f = !u.isLeaf && X(u);
|
|
803
|
+
return u.type.isTextblock && (p || !e.showOnlyCurrent) && f && a.push(
|
|
804
|
+
ie({
|
|
805
|
+
editor: n,
|
|
806
|
+
isEmptyDoc: d,
|
|
807
|
+
dataAttribute: t,
|
|
808
|
+
hasAnchor: p,
|
|
809
|
+
placeholder: e.placeholder,
|
|
810
|
+
classes: {
|
|
811
|
+
emptyEditor: e.emptyEditorClass,
|
|
812
|
+
emptyNode: se(e.emptyNodeClass, {
|
|
813
|
+
editor: n,
|
|
814
|
+
node: u,
|
|
815
|
+
pos: c,
|
|
816
|
+
hasAnchor: p
|
|
817
|
+
})
|
|
818
|
+
},
|
|
819
|
+
node: u,
|
|
820
|
+
pos: c
|
|
821
|
+
})
|
|
822
|
+
), e.includeChildren;
|
|
823
|
+
}), a;
|
|
824
|
+
}
|
|
825
|
+
function ae({
|
|
826
|
+
editor: n,
|
|
827
|
+
options: e,
|
|
828
|
+
dataAttribute: t,
|
|
829
|
+
doc: r,
|
|
830
|
+
selection: o
|
|
831
|
+
}) {
|
|
832
|
+
if (!(n.isEditable || !e.showOnlyWhenEditable))
|
|
833
|
+
return null;
|
|
834
|
+
const { anchor: s } = o, l = [], a = n.isEmpty;
|
|
835
|
+
if (e.showOnlyCurrent && !e.includeChildren) {
|
|
836
|
+
const u = r.resolve(s), c = u.depth > 0 ? u.node(1) : u.nodeAfter, p = u.depth > 0 ? u.before(1) : s;
|
|
837
|
+
if (c && c.type.isTextblock && X(c)) {
|
|
838
|
+
const f = s >= p && s <= p + c.nodeSize;
|
|
839
|
+
l.push(
|
|
840
|
+
ie({
|
|
841
|
+
editor: n,
|
|
842
|
+
isEmptyDoc: a,
|
|
843
|
+
dataAttribute: t,
|
|
844
|
+
hasAnchor: f,
|
|
845
|
+
placeholder: e.placeholder,
|
|
846
|
+
classes: {
|
|
847
|
+
emptyEditor: e.emptyEditorClass,
|
|
848
|
+
emptyNode: se(e.emptyNodeClass, {
|
|
849
|
+
editor: n,
|
|
850
|
+
node: c,
|
|
851
|
+
pos: p,
|
|
852
|
+
hasAnchor: f
|
|
853
|
+
})
|
|
854
|
+
},
|
|
855
|
+
node: c,
|
|
856
|
+
pos: p
|
|
857
|
+
})
|
|
858
|
+
);
|
|
804
859
|
}
|
|
805
|
-
|
|
860
|
+
} else
|
|
861
|
+
l.push(
|
|
862
|
+
...le({
|
|
863
|
+
editor: n,
|
|
864
|
+
options: e,
|
|
865
|
+
dataAttribute: t,
|
|
866
|
+
doc: r,
|
|
867
|
+
selection: o,
|
|
868
|
+
from: 0,
|
|
869
|
+
to: r.content.size
|
|
870
|
+
})
|
|
871
|
+
);
|
|
872
|
+
return P.create(r, l);
|
|
873
|
+
}
|
|
874
|
+
function A(n, e) {
|
|
875
|
+
var t;
|
|
876
|
+
const r = n.resolve(e);
|
|
877
|
+
if (r.depth === 0) {
|
|
878
|
+
const s = (t = r.nodeAfter) != null ? t : r.nodeBefore;
|
|
879
|
+
if (!s)
|
|
880
|
+
return { from: e, to: e };
|
|
881
|
+
const l = r.nodeAfter ? e : e - s.nodeSize;
|
|
882
|
+
return { from: l, to: l + s.nodeSize };
|
|
883
|
+
}
|
|
884
|
+
const o = r.before(1), i = r.node(1);
|
|
885
|
+
return { from: o, to: o + i.nodeSize };
|
|
886
|
+
}
|
|
887
|
+
function T(n, e) {
|
|
888
|
+
return {
|
|
889
|
+
from: Math.max(0, e.from - 1),
|
|
890
|
+
to: Math.min(n.content.size, e.to - 1)
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
function Be(n, e, t) {
|
|
894
|
+
const r = [];
|
|
895
|
+
return n.forEach((o, i) => {
|
|
896
|
+
const s = i, l = s + o.nodeSize, a = s + 1, d = l + 1;
|
|
897
|
+
a < t && d > e && r.push({ from: s, to: l });
|
|
898
|
+
}), r;
|
|
899
|
+
}
|
|
900
|
+
function _e(n) {
|
|
901
|
+
if (n.length === 0)
|
|
902
|
+
return [];
|
|
903
|
+
const e = [...n].sort((r, o) => r.from - o.from), t = [{ ...e[0] }];
|
|
904
|
+
for (let r = 1; r < e.length; r += 1) {
|
|
905
|
+
const o = t[t.length - 1], i = e[r];
|
|
906
|
+
i.from <= o.to ? o.to = Math.max(o.to, i.to) : t.push({ ...i });
|
|
907
|
+
}
|
|
908
|
+
return t;
|
|
909
|
+
}
|
|
910
|
+
function Ke(n, e) {
|
|
911
|
+
const t = Be(n, e.from, e.to);
|
|
912
|
+
return t.push(T(n, A(n, e.from))), e.to > e.from ? t.push(
|
|
913
|
+
T(
|
|
914
|
+
n,
|
|
915
|
+
A(n, Math.min(e.to, n.content.size + 1) - 1)
|
|
916
|
+
)
|
|
917
|
+
) : e.from < n.content.size + 1 && t.push(
|
|
918
|
+
T(
|
|
919
|
+
n,
|
|
920
|
+
A(n, Math.min(e.from + 1, n.content.size))
|
|
921
|
+
)
|
|
922
|
+
), t;
|
|
923
|
+
}
|
|
924
|
+
function Ge(n, e, t) {
|
|
925
|
+
const r = [];
|
|
926
|
+
if (n.docChanged) {
|
|
927
|
+
const o = ge(n);
|
|
928
|
+
for (const i of o)
|
|
929
|
+
r.push(...Ke(t.doc, i.newRange));
|
|
806
930
|
}
|
|
807
|
-
return
|
|
931
|
+
return n.selectionSet && (r.push(
|
|
932
|
+
T(
|
|
933
|
+
t.doc,
|
|
934
|
+
A(t.doc, n.mapping.map(e.selection.anchor))
|
|
935
|
+
)
|
|
936
|
+
), r.push(
|
|
937
|
+
T(
|
|
938
|
+
t.doc,
|
|
939
|
+
A(t.doc, t.selection.anchor)
|
|
940
|
+
)
|
|
941
|
+
)), _e(r);
|
|
808
942
|
}
|
|
809
|
-
function
|
|
810
|
-
|
|
943
|
+
function He(n, e, t) {
|
|
944
|
+
const r = Math.max(0, Math.min(n, t.content.size)), o = Math.max(r, Math.min(e, t.content.size));
|
|
945
|
+
return { from: r, to: o };
|
|
811
946
|
}
|
|
812
|
-
function
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
947
|
+
function We({
|
|
948
|
+
decorations: n,
|
|
949
|
+
ranges: e,
|
|
950
|
+
editor: t,
|
|
951
|
+
options: r,
|
|
952
|
+
dataAttribute: o,
|
|
953
|
+
doc: i,
|
|
954
|
+
selection: s
|
|
955
|
+
}) {
|
|
956
|
+
let l = n;
|
|
957
|
+
for (const a of e) {
|
|
958
|
+
const { from: d, to: u } = He(a.from, a.to, i), c = l.find(d, u).filter((f) => f.from >= d && f.to <= u);
|
|
959
|
+
c.length && (l = l.remove(c));
|
|
960
|
+
const p = le({
|
|
961
|
+
editor: t,
|
|
962
|
+
options: r,
|
|
963
|
+
dataAttribute: o,
|
|
964
|
+
doc: i,
|
|
965
|
+
selection: s,
|
|
966
|
+
from: d,
|
|
967
|
+
to: u
|
|
968
|
+
});
|
|
969
|
+
p.length && (l = l.add(i, p));
|
|
970
|
+
}
|
|
971
|
+
return l;
|
|
972
|
+
}
|
|
973
|
+
function je({
|
|
974
|
+
editor: n,
|
|
975
|
+
options: e,
|
|
976
|
+
dataAttribute: t
|
|
816
977
|
}) {
|
|
817
|
-
const n = e.dom.getBoundingClientRect(), r = t ? Ne(t) : { top: 0, bottom: window.innerHeight }, i = Math.max(n.top, r.top), s = Math.min(n.bottom, r.bottom);
|
|
818
|
-
if (i >= s)
|
|
819
|
-
return { top: 0, bottom: o.content.size };
|
|
820
|
-
const a = getComputedStyle(e.dom).direction === "rtl" ? Math.max(n.right - 2, n.left + 2) : n.left + 2, c = e.posAtCoords({ left: a, top: i + 2 }), p = e.posAtCoords({ left: a, top: s - 2 });
|
|
821
978
|
return {
|
|
822
|
-
|
|
823
|
-
|
|
979
|
+
init(r, o) {
|
|
980
|
+
const i = ae({
|
|
981
|
+
editor: n,
|
|
982
|
+
options: e,
|
|
983
|
+
dataAttribute: t,
|
|
984
|
+
doc: o.doc,
|
|
985
|
+
selection: o.selection
|
|
986
|
+
});
|
|
987
|
+
return i ?? P.empty;
|
|
988
|
+
},
|
|
989
|
+
apply(r, o, i, s) {
|
|
990
|
+
if (!r.docChanged && !r.selectionSet)
|
|
991
|
+
return o;
|
|
992
|
+
const l = o.map(r.mapping, r.doc), a = Ge(r, i, s);
|
|
993
|
+
return We({
|
|
994
|
+
decorations: l,
|
|
995
|
+
ranges: a,
|
|
996
|
+
editor: n,
|
|
997
|
+
options: e,
|
|
998
|
+
dataAttribute: t,
|
|
999
|
+
doc: s.doc,
|
|
1000
|
+
selection: s.selection
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
824
1003
|
};
|
|
825
1004
|
}
|
|
826
|
-
function
|
|
827
|
-
|
|
828
|
-
return { call: ((...i) => {
|
|
829
|
-
t || (o(...i), t = setTimeout(() => {
|
|
830
|
-
t = null;
|
|
831
|
-
}, e));
|
|
832
|
-
}), cancel: () => {
|
|
833
|
-
t && (clearTimeout(t), t = null);
|
|
834
|
-
} };
|
|
1005
|
+
function Ue(n) {
|
|
1006
|
+
return n.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
|
835
1007
|
}
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
return
|
|
1008
|
+
function Ye({ editor: n, options: e }) {
|
|
1009
|
+
const t = e.dataAttribute ? `data-${Ue(e.dataAttribute)}` : `data-${oe}`, r = e.showOnlyCurrent && !e.includeChildren;
|
|
1010
|
+
return new x({
|
|
1011
|
+
key: G,
|
|
1012
|
+
...r ? {} : {
|
|
1013
|
+
state: je({ editor: n, options: e, dataAttribute: t })
|
|
1014
|
+
},
|
|
1015
|
+
props: {
|
|
1016
|
+
decorations: r ? ({ doc: o, selection: i }) => ae({ editor: n, options: e, dataAttribute: t, doc: o, selection: i }) : (o) => {
|
|
1017
|
+
var i;
|
|
1018
|
+
return e.showOnlyWhenEditable && !n.isEditable ? P.empty : (i = G.getState(o)) != null ? i : P.empty;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
839
1022
|
}
|
|
840
|
-
|
|
841
|
-
b.create({
|
|
1023
|
+
C.create({
|
|
842
1024
|
name: "placeholder",
|
|
843
1025
|
addOptions() {
|
|
844
1026
|
return {
|
|
845
1027
|
emptyEditorClass: "is-editor-empty",
|
|
846
1028
|
emptyNodeClass: "is-empty",
|
|
847
|
-
dataAttribute:
|
|
1029
|
+
dataAttribute: oe,
|
|
848
1030
|
placeholder: "Write something …",
|
|
849
1031
|
showOnlyWhenEditable: !0,
|
|
850
1032
|
showOnlyCurrent: !0,
|
|
@@ -852,108 +1034,17 @@ b.create({
|
|
|
852
1034
|
};
|
|
853
1035
|
},
|
|
854
1036
|
addProseMirrorPlugins() {
|
|
855
|
-
|
|
856
|
-
return [
|
|
857
|
-
new A({
|
|
858
|
-
state: {
|
|
859
|
-
init() {
|
|
860
|
-
return {
|
|
861
|
-
// null means "no viewport info yet" — decoration callback falls
|
|
862
|
-
// back to full document scan until the scroll handler fires.
|
|
863
|
-
topPos: null,
|
|
864
|
-
bottomPos: null
|
|
865
|
-
};
|
|
866
|
-
},
|
|
867
|
-
apply(e, t) {
|
|
868
|
-
const n = e.getMeta(M);
|
|
869
|
-
return n != null && n.positions ? {
|
|
870
|
-
topPos: n.positions.top,
|
|
871
|
-
bottomPos: n.positions.bottom
|
|
872
|
-
} : e.docChanged ? {
|
|
873
|
-
topPos: t.topPos !== null ? e.mapping.map(t.topPos) : null,
|
|
874
|
-
bottomPos: t.bottomPos !== null ? e.mapping.map(t.bottomPos) : null
|
|
875
|
-
} : t;
|
|
876
|
-
}
|
|
877
|
-
},
|
|
878
|
-
key: M,
|
|
879
|
-
view(e) {
|
|
880
|
-
const t = ze(e.dom), n = () => {
|
|
881
|
-
const l = Le({
|
|
882
|
-
view: e,
|
|
883
|
-
doc: e.state.doc,
|
|
884
|
-
scrollContainer: t
|
|
885
|
-
}), a = M.getState(e.state);
|
|
886
|
-
if (a.topPos === l.top && a.bottomPos === l.bottom)
|
|
887
|
-
return;
|
|
888
|
-
const c = e.state.tr.setMeta(M, { positions: l }).setMeta("tiptap__viewportUpdate", !0);
|
|
889
|
-
e.dispatch(c);
|
|
890
|
-
}, { call: r, cancel: i } = Fe(n, 250), s = t;
|
|
891
|
-
return s.addEventListener("scroll", r, { passive: !0 }), n(), {
|
|
892
|
-
update(l, a) {
|
|
893
|
-
e.state.doc.content.size !== a.doc.content.size && n();
|
|
894
|
-
},
|
|
895
|
-
destroy: () => {
|
|
896
|
-
i(), s.removeEventListener("scroll", r);
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
},
|
|
900
|
-
props: {
|
|
901
|
-
decorations: ({ doc: e, selection: t }) => {
|
|
902
|
-
var n, r;
|
|
903
|
-
if (!(this.editor.isEditable || !this.options.showOnlyWhenEditable))
|
|
904
|
-
return null;
|
|
905
|
-
const { anchor: s } = t, l = [], a = this.editor.isEmpty;
|
|
906
|
-
if (this.options.showOnlyCurrent && !this.options.includeChildren) {
|
|
907
|
-
const p = e.resolve(s);
|
|
908
|
-
if (p.depth > 0) {
|
|
909
|
-
const d = p.node(1), u = p.before(1);
|
|
910
|
-
if (d.type.isTextblock && _(d)) {
|
|
911
|
-
const h = s >= u && s <= u + d.nodeSize, m = H({
|
|
912
|
-
node: d,
|
|
913
|
-
dataAttribute: o,
|
|
914
|
-
hasAnchor: h,
|
|
915
|
-
placeholder: this.options.placeholder,
|
|
916
|
-
classes: {
|
|
917
|
-
emptyEditor: this.options.emptyEditorClass,
|
|
918
|
-
emptyNode: this.options.emptyNodeClass
|
|
919
|
-
},
|
|
920
|
-
editor: this.editor,
|
|
921
|
-
isEmptyDoc: a,
|
|
922
|
-
pos: p.before(1)
|
|
923
|
-
});
|
|
924
|
-
l.push(m);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
} else {
|
|
928
|
-
const p = M.getState(this.editor.state), d = (n = p.topPos) != null ? n : 0, u = (r = p.bottomPos) != null ? r : e.content.size;
|
|
929
|
-
e.nodesBetween(d, u, (h, m) => {
|
|
930
|
-
const y = s >= m && s <= m + h.nodeSize, P = !h.isLeaf && _(h);
|
|
931
|
-
if (!h.type.isTextblock)
|
|
932
|
-
return this.options.includeChildren;
|
|
933
|
-
if ((y || !this.options.showOnlyCurrent) && P) {
|
|
934
|
-
const ie = H({
|
|
935
|
-
classes: { emptyEditor: this.options.emptyEditorClass, emptyNode: this.options.emptyNodeClass },
|
|
936
|
-
editor: this.editor,
|
|
937
|
-
isEmptyDoc: a,
|
|
938
|
-
dataAttribute: o,
|
|
939
|
-
hasAnchor: y,
|
|
940
|
-
placeholder: this.options.placeholder,
|
|
941
|
-
node: h,
|
|
942
|
-
pos: m
|
|
943
|
-
});
|
|
944
|
-
l.push(ie);
|
|
945
|
-
}
|
|
946
|
-
return this.options.includeChildren;
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
return O.create(e, l);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
})
|
|
953
|
-
];
|
|
1037
|
+
return [Ye({ editor: this.editor, options: this.options })];
|
|
954
1038
|
}
|
|
955
1039
|
});
|
|
956
|
-
|
|
1040
|
+
var Xe = `.ProseMirror:not(.ProseMirror-focused) *::selection {
|
|
1041
|
+
background: transparent;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
.ProseMirror:not(.ProseMirror-focused) *::-moz-selection {
|
|
1045
|
+
background: transparent;
|
|
1046
|
+
}`;
|
|
1047
|
+
C.create({
|
|
957
1048
|
name: "selection",
|
|
958
1049
|
addOptions() {
|
|
959
1050
|
return {
|
|
@@ -961,13 +1052,13 @@ b.create({
|
|
|
961
1052
|
};
|
|
962
1053
|
},
|
|
963
1054
|
addProseMirrorPlugins() {
|
|
964
|
-
const { editor:
|
|
965
|
-
return [
|
|
966
|
-
new
|
|
967
|
-
key: new
|
|
1055
|
+
const { editor: n, options: e } = this;
|
|
1056
|
+
return n.options.injectCSS && typeof document < "u" && he(Xe, n.options.injectNonce, "selection"), [
|
|
1057
|
+
new x({
|
|
1058
|
+
key: new I("selection"),
|
|
968
1059
|
props: {
|
|
969
1060
|
decorations(t) {
|
|
970
|
-
return t.selection.empty ||
|
|
1061
|
+
return t.selection.empty || n.isFocused || !n.isEditable || me(t.selection) || n.view.dragging ? null : P.create(t.doc, [
|
|
971
1062
|
L.inline(t.selection.from, t.selection.to, {
|
|
972
1063
|
class: e.className
|
|
973
1064
|
})
|
|
@@ -978,11 +1069,14 @@ b.create({
|
|
|
978
1069
|
];
|
|
979
1070
|
}
|
|
980
1071
|
});
|
|
981
|
-
var
|
|
982
|
-
function
|
|
983
|
-
|
|
1072
|
+
var Ze = "skipTrailingNode";
|
|
1073
|
+
function H({
|
|
1074
|
+
types: n,
|
|
1075
|
+
node: e
|
|
1076
|
+
}) {
|
|
1077
|
+
return e && Array.isArray(n) && n.includes(e.type) || (e == null ? void 0 : e.type) === n;
|
|
984
1078
|
}
|
|
985
|
-
|
|
1079
|
+
C.create({
|
|
986
1080
|
name: "trailingNode",
|
|
987
1081
|
addOptions() {
|
|
988
1082
|
return {
|
|
@@ -991,33 +1085,33 @@ b.create({
|
|
|
991
1085
|
};
|
|
992
1086
|
},
|
|
993
1087
|
addProseMirrorPlugins() {
|
|
994
|
-
var
|
|
995
|
-
const e = new
|
|
1088
|
+
var n;
|
|
1089
|
+
const e = new I(this.name), t = this.options.node || ((n = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : n.name) || "paragraph", r = Object.entries(this.editor.schema.nodes).map(([, o]) => o).filter((o) => (this.options.notAfter || []).concat(t).includes(o.name));
|
|
996
1090
|
return [
|
|
997
|
-
new
|
|
1091
|
+
new x({
|
|
998
1092
|
key: e,
|
|
999
|
-
appendTransaction: (
|
|
1000
|
-
const { doc: l, tr: a, schema:
|
|
1001
|
-
if (!
|
|
1002
|
-
return a.insert(
|
|
1093
|
+
appendTransaction: (o, i, s) => {
|
|
1094
|
+
const { doc: l, tr: a, schema: d } = s, u = e.getState(s), c = l.content.size, p = d.nodes[t];
|
|
1095
|
+
if (!o.some((f) => f.getMeta(Ze)) && u)
|
|
1096
|
+
return a.insert(c, p.create());
|
|
1003
1097
|
},
|
|
1004
1098
|
state: {
|
|
1005
|
-
init: (
|
|
1099
|
+
init: (o, i) => {
|
|
1006
1100
|
const s = i.tr.doc.lastChild;
|
|
1007
|
-
return !
|
|
1101
|
+
return !H({ node: s, types: r });
|
|
1008
1102
|
},
|
|
1009
|
-
apply: (
|
|
1010
|
-
if (!
|
|
1103
|
+
apply: (o, i) => {
|
|
1104
|
+
if (!o.docChanged || o.getMeta("__uniqueIDTransaction"))
|
|
1011
1105
|
return i;
|
|
1012
|
-
const s =
|
|
1013
|
-
return !
|
|
1106
|
+
const s = o.doc.lastChild;
|
|
1107
|
+
return !H({ node: s, types: r });
|
|
1014
1108
|
}
|
|
1015
1109
|
}
|
|
1016
1110
|
})
|
|
1017
1111
|
];
|
|
1018
1112
|
}
|
|
1019
1113
|
});
|
|
1020
|
-
var
|
|
1114
|
+
var Je = C.create({
|
|
1021
1115
|
name: "undoRedo",
|
|
1022
1116
|
addOptions() {
|
|
1023
1117
|
return {
|
|
@@ -1027,12 +1121,12 @@ var Be = b.create({
|
|
|
1027
1121
|
},
|
|
1028
1122
|
addCommands() {
|
|
1029
1123
|
return {
|
|
1030
|
-
undo: () => ({ state:
|
|
1031
|
-
redo: () => ({ state:
|
|
1124
|
+
undo: () => ({ state: n, dispatch: e }) => ne(n, e),
|
|
1125
|
+
redo: () => ({ state: n, dispatch: e }) => re(n, e)
|
|
1032
1126
|
};
|
|
1033
1127
|
},
|
|
1034
1128
|
addProseMirrorPlugins() {
|
|
1035
|
-
return [
|
|
1129
|
+
return [Ve(this.options)];
|
|
1036
1130
|
},
|
|
1037
1131
|
addKeyboardShortcuts() {
|
|
1038
1132
|
return {
|
|
@@ -1045,71 +1139,71 @@ var Be = b.create({
|
|
|
1045
1139
|
};
|
|
1046
1140
|
}
|
|
1047
1141
|
});
|
|
1048
|
-
function
|
|
1049
|
-
var
|
|
1050
|
-
const
|
|
1142
|
+
function it() {
|
|
1143
|
+
var u;
|
|
1144
|
+
const n = J(ce.name), {
|
|
1051
1145
|
icon: e = void 0,
|
|
1052
1146
|
tooltip: t = void 0,
|
|
1053
|
-
shortcutKeys:
|
|
1054
|
-
tooltipOptions:
|
|
1147
|
+
shortcutKeys: r = void 0,
|
|
1148
|
+
tooltipOptions: o = {},
|
|
1055
1149
|
action: i = void 0,
|
|
1056
1150
|
isActive: s = void 0
|
|
1057
|
-
} = ((
|
|
1151
|
+
} = ((u = n == null ? void 0 : n.componentProps) == null ? void 0 : u.undo) ?? {}, { disabled: l } = Q(s), a = Ce[e], d = () => {
|
|
1058
1152
|
l || i && i();
|
|
1059
1153
|
};
|
|
1060
|
-
return !
|
|
1154
|
+
return !n || !a ? /* @__PURE__ */ z(Z, {}) : /* @__PURE__ */ z(
|
|
1061
1155
|
$,
|
|
1062
1156
|
{
|
|
1063
|
-
action:
|
|
1157
|
+
action: d,
|
|
1064
1158
|
disabled: l,
|
|
1065
1159
|
icon: e,
|
|
1066
|
-
shortcutKeys:
|
|
1160
|
+
shortcutKeys: r,
|
|
1067
1161
|
tooltip: t,
|
|
1068
|
-
tooltipOptions:
|
|
1162
|
+
tooltipOptions: o
|
|
1069
1163
|
}
|
|
1070
1164
|
);
|
|
1071
1165
|
}
|
|
1072
|
-
function
|
|
1073
|
-
var
|
|
1074
|
-
const
|
|
1166
|
+
function st() {
|
|
1167
|
+
var d;
|
|
1168
|
+
const n = J(ce.name), {
|
|
1075
1169
|
icon: e = void 0,
|
|
1076
1170
|
tooltip: t = void 0,
|
|
1077
|
-
shortcutKeys:
|
|
1078
|
-
tooltipOptions:
|
|
1171
|
+
shortcutKeys: r = void 0,
|
|
1172
|
+
tooltipOptions: o = {},
|
|
1079
1173
|
action: i = void 0,
|
|
1080
1174
|
isActive: s = void 0
|
|
1081
|
-
} = ((
|
|
1175
|
+
} = ((d = n == null ? void 0 : n.componentProps) == null ? void 0 : d.redo) ?? {}, { disabled: l } = Q(s), a = () => {
|
|
1082
1176
|
l || i && i();
|
|
1083
1177
|
};
|
|
1084
|
-
return
|
|
1178
|
+
return n ? /* @__PURE__ */ z(
|
|
1085
1179
|
$,
|
|
1086
1180
|
{
|
|
1087
1181
|
action: a,
|
|
1088
1182
|
disabled: l,
|
|
1089
1183
|
icon: e,
|
|
1090
|
-
shortcutKeys:
|
|
1184
|
+
shortcutKeys: r,
|
|
1091
1185
|
tooltip: t,
|
|
1092
|
-
tooltipOptions:
|
|
1186
|
+
tooltipOptions: o
|
|
1093
1187
|
}
|
|
1094
|
-
) : /* @__PURE__ */
|
|
1188
|
+
) : /* @__PURE__ */ z(Z, {});
|
|
1095
1189
|
}
|
|
1096
|
-
const
|
|
1190
|
+
const ce = /* @__PURE__ */ Je.extend({
|
|
1097
1191
|
//@ts-expect-error
|
|
1098
1192
|
addOptions() {
|
|
1099
|
-
var
|
|
1193
|
+
var n;
|
|
1100
1194
|
return {
|
|
1101
|
-
...(
|
|
1195
|
+
...(n = this.parent) == null ? void 0 : n.call(this),
|
|
1102
1196
|
depth: 100,
|
|
1103
1197
|
newGroupDelay: 500,
|
|
1104
|
-
button: ({ editor: e, t, extension:
|
|
1105
|
-
var
|
|
1198
|
+
button: ({ editor: e, t, extension: r }) => {
|
|
1199
|
+
var o, i;
|
|
1106
1200
|
return {
|
|
1107
1201
|
componentProps: {
|
|
1108
1202
|
undo: {
|
|
1109
1203
|
action: () => {
|
|
1110
1204
|
e.chain().focus().undo().run();
|
|
1111
1205
|
},
|
|
1112
|
-
shortcutKeys: ((
|
|
1206
|
+
shortcutKeys: ((o = r.options.shortcutKeys) == null ? void 0 : o[0]) ?? ["mod", "Z"],
|
|
1113
1207
|
isActive: () => e.can().undo(),
|
|
1114
1208
|
icon: "Undo2",
|
|
1115
1209
|
tooltip: t("editor.undo.tooltip")
|
|
@@ -1118,7 +1212,7 @@ const re = /* @__PURE__ */ Be.extend({
|
|
|
1118
1212
|
action: () => {
|
|
1119
1213
|
e.chain().focus().redo().run();
|
|
1120
1214
|
},
|
|
1121
|
-
shortcutKeys: ((i =
|
|
1215
|
+
shortcutKeys: ((i = r.options.shortcutKeys) == null ? void 0 : i[1]) ?? ["shift", "mod", "Z"],
|
|
1122
1216
|
isActive: () => e.can().redo(),
|
|
1123
1217
|
icon: "Redo2",
|
|
1124
1218
|
tooltip: t("editor.redo.tooltip")
|
|
@@ -1130,7 +1224,7 @@ const re = /* @__PURE__ */ Be.extend({
|
|
|
1130
1224
|
}
|
|
1131
1225
|
});
|
|
1132
1226
|
export {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1227
|
+
ce as History,
|
|
1228
|
+
st as RichTextRedo,
|
|
1229
|
+
it as RichTextUndo
|
|
1136
1230
|
};
|