@harbour-enterprises/superdoc 1.0.0-beta.7 → 1.0.0-beta.8
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/dist/chunks/{PdfViewer-hAYAlKzI.es.js → PdfViewer-BfEwF25T.es.js} +1 -1
- package/dist/chunks/{PdfViewer-T4fTm1XF.cjs → PdfViewer-DJ7BWUbW.cjs} +1 -1
- package/dist/chunks/{index-DGYP5Xod.es.js → index-BCZ82zY5.es.js} +3 -3
- package/dist/chunks/{index-DV613LhK-CqFLIBmd.cjs → index-DJrRlj1_-E5dmStMF.cjs} +1 -1
- package/dist/chunks/{index-DV613LhK-BY095UD2.es.js → index-DJrRlj1_-HA-nVwDO.es.js} +1 -1
- package/dist/chunks/{index-CYQjWGo5.cjs → index-DMwWcmrk.cjs} +3 -3
- package/dist/chunks/{super-editor.es-DmhQckCV.cjs → super-editor.es-Bo_fWMy6.cjs} +150 -39
- package/dist/chunks/{super-editor.es-CcaD69pQ.es.js → super-editor.es-MRWI4sfo.es.js} +150 -39
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BM6gXTRC.js → converter-CflxlFnM.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-fwXPJGKu.js → docx-zipper-DKWL4mo2.js} +1 -1
- package/dist/super-editor/chunks/{editor-RPTrfArg.js → editor-B9V7oJbW.js} +164 -53
- package/dist/super-editor/chunks/{index-DV613LhK.js → index-DJrRlj1_.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-DacKXz_n.js → toolbar-B5WlPN4s.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +152 -41
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { y as defineComponent, z as h, O as Transition, $ as process$1, J as watchEffect, a as computed, r as ref, j as onMounted, W as onUnmounted, b as createElementBlock, o as openBlock, f as createBaseVNode, e as createCommentVNode, u as createVNode, v as unref } from "./vue-CztqUvm1.es.js";
|
|
2
|
-
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-
|
|
2
|
+
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-BCZ82zY5.es.js";
|
|
3
3
|
function self(vars) {
|
|
4
4
|
const {
|
|
5
5
|
opacityDisabled,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const vue = require("./vue-ARQSyfaw.cjs");
|
|
4
|
-
const superdoc = require("./index-
|
|
4
|
+
const superdoc = require("./index-DMwWcmrk.cjs");
|
|
5
5
|
function self(vars) {
|
|
6
6
|
const {
|
|
7
7
|
opacityDisabled,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as index, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, P as PresentationEditor, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-
|
|
1
|
+
import { q as index, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, P as PresentationEditor, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-MRWI4sfo.es.js";
|
|
2
2
|
import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
|
|
3
3
|
import { E as EventEmitter } from "./eventemitter3-ByBH0NYV.es.js";
|
|
4
4
|
import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
|
|
@@ -17210,7 +17210,7 @@ const _sfc_main = {
|
|
|
17210
17210
|
__name: "SuperDoc",
|
|
17211
17211
|
emits: ["selection-update"],
|
|
17212
17212
|
setup(__props, { emit: __emit }) {
|
|
17213
|
-
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-
|
|
17213
|
+
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BfEwF25T.es.js"));
|
|
17214
17214
|
const superdocStore = useSuperdocStore();
|
|
17215
17215
|
const commentsStore = useCommentsStore();
|
|
17216
17216
|
const {
|
|
@@ -18063,7 +18063,7 @@ class SuperDoc extends EventEmitter {
|
|
|
18063
18063
|
this.config.colors = shuffleArray(this.config.colors);
|
|
18064
18064
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
18065
18065
|
this.colorIndex = 0;
|
|
18066
|
-
this.version = "1.0.0-beta.
|
|
18066
|
+
this.version = "1.0.0-beta.8";
|
|
18067
18067
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
18068
18068
|
this.superdocId = config.superdocId || v4();
|
|
18069
18069
|
this.colors = this.config.colors;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const superEditor_es = require("./super-editor.es-
|
|
3
|
+
const superEditor_es = require("./super-editor.es-Bo_fWMy6.cjs");
|
|
4
4
|
const indexCvBqQJbG = require("./index-CvBqQJbG-Dwm0THD7.cjs");
|
|
5
5
|
function bail(error) {
|
|
6
6
|
if (error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const superEditor_es = require("./super-editor.es-
|
|
2
|
+
const superEditor_es = require("./super-editor.es-Bo_fWMy6.cjs");
|
|
3
3
|
const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
|
|
4
4
|
const eventemitter3 = require("./eventemitter3-CFCpOk3d.cjs");
|
|
5
5
|
const provider = require("@hocuspocus/provider");
|
|
@@ -17227,7 +17227,7 @@ const _sfc_main = {
|
|
|
17227
17227
|
__name: "SuperDoc",
|
|
17228
17228
|
emits: ["selection-update"],
|
|
17229
17229
|
setup(__props, { emit: __emit }) {
|
|
17230
|
-
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-
|
|
17230
|
+
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DJ7BWUbW.cjs")));
|
|
17231
17231
|
const superdocStore = useSuperdocStore();
|
|
17232
17232
|
const commentsStore = useCommentsStore();
|
|
17233
17233
|
const {
|
|
@@ -18080,7 +18080,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
|
|
|
18080
18080
|
this.config.colors = shuffleArray(this.config.colors);
|
|
18081
18081
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
18082
18082
|
this.colorIndex = 0;
|
|
18083
|
-
this.version = "1.0.0-beta.
|
|
18083
|
+
this.version = "1.0.0-beta.8";
|
|
18084
18084
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
18085
18085
|
this.superdocId = config.superdocId || uuid.v4();
|
|
18086
18086
|
this.colors = this.config.colors;
|
|
@@ -35580,7 +35580,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
35580
35580
|
static getStoredSuperdocVersion(docx) {
|
|
35581
35581
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
35582
35582
|
}
|
|
35583
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
35583
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.8") {
|
|
35584
35584
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
35585
35585
|
}
|
|
35586
35586
|
/**
|
|
@@ -52287,7 +52287,7 @@ const isHeadless = (editor) => {
|
|
|
52287
52287
|
const shouldSkipNodeView = (editor) => {
|
|
52288
52288
|
return isHeadless(editor);
|
|
52289
52289
|
};
|
|
52290
|
-
const summaryVersion = "1.0.0-beta.
|
|
52290
|
+
const summaryVersion = "1.0.0-beta.8";
|
|
52291
52291
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
52292
52292
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
52293
52293
|
function mapAttributes(attrs) {
|
|
@@ -53066,7 +53066,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53066
53066
|
{ default: remarkStringify },
|
|
53067
53067
|
{ default: remarkGfm }
|
|
53068
53068
|
] = await Promise.all([
|
|
53069
|
-
Promise.resolve().then(() => require("./index-
|
|
53069
|
+
Promise.resolve().then(() => require("./index-DJrRlj1_-E5dmStMF.cjs")),
|
|
53070
53070
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
53071
53071
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
53072
53072
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -53271,7 +53271,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53271
53271
|
* Process collaboration migrations
|
|
53272
53272
|
*/
|
|
53273
53273
|
processCollaborationMigrations() {
|
|
53274
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
53274
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.8");
|
|
53275
53275
|
if (!this.options.ydoc) return;
|
|
53276
53276
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
53277
53277
|
let docVersion = metaMap.get("version");
|
|
@@ -56823,8 +56823,6 @@ function calculateTabWidth(params2) {
|
|
|
56823
56823
|
const beforeWidth = measureText2 ? measureText2(before) : 0;
|
|
56824
56824
|
width -= beforeWidth;
|
|
56825
56825
|
}
|
|
56826
|
-
} else if (alignment2 === "bar") {
|
|
56827
|
-
width = 0;
|
|
56828
56826
|
}
|
|
56829
56827
|
if (width < 1) {
|
|
56830
56828
|
return fallbackWidth();
|
|
@@ -61867,14 +61865,14 @@ function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
|
61867
61865
|
return metrics.width;
|
|
61868
61866
|
}
|
|
61869
61867
|
function lineHeightForRuns(runs, fromRun, toRun) {
|
|
61870
|
-
let
|
|
61868
|
+
let maxSize2 = 0;
|
|
61871
61869
|
for (let i = fromRun; i <= toRun; i += 1) {
|
|
61872
61870
|
const run2 = runs[i];
|
|
61873
61871
|
const textRun = run2 && isTextRun(run2) ? run2 : null;
|
|
61874
61872
|
const size2 = textRun?.fontSize ?? 16;
|
|
61875
|
-
if (size2 >
|
|
61873
|
+
if (size2 > maxSize2) maxSize2 = size2;
|
|
61876
61874
|
}
|
|
61877
|
-
return
|
|
61875
|
+
return maxSize2 * 1.2;
|
|
61878
61876
|
}
|
|
61879
61877
|
function remeasureParagraph(block, maxWidth) {
|
|
61880
61878
|
const runs = block.runs ?? [];
|
|
@@ -67477,6 +67475,45 @@ function normalizeRotation(rotation) {
|
|
|
67477
67475
|
function degToRad(degrees) {
|
|
67478
67476
|
return degrees * Math.PI / 180;
|
|
67479
67477
|
}
|
|
67478
|
+
const defaultMaxSize = 5e3;
|
|
67479
|
+
let maxSize = defaultMaxSize;
|
|
67480
|
+
const cache$1 = /* @__PURE__ */ new Map();
|
|
67481
|
+
const makeKey = (text, font, letterSpacing) => {
|
|
67482
|
+
return `${text}|${font}|${letterSpacing || 0}`;
|
|
67483
|
+
};
|
|
67484
|
+
function getMeasuredTextWidth(text, font, letterSpacing, ctx2) {
|
|
67485
|
+
if (text.length > 32e3) {
|
|
67486
|
+
text = text.substring(0, 32e3);
|
|
67487
|
+
}
|
|
67488
|
+
const key2 = makeKey(text, font, letterSpacing);
|
|
67489
|
+
const hit = cache$1.get(key2);
|
|
67490
|
+
if (hit !== void 0) {
|
|
67491
|
+
cache$1.delete(key2);
|
|
67492
|
+
cache$1.set(key2, hit);
|
|
67493
|
+
return hit.width;
|
|
67494
|
+
}
|
|
67495
|
+
try {
|
|
67496
|
+
ctx2.font = font;
|
|
67497
|
+
const metrics = ctx2.measureText(text);
|
|
67498
|
+
const advanceWidth = metrics.width;
|
|
67499
|
+
const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
|
|
67500
|
+
const baseWidth = Math.max(advanceWidth, paintedWidth);
|
|
67501
|
+
const extra = letterSpacing ? Math.max(0, text.length - 1) * letterSpacing : 0;
|
|
67502
|
+
const width = baseWidth + extra;
|
|
67503
|
+
cache$1.set(key2, { width });
|
|
67504
|
+
evictIfNeeded();
|
|
67505
|
+
return width;
|
|
67506
|
+
} catch {
|
|
67507
|
+
return 0;
|
|
67508
|
+
}
|
|
67509
|
+
}
|
|
67510
|
+
function evictIfNeeded() {
|
|
67511
|
+
while (cache$1.size > maxSize) {
|
|
67512
|
+
const oldestKey = cache$1.keys().next().value;
|
|
67513
|
+
if (oldestKey === void 0) break;
|
|
67514
|
+
cache$1.delete(oldestKey);
|
|
67515
|
+
}
|
|
67516
|
+
}
|
|
67480
67517
|
const { computeTabStops } = Engines;
|
|
67481
67518
|
let canvasContext = null;
|
|
67482
67519
|
const DEFAULT_TAB_INTERVAL_TWIPS = 720;
|
|
@@ -67521,8 +67558,7 @@ function measureText(text, font, ctx2, _fontFamily, _letterSpacing) {
|
|
|
67521
67558
|
const metrics = ctx2.measureText(text);
|
|
67522
67559
|
const advanceWidth = metrics.width;
|
|
67523
67560
|
const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
|
|
67524
|
-
|
|
67525
|
-
return baseWidth;
|
|
67561
|
+
return Math.max(advanceWidth, paintedWidth);
|
|
67526
67562
|
}
|
|
67527
67563
|
const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
|
|
67528
67564
|
function calculateTypographyMetrics(fontSize2, spacing) {
|
|
@@ -68103,13 +68139,9 @@ const getPrimaryRun = (paragraph) => {
|
|
|
68103
68139
|
};
|
|
68104
68140
|
};
|
|
68105
68141
|
const measureRunWidth = (text, font, ctx2, run2) => {
|
|
68106
|
-
const
|
|
68107
|
-
const
|
|
68108
|
-
|
|
68109
|
-
return baseWidth;
|
|
68110
|
-
}
|
|
68111
|
-
const extra = Math.max(0, text.length - 1) * letterSpacing;
|
|
68112
|
-
return roundValue(baseWidth + extra);
|
|
68142
|
+
const letterSpacing = run2.kind !== "tab" ? run2.letterSpacing || 0 : 0;
|
|
68143
|
+
const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
|
|
68144
|
+
return roundValue(width);
|
|
68113
68145
|
};
|
|
68114
68146
|
const appendSegment = (segments, runIndex, fromChar, toChar, width, x2) => {
|
|
68115
68147
|
if (!segments) return;
|
|
@@ -74858,7 +74890,7 @@ function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext,
|
|
|
74858
74890
|
const tabHeight = paragraphContext.tabHeight;
|
|
74859
74891
|
paragraphContext.accumulatedTabWidth = accumulatedTabWidth + tabWidth;
|
|
74860
74892
|
return `width: ${tabWidth}px; height: ${tabHeight}; ${extraStyles}`;
|
|
74861
|
-
} catch
|
|
74893
|
+
} catch {
|
|
74862
74894
|
return null;
|
|
74863
74895
|
}
|
|
74864
74896
|
}
|
|
@@ -75952,6 +75984,19 @@ const CommentsMark = Mark2.create({
|
|
|
75952
75984
|
return [CommentMarkName, Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
75953
75985
|
}
|
|
75954
75986
|
});
|
|
75987
|
+
let cache$2 = /* @__PURE__ */ new WeakMap();
|
|
75988
|
+
function getParagraphContext(paragraph, startPos, helpers2, revision, compute) {
|
|
75989
|
+
const cached = cache$2.get(paragraph);
|
|
75990
|
+
if (cached && cached.revision === revision) {
|
|
75991
|
+
return cached.context;
|
|
75992
|
+
}
|
|
75993
|
+
const context = compute(paragraph, startPos, helpers2);
|
|
75994
|
+
cache$2.set(paragraph, { revision, context });
|
|
75995
|
+
return context;
|
|
75996
|
+
}
|
|
75997
|
+
function clearAllParagraphContexts() {
|
|
75998
|
+
cache$2 = /* @__PURE__ */ new WeakMap();
|
|
75999
|
+
}
|
|
75955
76000
|
const leaderStyles = {
|
|
75956
76001
|
dot: "border-bottom: 1px dotted black;",
|
|
75957
76002
|
heavy: "border-bottom: 2px solid black;",
|
|
@@ -75968,6 +76013,14 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
|
|
|
75968
76013
|
if (!paragraphContext) return null;
|
|
75969
76014
|
const paragraphId = paragraphIdFromPos(paragraphContext.startPos);
|
|
75970
76015
|
const paragraphNode = paragraphContext.paragraph;
|
|
76016
|
+
const cachedContext = getParagraphContext(
|
|
76017
|
+
paragraphNode,
|
|
76018
|
+
paragraphContext.startPos,
|
|
76019
|
+
helpers2,
|
|
76020
|
+
revision,
|
|
76021
|
+
() => extractParagraphContext(paragraphNode, paragraphContext.startPos, helpers2, paragraphContext.paragraphDepth)
|
|
76022
|
+
);
|
|
76023
|
+
const effectiveContext = cachedContext || paragraphContext;
|
|
75971
76024
|
const { entries } = flattenParagraph(paragraphNode, paragraphContext.startPos);
|
|
75972
76025
|
const spans = [];
|
|
75973
76026
|
let tabIndex = 0;
|
|
@@ -75995,13 +76048,13 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
|
|
|
75995
76048
|
});
|
|
75996
76049
|
}
|
|
75997
76050
|
});
|
|
75998
|
-
const tabStops = Array.isArray(
|
|
75999
|
-
const hangingPx = twipsToPixels(Number(
|
|
76000
|
-
if (hangingPx > 0 &&
|
|
76001
|
-
tabStops.unshift({ val: "start", pos:
|
|
76051
|
+
const tabStops = Array.isArray(effectiveContext.tabStops) ? [...effectiveContext.tabStops] : [];
|
|
76052
|
+
const hangingPx = twipsToPixels(Number(effectiveContext.indent?.hanging) || 0);
|
|
76053
|
+
if (hangingPx > 0 && effectiveContext.indentWidth != null) {
|
|
76054
|
+
tabStops.unshift({ val: "start", pos: effectiveContext.indentWidth + hangingPx, leader: "none" });
|
|
76002
76055
|
}
|
|
76003
|
-
const paragraphWidth = getBlockNodeWidth(view,
|
|
76004
|
-
const indentWidth =
|
|
76056
|
+
const paragraphWidth = getBlockNodeWidth(view, effectiveContext.startPos) ?? defaultLineLength;
|
|
76057
|
+
const indentWidth = effectiveContext.indentWidth ?? getIndentWidth(view, effectiveContext.startPos, effectiveContext.indent);
|
|
76005
76058
|
return {
|
|
76006
76059
|
paragraphId,
|
|
76007
76060
|
revision,
|
|
@@ -76009,9 +76062,9 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
|
|
|
76009
76062
|
defaultTabDistance,
|
|
76010
76063
|
defaultLineLength,
|
|
76011
76064
|
indents: {
|
|
76012
|
-
left: twipsToPixels(Number(
|
|
76013
|
-
right: twipsToPixels(Number(
|
|
76014
|
-
firstLine: twipsToPixels(Number(
|
|
76065
|
+
left: twipsToPixels(Number(effectiveContext.indent?.left) || 0),
|
|
76066
|
+
right: twipsToPixels(Number(effectiveContext.indent?.right) || 0),
|
|
76067
|
+
firstLine: twipsToPixels(Number(effectiveContext.indent?.firstLine) || 0),
|
|
76015
76068
|
hanging: hangingPx
|
|
76016
76069
|
},
|
|
76017
76070
|
tabStops,
|
|
@@ -76176,31 +76229,58 @@ const TabNode = Node$1.create({
|
|
|
76176
76229
|
key: new PluginKey("tabPlugin"),
|
|
76177
76230
|
state: {
|
|
76178
76231
|
init() {
|
|
76179
|
-
|
|
76232
|
+
const initialDecorations = buildInitialDecorations(view.state.doc, view, helpers2, 0);
|
|
76233
|
+
return { decorations: initialDecorations, revision: 0 };
|
|
76180
76234
|
},
|
|
76181
76235
|
apply(tr, { decorations, revision }, _oldState, newState) {
|
|
76182
|
-
|
|
76183
|
-
const newDecorations2 = buildDecorations(newState.doc, view, helpers2, 0);
|
|
76184
|
-
return { decorations: newDecorations2, revision: 0 };
|
|
76185
|
-
}
|
|
76236
|
+
const currentDecorations = decorations && decorations.map ? decorations.map(tr.mapping, tr.doc) : DecorationSet.empty;
|
|
76186
76237
|
if (!tr.docChanged || tr.getMeta("blockNodeInitialUpdate")) {
|
|
76187
|
-
return { decorations, revision };
|
|
76188
|
-
}
|
|
76189
|
-
const
|
|
76190
|
-
|
|
76191
|
-
|
|
76238
|
+
return { decorations: currentDecorations, revision };
|
|
76239
|
+
}
|
|
76240
|
+
const affectedParagraphs = getAffectedParagraphStarts(tr, newState);
|
|
76241
|
+
if (affectedParagraphs.size === 0) {
|
|
76242
|
+
return { decorations: currentDecorations, revision };
|
|
76243
|
+
}
|
|
76244
|
+
let nextDecorations = currentDecorations;
|
|
76245
|
+
affectedParagraphs.forEach((pos) => {
|
|
76246
|
+
const paragraph = newState.doc.nodeAt(pos);
|
|
76247
|
+
if (!paragraph || paragraph.type.name !== "paragraph") return;
|
|
76248
|
+
const from2 = pos;
|
|
76249
|
+
const to = pos + paragraph.nodeSize;
|
|
76250
|
+
const existing = nextDecorations.find(from2, to);
|
|
76251
|
+
if (existing?.length) {
|
|
76252
|
+
nextDecorations = nextDecorations.remove(existing);
|
|
76253
|
+
}
|
|
76254
|
+
const paragraphDecorations = buildParagraphDecorations(
|
|
76255
|
+
newState.doc,
|
|
76256
|
+
pos + 1,
|
|
76257
|
+
paragraph,
|
|
76258
|
+
view,
|
|
76259
|
+
helpers2,
|
|
76260
|
+
revision + 1
|
|
76261
|
+
);
|
|
76262
|
+
nextDecorations = nextDecorations.add(newState.doc, paragraphDecorations);
|
|
76263
|
+
});
|
|
76264
|
+
return { decorations: nextDecorations, revision: revision + 1 };
|
|
76192
76265
|
}
|
|
76193
76266
|
},
|
|
76194
76267
|
props: {
|
|
76195
76268
|
decorations(state2) {
|
|
76196
76269
|
return this.getState(state2).decorations;
|
|
76197
76270
|
}
|
|
76271
|
+
},
|
|
76272
|
+
view() {
|
|
76273
|
+
return {
|
|
76274
|
+
destroy() {
|
|
76275
|
+
clearAllParagraphContexts();
|
|
76276
|
+
}
|
|
76277
|
+
};
|
|
76198
76278
|
}
|
|
76199
76279
|
});
|
|
76200
76280
|
return [tabPlugin];
|
|
76201
76281
|
}
|
|
76202
76282
|
});
|
|
76203
|
-
function
|
|
76283
|
+
function buildInitialDecorations(doc2, view, helpers2, revision) {
|
|
76204
76284
|
const decorations = [];
|
|
76205
76285
|
doc2.descendants((node, pos) => {
|
|
76206
76286
|
if (node.type.name !== "paragraph") return;
|
|
@@ -76221,6 +76301,37 @@ function buildDecorations(doc2, view, helpers2, revision) {
|
|
|
76221
76301
|
});
|
|
76222
76302
|
return DecorationSet.create(doc2, decorations);
|
|
76223
76303
|
}
|
|
76304
|
+
function buildParagraphDecorations(doc2, paragraphContentPos, paragraphNode, view, helpers2, revision) {
|
|
76305
|
+
const request = createLayoutRequest(doc2, paragraphContentPos, view, helpers2, revision);
|
|
76306
|
+
if (!request) return [];
|
|
76307
|
+
const result = calculateTabLayout(request, void 0, view);
|
|
76308
|
+
return applyLayoutResult(result, paragraphNode, paragraphContentPos - 1);
|
|
76309
|
+
}
|
|
76310
|
+
function getAffectedParagraphStarts(tr, newState) {
|
|
76311
|
+
const affected = /* @__PURE__ */ new Set();
|
|
76312
|
+
tr.steps.forEach((step, index2) => {
|
|
76313
|
+
if (step.from == null && step.to == null) return;
|
|
76314
|
+
let fromPos = step.from;
|
|
76315
|
+
let toPos = step.to;
|
|
76316
|
+
if (typeof fromPos !== "number" || typeof toPos !== "number") return;
|
|
76317
|
+
for (let i = index2; i < tr.steps.length; i++) {
|
|
76318
|
+
const stepMap = tr.steps[i].getMap();
|
|
76319
|
+
fromPos = stepMap.map(fromPos, -1);
|
|
76320
|
+
toPos = stepMap.map(toPos, 1);
|
|
76321
|
+
}
|
|
76322
|
+
if (fromPos < 0 || toPos < 0 || fromPos > newState.doc.content.size || toPos > newState.doc.content.size) {
|
|
76323
|
+
return;
|
|
76324
|
+
}
|
|
76325
|
+
newState.doc.nodesBetween(fromPos, toPos, (node, pos) => {
|
|
76326
|
+
if (node.type.name === "paragraph") {
|
|
76327
|
+
affected.add(pos);
|
|
76328
|
+
return false;
|
|
76329
|
+
}
|
|
76330
|
+
return true;
|
|
76331
|
+
});
|
|
76332
|
+
});
|
|
76333
|
+
return affected;
|
|
76334
|
+
}
|
|
76224
76335
|
const LineBreak = Node$1.create({
|
|
76225
76336
|
name: "lineBreak",
|
|
76226
76337
|
group: "inline",
|