@superdoc-dev/cli 0.2.0-next.137 → 0.2.0-next.138
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/index.js +295 -256
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -135979,7 +135979,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
|
|
|
135979
135979
|
init_remark_gfm_z_sDF4ss_es();
|
|
135980
135980
|
});
|
|
135981
135981
|
|
|
135982
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
135982
|
+
// ../../packages/superdoc/dist/chunks/src-SNuegb28.es.js
|
|
135983
135983
|
function deleteProps(obj, propOrProps) {
|
|
135984
135984
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
135985
135985
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -138677,6 +138677,60 @@ function getSuperdocVersion() {
|
|
|
138677
138677
|
return "unknown";
|
|
138678
138678
|
}
|
|
138679
138679
|
}
|
|
138680
|
+
function getFocusMeta(tr) {
|
|
138681
|
+
return tr.getMeta(CustomSelectionPluginKey);
|
|
138682
|
+
}
|
|
138683
|
+
function setFocusMeta(tr, value) {
|
|
138684
|
+
return tr.setMeta(CustomSelectionPluginKey, value);
|
|
138685
|
+
}
|
|
138686
|
+
function getFocusState(state) {
|
|
138687
|
+
return CustomSelectionPluginKey.getState(state);
|
|
138688
|
+
}
|
|
138689
|
+
function mapPreservedSelection(selection, tr) {
|
|
138690
|
+
if (!selection || !tr.docChanged)
|
|
138691
|
+
return selection;
|
|
138692
|
+
if (typeof selection.from !== "number" || typeof selection.to !== "number")
|
|
138693
|
+
return null;
|
|
138694
|
+
const from$1 = tr.mapping.map(selection.from, -1);
|
|
138695
|
+
const to = tr.mapping.map(selection.to, 1);
|
|
138696
|
+
if (from$1 >= to)
|
|
138697
|
+
return null;
|
|
138698
|
+
try {
|
|
138699
|
+
return TextSelection2.create(tr.doc, from$1, to);
|
|
138700
|
+
} catch {
|
|
138701
|
+
return null;
|
|
138702
|
+
}
|
|
138703
|
+
}
|
|
138704
|
+
function applySelectionCleanup(editor, tr) {
|
|
138705
|
+
let cleaned = tr.setMeta(CustomSelectionPluginKey, DEFAULT_SELECTION_STATE);
|
|
138706
|
+
const sel = cleaned.selection;
|
|
138707
|
+
if (sel && sel instanceof TextSelection2 && !sel.empty)
|
|
138708
|
+
try {
|
|
138709
|
+
const collapsed = TextSelection2.create(cleaned.doc, sel.head);
|
|
138710
|
+
cleaned = cleaned.setSelection(collapsed);
|
|
138711
|
+
} catch {}
|
|
138712
|
+
editor.setOptions({
|
|
138713
|
+
preservedSelection: null,
|
|
138714
|
+
lastSelection: null
|
|
138715
|
+
});
|
|
138716
|
+
return cleaned;
|
|
138717
|
+
}
|
|
138718
|
+
function createHistoryDispatch(editor, dispatch) {
|
|
138719
|
+
if (!dispatch)
|
|
138720
|
+
return dispatch;
|
|
138721
|
+
return (historyTr) => {
|
|
138722
|
+
dispatch(applySelectionCleanup(editor, historyTr));
|
|
138723
|
+
};
|
|
138724
|
+
}
|
|
138725
|
+
function runSelectionCleanupAfterCollabHistory(editor) {
|
|
138726
|
+
const view = editor?.view;
|
|
138727
|
+
const state = editor?.state;
|
|
138728
|
+
if (!view || !state)
|
|
138729
|
+
return;
|
|
138730
|
+
let tr = applySelectionCleanup(editor, state.tr);
|
|
138731
|
+
tr = tr.setMeta("addToHistory", false);
|
|
138732
|
+
view.dispatch(tr);
|
|
138733
|
+
}
|
|
138680
138734
|
function getNodeIdCandidates(node3) {
|
|
138681
138735
|
const attrs = node3.attrs ?? {};
|
|
138682
138736
|
const candidateFields = [
|
|
@@ -169874,30 +169928,6 @@ function replaceCommand(wrap4, moveForward) {
|
|
|
169874
169928
|
return true;
|
|
169875
169929
|
};
|
|
169876
169930
|
}
|
|
169877
|
-
function getFocusMeta(tr) {
|
|
169878
|
-
return tr.getMeta(CustomSelectionPluginKey);
|
|
169879
|
-
}
|
|
169880
|
-
function setFocusMeta(tr, value) {
|
|
169881
|
-
return tr.setMeta(CustomSelectionPluginKey, value);
|
|
169882
|
-
}
|
|
169883
|
-
function getFocusState(state) {
|
|
169884
|
-
return CustomSelectionPluginKey.getState(state);
|
|
169885
|
-
}
|
|
169886
|
-
function mapPreservedSelection(selection, tr) {
|
|
169887
|
-
if (!selection || !tr.docChanged)
|
|
169888
|
-
return selection;
|
|
169889
|
-
if (typeof selection.from !== "number" || typeof selection.to !== "number")
|
|
169890
|
-
return null;
|
|
169891
|
-
const from$1 = tr.mapping.map(selection.from, -1);
|
|
169892
|
-
const to = tr.mapping.map(selection.to, 1);
|
|
169893
|
-
if (from$1 >= to)
|
|
169894
|
-
return null;
|
|
169895
|
-
try {
|
|
169896
|
-
return TextSelection2.create(tr.doc, from$1, to);
|
|
169897
|
-
} catch {
|
|
169898
|
-
return null;
|
|
169899
|
-
}
|
|
169900
|
-
}
|
|
169901
169931
|
function charOffsetToPosition(doc$2, charOffset, blockSep, leafSep) {
|
|
169902
169932
|
const docSize = doc$2.content.size;
|
|
169903
169933
|
if (charOffset <= 0)
|
|
@@ -195220,7 +195250,32 @@ var Node$13 = class Node$14 {
|
|
|
195220
195250
|
static create(config2) {
|
|
195221
195251
|
return new Extension2(config2);
|
|
195222
195252
|
}
|
|
195223
|
-
},
|
|
195253
|
+
}, isKeyboardInvocation = (event) => {
|
|
195254
|
+
return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === undefined) && event.clientX === 0 && event.clientY === 0;
|
|
195255
|
+
}, prefersNativeMenu = (event) => {
|
|
195256
|
+
if (!event)
|
|
195257
|
+
return false;
|
|
195258
|
+
if (event.ctrlKey || event.metaKey)
|
|
195259
|
+
return true;
|
|
195260
|
+
return isKeyboardInvocation(event);
|
|
195261
|
+
}, shouldAllowNativeContextMenu = (event) => {
|
|
195262
|
+
return prefersNativeMenu(event);
|
|
195263
|
+
}, DEFAULT_SELECTION_STATE, normalizeSelectionState = (state = {}) => ({
|
|
195264
|
+
...DEFAULT_SELECTION_STATE,
|
|
195265
|
+
...state
|
|
195266
|
+
}), CustomSelectionPluginKey, handleClickOutside = (event, editor) => {
|
|
195267
|
+
const editorElem = editor?.options?.element;
|
|
195268
|
+
if (!editorElem)
|
|
195269
|
+
return;
|
|
195270
|
+
if (!editorElem?.contains(event.target))
|
|
195271
|
+
editor.setOptions({ focusTarget: event.target });
|
|
195272
|
+
else
|
|
195273
|
+
editor.setOptions({ focusTarget: null });
|
|
195274
|
+
}, isToolbarInput = (target) => {
|
|
195275
|
+
return !!target?.closest(".button-text-input") || target?.classList?.contains("button-text-input");
|
|
195276
|
+
}, isToolbarButton = (target) => {
|
|
195277
|
+
return !!target?.closest(".toolbar-button") || target?.classList?.contains("toolbar-button");
|
|
195278
|
+
}, CustomSelection, History, createUndoPlugin = () => {
|
|
195224
195279
|
return yUndoPlugin();
|
|
195225
195280
|
}, Attribute2 = class {
|
|
195226
195281
|
static getAttributesFromExtensions(extensions) {
|
|
@@ -201762,32 +201817,7 @@ var Node$13 = class Node$14 {
|
|
|
201762
201817
|
}
|
|
201763
201818
|
});
|
|
201764
201819
|
return { decorations };
|
|
201765
|
-
},
|
|
201766
|
-
return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === undefined) && event.clientX === 0 && event.clientY === 0;
|
|
201767
|
-
}, prefersNativeMenu = (event) => {
|
|
201768
|
-
if (!event)
|
|
201769
|
-
return false;
|
|
201770
|
-
if (event.ctrlKey || event.metaKey)
|
|
201771
|
-
return true;
|
|
201772
|
-
return isKeyboardInvocation(event);
|
|
201773
|
-
}, shouldAllowNativeContextMenu = (event) => {
|
|
201774
|
-
return prefersNativeMenu(event);
|
|
201775
|
-
}, DEFAULT_SELECTION_STATE, normalizeSelectionState = (state = {}) => ({
|
|
201776
|
-
...DEFAULT_SELECTION_STATE,
|
|
201777
|
-
...state
|
|
201778
|
-
}), CustomSelectionPluginKey, handleClickOutside = (event, editor) => {
|
|
201779
|
-
const editorElem = editor?.options?.element;
|
|
201780
|
-
if (!editorElem)
|
|
201781
|
-
return;
|
|
201782
|
-
if (!editorElem?.contains(event.target))
|
|
201783
|
-
editor.setOptions({ focusTarget: event.target });
|
|
201784
|
-
else
|
|
201785
|
-
editor.setOptions({ focusTarget: null });
|
|
201786
|
-
}, isToolbarInput = (target) => {
|
|
201787
|
-
return !!target?.closest(".button-text-input") || target?.classList?.contains("button-text-input");
|
|
201788
|
-
}, isToolbarButton = (target) => {
|
|
201789
|
-
return !!target?.closest(".toolbar-button") || target?.classList?.contains("toolbar-button");
|
|
201790
|
-
}, CustomSelection, LinkedStyles, FORMATTING_MARK_NAMES, getLinkedStyle = (styleId, styles = []) => {
|
|
201820
|
+
}, LinkedStyles, FORMATTING_MARK_NAMES, getLinkedStyle = (styleId, styles = []) => {
|
|
201791
201821
|
const linkedStyle = styles.find((style2) => style2.id === styleId);
|
|
201792
201822
|
const basedOn = linkedStyle?.definition?.attrs?.basedOn;
|
|
201793
201823
|
return {
|
|
@@ -219696,7 +219726,7 @@ var Node$13 = class Node$14 {
|
|
|
219696
219726
|
return false;
|
|
219697
219727
|
return Boolean(checker(attrs));
|
|
219698
219728
|
}, SuperToolbar, ICONS, TEXTS, tableActionsOptions;
|
|
219699
|
-
var
|
|
219729
|
+
var init_src_SNuegb28_es = __esm(() => {
|
|
219700
219730
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
219701
219731
|
init_SuperConverter_BQCVReWb_es();
|
|
219702
219732
|
init_jszip_ChlR43oI_es();
|
|
@@ -221017,6 +221047,209 @@ ${err.toString()}`);
|
|
|
221017
221047
|
}
|
|
221018
221048
|
}
|
|
221019
221049
|
};
|
|
221050
|
+
DEFAULT_SELECTION_STATE = Object.freeze({
|
|
221051
|
+
focused: false,
|
|
221052
|
+
preservedSelection: null,
|
|
221053
|
+
showVisualSelection: false,
|
|
221054
|
+
skipFocusReset: false
|
|
221055
|
+
});
|
|
221056
|
+
CustomSelectionPluginKey = new PluginKey("CustomSelection");
|
|
221057
|
+
CustomSelection = Extension.create({
|
|
221058
|
+
name: "customSelection",
|
|
221059
|
+
addPmPlugins() {
|
|
221060
|
+
const editor = this.editor;
|
|
221061
|
+
return [new Plugin({
|
|
221062
|
+
key: CustomSelectionPluginKey,
|
|
221063
|
+
state: {
|
|
221064
|
+
init: () => ({ ...DEFAULT_SELECTION_STATE }),
|
|
221065
|
+
apply: (tr, value) => {
|
|
221066
|
+
const meta2 = getFocusMeta(tr);
|
|
221067
|
+
const nextState = meta2 !== undefined ? normalizeSelectionState({
|
|
221068
|
+
...value,
|
|
221069
|
+
...meta2
|
|
221070
|
+
}) : value;
|
|
221071
|
+
if (!nextState?.preservedSelection)
|
|
221072
|
+
return nextState;
|
|
221073
|
+
if (!tr.docChanged)
|
|
221074
|
+
return nextState;
|
|
221075
|
+
const mappedSelection = mapPreservedSelection(nextState.preservedSelection, tr);
|
|
221076
|
+
if (!mappedSelection)
|
|
221077
|
+
return {
|
|
221078
|
+
...nextState,
|
|
221079
|
+
preservedSelection: null,
|
|
221080
|
+
showVisualSelection: false
|
|
221081
|
+
};
|
|
221082
|
+
return {
|
|
221083
|
+
...nextState,
|
|
221084
|
+
preservedSelection: mappedSelection
|
|
221085
|
+
};
|
|
221086
|
+
}
|
|
221087
|
+
},
|
|
221088
|
+
view: () => {
|
|
221089
|
+
const clickHandler = (event) => handleClickOutside(event, editor);
|
|
221090
|
+
document?.addEventListener("mousedown", clickHandler);
|
|
221091
|
+
return { destroy: () => {
|
|
221092
|
+
document?.removeEventListener("mousedown", clickHandler);
|
|
221093
|
+
} };
|
|
221094
|
+
},
|
|
221095
|
+
props: {
|
|
221096
|
+
handleDOMEvents: {
|
|
221097
|
+
contextmenu: (view, event) => {
|
|
221098
|
+
if (shouldAllowNativeContextMenu(event))
|
|
221099
|
+
return false;
|
|
221100
|
+
event.preventDefault();
|
|
221101
|
+
const { selection } = view.state;
|
|
221102
|
+
if (!selection.empty)
|
|
221103
|
+
view.dispatch(setFocusMeta(view.state.tr, {
|
|
221104
|
+
focused: true,
|
|
221105
|
+
preservedSelection: selection,
|
|
221106
|
+
showVisualSelection: true,
|
|
221107
|
+
skipFocusReset: true
|
|
221108
|
+
}));
|
|
221109
|
+
setTimeout(() => {
|
|
221110
|
+
view.focus();
|
|
221111
|
+
}, 0);
|
|
221112
|
+
return false;
|
|
221113
|
+
},
|
|
221114
|
+
mousedown: (view, event) => {
|
|
221115
|
+
if (event.button === 2) {
|
|
221116
|
+
if (shouldAllowNativeContextMenu(event))
|
|
221117
|
+
return false;
|
|
221118
|
+
const { selection: selection$1 } = view.state;
|
|
221119
|
+
if (!selection$1.empty) {
|
|
221120
|
+
view.dispatch(setFocusMeta(view.state.tr, {
|
|
221121
|
+
focused: true,
|
|
221122
|
+
preservedSelection: selection$1,
|
|
221123
|
+
showVisualSelection: true,
|
|
221124
|
+
skipFocusReset: true
|
|
221125
|
+
}));
|
|
221126
|
+
this.editor.setOptions({
|
|
221127
|
+
lastSelection: selection$1,
|
|
221128
|
+
preservedSelection: selection$1
|
|
221129
|
+
});
|
|
221130
|
+
}
|
|
221131
|
+
return false;
|
|
221132
|
+
}
|
|
221133
|
+
const { selection } = view.state;
|
|
221134
|
+
const target = event.target;
|
|
221135
|
+
const isElement$2 = target instanceof Element;
|
|
221136
|
+
const isToolbarBtn = isElement$2 && isToolbarButton(target);
|
|
221137
|
+
const isToolbarInp = isElement$2 && isToolbarInput(target);
|
|
221138
|
+
this.editor.setOptions({ focusTarget: target });
|
|
221139
|
+
if (isToolbarInp && !selection.empty) {
|
|
221140
|
+
view.dispatch(setFocusMeta(view.state.tr, {
|
|
221141
|
+
focused: true,
|
|
221142
|
+
preservedSelection: selection,
|
|
221143
|
+
showVisualSelection: true,
|
|
221144
|
+
skipFocusReset: false
|
|
221145
|
+
}));
|
|
221146
|
+
this.editor.setOptions({
|
|
221147
|
+
lastSelection: selection,
|
|
221148
|
+
preservedSelection: selection
|
|
221149
|
+
});
|
|
221150
|
+
return false;
|
|
221151
|
+
}
|
|
221152
|
+
if (isToolbarBtn && !isToolbarInp) {
|
|
221153
|
+
if (!selection.empty) {
|
|
221154
|
+
this.editor.setOptions({ lastSelection: selection });
|
|
221155
|
+
view.dispatch(setFocusMeta(view.state.tr, {
|
|
221156
|
+
focused: true,
|
|
221157
|
+
preservedSelection: selection,
|
|
221158
|
+
showVisualSelection: true,
|
|
221159
|
+
skipFocusReset: false
|
|
221160
|
+
}));
|
|
221161
|
+
}
|
|
221162
|
+
return false;
|
|
221163
|
+
}
|
|
221164
|
+
if (!isToolbarBtn && !isToolbarInp) {
|
|
221165
|
+
view.dispatch(setFocusMeta(view.state.tr, {
|
|
221166
|
+
focused: false,
|
|
221167
|
+
preservedSelection: null,
|
|
221168
|
+
showVisualSelection: false,
|
|
221169
|
+
skipFocusReset: false
|
|
221170
|
+
}));
|
|
221171
|
+
if (!selection.empty && !this.editor.options.element?.contains(target)) {
|
|
221172
|
+
this.editor.setOptions({ lastSelection: selection });
|
|
221173
|
+
const clearSelectionTr = view.state.tr.setSelection(TextSelection2.create(view.state.doc, 0));
|
|
221174
|
+
view.dispatch(clearSelectionTr);
|
|
221175
|
+
}
|
|
221176
|
+
}
|
|
221177
|
+
},
|
|
221178
|
+
focus: (view) => {
|
|
221179
|
+
const target = this.editor.options.focusTarget;
|
|
221180
|
+
const isElement$2 = target instanceof Element;
|
|
221181
|
+
const isToolbarBtn = isElement$2 && isToolbarButton(target);
|
|
221182
|
+
const isToolbarInp = isElement$2 && isToolbarInput(target);
|
|
221183
|
+
const focusState = getFocusState(view.state);
|
|
221184
|
+
if (focusState?.skipFocusReset) {
|
|
221185
|
+
view.dispatch(setFocusMeta(view.state.tr, normalizeSelectionState({
|
|
221186
|
+
...focusState,
|
|
221187
|
+
skipFocusReset: false
|
|
221188
|
+
})));
|
|
221189
|
+
return false;
|
|
221190
|
+
}
|
|
221191
|
+
if (!isToolbarBtn && !isToolbarInp)
|
|
221192
|
+
view.dispatch(setFocusMeta(view.state.tr, {
|
|
221193
|
+
focused: false,
|
|
221194
|
+
preservedSelection: null,
|
|
221195
|
+
showVisualSelection: false,
|
|
221196
|
+
skipFocusReset: false
|
|
221197
|
+
}));
|
|
221198
|
+
},
|
|
221199
|
+
blur: (view) => {
|
|
221200
|
+
const target = this.editor.options.focusTarget;
|
|
221201
|
+
const isElement$2 = target instanceof Element;
|
|
221202
|
+
const isToolbarBtn = isElement$2 && isToolbarButton(target);
|
|
221203
|
+
const isToolbarInp = isElement$2 && isToolbarInput(target);
|
|
221204
|
+
const state = getFocusState(view.state);
|
|
221205
|
+
if (state?.skipFocusReset)
|
|
221206
|
+
return false;
|
|
221207
|
+
if (isToolbarBtn || isToolbarInp)
|
|
221208
|
+
view.dispatch(setFocusMeta(view.state.tr, {
|
|
221209
|
+
focused: true,
|
|
221210
|
+
preservedSelection: state.preservedSelection || view.state.selection,
|
|
221211
|
+
showVisualSelection: true,
|
|
221212
|
+
skipFocusReset: false
|
|
221213
|
+
}));
|
|
221214
|
+
else {
|
|
221215
|
+
view.dispatch(setFocusMeta(view.state.tr, {
|
|
221216
|
+
focused: false,
|
|
221217
|
+
preservedSelection: null,
|
|
221218
|
+
showVisualSelection: false,
|
|
221219
|
+
skipFocusReset: false
|
|
221220
|
+
}));
|
|
221221
|
+
this.editor.setOptions({
|
|
221222
|
+
preservedSelection: null,
|
|
221223
|
+
lastSelection: null
|
|
221224
|
+
});
|
|
221225
|
+
}
|
|
221226
|
+
}
|
|
221227
|
+
},
|
|
221228
|
+
decorations: (state) => {
|
|
221229
|
+
const { selection, doc: doc$2 } = state;
|
|
221230
|
+
const focusState = getFocusState(state);
|
|
221231
|
+
if (!(focusState.showVisualSelection && (focusState.preservedSelection || !selection.empty && focusState.focused)))
|
|
221232
|
+
return null;
|
|
221233
|
+
const targetSelection = focusState.preservedSelection || selection;
|
|
221234
|
+
if (targetSelection.empty)
|
|
221235
|
+
return null;
|
|
221236
|
+
return DecorationSet.create(doc$2, [Decoration.inline(targetSelection.from, targetSelection.to, { class: "sd-custom-selection" })]);
|
|
221237
|
+
}
|
|
221238
|
+
}
|
|
221239
|
+
})];
|
|
221240
|
+
},
|
|
221241
|
+
addCommands() {
|
|
221242
|
+
return { restorePreservedSelection: () => ({ tr, state }) => {
|
|
221243
|
+
const focusState = getFocusState(state);
|
|
221244
|
+
if (focusState.preservedSelection)
|
|
221245
|
+
return tr.setSelection(focusState.preservedSelection);
|
|
221246
|
+
const lastSelection = this.editor.options.lastSelection;
|
|
221247
|
+
if (lastSelection)
|
|
221248
|
+
return tr.setSelection(lastSelection);
|
|
221249
|
+
return tr;
|
|
221250
|
+
} };
|
|
221251
|
+
}
|
|
221252
|
+
});
|
|
221020
221253
|
History = Extension.create({
|
|
221021
221254
|
name: "history",
|
|
221022
221255
|
addOptions() {
|
|
@@ -221035,18 +221268,22 @@ ${err.toString()}`);
|
|
|
221035
221268
|
undo: () => ({ state, dispatch, tr }) => {
|
|
221036
221269
|
if (this.editor.options.collaborationProvider && this.editor.options.ydoc) {
|
|
221037
221270
|
tr.setMeta("preventDispatch", true);
|
|
221038
|
-
|
|
221271
|
+
const result = undo$1(state);
|
|
221272
|
+
runSelectionCleanupAfterCollabHistory(this.editor);
|
|
221273
|
+
return result;
|
|
221039
221274
|
}
|
|
221040
221275
|
tr.setMeta("inputType", "historyUndo");
|
|
221041
|
-
return undo(state, dispatch);
|
|
221276
|
+
return undo(state, createHistoryDispatch(this.editor, dispatch));
|
|
221042
221277
|
},
|
|
221043
221278
|
redo: () => ({ state, dispatch, tr }) => {
|
|
221044
221279
|
if (this.editor.options.collaborationProvider && this.editor.options.ydoc) {
|
|
221045
221280
|
tr.setMeta("preventDispatch", true);
|
|
221046
|
-
|
|
221281
|
+
const result = redo$1(state);
|
|
221282
|
+
runSelectionCleanupAfterCollabHistory(this.editor);
|
|
221283
|
+
return result;
|
|
221047
221284
|
}
|
|
221048
221285
|
tr.setMeta("inputType", "historyRedo");
|
|
221049
|
-
return redo(state, dispatch);
|
|
221286
|
+
return redo(state, createHistoryDispatch(this.editor, dispatch));
|
|
221050
221287
|
}
|
|
221051
221288
|
};
|
|
221052
221289
|
},
|
|
@@ -231085,204 +231322,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
231085
231322
|
})];
|
|
231086
231323
|
}
|
|
231087
231324
|
});
|
|
231088
|
-
DEFAULT_SELECTION_STATE = Object.freeze({
|
|
231089
|
-
focused: false,
|
|
231090
|
-
preservedSelection: null,
|
|
231091
|
-
showVisualSelection: false,
|
|
231092
|
-
skipFocusReset: false
|
|
231093
|
-
});
|
|
231094
|
-
CustomSelectionPluginKey = new PluginKey("CustomSelection");
|
|
231095
|
-
CustomSelection = Extension.create({
|
|
231096
|
-
name: "customSelection",
|
|
231097
|
-
addPmPlugins() {
|
|
231098
|
-
const editor = this.editor;
|
|
231099
|
-
return [new Plugin({
|
|
231100
|
-
key: CustomSelectionPluginKey,
|
|
231101
|
-
state: {
|
|
231102
|
-
init: () => ({ ...DEFAULT_SELECTION_STATE }),
|
|
231103
|
-
apply: (tr, value) => {
|
|
231104
|
-
const meta2 = getFocusMeta(tr);
|
|
231105
|
-
const nextState = meta2 !== undefined ? normalizeSelectionState({
|
|
231106
|
-
...value,
|
|
231107
|
-
...meta2
|
|
231108
|
-
}) : value;
|
|
231109
|
-
if (!nextState?.preservedSelection)
|
|
231110
|
-
return nextState;
|
|
231111
|
-
if (!tr.docChanged)
|
|
231112
|
-
return nextState;
|
|
231113
|
-
const mappedSelection = mapPreservedSelection(nextState.preservedSelection, tr);
|
|
231114
|
-
if (!mappedSelection)
|
|
231115
|
-
return {
|
|
231116
|
-
...nextState,
|
|
231117
|
-
preservedSelection: null,
|
|
231118
|
-
showVisualSelection: false
|
|
231119
|
-
};
|
|
231120
|
-
return {
|
|
231121
|
-
...nextState,
|
|
231122
|
-
preservedSelection: mappedSelection
|
|
231123
|
-
};
|
|
231124
|
-
}
|
|
231125
|
-
},
|
|
231126
|
-
view: () => {
|
|
231127
|
-
const clickHandler = (event) => handleClickOutside(event, editor);
|
|
231128
|
-
document?.addEventListener("mousedown", clickHandler);
|
|
231129
|
-
return { destroy: () => {
|
|
231130
|
-
document?.removeEventListener("mousedown", clickHandler);
|
|
231131
|
-
} };
|
|
231132
|
-
},
|
|
231133
|
-
props: {
|
|
231134
|
-
handleDOMEvents: {
|
|
231135
|
-
contextmenu: (view, event) => {
|
|
231136
|
-
if (shouldAllowNativeContextMenu(event))
|
|
231137
|
-
return false;
|
|
231138
|
-
event.preventDefault();
|
|
231139
|
-
const { selection } = view.state;
|
|
231140
|
-
if (!selection.empty)
|
|
231141
|
-
view.dispatch(setFocusMeta(view.state.tr, {
|
|
231142
|
-
focused: true,
|
|
231143
|
-
preservedSelection: selection,
|
|
231144
|
-
showVisualSelection: true,
|
|
231145
|
-
skipFocusReset: true
|
|
231146
|
-
}));
|
|
231147
|
-
setTimeout(() => {
|
|
231148
|
-
view.focus();
|
|
231149
|
-
}, 0);
|
|
231150
|
-
return false;
|
|
231151
|
-
},
|
|
231152
|
-
mousedown: (view, event) => {
|
|
231153
|
-
if (event.button === 2) {
|
|
231154
|
-
if (shouldAllowNativeContextMenu(event))
|
|
231155
|
-
return false;
|
|
231156
|
-
const { selection: selection$1 } = view.state;
|
|
231157
|
-
if (!selection$1.empty) {
|
|
231158
|
-
view.dispatch(setFocusMeta(view.state.tr, {
|
|
231159
|
-
focused: true,
|
|
231160
|
-
preservedSelection: selection$1,
|
|
231161
|
-
showVisualSelection: true,
|
|
231162
|
-
skipFocusReset: true
|
|
231163
|
-
}));
|
|
231164
|
-
this.editor.setOptions({
|
|
231165
|
-
lastSelection: selection$1,
|
|
231166
|
-
preservedSelection: selection$1
|
|
231167
|
-
});
|
|
231168
|
-
}
|
|
231169
|
-
return false;
|
|
231170
|
-
}
|
|
231171
|
-
const { selection } = view.state;
|
|
231172
|
-
const target = event.target;
|
|
231173
|
-
const isElement$2 = target instanceof Element;
|
|
231174
|
-
const isToolbarBtn = isElement$2 && isToolbarButton(target);
|
|
231175
|
-
const isToolbarInp = isElement$2 && isToolbarInput(target);
|
|
231176
|
-
this.editor.setOptions({ focusTarget: target });
|
|
231177
|
-
if (isToolbarInp && !selection.empty) {
|
|
231178
|
-
view.dispatch(setFocusMeta(view.state.tr, {
|
|
231179
|
-
focused: true,
|
|
231180
|
-
preservedSelection: selection,
|
|
231181
|
-
showVisualSelection: true,
|
|
231182
|
-
skipFocusReset: false
|
|
231183
|
-
}));
|
|
231184
|
-
this.editor.setOptions({
|
|
231185
|
-
lastSelection: selection,
|
|
231186
|
-
preservedSelection: selection
|
|
231187
|
-
});
|
|
231188
|
-
return false;
|
|
231189
|
-
}
|
|
231190
|
-
if (isToolbarBtn && !isToolbarInp) {
|
|
231191
|
-
if (!selection.empty) {
|
|
231192
|
-
this.editor.setOptions({ lastSelection: selection });
|
|
231193
|
-
view.dispatch(setFocusMeta(view.state.tr, {
|
|
231194
|
-
focused: true,
|
|
231195
|
-
preservedSelection: selection,
|
|
231196
|
-
showVisualSelection: true,
|
|
231197
|
-
skipFocusReset: false
|
|
231198
|
-
}));
|
|
231199
|
-
}
|
|
231200
|
-
return false;
|
|
231201
|
-
}
|
|
231202
|
-
if (!isToolbarBtn && !isToolbarInp) {
|
|
231203
|
-
view.dispatch(setFocusMeta(view.state.tr, {
|
|
231204
|
-
focused: false,
|
|
231205
|
-
preservedSelection: null,
|
|
231206
|
-
showVisualSelection: false,
|
|
231207
|
-
skipFocusReset: false
|
|
231208
|
-
}));
|
|
231209
|
-
if (!selection.empty && !this.editor.options.element?.contains(target)) {
|
|
231210
|
-
this.editor.setOptions({ lastSelection: selection });
|
|
231211
|
-
const clearSelectionTr = view.state.tr.setSelection(TextSelection2.create(view.state.doc, 0));
|
|
231212
|
-
view.dispatch(clearSelectionTr);
|
|
231213
|
-
}
|
|
231214
|
-
}
|
|
231215
|
-
},
|
|
231216
|
-
focus: (view) => {
|
|
231217
|
-
const target = this.editor.options.focusTarget;
|
|
231218
|
-
const isElement$2 = target instanceof Element;
|
|
231219
|
-
const isToolbarBtn = isElement$2 && isToolbarButton(target);
|
|
231220
|
-
const isToolbarInp = isElement$2 && isToolbarInput(target);
|
|
231221
|
-
const focusState = getFocusState(view.state);
|
|
231222
|
-
if (focusState?.skipFocusReset) {
|
|
231223
|
-
view.dispatch(setFocusMeta(view.state.tr, normalizeSelectionState({
|
|
231224
|
-
...focusState,
|
|
231225
|
-
skipFocusReset: false
|
|
231226
|
-
})));
|
|
231227
|
-
return false;
|
|
231228
|
-
}
|
|
231229
|
-
if (!isToolbarBtn && !isToolbarInp)
|
|
231230
|
-
view.dispatch(setFocusMeta(view.state.tr, {
|
|
231231
|
-
focused: false,
|
|
231232
|
-
preservedSelection: null,
|
|
231233
|
-
showVisualSelection: false,
|
|
231234
|
-
skipFocusReset: false
|
|
231235
|
-
}));
|
|
231236
|
-
},
|
|
231237
|
-
blur: (view) => {
|
|
231238
|
-
const target = this.editor.options.focusTarget;
|
|
231239
|
-
const isElement$2 = target instanceof Element;
|
|
231240
|
-
const isToolbarBtn = isElement$2 && isToolbarButton(target);
|
|
231241
|
-
const isToolbarInp = isElement$2 && isToolbarInput(target);
|
|
231242
|
-
const state = getFocusState(view.state);
|
|
231243
|
-
if (state?.skipFocusReset)
|
|
231244
|
-
return false;
|
|
231245
|
-
if (isToolbarBtn || isToolbarInp)
|
|
231246
|
-
view.dispatch(setFocusMeta(view.state.tr, {
|
|
231247
|
-
focused: true,
|
|
231248
|
-
preservedSelection: state.preservedSelection || view.state.selection,
|
|
231249
|
-
showVisualSelection: true,
|
|
231250
|
-
skipFocusReset: false
|
|
231251
|
-
}));
|
|
231252
|
-
else
|
|
231253
|
-
view.dispatch(setFocusMeta(view.state.tr, {
|
|
231254
|
-
focused: false,
|
|
231255
|
-
preservedSelection: null,
|
|
231256
|
-
showVisualSelection: false,
|
|
231257
|
-
skipFocusReset: false
|
|
231258
|
-
}));
|
|
231259
|
-
}
|
|
231260
|
-
},
|
|
231261
|
-
decorations: (state) => {
|
|
231262
|
-
const { selection, doc: doc$2 } = state;
|
|
231263
|
-
const focusState = getFocusState(state);
|
|
231264
|
-
if (!(focusState.showVisualSelection && (focusState.preservedSelection || !selection.empty && focusState.focused)))
|
|
231265
|
-
return null;
|
|
231266
|
-
const targetSelection = focusState.preservedSelection || selection;
|
|
231267
|
-
if (targetSelection.empty)
|
|
231268
|
-
return null;
|
|
231269
|
-
return DecorationSet.create(doc$2, [Decoration.inline(targetSelection.from, targetSelection.to, { class: "sd-custom-selection" })]);
|
|
231270
|
-
}
|
|
231271
|
-
}
|
|
231272
|
-
})];
|
|
231273
|
-
},
|
|
231274
|
-
addCommands() {
|
|
231275
|
-
return { restorePreservedSelection: () => ({ tr, state }) => {
|
|
231276
|
-
const focusState = getFocusState(state);
|
|
231277
|
-
if (focusState.preservedSelection)
|
|
231278
|
-
return tr.setSelection(focusState.preservedSelection);
|
|
231279
|
-
const lastSelection = this.editor.options.lastSelection;
|
|
231280
|
-
if (lastSelection)
|
|
231281
|
-
return tr.setSelection(lastSelection);
|
|
231282
|
-
return tr;
|
|
231283
|
-
} };
|
|
231284
|
-
}
|
|
231285
|
-
});
|
|
231286
231325
|
LinkedStyles = Extension.create({
|
|
231287
231326
|
name: "linkedStyles",
|
|
231288
231327
|
priority: 1,
|
|
@@ -253389,7 +253428,7 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
|
|
|
253389
253428
|
|
|
253390
253429
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
253391
253430
|
var init_super_editor_es = __esm(() => {
|
|
253392
|
-
|
|
253431
|
+
init_src_SNuegb28_es();
|
|
253393
253432
|
init_SuperConverter_BQCVReWb_es();
|
|
253394
253433
|
init_jszip_ChlR43oI_es();
|
|
253395
253434
|
init_xml_js_DLE8mr0n_es();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc-dev/cli",
|
|
3
|
-
"version": "0.2.0-next.
|
|
3
|
+
"version": "0.2.0-next.138",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superdoc": "./dist/index.js"
|
|
@@ -20,21 +20,21 @@
|
|
|
20
20
|
"@types/bun": "^1.3.8",
|
|
21
21
|
"@types/node": "22.19.2",
|
|
22
22
|
"typescript": "^5.9.2",
|
|
23
|
-
"@superdoc/document-api": "0.0.1",
|
|
24
23
|
"@superdoc/pm-adapter": "0.0.0",
|
|
25
24
|
"superdoc": "1.18.0",
|
|
26
|
-
"@superdoc/super-editor": "0.0.1"
|
|
25
|
+
"@superdoc/super-editor": "0.0.1",
|
|
26
|
+
"@superdoc/document-api": "0.0.1"
|
|
27
27
|
},
|
|
28
28
|
"module": "src/index.ts",
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@superdoc-dev/cli-darwin-arm64": "0.2.0-next.
|
|
34
|
-
"@superdoc-dev/cli-darwin-x64": "0.2.0-next.
|
|
35
|
-
"@superdoc-dev/cli-linux-x64": "0.2.0-next.
|
|
36
|
-
"@superdoc-dev/cli-linux-arm64": "0.2.0-next.
|
|
37
|
-
"@superdoc-dev/cli-windows-x64": "0.2.0-next.
|
|
33
|
+
"@superdoc-dev/cli-darwin-arm64": "0.2.0-next.138",
|
|
34
|
+
"@superdoc-dev/cli-darwin-x64": "0.2.0-next.138",
|
|
35
|
+
"@superdoc-dev/cli-linux-x64": "0.2.0-next.138",
|
|
36
|
+
"@superdoc-dev/cli-linux-arm64": "0.2.0-next.138",
|
|
37
|
+
"@superdoc-dev/cli-windows-x64": "0.2.0-next.138"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"dev": "bun run src/index.ts",
|