@harbour-enterprises/superdoc 0.21.0 → 0.22.0-next.2
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-OZDJ7gwT.cjs → PdfViewer-Ck3Syakz.cjs} +1 -1
- package/dist/chunks/{PdfViewer-D3zo7tPo.es.js → PdfViewer-OEs-MC5j.es.js} +1 -1
- package/dist/chunks/{index-MzW5BVNd.es.js → index-B4aklZ4_.es.js} +5 -4
- package/dist/chunks/{index-CfYf4T_z.cjs → index-BM732Zfw.cjs} +5 -4
- package/dist/chunks/{super-editor.es-Bntob7Wd.es.js → super-editor.es-Bokezk1E.es.js} +1179 -766
- package/dist/chunks/{super-editor.es-U-GVCd_F.cjs → super-editor.es-DwGNbrZq.cjs} +1179 -766
- package/dist/core/types/index.d.ts +8 -0
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/style.css +32 -27
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-3xnF_NHq.js → converter-BcqEfCTg.js} +775 -645
- package/dist/super-editor/chunks/{docx-zipper-CZdELYi-.js → docx-zipper-DZ9ph0iQ.js} +1 -1
- package/dist/super-editor/chunks/{editor-BqYH4kDD.js → editor-CTHD3ziL.js} +26 -3
- package/dist/super-editor/chunks/{toolbar-TkaE2kKM.js → toolbar-DLQeMuoQ.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/src/components/slash-menu/menuItems.d.ts +5 -1
- package/dist/super-editor/src/components/slash-menu/tests/testHelpers.d.ts +466 -0
- package/dist/super-editor/src/components/slash-menu/utils.d.ts +9 -2
- package/dist/super-editor/src/core/commands/__tests__/schemaWithLists.d.ts +2 -0
- package/dist/super-editor/src/core/commands/__tests__/testHelpers.d.ts +4 -0
- package/dist/super-editor/src/core/commands/__tests__/testSchema.d.ts +2 -0
- package/dist/super-editor/src/core/commands/tests/commandTestUtils.d.ts +7 -0
- package/dist/super-editor/src/core/commands/tests/test-schema.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/alternate-content-translator.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/index.d.ts +1 -0
- package/dist/super-editor/src/tests/helpers/helpers.d.ts +1 -0
- package/dist/super-editor/src/utils/contextmenu-helpers.d.ts +24 -0
- package/dist/super-editor/style.css +5 -0
- package/dist/super-editor/super-editor.es.js +453 -153
- 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 +1182 -768
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/extensions/run-item/index.d.ts +0 -1
- package/dist/super-editor/src/extensions/run-item/run-item.d.ts +0 -26
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as process$1, au as commonjsGlobal, B as Buffer, av as getDefaultExportFromCjs, aw as getContentTypesFromXml, ax as xmljs } from "./converter-
|
|
1
|
+
import { p as process$1, au as commonjsGlobal, B as Buffer, av as getDefaultExportFromCjs, aw as getContentTypesFromXml, ax as xmljs } from "./converter-BcqEfCTg.js";
|
|
2
2
|
function commonjsRequire(path) {
|
|
3
3
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
4
4
|
}
|
|
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
12
12
|
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as SelectionRange, ao as Transform, ap as isInTable$1, aq as generateDocxRandomId, ar as insertNewRelationship, as as updateDOMAttributes, at as htmlHandler } from "./converter-
|
|
15
|
+
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as SelectionRange, ao as Transform, ap as isInTable$1, aq as generateDocxRandomId, ar as insertNewRelationship, as as updateDOMAttributes, at as htmlHandler } from "./converter-BcqEfCTg.js";
|
|
16
16
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
17
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
17
|
+
import { D as DocxZipper } from "./docx-zipper-DZ9ph0iQ.js";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
20
20
|
};
|
|
@@ -14562,6 +14562,8 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14562
14562
|
element.style.isolation = "isolate";
|
|
14563
14563
|
proseMirror.style.outline = "none";
|
|
14564
14564
|
proseMirror.style.border = "none";
|
|
14565
|
+
element.style.backgroundColor = "#fff";
|
|
14566
|
+
proseMirror.style.backgroundColor = "#fff";
|
|
14565
14567
|
const { typeface, fontSizePt, fontFamilyCss } = this.converter.getDocumentDefaultStyles() ?? {};
|
|
14566
14568
|
const resolvedFontFamily = fontFamilyCss || typeface;
|
|
14567
14569
|
if (resolvedFontFamily) {
|
|
@@ -14884,7 +14886,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14884
14886
|
* @returns {Object | void} Migration results
|
|
14885
14887
|
*/
|
|
14886
14888
|
processCollaborationMigrations() {
|
|
14887
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.
|
|
14889
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.21.0");
|
|
14888
14890
|
if (!this.options.ydoc) return;
|
|
14889
14891
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
14890
14892
|
let docVersion = metaMap.get("version");
|
|
@@ -17478,6 +17480,20 @@ const intToJapaneseCounting = (num) => {
|
|
|
17478
17480
|
}
|
|
17479
17481
|
return result;
|
|
17480
17482
|
};
|
|
17483
|
+
const isKeyboardInvocation = (event) => {
|
|
17484
|
+
return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
|
|
17485
|
+
};
|
|
17486
|
+
const prefersNativeMenu = (event) => {
|
|
17487
|
+
if (!event) return false;
|
|
17488
|
+
if (event.ctrlKey || event.metaKey) {
|
|
17489
|
+
return true;
|
|
17490
|
+
}
|
|
17491
|
+
return isKeyboardInvocation(event);
|
|
17492
|
+
};
|
|
17493
|
+
const shouldAllowNativeContextMenu = (event) => {
|
|
17494
|
+
return prefersNativeMenu(event);
|
|
17495
|
+
};
|
|
17496
|
+
const shouldBypassContextMenu = shouldAllowNativeContextMenu;
|
|
17481
17497
|
const CustomSelectionPluginKey = new PluginKey("CustomSelection");
|
|
17482
17498
|
const handleClickOutside = (event, editor) => {
|
|
17483
17499
|
const editorElem = editor?.options?.element;
|
|
@@ -17540,6 +17556,9 @@ const CustomSelection = Extension.create({
|
|
|
17540
17556
|
props: {
|
|
17541
17557
|
handleDOMEvents: {
|
|
17542
17558
|
contextmenu: (view, event) => {
|
|
17559
|
+
if (shouldAllowNativeContextMenu(event)) {
|
|
17560
|
+
return false;
|
|
17561
|
+
}
|
|
17543
17562
|
event.preventDefault();
|
|
17544
17563
|
const { selection } = view.state;
|
|
17545
17564
|
if (!selection.empty) {
|
|
@@ -17558,6 +17577,9 @@ const CustomSelection = Extension.create({
|
|
|
17558
17577
|
},
|
|
17559
17578
|
mousedown: (view, event) => {
|
|
17560
17579
|
if (event.button === 2) {
|
|
17580
|
+
if (shouldAllowNativeContextMenu(event)) {
|
|
17581
|
+
return false;
|
|
17582
|
+
}
|
|
17561
17583
|
event.preventDefault();
|
|
17562
17584
|
const { selection: selection2 } = view.state;
|
|
17563
17585
|
if (!selection2.empty) {
|
|
@@ -33752,6 +33774,7 @@ export {
|
|
|
33752
33774
|
SectionHelpers as o,
|
|
33753
33775
|
getAllowedImageDimensions as p,
|
|
33754
33776
|
replaceSelectionWithImagePlaceholder as r,
|
|
33777
|
+
shouldBypassContextMenu as s,
|
|
33755
33778
|
useHighContrastMode as u,
|
|
33756
33779
|
yUndoPluginKey as y
|
|
33757
33780
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, nextTick, getCurrentInstance, createVNode, readonly, watch, onMounted, onBeforeUnmount, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
|
|
2
|
-
import { p as process$1 } from "./converter-
|
|
3
|
-
import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-
|
|
2
|
+
import { p as process$1 } from "./converter-BcqEfCTg.js";
|
|
3
|
+
import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-CTHD3ziL.js";
|
|
4
4
|
const sanitizeNumber = (value, defaultNumber) => {
|
|
5
5
|
let sanitized = value.replace(/[^0-9.]/g, "");
|
|
6
6
|
sanitized = parseFloat(sanitized);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E } from "./chunks/editor-
|
|
2
|
-
import "./chunks/converter-
|
|
3
|
-
import "./chunks/docx-zipper-
|
|
1
|
+
import { E } from "./chunks/editor-CTHD3ziL.js";
|
|
2
|
+
import "./chunks/converter-BcqEfCTg.js";
|
|
3
|
+
import "./chunks/docx-zipper-DZ9ph0iQ.js";
|
|
4
4
|
export {
|
|
5
5
|
E as Editor
|
|
6
6
|
};
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
* requiresClipboard?: boolean
|
|
15
15
|
* requiresTableParent?: boolean
|
|
16
16
|
* requiredSectionParent?: boolean,
|
|
17
|
-
* requiresModule?: string
|
|
17
|
+
* requiresModule?: string,
|
|
18
|
+
* render?: (context: Object) => HTMLElement,
|
|
19
|
+
* showWhen?: (context: Object) => boolean
|
|
18
20
|
* }>
|
|
19
21
|
* }>} Array of menu sections
|
|
20
22
|
*/
|
|
@@ -32,5 +34,7 @@ export function getItems(context: any): Array<{
|
|
|
32
34
|
requiresTableParent?: boolean;
|
|
33
35
|
requiredSectionParent?: boolean;
|
|
34
36
|
requiresModule?: string;
|
|
37
|
+
render?: (context: any) => HTMLElement;
|
|
38
|
+
showWhen?: (context: any) => boolean;
|
|
35
39
|
}>;
|
|
36
40
|
}>;
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test helper utilities for slash menu components
|
|
3
|
+
* Extracts shared patterns from utils.test.js, SlashMenu.test.js, and menuItems.test.js
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Creates a mock ProseMirror selection object with configurable properties
|
|
7
|
+
*/
|
|
8
|
+
export function createMockSelection(options?: {}): {
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
empty: boolean;
|
|
12
|
+
$head: {
|
|
13
|
+
marks: import("vitest").Mock<() => {
|
|
14
|
+
type: {
|
|
15
|
+
name: any;
|
|
16
|
+
};
|
|
17
|
+
}[]>;
|
|
18
|
+
};
|
|
19
|
+
$from: {
|
|
20
|
+
depth: number;
|
|
21
|
+
node: import("vitest").Mock<() => {
|
|
22
|
+
type: {
|
|
23
|
+
name: string;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
$to: {
|
|
28
|
+
depth: number;
|
|
29
|
+
node: import("vitest").Mock<() => {
|
|
30
|
+
type: {
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
constructor: {
|
|
36
|
+
near: import("vitest").Mock<() => {
|
|
37
|
+
from: number;
|
|
38
|
+
to: number;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Creates a mock ProseMirror state object with configurable properties
|
|
44
|
+
*/
|
|
45
|
+
export function createMockState(options?: {}): {
|
|
46
|
+
selection: {
|
|
47
|
+
from: number;
|
|
48
|
+
to: number;
|
|
49
|
+
empty: boolean;
|
|
50
|
+
$head: {
|
|
51
|
+
marks: import("vitest").Mock<() => {
|
|
52
|
+
type: {
|
|
53
|
+
name: any;
|
|
54
|
+
};
|
|
55
|
+
}[]>;
|
|
56
|
+
};
|
|
57
|
+
$from: {
|
|
58
|
+
depth: number;
|
|
59
|
+
node: import("vitest").Mock<() => {
|
|
60
|
+
type: {
|
|
61
|
+
name: string;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
$to: {
|
|
66
|
+
depth: number;
|
|
67
|
+
node: import("vitest").Mock<() => {
|
|
68
|
+
type: {
|
|
69
|
+
name: string;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
constructor: {
|
|
74
|
+
near: import("vitest").Mock<() => {
|
|
75
|
+
from: number;
|
|
76
|
+
to: number;
|
|
77
|
+
}>;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
doc: {
|
|
81
|
+
textBetween: import("vitest").Mock<() => string>;
|
|
82
|
+
nodeAt: import("vitest").Mock<() => {
|
|
83
|
+
type: {
|
|
84
|
+
name: string;
|
|
85
|
+
};
|
|
86
|
+
}>;
|
|
87
|
+
resolve: import("vitest").Mock<() => {}>;
|
|
88
|
+
};
|
|
89
|
+
schema: {
|
|
90
|
+
marks: {};
|
|
91
|
+
nodes: {
|
|
92
|
+
paragraph: {
|
|
93
|
+
name: string;
|
|
94
|
+
};
|
|
95
|
+
table: {
|
|
96
|
+
name: string;
|
|
97
|
+
};
|
|
98
|
+
bulletList: {
|
|
99
|
+
name: string;
|
|
100
|
+
};
|
|
101
|
+
documentSection: {
|
|
102
|
+
name: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
storedMarks: any;
|
|
107
|
+
history: {
|
|
108
|
+
undoDepth: number;
|
|
109
|
+
redoDepth: number;
|
|
110
|
+
};
|
|
111
|
+
tr: {
|
|
112
|
+
setMeta: import("vitest").Mock<() => any>;
|
|
113
|
+
setSelection: import("vitest").Mock<() => any>;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Creates a mock ProseMirror view object with configurable properties
|
|
118
|
+
*/
|
|
119
|
+
export function createMockView(options?: {}): {
|
|
120
|
+
state: {
|
|
121
|
+
selection: {
|
|
122
|
+
from: number;
|
|
123
|
+
to: number;
|
|
124
|
+
empty: boolean;
|
|
125
|
+
$head: {
|
|
126
|
+
marks: import("vitest").Mock<() => {
|
|
127
|
+
type: {
|
|
128
|
+
name: any;
|
|
129
|
+
};
|
|
130
|
+
}[]>;
|
|
131
|
+
};
|
|
132
|
+
$from: {
|
|
133
|
+
depth: number;
|
|
134
|
+
node: import("vitest").Mock<() => {
|
|
135
|
+
type: {
|
|
136
|
+
name: string;
|
|
137
|
+
};
|
|
138
|
+
}>;
|
|
139
|
+
};
|
|
140
|
+
$to: {
|
|
141
|
+
depth: number;
|
|
142
|
+
node: import("vitest").Mock<() => {
|
|
143
|
+
type: {
|
|
144
|
+
name: string;
|
|
145
|
+
};
|
|
146
|
+
}>;
|
|
147
|
+
};
|
|
148
|
+
constructor: {
|
|
149
|
+
near: import("vitest").Mock<() => {
|
|
150
|
+
from: number;
|
|
151
|
+
to: number;
|
|
152
|
+
}>;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
doc: {
|
|
156
|
+
textBetween: import("vitest").Mock<() => string>;
|
|
157
|
+
nodeAt: import("vitest").Mock<() => {
|
|
158
|
+
type: {
|
|
159
|
+
name: string;
|
|
160
|
+
};
|
|
161
|
+
}>;
|
|
162
|
+
resolve: import("vitest").Mock<() => {}>;
|
|
163
|
+
};
|
|
164
|
+
schema: {
|
|
165
|
+
marks: {};
|
|
166
|
+
nodes: {
|
|
167
|
+
paragraph: {
|
|
168
|
+
name: string;
|
|
169
|
+
};
|
|
170
|
+
table: {
|
|
171
|
+
name: string;
|
|
172
|
+
};
|
|
173
|
+
bulletList: {
|
|
174
|
+
name: string;
|
|
175
|
+
};
|
|
176
|
+
documentSection: {
|
|
177
|
+
name: string;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
storedMarks: any;
|
|
182
|
+
history: {
|
|
183
|
+
undoDepth: number;
|
|
184
|
+
redoDepth: number;
|
|
185
|
+
};
|
|
186
|
+
tr: {
|
|
187
|
+
setMeta: import("vitest").Mock<() => any>;
|
|
188
|
+
setSelection: import("vitest").Mock<() => any>;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
coordsAtPos: import("vitest").Mock<() => {
|
|
192
|
+
left: number;
|
|
193
|
+
top: number;
|
|
194
|
+
}>;
|
|
195
|
+
posAtCoords: import("vitest").Mock<() => {
|
|
196
|
+
pos: number;
|
|
197
|
+
}>;
|
|
198
|
+
dispatch: import("vitest").Mock<(...args: any[]) => any>;
|
|
199
|
+
focus: import("vitest").Mock<(...args: any[]) => any>;
|
|
200
|
+
dom: {
|
|
201
|
+
addEventListener: import("vitest").Mock<(...args: any[]) => any>;
|
|
202
|
+
removeEventListener: import("vitest").Mock<(...args: any[]) => any>;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Creates a mock editor object with configurable options
|
|
207
|
+
*/
|
|
208
|
+
export function createMockEditor(options?: {}): {
|
|
209
|
+
view: {
|
|
210
|
+
state: {
|
|
211
|
+
selection: {
|
|
212
|
+
from: number;
|
|
213
|
+
to: number;
|
|
214
|
+
empty: boolean;
|
|
215
|
+
$head: {
|
|
216
|
+
marks: import("vitest").Mock<() => {
|
|
217
|
+
type: {
|
|
218
|
+
name: any;
|
|
219
|
+
};
|
|
220
|
+
}[]>;
|
|
221
|
+
};
|
|
222
|
+
$from: {
|
|
223
|
+
depth: number;
|
|
224
|
+
node: import("vitest").Mock<() => {
|
|
225
|
+
type: {
|
|
226
|
+
name: string;
|
|
227
|
+
};
|
|
228
|
+
}>;
|
|
229
|
+
};
|
|
230
|
+
$to: {
|
|
231
|
+
depth: number;
|
|
232
|
+
node: import("vitest").Mock<() => {
|
|
233
|
+
type: {
|
|
234
|
+
name: string;
|
|
235
|
+
};
|
|
236
|
+
}>;
|
|
237
|
+
};
|
|
238
|
+
constructor: {
|
|
239
|
+
near: import("vitest").Mock<() => {
|
|
240
|
+
from: number;
|
|
241
|
+
to: number;
|
|
242
|
+
}>;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
doc: {
|
|
246
|
+
textBetween: import("vitest").Mock<() => string>;
|
|
247
|
+
nodeAt: import("vitest").Mock<() => {
|
|
248
|
+
type: {
|
|
249
|
+
name: string;
|
|
250
|
+
};
|
|
251
|
+
}>;
|
|
252
|
+
resolve: import("vitest").Mock<() => {}>;
|
|
253
|
+
};
|
|
254
|
+
schema: {
|
|
255
|
+
marks: {};
|
|
256
|
+
nodes: {
|
|
257
|
+
paragraph: {
|
|
258
|
+
name: string;
|
|
259
|
+
};
|
|
260
|
+
table: {
|
|
261
|
+
name: string;
|
|
262
|
+
};
|
|
263
|
+
bulletList: {
|
|
264
|
+
name: string;
|
|
265
|
+
};
|
|
266
|
+
documentSection: {
|
|
267
|
+
name: string;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
storedMarks: any;
|
|
272
|
+
history: {
|
|
273
|
+
undoDepth: number;
|
|
274
|
+
redoDepth: number;
|
|
275
|
+
};
|
|
276
|
+
tr: {
|
|
277
|
+
setMeta: import("vitest").Mock<() => any>;
|
|
278
|
+
setSelection: import("vitest").Mock<() => any>;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
coordsAtPos: import("vitest").Mock<() => {
|
|
282
|
+
left: number;
|
|
283
|
+
top: number;
|
|
284
|
+
}>;
|
|
285
|
+
posAtCoords: import("vitest").Mock<() => {
|
|
286
|
+
pos: number;
|
|
287
|
+
}>;
|
|
288
|
+
dispatch: import("vitest").Mock<(...args: any[]) => any>;
|
|
289
|
+
focus: import("vitest").Mock<(...args: any[]) => any>;
|
|
290
|
+
dom: {
|
|
291
|
+
addEventListener: import("vitest").Mock<(...args: any[]) => any>;
|
|
292
|
+
removeEventListener: import("vitest").Mock<(...args: any[]) => any>;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
options: {
|
|
296
|
+
documentMode: string;
|
|
297
|
+
isAiEnabled: boolean;
|
|
298
|
+
slashMenuConfig: any;
|
|
299
|
+
aiApiKey: any;
|
|
300
|
+
aiEndpoint: any;
|
|
301
|
+
};
|
|
302
|
+
isEditable: boolean;
|
|
303
|
+
commands: any;
|
|
304
|
+
on: import("vitest").Mock<(...args: any[]) => any>;
|
|
305
|
+
off: import("vitest").Mock<(...args: any[]) => any>;
|
|
306
|
+
emit: import("vitest").Mock<(...args: any[]) => any>;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Creates a mock editor context object for slash menu utilities
|
|
310
|
+
*/
|
|
311
|
+
export function createMockContext(options?: {}): {
|
|
312
|
+
editor: any;
|
|
313
|
+
cursorPosition: {
|
|
314
|
+
x: number;
|
|
315
|
+
y: number;
|
|
316
|
+
};
|
|
317
|
+
pos: number;
|
|
318
|
+
node: {
|
|
319
|
+
type: {
|
|
320
|
+
name: string;
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
event: any;
|
|
324
|
+
selectedText: string;
|
|
325
|
+
hasSelection: boolean;
|
|
326
|
+
trigger: string;
|
|
327
|
+
clipboardContent: {
|
|
328
|
+
html: any;
|
|
329
|
+
text: any;
|
|
330
|
+
hasContent: boolean;
|
|
331
|
+
};
|
|
332
|
+
selectionStart: number;
|
|
333
|
+
selectionEnd: number;
|
|
334
|
+
isInTable: boolean;
|
|
335
|
+
isInList: boolean;
|
|
336
|
+
isInSectionNode: boolean;
|
|
337
|
+
currentNodeType: string;
|
|
338
|
+
activeMarks: any[];
|
|
339
|
+
isTrackedChange: boolean;
|
|
340
|
+
documentMode: string;
|
|
341
|
+
canUndo: boolean;
|
|
342
|
+
canRedo: boolean;
|
|
343
|
+
isEditable: boolean;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Sets up common mocks and returns cleanup functions
|
|
347
|
+
* Returns an object with mock functions and a cleanup function
|
|
348
|
+
*/
|
|
349
|
+
export function setupCommonMocks(): {
|
|
350
|
+
mocks: {
|
|
351
|
+
readFromClipboard: import("vitest").Mock<(...args: any[]) => any>;
|
|
352
|
+
selectionHasNodeOrMark: import("vitest").Mock<() => boolean>;
|
|
353
|
+
moveCursorToMouseEvent: import("vitest").Mock<(...args: any[]) => any>;
|
|
354
|
+
handleClipboardPaste: import("vitest").Mock<() => boolean>;
|
|
355
|
+
};
|
|
356
|
+
spies: {
|
|
357
|
+
docAddEventListener: import("vitest").MockInstance<{
|
|
358
|
+
<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
359
|
+
(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
360
|
+
}>;
|
|
361
|
+
docRemoveEventListener: import("vitest").MockInstance<{
|
|
362
|
+
<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
363
|
+
(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
364
|
+
}>;
|
|
365
|
+
};
|
|
366
|
+
cleanup: () => void;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Creates a beforeEach setup function with common mock resets
|
|
370
|
+
* Has a callback for any custom setup that needs to be done before each test
|
|
371
|
+
*/
|
|
372
|
+
export function createBeforeEachSetup(customSetup?: () => void): () => void;
|
|
373
|
+
/**
|
|
374
|
+
* Mounts a Vue component with common props and returns wrapper with helper methods
|
|
375
|
+
*/
|
|
376
|
+
export function mountSlashMenuComponent(component: any, options?: {}): {
|
|
377
|
+
wrapper: import("@vue/test-utils").VueWrapper<unknown, import("vue").ComponentPublicInstance<unknown, Omit<unknown, never>>>;
|
|
378
|
+
props: any;
|
|
379
|
+
openMenu(menuPosition?: {
|
|
380
|
+
left: string;
|
|
381
|
+
top: string;
|
|
382
|
+
}): Promise<void>;
|
|
383
|
+
closeMenu(): Promise<void>;
|
|
384
|
+
triggerKeydown(key: any, target?: string): Promise<void>;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Filters menu items by various criteria (helper for testing menu item filtering)
|
|
388
|
+
*/
|
|
389
|
+
export function filterMenuItems(sections: any, criteria?: {}): any;
|
|
390
|
+
/**
|
|
391
|
+
* Creates mock menu items for testing
|
|
392
|
+
*/
|
|
393
|
+
export function createMockMenuItems(count?: number, customItems?: any[]): {
|
|
394
|
+
id: string;
|
|
395
|
+
items: any[];
|
|
396
|
+
}[];
|
|
397
|
+
/**
|
|
398
|
+
* Creates a mock item with custom render function for testing
|
|
399
|
+
*/
|
|
400
|
+
export function createMockRenderItem(id?: string, renderFn?: any): {
|
|
401
|
+
id: string;
|
|
402
|
+
label: string;
|
|
403
|
+
render: any;
|
|
404
|
+
allowedTriggers: string[];
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* Common assertions for editor mock objects
|
|
408
|
+
*/
|
|
409
|
+
export function assertEditorMockStructure(editor: any): void;
|
|
410
|
+
/**
|
|
411
|
+
* Common assertions for menu sections structure
|
|
412
|
+
*/
|
|
413
|
+
export function assertMenuSectionsStructure(sections: any): void;
|
|
414
|
+
/**
|
|
415
|
+
* Asserts that event listeners are properly set up
|
|
416
|
+
*/
|
|
417
|
+
export function assertEventListenersSetup(editor: any, documentSpies: any): void;
|
|
418
|
+
/**
|
|
419
|
+
* Asserts that event listeners are properly cleaned up
|
|
420
|
+
*/
|
|
421
|
+
export function assertEventListenersCleanup(editor: any, documentSpies: any): void;
|
|
422
|
+
export namespace SlashMenuConfigs {
|
|
423
|
+
namespace withAI {
|
|
424
|
+
let includeDefaultItems: boolean;
|
|
425
|
+
let customItems: any[];
|
|
426
|
+
}
|
|
427
|
+
namespace customOnly {
|
|
428
|
+
let includeDefaultItems_1: boolean;
|
|
429
|
+
export { includeDefaultItems_1 as includeDefaultItems };
|
|
430
|
+
let customItems_1: {
|
|
431
|
+
id: string;
|
|
432
|
+
items: {
|
|
433
|
+
id: string;
|
|
434
|
+
label: string;
|
|
435
|
+
allowedTriggers: string[];
|
|
436
|
+
action: import("vitest").Mock<(...args: any[]) => any>;
|
|
437
|
+
}[];
|
|
438
|
+
}[];
|
|
439
|
+
export { customItems_1 as customItems };
|
|
440
|
+
}
|
|
441
|
+
function withProvider(providerFn: any): {
|
|
442
|
+
includeDefaultItems: boolean;
|
|
443
|
+
menuProvider: any;
|
|
444
|
+
};
|
|
445
|
+
namespace withConditionalItems {
|
|
446
|
+
let includeDefaultItems_2: boolean;
|
|
447
|
+
export { includeDefaultItems_2 as includeDefaultItems };
|
|
448
|
+
let customItems_2: {
|
|
449
|
+
id: string;
|
|
450
|
+
items: ({
|
|
451
|
+
id: string;
|
|
452
|
+
label: string;
|
|
453
|
+
allowedTriggers: string[];
|
|
454
|
+
action: import("vitest").Mock<(...args: any[]) => any>;
|
|
455
|
+
showWhen?: undefined;
|
|
456
|
+
} | {
|
|
457
|
+
id: string;
|
|
458
|
+
label: string;
|
|
459
|
+
allowedTriggers: string[];
|
|
460
|
+
action: import("vitest").Mock<(...args: any[]) => any>;
|
|
461
|
+
showWhen: (context: any) => any;
|
|
462
|
+
})[];
|
|
463
|
+
}[];
|
|
464
|
+
export { customItems_2 as customItems };
|
|
465
|
+
}
|
|
466
|
+
}
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Object} editor - The editor instance
|
|
5
5
|
* @param {MouseEvent} [event] - Optional mouse event (for context menu)
|
|
6
|
-
* @returns {Object} context -
|
|
6
|
+
* @returns {Promise<Object>} context - Enhanced editor context with comprehensive state information
|
|
7
7
|
*/
|
|
8
|
-
export function getEditorContext(editor: any, event?: MouseEvent): any
|
|
8
|
+
export function getEditorContext(editor: any, event?: MouseEvent): Promise<any>;
|
|
9
9
|
export function getPropsByItemId(itemId: string, props: any): any;
|
|
10
|
+
declare function getStructureFromResolvedPos(state: any, pos: any): {
|
|
11
|
+
isInTable: boolean;
|
|
12
|
+
isInList: boolean;
|
|
13
|
+
isInSectionNode: boolean;
|
|
14
|
+
};
|
|
15
|
+
declare function isCollaborationEnabled(editor: any): boolean;
|
|
16
|
+
export { getStructureFromResolvedPos as __getStructureFromResolvedPosForTest, isCollaborationEnabled as __isCollaborationEnabledForTest };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function createState(doc: any): EditorState;
|
|
2
|
+
export function setSelection(state: any, pos: any, end?: any): any;
|
|
3
|
+
export function createDispatch(): {
|
|
4
|
+
dispatch: (tr: any) => number;
|
|
5
|
+
dispatched: any[];
|
|
6
|
+
};
|
|
7
|
+
import { EditorState } from 'prosemirror-state';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./alternate-content-translator.js";
|