@harbour-enterprises/superdoc 1.5.0-next.6 → 1.5.0-next.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/README.md +2 -2
- package/dist/chunks/{PdfViewer-DICnVjkl.es.js → PdfViewer-ChE3uW6-.es.js} +2 -2
- package/dist/chunks/{PdfViewer-Bm3aYkue.cjs → PdfViewer-DKfNDdEk.cjs} +2 -2
- package/dist/chunks/{SuperConverter-q49H1rID.es.js → SuperConverter-CXmwt666.es.js} +1088 -470
- package/dist/chunks/{SuperConverter-Cih2T-NE.cjs → SuperConverter-iLb7JzYI.cjs} +1088 -470
- package/dist/chunks/{index-BhJCVQFg.es.js → index-BpblHOoK.es.js} +4 -4
- package/dist/chunks/{index-224wdSXe.cjs → index-CJcGqc_k.cjs} +410 -25
- package/dist/chunks/{index-RKdc-5FM.cjs → index-Cv7KI1Ex.cjs} +4 -4
- package/dist/chunks/{index-BgZnM0Uj.es.js → index-DIb368iJ.es.js} +410 -25
- package/dist/style.css +7 -0
- package/dist/super-editor/converter.cjs +1 -1
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +3 -3
- package/dist/superdoc.cjs +3 -3
- package/dist/superdoc.es.js +3 -3
- package/dist/superdoc.umd.js +1496 -493
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-
|
|
2
|
-
import "./SuperConverter-
|
|
1
|
+
import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-DIb368iJ.es.js";
|
|
2
|
+
import "./SuperConverter-CXmwt666.es.js";
|
|
3
3
|
import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
|
|
4
4
|
import { E as EventEmitter } from "./eventemitter3-CwrdEv8r.es.js";
|
|
5
5
|
import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
|
|
@@ -7513,7 +7513,7 @@ const _sfc_main = {
|
|
|
7513
7513
|
__name: "SuperDoc",
|
|
7514
7514
|
emits: ["selection-update"],
|
|
7515
7515
|
setup(__props, { emit: __emit }) {
|
|
7516
|
-
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-
|
|
7516
|
+
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-ChE3uW6-.es.js"));
|
|
7517
7517
|
const superdocStore = useSuperdocStore();
|
|
7518
7518
|
const commentsStore = useCommentsStore();
|
|
7519
7519
|
const {
|
|
@@ -8467,7 +8467,7 @@ class SuperDoc extends EventEmitter {
|
|
|
8467
8467
|
this.config.colors = shuffleArray(this.config.colors);
|
|
8468
8468
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
8469
8469
|
this.colorIndex = 0;
|
|
8470
|
-
this.version = "1.5.0-next.
|
|
8470
|
+
this.version = "1.5.0-next.8";
|
|
8471
8471
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
8472
8472
|
this.superdocId = config.superdocId || v4();
|
|
8473
8473
|
this.colors = this.config.colors;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jszip = require("./jszip-C8_CqJxM.cjs");
|
|
3
3
|
const helpers$1 = require("./helpers-nOdwpmwb.cjs");
|
|
4
|
-
const superEditor_converter = require("./SuperConverter-
|
|
4
|
+
const superEditor_converter = require("./SuperConverter-iLb7JzYI.cjs");
|
|
5
5
|
const vue = require("./vue-De9wkgLl.cjs");
|
|
6
6
|
require("./jszip.min-BPh2MMAa.cjs");
|
|
7
7
|
const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
|
|
@@ -15524,7 +15524,7 @@ const canUseDOM = () => {
|
|
|
15524
15524
|
return false;
|
|
15525
15525
|
}
|
|
15526
15526
|
};
|
|
15527
|
-
const summaryVersion = "1.5.0-next.
|
|
15527
|
+
const summaryVersion = "1.5.0-next.8";
|
|
15528
15528
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
15529
15529
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
15530
15530
|
function mapAttributes(attrs) {
|
|
@@ -18181,7 +18181,7 @@ class Editor extends EventEmitter {
|
|
|
18181
18181
|
* Process collaboration migrations
|
|
18182
18182
|
*/
|
|
18183
18183
|
processCollaborationMigrations() {
|
|
18184
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.5.0-next.
|
|
18184
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.5.0-next.8");
|
|
18185
18185
|
if (!this.options.ydoc) return;
|
|
18186
18186
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
18187
18187
|
let docVersion = metaMap.get("version");
|
|
@@ -23469,7 +23469,8 @@ const lineStyles = (lineHeight2) => ({
|
|
|
23469
23469
|
// The primary fix uses accurate font metrics from Canvas API, but this
|
|
23470
23470
|
// provides defense-in-depth against any remaining sub-pixel rendering
|
|
23471
23471
|
// differences between measurement and display.
|
|
23472
|
-
overflow: "visible"
|
|
23472
|
+
overflow: "visible",
|
|
23473
|
+
zIndex: "10"
|
|
23473
23474
|
});
|
|
23474
23475
|
const PRINT_STYLES = `
|
|
23475
23476
|
@media print {
|
|
@@ -23775,6 +23776,7 @@ const SDT_CONTAINER_STYLES = `
|
|
|
23775
23776
|
border: 1px solid #629be7;
|
|
23776
23777
|
position: relative;
|
|
23777
23778
|
display: inline;
|
|
23779
|
+
z-index: 10;
|
|
23778
23780
|
}
|
|
23779
23781
|
|
|
23780
23782
|
/* Hover effect for inline structured content */
|
|
@@ -43708,7 +43710,14 @@ const EMPTY_NUMBERING_CONTEXT = {
|
|
|
43708
43710
|
definitions: {},
|
|
43709
43711
|
abstracts: {}
|
|
43710
43712
|
};
|
|
43711
|
-
const
|
|
43713
|
+
const toOoxmlTranslator = (translator) => ({
|
|
43714
|
+
xmlName: translator.xmlName,
|
|
43715
|
+
encode: (params2) => translator.encode(params2)
|
|
43716
|
+
});
|
|
43717
|
+
const ooxmlResolver = superEditor_converter.createOoxmlResolver({
|
|
43718
|
+
pPr: toOoxmlTranslator(superEditor_converter.translator$1),
|
|
43719
|
+
rPr: toOoxmlTranslator(superEditor_converter.translator)
|
|
43720
|
+
});
|
|
43712
43721
|
const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
|
|
43713
43722
|
if (!hasParagraphStyleContext(context)) {
|
|
43714
43723
|
return null;
|
|
@@ -49101,8 +49110,6 @@ class EditorOverlayManager {
|
|
|
49101
49110
|
#activeRegion = null;
|
|
49102
49111
|
/** Full-width border line element (MS Word style) */
|
|
49103
49112
|
#borderLine = null;
|
|
49104
|
-
/** Dimming overlay element (for dimming body content during editing) */
|
|
49105
|
-
#dimmingOverlay = null;
|
|
49106
49113
|
/**
|
|
49107
49114
|
* Creates a new EditorOverlayManager instance.
|
|
49108
49115
|
*
|
|
@@ -49396,17 +49403,6 @@ class EditorOverlayManager {
|
|
|
49396
49403
|
}
|
|
49397
49404
|
}
|
|
49398
49405
|
}
|
|
49399
|
-
/**
|
|
49400
|
-
* Hides and removes the dimming overlay.
|
|
49401
|
-
* @internal Reserved for future implementation of body dimming during header/footer editing.
|
|
49402
|
-
*/
|
|
49403
|
-
// eslint-disable-next-line no-unused-private-class-members
|
|
49404
|
-
#hideDimmingOverlay() {
|
|
49405
|
-
if (this.#dimmingOverlay) {
|
|
49406
|
-
this.#dimmingOverlay.remove();
|
|
49407
|
-
this.#dimmingOverlay = null;
|
|
49408
|
-
}
|
|
49409
|
-
}
|
|
49410
49406
|
/**
|
|
49411
49407
|
* Shows a full-width border line at the bottom of the header or top of the footer.
|
|
49412
49408
|
* This creates the MS Word style visual indicator spanning edge-to-edge of the page.
|
|
@@ -51579,6 +51575,7 @@ class PresentationEditor extends EventEmitter {
|
|
|
51579
51575
|
#viewportHost;
|
|
51580
51576
|
#painterHost;
|
|
51581
51577
|
#selectionOverlay;
|
|
51578
|
+
#permissionOverlay = null;
|
|
51582
51579
|
#hiddenHost;
|
|
51583
51580
|
#layoutOptions;
|
|
51584
51581
|
#layoutState = { blocks: [], measures: [], layout: null, bookmarks: /* @__PURE__ */ new Map() };
|
|
@@ -51738,6 +51735,16 @@ class PresentationEditor extends EventEmitter {
|
|
|
51738
51735
|
});
|
|
51739
51736
|
this.#domIndexObserverManager.setup();
|
|
51740
51737
|
this.#selectionSync.on("render", () => this.#updateSelection());
|
|
51738
|
+
this.#selectionSync.on("render", () => this.#updatePermissionOverlay());
|
|
51739
|
+
this.#permissionOverlay = doc2.createElement("div");
|
|
51740
|
+
this.#permissionOverlay.className = "presentation-editor__permission-overlay";
|
|
51741
|
+
Object.assign(this.#permissionOverlay.style, {
|
|
51742
|
+
position: "absolute",
|
|
51743
|
+
inset: "0",
|
|
51744
|
+
pointerEvents: "none",
|
|
51745
|
+
zIndex: "5"
|
|
51746
|
+
});
|
|
51747
|
+
this.#viewportHost.appendChild(this.#permissionOverlay);
|
|
51741
51748
|
this.#selectionOverlay = doc2.createElement("div");
|
|
51742
51749
|
this.#selectionOverlay.className = "presentation-editor__selection-overlay";
|
|
51743
51750
|
this.#selectionOverlay.id = `presentation-overlay-${options.documentId || "default"}`;
|
|
@@ -51823,7 +51830,7 @@ class PresentationEditor extends EventEmitter {
|
|
|
51823
51830
|
const normalizedEditorProps = {
|
|
51824
51831
|
...editorOptions.editorProps ?? {},
|
|
51825
51832
|
editable: () => {
|
|
51826
|
-
return this.#
|
|
51833
|
+
return !this.#isViewLocked();
|
|
51827
51834
|
}
|
|
51828
51835
|
};
|
|
51829
51836
|
try {
|
|
@@ -52265,6 +52272,7 @@ class PresentationEditor extends EventEmitter {
|
|
|
52265
52272
|
this.#pendingDocChange = true;
|
|
52266
52273
|
this.#scheduleRerender();
|
|
52267
52274
|
}
|
|
52275
|
+
this.#updatePermissionOverlay();
|
|
52268
52276
|
}
|
|
52269
52277
|
#syncDocumentModeClass() {
|
|
52270
52278
|
if (!this.#visibleHost) return;
|
|
@@ -53654,7 +53662,7 @@ class PresentationEditor extends EventEmitter {
|
|
|
53654
53662
|
win,
|
|
53655
53663
|
this.#visibleHost,
|
|
53656
53664
|
() => this.#getActiveDomTarget(),
|
|
53657
|
-
() => this.#
|
|
53665
|
+
() => !this.#isViewLocked()
|
|
53658
53666
|
);
|
|
53659
53667
|
this.#inputBridge.bind();
|
|
53660
53668
|
}
|
|
@@ -54579,7 +54587,7 @@ class PresentationEditor extends EventEmitter {
|
|
|
54579
54587
|
this.#dragUsedPageNotMountedFallback = false;
|
|
54580
54588
|
return;
|
|
54581
54589
|
}
|
|
54582
|
-
if (this.#session.mode !== "body" || this.#
|
|
54590
|
+
if (this.#session.mode !== "body" || this.#isViewLocked()) {
|
|
54583
54591
|
this.#dragLastPointer = null;
|
|
54584
54592
|
this.#dragLastRawHit = null;
|
|
54585
54593
|
this.#dragUsedPageNotMountedFallback = false;
|
|
@@ -54929,6 +54937,7 @@ class PresentationEditor extends EventEmitter {
|
|
|
54929
54937
|
this.#epochMapper.onLayoutComplete(layoutEpoch);
|
|
54930
54938
|
this.#selectionSync.onLayoutComplete(layoutEpoch);
|
|
54931
54939
|
layoutCompleted = true;
|
|
54940
|
+
this.#updatePermissionOverlay();
|
|
54932
54941
|
this.#layoutError = null;
|
|
54933
54942
|
this.#layoutErrorState = "healthy";
|
|
54934
54943
|
this.#dismissErrorBanner();
|
|
@@ -55017,7 +55026,7 @@ class PresentationEditor extends EventEmitter {
|
|
|
55017
55026
|
if (!this.#localSelectionLayer) {
|
|
55018
55027
|
return;
|
|
55019
55028
|
}
|
|
55020
|
-
if (this.#
|
|
55029
|
+
if (this.#isViewLocked()) {
|
|
55021
55030
|
try {
|
|
55022
55031
|
this.#localSelectionLayer.innerHTML = "";
|
|
55023
55032
|
} catch (error) {
|
|
@@ -55099,6 +55108,76 @@ class PresentationEditor extends EventEmitter {
|
|
|
55099
55108
|
}
|
|
55100
55109
|
}
|
|
55101
55110
|
}
|
|
55111
|
+
/**
|
|
55112
|
+
* Updates the permission overlay (w:permStart/w:permEnd) to match the current editor permission ranges.
|
|
55113
|
+
*
|
|
55114
|
+
* This method is called after layout completes to ensure permission overlay
|
|
55115
|
+
* is based on stable permission ranges data.
|
|
55116
|
+
*/
|
|
55117
|
+
#updatePermissionOverlay() {
|
|
55118
|
+
const overlay2 = this.#permissionOverlay;
|
|
55119
|
+
if (!overlay2) {
|
|
55120
|
+
return;
|
|
55121
|
+
}
|
|
55122
|
+
if (this.#session.mode !== "body") {
|
|
55123
|
+
overlay2.innerHTML = "";
|
|
55124
|
+
return;
|
|
55125
|
+
}
|
|
55126
|
+
const permissionStorage = this.#editor?.storage?.permissionRanges;
|
|
55127
|
+
const ranges = permissionStorage?.ranges ?? [];
|
|
55128
|
+
const shouldRender = ranges.length > 0;
|
|
55129
|
+
if (!shouldRender) {
|
|
55130
|
+
overlay2.innerHTML = "";
|
|
55131
|
+
return;
|
|
55132
|
+
}
|
|
55133
|
+
const layout = this.#layoutState.layout;
|
|
55134
|
+
if (!layout) {
|
|
55135
|
+
overlay2.innerHTML = "";
|
|
55136
|
+
return;
|
|
55137
|
+
}
|
|
55138
|
+
const docEpoch = this.#epochMapper.getCurrentEpoch();
|
|
55139
|
+
if (this.#layoutEpoch < docEpoch) {
|
|
55140
|
+
return;
|
|
55141
|
+
}
|
|
55142
|
+
const pageHeight = this.#getBodyPageHeight();
|
|
55143
|
+
const pageGap = layout.pageGap ?? this.#getEffectivePageGap();
|
|
55144
|
+
const fragment = overlay2.ownerDocument?.createDocumentFragment();
|
|
55145
|
+
if (!fragment) {
|
|
55146
|
+
overlay2.innerHTML = "";
|
|
55147
|
+
return;
|
|
55148
|
+
}
|
|
55149
|
+
ranges.forEach(({ from: from3, to }) => {
|
|
55150
|
+
const rects = this.#computeSelectionRectsFromDom(from3, to);
|
|
55151
|
+
if (!rects?.length) {
|
|
55152
|
+
return;
|
|
55153
|
+
}
|
|
55154
|
+
rects.forEach((rect) => {
|
|
55155
|
+
const pageLocalY = rect.y - rect.pageIndex * (pageHeight + pageGap);
|
|
55156
|
+
const coords = this.#convertPageLocalToOverlayCoords(rect.pageIndex, rect.x, pageLocalY);
|
|
55157
|
+
if (!coords) {
|
|
55158
|
+
return;
|
|
55159
|
+
}
|
|
55160
|
+
const highlight = overlay2.ownerDocument?.createElement("div");
|
|
55161
|
+
if (!highlight) {
|
|
55162
|
+
return;
|
|
55163
|
+
}
|
|
55164
|
+
highlight.className = "presentation-editor__permission-highlight";
|
|
55165
|
+
Object.assign(highlight.style, {
|
|
55166
|
+
position: "absolute",
|
|
55167
|
+
left: `${coords.x}px`,
|
|
55168
|
+
top: `${coords.y}px`,
|
|
55169
|
+
width: `${Math.max(1, rect.width)}px`,
|
|
55170
|
+
height: `${Math.max(1, rect.height)}px`,
|
|
55171
|
+
borderRadius: "2px",
|
|
55172
|
+
pointerEvents: "none",
|
|
55173
|
+
zIndex: 1
|
|
55174
|
+
});
|
|
55175
|
+
fragment.appendChild(highlight);
|
|
55176
|
+
});
|
|
55177
|
+
});
|
|
55178
|
+
overlay2.innerHTML = "";
|
|
55179
|
+
overlay2.appendChild(fragment);
|
|
55180
|
+
}
|
|
55102
55181
|
#resolveLayoutOptions(blocks, sectionMetadata) {
|
|
55103
55182
|
const defaults = this.#computeDefaultLayoutDefaults();
|
|
55104
55183
|
const firstSection = blocks?.find(
|
|
@@ -55844,7 +55923,7 @@ class PresentationEditor extends EventEmitter {
|
|
|
55844
55923
|
this.#announce(announcement.message);
|
|
55845
55924
|
}
|
|
55846
55925
|
#validateHeaderFooterEditPermission() {
|
|
55847
|
-
if (this.#
|
|
55926
|
+
if (this.#isViewLocked()) {
|
|
55848
55927
|
return { allowed: false, reason: "documentMode" };
|
|
55849
55928
|
}
|
|
55850
55929
|
if (!this.#editor.isEditable) {
|
|
@@ -56707,6 +56786,17 @@ class PresentationEditor extends EventEmitter {
|
|
|
56707
56786
|
this.#errorBanner = null;
|
|
56708
56787
|
this.#errorBannerMessage = null;
|
|
56709
56788
|
}
|
|
56789
|
+
/**
|
|
56790
|
+
* Determines whether the current viewing mode should block edits.
|
|
56791
|
+
* When documentMode is viewing but the active editor has been toggled
|
|
56792
|
+
* back to editable (e.g. permission ranges), we treat the view as editable.
|
|
56793
|
+
*/
|
|
56794
|
+
#isViewLocked() {
|
|
56795
|
+
if (this.#documentMode !== "viewing") return false;
|
|
56796
|
+
const hasPermissionOverride = !!this.#editor?.storage?.permissionRanges?.hasAllowedRanges;
|
|
56797
|
+
if (hasPermissionOverride) return false;
|
|
56798
|
+
return this.#documentMode === "viewing";
|
|
56799
|
+
}
|
|
56710
56800
|
/**
|
|
56711
56801
|
* Applies vertical alignment and font scaling to layout DOM elements for subscript/superscript rendering.
|
|
56712
56802
|
*
|
|
@@ -58586,6 +58676,11 @@ const structuredContentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ O
|
|
|
58586
58676
|
parseTagObject
|
|
58587
58677
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
58588
58678
|
const STRUCTURED_CONTENT_NAMES = ["structuredContent", "structuredContentBlock"];
|
|
58679
|
+
function isValidIntegerId(id) {
|
|
58680
|
+
if (id === null || id === void 0) return true;
|
|
58681
|
+
const str = String(id);
|
|
58682
|
+
return /^-?\d+$/.test(str);
|
|
58683
|
+
}
|
|
58589
58684
|
const findFirstTextNode = (node) => {
|
|
58590
58685
|
let firstTextNode = null;
|
|
58591
58686
|
node.descendants((child) => {
|
|
@@ -58627,6 +58722,9 @@ const StructuredContentCommands = Extension.create({
|
|
|
58627
58722
|
* });
|
|
58628
58723
|
*/
|
|
58629
58724
|
insertStructuredContentInline: (options = {}) => ({ editor, dispatch, state, tr }) => {
|
|
58725
|
+
if (options.attrs?.id !== void 0 && !isValidIntegerId(options.attrs.id)) {
|
|
58726
|
+
throw new Error("Invalid structured content id - must be an integer, got: " + options.attrs.id);
|
|
58727
|
+
}
|
|
58630
58728
|
const { schema } = editor;
|
|
58631
58729
|
let { from: from3, to } = state.selection;
|
|
58632
58730
|
if (dispatch) {
|
|
@@ -58689,6 +58787,9 @@ const StructuredContentCommands = Extension.create({
|
|
|
58689
58787
|
* });
|
|
58690
58788
|
*/
|
|
58691
58789
|
insertStructuredContentBlock: (options = {}) => ({ editor, dispatch, state, tr }) => {
|
|
58790
|
+
if (options.attrs?.id !== void 0 && !isValidIntegerId(options.attrs.id)) {
|
|
58791
|
+
throw new Error("Invalid structured content id - must be an integer, got: " + options.attrs.id);
|
|
58792
|
+
}
|
|
58692
58793
|
const { schema } = editor;
|
|
58693
58794
|
let { from: from3, to } = state.selection;
|
|
58694
58795
|
if (dispatch) {
|
|
@@ -58746,6 +58847,9 @@ const StructuredContentCommands = Extension.create({
|
|
|
58746
58847
|
* });
|
|
58747
58848
|
*/
|
|
58748
58849
|
updateStructuredContentById: (id, options = {}) => ({ editor, dispatch, state, tr }) => {
|
|
58850
|
+
if (options.attrs?.id !== void 0 && !isValidIntegerId(options.attrs.id)) {
|
|
58851
|
+
throw new Error("Invalid structured content id - must be an integer, got: " + options.attrs.id);
|
|
58852
|
+
}
|
|
58749
58853
|
const structuredContentTags = getStructuredContentTagsById(id, state);
|
|
58750
58854
|
if (!structuredContentTags.length) {
|
|
58751
58855
|
return true;
|
|
@@ -58873,6 +58977,9 @@ const StructuredContentCommands = Extension.create({
|
|
|
58873
58977
|
* });
|
|
58874
58978
|
*/
|
|
58875
58979
|
updateStructuredContentByGroup: (group, options = {}) => ({ editor, dispatch, state, tr }) => {
|
|
58980
|
+
if (options.attrs?.id !== void 0 && !isValidIntegerId(options.attrs.id)) {
|
|
58981
|
+
throw new Error("Invalid structured content id - must be an integer, got: " + options.attrs.id);
|
|
58982
|
+
}
|
|
58876
58983
|
const structuredContentTags = getStructuredContentByGroup(group, state);
|
|
58877
58984
|
if (!structuredContentTags.length) {
|
|
58878
58985
|
return true;
|
|
@@ -59550,7 +59657,7 @@ const mergeRanges$2 = (ranges, docSize) => {
|
|
|
59550
59657
|
}
|
|
59551
59658
|
return merged;
|
|
59552
59659
|
};
|
|
59553
|
-
const collectChangedRanges = (trs, docSize) => {
|
|
59660
|
+
const collectChangedRanges$1 = (trs, docSize) => {
|
|
59554
59661
|
const ranges = [];
|
|
59555
59662
|
trs.forEach((tr) => {
|
|
59556
59663
|
if (!tr.docChanged) return;
|
|
@@ -59753,7 +59860,7 @@ const wrapTextInRunsPlugin = (editor) => {
|
|
|
59753
59860
|
const runType = newState.schema.nodes.run;
|
|
59754
59861
|
if (!runType) return null;
|
|
59755
59862
|
pendingRanges = mapRangesThroughTransactions(pendingRanges, transactions, docSize);
|
|
59756
|
-
const changedRanges = collectChangedRanges(transactions, docSize);
|
|
59863
|
+
const changedRanges = collectChangedRanges$1(transactions, docSize);
|
|
59757
59864
|
pendingRanges = mergeRanges$2([...pendingRanges, ...changedRanges], docSize);
|
|
59758
59865
|
if (view?.composing) {
|
|
59759
59866
|
return null;
|
|
@@ -74628,6 +74735,283 @@ const NodeResizer = Extension.create({
|
|
|
74628
74735
|
return [nodeResizer(["image"], this.editor)];
|
|
74629
74736
|
}
|
|
74630
74737
|
});
|
|
74738
|
+
const PERMISSION_PLUGIN_KEY = new superEditor_converter.PluginKey("permissionRanges");
|
|
74739
|
+
const EVERYONE_GROUP = "everyone";
|
|
74740
|
+
const EMPTY_IDENTIFIER_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
74741
|
+
const normalizeIdentifier = (value) => typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
74742
|
+
const buildAllowedIdentifierSet = (editor) => {
|
|
74743
|
+
const email = normalizeIdentifier(editor?.options?.user?.email);
|
|
74744
|
+
if (!email) {
|
|
74745
|
+
return EMPTY_IDENTIFIER_SET;
|
|
74746
|
+
}
|
|
74747
|
+
const [localPart, domain] = email.split("@");
|
|
74748
|
+
if (!localPart || !domain) {
|
|
74749
|
+
return EMPTY_IDENTIFIER_SET;
|
|
74750
|
+
}
|
|
74751
|
+
const formatted = `${domain}\\${localPart}`;
|
|
74752
|
+
return formatted ? /* @__PURE__ */ new Set([formatted]) : EMPTY_IDENTIFIER_SET;
|
|
74753
|
+
};
|
|
74754
|
+
const isEveryoneGroup = (value) => normalizeIdentifier(value) === EVERYONE_GROUP;
|
|
74755
|
+
const isRangeAllowedForUser = (attrs, allowedIdentifiers) => {
|
|
74756
|
+
if (!attrs) return false;
|
|
74757
|
+
if (isEveryoneGroup(attrs.edGrp)) {
|
|
74758
|
+
return true;
|
|
74759
|
+
}
|
|
74760
|
+
if (!allowedIdentifiers?.size) {
|
|
74761
|
+
return false;
|
|
74762
|
+
}
|
|
74763
|
+
const normalizedEd = normalizeIdentifier(attrs.ed);
|
|
74764
|
+
return normalizedEd && allowedIdentifiers.has(normalizedEd);
|
|
74765
|
+
};
|
|
74766
|
+
const getPermissionNodeId = (node, pos, fallbackPrefix) => String(node.attrs?.id ?? `${fallbackPrefix}-${pos}`);
|
|
74767
|
+
const buildPermissionState = (doc2, allowedIdentifiers = EMPTY_IDENTIFIER_SET) => {
|
|
74768
|
+
const ranges = [];
|
|
74769
|
+
const openRanges = /* @__PURE__ */ new Map();
|
|
74770
|
+
doc2.descendants((node, pos) => {
|
|
74771
|
+
if (node.type?.name === "permStart") {
|
|
74772
|
+
const id = getPermissionNodeId(node, pos, "permStart");
|
|
74773
|
+
openRanges.set(id, {
|
|
74774
|
+
from: pos + node.nodeSize,
|
|
74775
|
+
attrs: node.attrs ?? {}
|
|
74776
|
+
});
|
|
74777
|
+
return false;
|
|
74778
|
+
}
|
|
74779
|
+
if (node.type?.name === "permEnd") {
|
|
74780
|
+
const id = getPermissionNodeId(node, pos, "permEnd");
|
|
74781
|
+
const start2 = openRanges.get(id);
|
|
74782
|
+
if (start2 && isRangeAllowedForUser(start2.attrs, allowedIdentifiers)) {
|
|
74783
|
+
const to = Math.max(pos, start2.from);
|
|
74784
|
+
if (to > start2.from) {
|
|
74785
|
+
ranges.push({
|
|
74786
|
+
id,
|
|
74787
|
+
from: start2.from,
|
|
74788
|
+
to
|
|
74789
|
+
});
|
|
74790
|
+
}
|
|
74791
|
+
}
|
|
74792
|
+
if (start2) {
|
|
74793
|
+
openRanges.delete(id);
|
|
74794
|
+
}
|
|
74795
|
+
return false;
|
|
74796
|
+
}
|
|
74797
|
+
});
|
|
74798
|
+
return {
|
|
74799
|
+
ranges,
|
|
74800
|
+
hasAllowedRanges: ranges.length > 0
|
|
74801
|
+
};
|
|
74802
|
+
};
|
|
74803
|
+
const collectPermissionTags = (doc2, permStartType, permEndType) => {
|
|
74804
|
+
const tags = /* @__PURE__ */ new Map();
|
|
74805
|
+
doc2.descendants((node, pos) => {
|
|
74806
|
+
if (node.type !== permStartType && node.type !== permEndType) {
|
|
74807
|
+
return;
|
|
74808
|
+
}
|
|
74809
|
+
const id = node.attrs?.id;
|
|
74810
|
+
if (!id) {
|
|
74811
|
+
return;
|
|
74812
|
+
}
|
|
74813
|
+
const entry = tags.get(id) ?? {};
|
|
74814
|
+
if (node.type === permStartType) {
|
|
74815
|
+
entry.start = { pos, attrs: node.attrs ?? {} };
|
|
74816
|
+
} else if (node.type === permEndType) {
|
|
74817
|
+
entry.end = { pos, attrs: node.attrs ?? {} };
|
|
74818
|
+
}
|
|
74819
|
+
tags.set(id, entry);
|
|
74820
|
+
});
|
|
74821
|
+
return tags;
|
|
74822
|
+
};
|
|
74823
|
+
const clampPosition = (pos, size2) => {
|
|
74824
|
+
if (Number.isNaN(pos) || !Number.isFinite(pos)) {
|
|
74825
|
+
return 0;
|
|
74826
|
+
}
|
|
74827
|
+
return Math.max(0, Math.min(pos, size2));
|
|
74828
|
+
};
|
|
74829
|
+
const trimPermissionTagsFromRange = (doc2, range, permStartType, permEndType) => {
|
|
74830
|
+
let from3 = range.from;
|
|
74831
|
+
let to = range.to;
|
|
74832
|
+
while (from3 < to) {
|
|
74833
|
+
const node = doc2.nodeAt(from3);
|
|
74834
|
+
if (!node || node.type !== permStartType && node.type !== permEndType) {
|
|
74835
|
+
break;
|
|
74836
|
+
}
|
|
74837
|
+
from3 += node.nodeSize;
|
|
74838
|
+
}
|
|
74839
|
+
while (to > from3) {
|
|
74840
|
+
const $pos = doc2.resolve(to);
|
|
74841
|
+
const nodeBefore = $pos.nodeBefore;
|
|
74842
|
+
if (!nodeBefore || nodeBefore.type !== permStartType && nodeBefore.type !== permEndType) {
|
|
74843
|
+
break;
|
|
74844
|
+
}
|
|
74845
|
+
to -= nodeBefore.nodeSize;
|
|
74846
|
+
}
|
|
74847
|
+
return { from: from3, to };
|
|
74848
|
+
};
|
|
74849
|
+
const collectChangedRanges = (tr) => {
|
|
74850
|
+
const ranges = [];
|
|
74851
|
+
tr.mapping.maps.forEach((map3) => {
|
|
74852
|
+
map3.forEach((oldStart, oldEnd) => {
|
|
74853
|
+
const from3 = Math.min(oldStart, oldEnd);
|
|
74854
|
+
const to = Math.max(oldStart, oldEnd);
|
|
74855
|
+
ranges.push({ from: from3, to });
|
|
74856
|
+
});
|
|
74857
|
+
});
|
|
74858
|
+
return ranges;
|
|
74859
|
+
};
|
|
74860
|
+
const isRangeAllowed = (range, allowedRanges) => {
|
|
74861
|
+
if (!allowedRanges?.length) return false;
|
|
74862
|
+
return allowedRanges.some((allowed) => range.from >= allowed.from && range.to <= allowed.to);
|
|
74863
|
+
};
|
|
74864
|
+
const PermissionRanges = Extension.create({
|
|
74865
|
+
name: "permissionRanges",
|
|
74866
|
+
addStorage() {
|
|
74867
|
+
return {
|
|
74868
|
+
ranges: [],
|
|
74869
|
+
hasAllowedRanges: false
|
|
74870
|
+
};
|
|
74871
|
+
},
|
|
74872
|
+
addPmPlugins() {
|
|
74873
|
+
const editor = this.editor;
|
|
74874
|
+
const storage = this.storage;
|
|
74875
|
+
let originalSetDocumentMode = null;
|
|
74876
|
+
const getAllowedIdentifiers = () => buildAllowedIdentifierSet(editor);
|
|
74877
|
+
const toggleEditableIfAllowed = (hasAllowedRanges) => {
|
|
74878
|
+
if (!editor || editor.isDestroyed) return;
|
|
74879
|
+
if (editor.options.documentMode !== "viewing") return;
|
|
74880
|
+
if (hasAllowedRanges && !editor.isEditable) {
|
|
74881
|
+
editor.setEditable(true, false);
|
|
74882
|
+
} else if (!hasAllowedRanges && editor.isEditable) {
|
|
74883
|
+
editor.setEditable(false, false);
|
|
74884
|
+
}
|
|
74885
|
+
};
|
|
74886
|
+
const updateEditableState = (hasAllowedRanges) => {
|
|
74887
|
+
const nextValue = Boolean(hasAllowedRanges);
|
|
74888
|
+
const previousValue = storage.hasAllowedRanges;
|
|
74889
|
+
storage.hasAllowedRanges = nextValue;
|
|
74890
|
+
if (previousValue === nextValue) {
|
|
74891
|
+
return;
|
|
74892
|
+
}
|
|
74893
|
+
toggleEditableIfAllowed(nextValue);
|
|
74894
|
+
};
|
|
74895
|
+
if (editor && typeof editor.setDocumentMode === "function") {
|
|
74896
|
+
originalSetDocumentMode = editor.setDocumentMode.bind(editor);
|
|
74897
|
+
editor.setDocumentMode = (mode, caller) => {
|
|
74898
|
+
originalSetDocumentMode(mode, caller);
|
|
74899
|
+
const state = editor.state;
|
|
74900
|
+
if (!state) return;
|
|
74901
|
+
const pluginState = PERMISSION_PLUGIN_KEY.getState(state);
|
|
74902
|
+
if (pluginState) {
|
|
74903
|
+
toggleEditableIfAllowed(pluginState.hasAllowedRanges);
|
|
74904
|
+
}
|
|
74905
|
+
};
|
|
74906
|
+
}
|
|
74907
|
+
return [
|
|
74908
|
+
new superEditor_converter.Plugin({
|
|
74909
|
+
key: PERMISSION_PLUGIN_KEY,
|
|
74910
|
+
state: {
|
|
74911
|
+
init(_2, state) {
|
|
74912
|
+
const permissionState = buildPermissionState(state.doc, getAllowedIdentifiers());
|
|
74913
|
+
storage.ranges = permissionState.ranges;
|
|
74914
|
+
updateEditableState(permissionState.hasAllowedRanges);
|
|
74915
|
+
return permissionState;
|
|
74916
|
+
},
|
|
74917
|
+
apply(tr, value, _oldState, newState) {
|
|
74918
|
+
let permissionState = value;
|
|
74919
|
+
if (tr.docChanged) {
|
|
74920
|
+
permissionState = buildPermissionState(newState.doc, getAllowedIdentifiers());
|
|
74921
|
+
storage.ranges = permissionState.ranges;
|
|
74922
|
+
updateEditableState(permissionState.hasAllowedRanges);
|
|
74923
|
+
}
|
|
74924
|
+
return permissionState;
|
|
74925
|
+
}
|
|
74926
|
+
},
|
|
74927
|
+
view() {
|
|
74928
|
+
return {
|
|
74929
|
+
destroy() {
|
|
74930
|
+
if (editor && originalSetDocumentMode) {
|
|
74931
|
+
editor.setDocumentMode = originalSetDocumentMode;
|
|
74932
|
+
}
|
|
74933
|
+
}
|
|
74934
|
+
};
|
|
74935
|
+
},
|
|
74936
|
+
// Appends transactions to the document to ensure permission ranges are updated.
|
|
74937
|
+
appendTransaction(transactions, oldState, newState) {
|
|
74938
|
+
if (!transactions.some((tr2) => tr2.docChanged)) return null;
|
|
74939
|
+
const permStartType = newState.schema.nodes["permStart"];
|
|
74940
|
+
const permEndType = newState.schema.nodes["permEnd"];
|
|
74941
|
+
if (!permStartType || !permEndType) return null;
|
|
74942
|
+
const oldTags = collectPermissionTags(oldState.doc, permStartType, permEndType);
|
|
74943
|
+
if (!oldTags.size) {
|
|
74944
|
+
return null;
|
|
74945
|
+
}
|
|
74946
|
+
const newTags = collectPermissionTags(newState.doc, permStartType, permEndType);
|
|
74947
|
+
const mappingToNew = new superEditor_converter.Mapping();
|
|
74948
|
+
transactions.forEach((tr2) => {
|
|
74949
|
+
mappingToNew.appendMapping(tr2.mapping);
|
|
74950
|
+
});
|
|
74951
|
+
const pendingInsertions = [];
|
|
74952
|
+
oldTags.forEach((tag, id) => {
|
|
74953
|
+
const current = newTags.get(id);
|
|
74954
|
+
if (tag.start && !current?.start) {
|
|
74955
|
+
const mapped = mappingToNew.mapResult(tag.start.pos, -1);
|
|
74956
|
+
pendingInsertions.push({
|
|
74957
|
+
pos: mapped.pos,
|
|
74958
|
+
nodeType: permStartType,
|
|
74959
|
+
attrs: tag.start.attrs,
|
|
74960
|
+
priority: 0
|
|
74961
|
+
});
|
|
74962
|
+
}
|
|
74963
|
+
if (tag.end && !current?.end) {
|
|
74964
|
+
const mapped = mappingToNew.mapResult(tag.end.pos, 1);
|
|
74965
|
+
pendingInsertions.push({
|
|
74966
|
+
pos: mapped.pos,
|
|
74967
|
+
nodeType: permEndType,
|
|
74968
|
+
attrs: tag.end.attrs,
|
|
74969
|
+
priority: 1
|
|
74970
|
+
});
|
|
74971
|
+
}
|
|
74972
|
+
});
|
|
74973
|
+
if (!pendingInsertions.length) {
|
|
74974
|
+
return null;
|
|
74975
|
+
}
|
|
74976
|
+
pendingInsertions.sort((a, b2) => {
|
|
74977
|
+
if (a.pos === b2.pos) {
|
|
74978
|
+
return a.priority - b2.priority;
|
|
74979
|
+
}
|
|
74980
|
+
return a.pos - b2.pos;
|
|
74981
|
+
});
|
|
74982
|
+
const tr = newState.tr;
|
|
74983
|
+
let offset2 = 0;
|
|
74984
|
+
pendingInsertions.forEach((item) => {
|
|
74985
|
+
const node = item.nodeType.create(item.attrs);
|
|
74986
|
+
const insertPos = clampPosition(item.pos + offset2, tr.doc.content.size);
|
|
74987
|
+
tr.insert(insertPos, node);
|
|
74988
|
+
offset2 += node.nodeSize;
|
|
74989
|
+
});
|
|
74990
|
+
return tr.docChanged ? tr : null;
|
|
74991
|
+
},
|
|
74992
|
+
// Filters transactions to ensure only allowed edits are applied.
|
|
74993
|
+
filterTransaction(tr, state) {
|
|
74994
|
+
if (!tr.docChanged) return true;
|
|
74995
|
+
if (!editor || editor.options.documentMode !== "viewing") return true;
|
|
74996
|
+
const pluginState = PERMISSION_PLUGIN_KEY.getState(state);
|
|
74997
|
+
if (!pluginState?.hasAllowedRanges) {
|
|
74998
|
+
return true;
|
|
74999
|
+
}
|
|
75000
|
+
const changedRanges = collectChangedRanges(tr);
|
|
75001
|
+
if (!changedRanges.length) return true;
|
|
75002
|
+
const permStartType = state.schema.nodes["permStart"];
|
|
75003
|
+
const permEndType = state.schema.nodes["permEnd"];
|
|
75004
|
+
if (!permStartType || !permEndType) return true;
|
|
75005
|
+
const allRangesAllowed = changedRanges.every((range) => {
|
|
75006
|
+
const trimmed = trimPermissionTagsFromRange(state.doc, range, permStartType, permEndType);
|
|
75007
|
+
return isRangeAllowed(trimmed, pluginState.ranges);
|
|
75008
|
+
});
|
|
75009
|
+
return allRangesAllowed;
|
|
75010
|
+
}
|
|
75011
|
+
})
|
|
75012
|
+
];
|
|
75013
|
+
}
|
|
75014
|
+
});
|
|
74631
75015
|
const PermStart = Node$1.create({
|
|
74632
75016
|
name: "permStart",
|
|
74633
75017
|
group: "inline",
|
|
@@ -74787,6 +75171,7 @@ const getStarterExtensions = () => {
|
|
|
74787
75171
|
ShapeGroup,
|
|
74788
75172
|
PermStart,
|
|
74789
75173
|
PermEnd,
|
|
75174
|
+
PermissionRanges,
|
|
74790
75175
|
PassthroughInline,
|
|
74791
75176
|
PassthroughBlock
|
|
74792
75177
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const index = require("./index-
|
|
3
|
-
require("./SuperConverter-
|
|
2
|
+
const index = require("./index-CJcGqc_k.cjs");
|
|
3
|
+
require("./SuperConverter-iLb7JzYI.cjs");
|
|
4
4
|
const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
|
|
5
5
|
const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
|
|
6
6
|
const provider = require("@hocuspocus/provider");
|
|
@@ -7530,7 +7530,7 @@ const _sfc_main = {
|
|
|
7530
7530
|
__name: "SuperDoc",
|
|
7531
7531
|
emits: ["selection-update"],
|
|
7532
7532
|
setup(__props, { emit: __emit }) {
|
|
7533
|
-
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-
|
|
7533
|
+
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DKfNDdEk.cjs")));
|
|
7534
7534
|
const superdocStore = useSuperdocStore();
|
|
7535
7535
|
const commentsStore = useCommentsStore();
|
|
7536
7536
|
const {
|
|
@@ -8484,7 +8484,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
|
|
|
8484
8484
|
this.config.colors = shuffleArray(this.config.colors);
|
|
8485
8485
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
8486
8486
|
this.colorIndex = 0;
|
|
8487
|
-
this.version = "1.5.0-next.
|
|
8487
|
+
this.version = "1.5.0-next.8";
|
|
8488
8488
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
8489
8489
|
this.superdocId = config.superdocId || uuid.v4();
|
|
8490
8490
|
this.colors = this.config.colors;
|