kindy-editor 3.2.1 → 3.2.3

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.
Files changed (51) hide show
  1. package/dist-lib/assets/{worker-CHtzL1YW.js → worker-BIFTSRF2.js} +7043 -7021
  2. package/dist-lib/assets/{worker-_GAJUHf5.js → worker-DO8U44KQ.js} +1 -0
  3. package/dist-lib/{browser-BxYyzpLt.js → browser-xuRja-pP.js} +2 -2
  4. package/dist-lib/builder.js +7 -7
  5. package/dist-lib/changeAggregator-ymKDXGA8.js +376 -0
  6. package/dist-lib/{editorApp-7-JzxxVn.js → editorApp-zIpjgEaZ.js} +9026 -8276
  7. package/dist-lib/events.js +119 -43
  8. package/dist-lib/export.js +1742 -1724
  9. package/dist-lib/generate-toc.js +5 -5
  10. package/dist-lib/import.js +2 -2
  11. package/dist-lib/index-Dd7gMK7l.js +12857 -0
  12. package/dist-lib/{kindy-editor-DKDwpt09.js → kindy-editor-DuN692fi.js} +133 -83
  13. package/dist-lib/kindy-editor.js +9 -6
  14. package/dist-lib/{lists-DpmgbDyt.js → lists-BVCy5dMa.js} +2 -2
  15. package/dist-lib/measure.js +3 -3
  16. package/dist-lib/{measureHost-C2NOdNkI.js → measureHost-y37gLU6M.js} +2 -2
  17. package/dist-lib/{metrics-DHgtBP-R.js → metrics-CdfHD-8y.js} +3 -3
  18. package/dist-lib/{paintStyle-Cjk9egel.js → paintStyle-Cb7IGKPW.js} +51 -51
  19. package/dist-lib/{parse-D4RpPrd7.js → parse-DJZd-2A7.js} +20 -20
  20. package/dist-lib/{pipeline-DhhBcLvV.js → pipeline-DKgBMmw1.js} +301 -301
  21. package/dist-lib/recalc-docx.js +2 -2
  22. package/dist-lib/{recalcToc-n50vq4nC.js → recalcToc-DCykIt4o.js} +80 -80
  23. package/dist-lib/{styleProps-OePkgWnD.js → styleProps-Dg3Wf-ZJ.js} +3 -3
  24. package/dist-lib/{stylesheet-E5bu1xch.js → stylesheet-EQFx9l5c.js} +3 -3
  25. package/dist-lib/{toc-DSwkNKls.js → toc-BIj8uQ-W.js} +417 -388
  26. package/dist-lib/{webmcp-KVT__0GH.js → webmcp-QA5rVg1F.js} +2 -2
  27. package/docs/http-event-sink.md +7 -0
  28. package/docs/public-events.md +103 -0
  29. package/docs/template-variables.md +310 -0
  30. package/docs/track-changes-events.md +551 -0
  31. package/package.json +2 -2
  32. package/types/events.d.ts +67 -1
  33. package/types/kindy-editor.d.ts +126 -3
  34. package/dist-lib/eventHub-CZFpTVqe.js +0 -71
  35. package/dist-lib/events-D_WEQDa6.js +0 -104
  36. package/dist-lib/index-Brv5TV-9.js +0 -11822
  37. package/docs/.vitepress/cache/deps/@theme_index.js +0 -275
  38. package/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
  39. package/docs/.vitepress/cache/deps/_metadata.json +0 -40
  40. package/docs/.vitepress/cache/deps/chunk-FNDFPMRQ.js +0 -13131
  41. package/docs/.vitepress/cache/deps/chunk-FNDFPMRQ.js.map +0 -7
  42. package/docs/.vitepress/cache/deps/chunk-IOFLAFGL.js +0 -9719
  43. package/docs/.vitepress/cache/deps/chunk-IOFLAFGL.js.map +0 -7
  44. package/docs/.vitepress/cache/deps/package.json +0 -3
  45. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4483
  46. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
  47. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -583
  48. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
  49. package/docs/.vitepress/cache/deps/vue.js +0 -347
  50. package/docs/.vitepress/cache/deps/vue.js.map +0 -7
  51. package/docs/.vitepress/config.ts +0 -30
@@ -8,6 +8,10 @@ import type { EditorEvents, EditorEventsOptions } from "./events";
8
8
  export type { Document } from "./model";
9
9
  export { EditorEvents } from "./events";
10
10
  export type { EditorEventsOptions, PublicEditorEvent, PublicEditorEventDataMap, PublicEditorEventType } from "./events";
11
+ export type { TextDiffSummary, DocumentChangeEventData, DocumentChangeCommittedData } from "./events";
12
+ export { createHttpEventSink, type HttpEventSink, type HttpEventSinkOptions } from "./events";
13
+ export { ChangeAggregator, type ChangeAggregatorOptions } from "./events";
14
+ export { CommitPolicy, type CommitPolicyOptions, type CommitBoundaryReason } from "./events";
11
15
 
12
16
  /** Caller-supplied identity, used for change attribution and presence. */
13
17
  export interface UserInfo {
@@ -54,7 +58,71 @@ export interface RevealRangeOptions {
54
58
  align?: "center" | "nearest" | "top" | "bottom";
55
59
  }
56
60
 
57
- export type TemplateVariableValues = Record<string, string | number | null | undefined>;
61
+ export type TemplateVariableValues = Record<string, string | number | boolean | null | undefined>;
62
+
63
+ export type MetadataDataType = "TEXT" | "NUMBER" | "DATE" | "CURRENCY" | "SELECT";
64
+ export type VariableDisplayMode = "code" | "value" | "placeholder" | "label";
65
+
66
+ export interface VariableBoundingBox {
67
+ left: number;
68
+ top: number;
69
+ right: number;
70
+ bottom: number;
71
+ width: number;
72
+ height: number;
73
+ }
74
+
75
+ export interface VariableClickInfo {
76
+ key: string;
77
+ def: TemplateVariableDef;
78
+ position: DocPosition;
79
+ rect: VariableBoundingBox;
80
+ clientRect?: VariableBoundingBox;
81
+ }
82
+
83
+ export interface MetadataAuditEntry {
84
+ id: string;
85
+ author: UserInfo;
86
+ timestamp: number;
87
+ previousValue: unknown;
88
+ newValue: unknown;
89
+ action: "created" | "updated" | "reverted";
90
+ source?: "api" | "editor" | "sidebar" | "palette" | "inline" | "import";
91
+ }
92
+
93
+ export interface TemplateVariableDef {
94
+ key: string;
95
+ label: string;
96
+ dataType: MetadataDataType;
97
+ dateFormat?: string;
98
+ value?: unknown;
99
+ defaultValue?: string;
100
+ metadataId?: number | string;
101
+ group?: string;
102
+ createdBy?: UserInfo;
103
+ createdAt?: number;
104
+ lastModifiedBy?: UserInfo;
105
+ lastModifiedAt?: number;
106
+ history?: MetadataAuditEntry[];
107
+ }
108
+
109
+ export interface SetTemplateVariablesOptions {
110
+ author?: UserInfo;
111
+ source?: "api" | "editor" | "sidebar" | "inline" | "import" | "palette";
112
+ trackInReview?: boolean;
113
+ metadata?: Record<string, Partial<TemplateVariableDef>>;
114
+ }
115
+
116
+ export interface InsertTemplateVariableItem {
117
+ key: string;
118
+ label: string;
119
+ dataType?: MetadataDataType;
120
+ dateFormat?: string;
121
+ value?: unknown;
122
+ defaultValue?: string;
123
+ metadataId?: number | string;
124
+ group?: string;
125
+ }
58
126
 
59
127
  export interface EditorPermissions {
60
128
  editContent: boolean;
@@ -547,6 +615,13 @@ export interface KindyEditorOptions {
547
615
  onLoadProgress?: (progress: LoadProgress) => void;
548
616
  /** Granular capabilities governing content edits, annotations, and selection. */
549
617
  permissions?: Partial<EditorPermissions>;
618
+ /** Callback fired when a template variable token is clicked in the editor.
619
+ * Provides variable key, definition, doc position, and bounding rects (container & client viewport).
620
+ * Allows host application (React/Vue/etc.) to render custom modals, drawers, or popovers. */
621
+ onVariableClick?: (info: VariableClickInfo) => void;
622
+ /** Whether to show the built-in variable audit popover UI on click. Defaults to false.
623
+ * When false, the built-in popover does not appear, leaving UI rendering to the host via onVariableClick / event. */
624
+ showVariablePopover?: boolean;
550
625
  }
551
626
 
552
627
  /** Initial view-chrome state (see KindyEditorOptions.view). Every field is
@@ -805,7 +880,31 @@ export interface EditorHandle {
805
880
  revealRange(range: ExternalRange, options?: RevealRangeOptions): void;
806
881
  /** Live-update {{KEY}} template placeholders in the document without full reload,
807
882
  * preserving zoom, scroll position, and selection. */
808
- setTemplateVariables(values: TemplateVariableValues): void;
883
+ setTemplateVariables(values: TemplateVariableValues, options?: SetTemplateVariablesOptions): void;
884
+ /** Revert a template variable to an earlier value recorded in its audit history. */
885
+ revertTemplateVariable(key: string, historyId: string, actor?: UserInfo): boolean;
886
+ /** Insert an atomic template variable token at current caret/selection. */
887
+ insertTemplateVariable(item: InsertTemplateVariableItem, author?: UserInfo): boolean;
888
+ /** Open the contract metadata palette autocomplete at current caret position. */
889
+ openMetadataPalette(): void;
890
+ /** Set template variable display mode ('code' | 'value' | 'placeholder'). */
891
+ setVariableDisplayMode(mode: VariableDisplayMode): void;
892
+ /** Get current template variable display mode. */
893
+ getVariableDisplayMode(): VariableDisplayMode;
894
+ /** Get all registered template variables in the document. */
895
+ getTemplateVariables(): Record<string, TemplateVariableDef>;
896
+ /** Get a single registered template variable definition by key. */
897
+ getTemplateVariable(key: string): TemplateVariableDef | null;
898
+ /** Get audit trail history for a template variable. */
899
+ getVariableHistory(key: string): MetadataAuditEntry[];
900
+ /** Open built-in variable popover explicitly. */
901
+ openVariablePopover(key: string, pos?: DocPosition): void;
902
+ /** Close built-in variable popover. */
903
+ closeVariablePopover(): void;
904
+ /** Get all metadata IDs (numbers) currently used by template variables in the document. */
905
+ getUsedMetadataIds(): number[];
906
+ /** Set custom metadata catalog for autocomplete palette. */
907
+ setMetadataCatalog(catalog: TemplateVariableDef[]): void;
809
908
  /** Update fine-grained capabilities (e.g. allow comments/selection in view mode). */
810
909
  setPermissions(permissions: Partial<EditorPermissions>): void;
811
910
  /** Current effective permissions. */
@@ -894,7 +993,31 @@ export declare class KindyEditor {
894
993
  revealRange(range: ExternalRange, options?: RevealRangeOptions): Promise<void>;
895
994
  /** Live-update {{KEY}} template placeholders in the document without full reload,
896
995
  * preserving zoom, scroll position, and selection. */
897
- setTemplateVariables(values: TemplateVariableValues): Promise<void>;
996
+ setTemplateVariables(values: TemplateVariableValues, options?: SetTemplateVariablesOptions): Promise<void>;
997
+ /** Revert a template variable to an earlier value recorded in its audit history. */
998
+ revertTemplateVariable(key: string, historyId: string, actor?: UserInfo): Promise<boolean>;
999
+ /** Insert an atomic template variable token at current caret/selection. */
1000
+ insertTemplateVariable(item: InsertTemplateVariableItem, author?: UserInfo): Promise<boolean>;
1001
+ /** Open the contract metadata palette autocomplete at current caret position. */
1002
+ openMetadataPalette(): Promise<void>;
1003
+ /** Set template variable display mode ('code' | 'value' | 'placeholder'). */
1004
+ setVariableDisplayMode(mode: VariableDisplayMode): Promise<void>;
1005
+ /** Get current template variable display mode. */
1006
+ getVariableDisplayMode(): Promise<VariableDisplayMode>;
1007
+ /** Get all registered template variables in the document. */
1008
+ getTemplateVariables(): Promise<Record<string, TemplateVariableDef>>;
1009
+ /** Get a single registered template variable definition by key. */
1010
+ getTemplateVariable(key: string): Promise<TemplateVariableDef | null>;
1011
+ /** Get audit trail history for a template variable. */
1012
+ getVariableHistory(key: string): Promise<MetadataAuditEntry[]>;
1013
+ /** Open built-in variable popover explicitly. */
1014
+ openVariablePopover(key: string, pos?: DocPosition): Promise<void>;
1015
+ /** Close built-in variable popover. */
1016
+ closeVariablePopover(): Promise<void>;
1017
+ /** Get all metadata IDs (numbers) currently used by template variables in the document. */
1018
+ getUsedMetadataIds(): Promise<number[]>;
1019
+ /** Set custom metadata catalog for autocomplete palette. */
1020
+ setMetadataCatalog(catalog: TemplateVariableDef[]): Promise<void>;
898
1021
  /** Update fine-grained capabilities (e.g. allow comments/selection in view mode). */
899
1022
  setPermissions(permissions: Partial<EditorPermissions>): Promise<void>;
900
1023
  /** Current effective permissions. */
@@ -1,71 +0,0 @@
1
- class a {
2
- detail;
3
- includeSelection;
4
- handlers = /* @__PURE__ */ new Map();
5
- anyHandlers = /* @__PURE__ */ new Set();
6
- sink;
7
- redact;
8
- onError;
9
- disposed = !1;
10
- constructor(e = {}) {
11
- this.detail = e.detail ?? "metadata", this.includeSelection = e.includeSelection ?? !1, this.sink = e.sink, this.redact = e.redact, this.onError = e.onError ?? ((r) => console.error("[kindy-editor:event]", r));
12
- }
13
- on(e, r, t = {}) {
14
- if (this.disposed || t.signal?.aborted) return () => {
15
- };
16
- let s = this.handlers.get(e);
17
- s || this.handlers.set(e, s = /* @__PURE__ */ new Set()), s.add(r);
18
- const i = () => {
19
- s?.delete(r), s?.size === 0 && this.handlers.delete(e);
20
- };
21
- return t.signal?.addEventListener("abort", i, { once: !0 }), i;
22
- }
23
- onAny(e, r = {}) {
24
- if (this.disposed || r.signal?.aborted) return () => {
25
- };
26
- this.anyHandlers.add(e);
27
- const t = () => {
28
- this.anyHandlers.delete(e);
29
- };
30
- return r.signal?.addEventListener("abort", t, { once: !0 }), t;
31
- }
32
- off(e, r) {
33
- this.handlers.get(e)?.delete(r);
34
- }
35
- /** Called by the editor runtime after state is already consistent. Public only
36
- * for custom bridges; normal integrations subscribe with on/onAny. */
37
- dispatch(e) {
38
- if (this.disposed) return;
39
- const r = this.redact ? this.redact(e) : e;
40
- if (r) {
41
- for (const t of this.handlers.get(r.type) ?? []) this.safeCall(t, r);
42
- for (const t of this.anyHandlers) this.safeCall(t, r);
43
- if (this.sink)
44
- try {
45
- Promise.resolve(this.sink(r)).catch((t) => this.reportError(t, r));
46
- } catch (t) {
47
- this.reportError(t, r);
48
- }
49
- }
50
- }
51
- destroy() {
52
- this.disposed = !0, this.handlers.clear(), this.anyHandlers.clear();
53
- }
54
- safeCall(e, r) {
55
- try {
56
- e(r);
57
- } catch (t) {
58
- this.reportError(t, r);
59
- }
60
- }
61
- reportError(e, r) {
62
- try {
63
- this.onError(e, r);
64
- } catch (t) {
65
- console.error("[kindy-editor:event:onError]", t);
66
- }
67
- }
68
- }
69
- export {
70
- a as E
71
- };
@@ -1,104 +0,0 @@
1
- const r = "1.0";
2
- function n(e) {
3
- const t = /* @__PURE__ */ new Set();
4
- for (const a of e)
5
- switch (a.type) {
6
- case "insertText":
7
- case "insertRuns":
8
- case "splitParagraph":
9
- t.add(a.at.blockId), a.type === "splitParagraph" && t.add(a.newBlockId);
10
- break;
11
- case "mergeParagraphs":
12
- t.add(a.firstBlockId);
13
- break;
14
- case "insertBlock":
15
- t.add(a.block.id);
16
- break;
17
- case "setTableRow":
18
- case "setTableStructure":
19
- case "setTableStyleRef":
20
- case "insertTableRow":
21
- case "removeTableRow":
22
- case "setRowHeight":
23
- case "insertTableColumn":
24
- case "removeTableColumn":
25
- t.add(a.tableId);
26
- break;
27
- case "deleteRange":
28
- case "setRuns":
29
- case "setParaStyle":
30
- case "removeBlock":
31
- case "setImageProps":
32
- case "setEquation":
33
- case "setEquationAlign":
34
- case "setTableColFractions":
35
- case "setTableWidthMode":
36
- case "setTablePreferredWidth":
37
- case "setTableAlign":
38
- case "setTableProps":
39
- t.add(a.blockId);
40
- break;
41
- }
42
- return [...t];
43
- }
44
- function c(e, t) {
45
- const a = { type: "review.operation.applied", data: { operation: e, remote: t } };
46
- switch (e.type) {
47
- case "addSuggestion":
48
- return [a, { type: "review.suggestion.created", data: { suggestionId: e.s.id, kind: e.s.kind, remote: t } }];
49
- case "removeSuggestion":
50
- return [a, { type: "review.suggestion.removed", data: { suggestionId: e.id, remote: t } }];
51
- case "growSuggestion":
52
- return [a];
53
- case "addThread": {
54
- const d = e.t.comments[0];
55
- return d ? [
56
- a,
57
- { type: "review.thread.created", data: { threadId: e.t.id, remote: t } },
58
- { type: "review.comment.added", data: {
59
- threadId: e.t.id,
60
- commentId: d.id,
61
- authorId: d.author.id,
62
- isReply: !1,
63
- mentionedUserIds: (d.mentions ?? []).map((s) => s.id),
64
- remote: t
65
- } }
66
- ] : [a, { type: "review.thread.created", data: { threadId: e.t.id, remote: t } }];
67
- }
68
- case "removeThread":
69
- return [a, { type: "review.thread.removed", data: { threadId: e.id, remote: t } }];
70
- case "addComment":
71
- return [a, { type: "review.comment.added", data: {
72
- threadId: e.threadId,
73
- commentId: e.c.id,
74
- authorId: e.c.author.id,
75
- isReply: !0,
76
- mentionedUserIds: (e.c.mentions ?? []).map((d) => d.id),
77
- remote: t
78
- } }];
79
- case "removeComment":
80
- return [a, { type: "review.comment.removed", data: { threadId: e.threadId, commentId: e.commentId, remote: t } }];
81
- case "editComment":
82
- return [a, { type: "review.comment.edited", data: {
83
- threadId: e.threadId,
84
- commentId: e.commentId,
85
- mentionedUserIds: (e.mentions ?? []).map((d) => d.id),
86
- newlyMentionedUserIds: e.newlyMentionedUserIds ?? [],
87
- remote: t
88
- } }];
89
- case "deleteComment":
90
- return [a, { type: "review.comment.deleted", data: {
91
- threadId: e.threadId,
92
- commentId: e.commentId,
93
- deletedByUserId: e.deletedBy.id,
94
- remote: t
95
- } }];
96
- case "setThreadStatus":
97
- return [a, { type: "review.thread.status.changed", data: { threadId: e.threadId, status: e.status, remote: t } }];
98
- }
99
- }
100
- export {
101
- r as E,
102
- n as a,
103
- c as p
104
- };