superdoc-macros 0.2.0 → 0.3.0

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/types.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  /**
2
- * החוזים המשותפים של הערכה.
2
+ * Shared contracts.
3
3
  *
4
- * `MacroHost` הוא נקודת החיבור היחידה לעורך: כל שלוש היכולות (סקריפטים,
5
- * מקליט, קטעי טקסט) עובדות מולו ולא מול SuperDoc ישירות. כך אפשר לבדוק את
6
- * הערכה עם כפיל בזיכרון, וכך מארח אחר (גרסת מנוע אחרת, עורך אחר) מתחבר
7
- * במימוש אחד של הממשק הזה.
4
+ * `MacroHost` is the single connection point to the editor: all three
5
+ * capabilities (scripts, recorder, snippets) work against it rather than
6
+ * against SuperDoc directly. That is what makes the toolkit testable with an
7
+ * in-memory double, and what lets another host (a different engine version,
8
+ * a different editor) plug in with one implementation of this interface.
8
9
  */
9
- /** תוצאת פעולה. אותה צורה כמו `CommandOutcome` של otzaria-word-editor. */
10
+ /** Result of an operation. Same shape as otzaria-word-editor's `CommandOutcome`. */
10
11
  export type MacroOutcome = {
11
12
  ok: true;
12
13
  } | {
@@ -14,20 +15,20 @@ export type MacroOutcome = {
14
15
  message: string;
15
16
  reason?: string;
16
17
  };
17
- /** תצלום הבחירה במסמך ברגע הקריאה. */
18
+ /** Snapshot of the document selection at the moment of the call. */
18
19
  export interface SelectionSnapshot {
19
- /** הטקסט המסומן. `''` כשאין בחירה או כשלא התבקש. */
20
+ /** The selected text. `''` when there is no selection or it was not requested. */
20
21
  text: string;
21
- /** האם יש טווח מסומן ולא רק סמן. */
22
+ /** Whether a range is selected, as opposed to a caret only. */
22
23
  hasRange: boolean;
23
- /** מזהה הפסקה שהבחירה מתחילה בה, או `null`. */
24
+ /** Id of the block the selection starts in, or `null`. */
24
25
  blockId: string | null;
25
- /** היעד שפעולות כתיבה (`insert`) צורכות. אטוםנמסר חזרה למנוע כמו שהוא. */
26
+ /** The target that write operations (`insert`) consume. Opaquehanded back to the engine as-is. */
26
27
  selectionTarget: unknown | null;
27
- /** האם הבחירה ריקה (סמן בלבד). */
28
+ /** Whether the selection is empty (caret only). */
28
29
  empty: boolean;
29
30
  }
30
- /** אירוע הקלדה שהמארח מדווח למקליט ולהשלמה האוטומטית. */
31
+ /** A typing event the host reports to the recorder and to auto-text. */
31
32
  export type TextInputEvent = {
32
33
  kind: 'insert-text';
33
34
  text: string;
@@ -39,40 +40,40 @@ export type TextInputEvent = {
39
40
  kind: 'delete-forward';
40
41
  };
41
42
  /**
42
- * מה שהערכה צריכה מהעורך. מימוש ל-SuperDoc v2 נמצא ב-`createSuperdocHost`;
43
- * לבדיקות יש כפיל בזיכרון.
43
+ * What the toolkit needs from the editor. The SuperDoc v2 implementation is
44
+ * `createSuperdocHost`; tests use an in-memory double.
44
45
  */
45
46
  export interface MacroHost {
46
47
  commands: {
47
- /** האם המנוע מכיר את הפקודה. */
48
+ /** Whether the engine recognizes the command. */
48
49
  has(id: string): boolean;
49
- /** מריצה פקודה מהקטלוג של המנוע ומחזירה תוצאה מנורמלת. */
50
+ /** Runs a command from the engine's catalog and returns a normalized outcome. */
50
51
  execute(id: string, payload?: unknown): Promise<MacroOutcome>;
51
- /** מזהי הפקודות המוכרות, אם המארח יודע למנות אותם. */
52
+ /** The known command ids, when the host can enumerate them. */
52
53
  ids(): readonly string[];
53
54
  };
54
- /** מכניסה טקסט במיקום הסמן (או בסוף המסמך כשאין סמן). */
55
+ /** Inserts text at the caret (or at the end of the document when there is no caret). */
55
56
  insertText(text: string): Promise<MacroOutcome>;
56
- /** מוחקת תווים לאחור מהסמן. */
57
+ /** Deletes characters backwards from the caret. */
57
58
  deleteBackward(count: number): Promise<MacroOutcome>;
58
- /** תצלום הבחירה הנוכחית. לעולם לא זורקת. */
59
+ /** Snapshot of the current selection. Never throws. */
59
60
  getSelection(options?: {
60
61
  includeText?: boolean;
61
62
  }): Promise<SelectionSnapshot>;
62
- /** מחליפה את כל המופעים של `query` ב-`replacement`. מחזירה כמה הוחלפו. */
63
+ /** Replaces every occurrence of `query` with `replacement`. Returns how many were replaced. */
63
64
  replaceAll(query: string, replacement: string): Promise<{
64
65
  ok: boolean;
65
66
  replaced: number;
66
67
  message?: string;
67
68
  }>;
68
- /** הטקסט המלא של גוף המסמך. `''` כשאינו זמין. */
69
+ /** The full text of the document body. `''` when unavailable. */
69
70
  getDocumentText(): Promise<string>;
70
- /** מאזינה לכל פקודה שהמנוע מריץ (מכל מקור). מחזירה פונקציית ביטול. */
71
+ /** Observes every command the engine runs (from any source). Returns a dispose function. */
71
72
  onCommand(listener: (id: string, payload: unknown) => void): () => void;
72
- /** מאזינה להקלדה במסמך. מחזירה פונקציית ביטול. */
73
+ /** Observes typing in the document. Returns a dispose function. */
73
74
  onTextInput(listener: (event: TextInputEvent) => void): () => void;
74
75
  }
75
- /** צעד אחד במאקרו מוקלט. JSON-serializable במלואו. */
76
+ /** One step of a recorded macro. Fully JSON-serializable. */
76
77
  export type MacroStep = {
77
78
  type: 'command';
78
79
  id: string;
@@ -89,7 +90,7 @@ export type MacroStep = {
89
90
  type: 'delete-forward';
90
91
  count: number;
91
92
  };
92
- /** מאקרו מוקלט, כפי שהוא נשמר ומיובא/מיוצא. */
93
+ /** A recorded macro, as persisted and imported/exported. */
93
94
  export interface RecordedMacro {
94
95
  version: 1;
95
96
  id: string;
@@ -99,21 +100,21 @@ export interface RecordedMacro {
99
100
  shortcut?: string;
100
101
  steps: MacroStep[];
101
102
  }
102
- /** מאקרו כתובסקריפט JavaScript שרץ מול ה-API של הערכה. */
103
+ /** A written macro a JavaScript script that runs against the toolkit's API. */
103
104
  export interface SavedScript {
104
105
  id: string;
105
106
  name: string;
106
107
  source: string;
107
108
  shortcut?: string;
108
109
  }
109
- /** קטע טקסט (Snippet / AutoText). */
110
+ /** A text snippet (AutoText building block). */
110
111
  export interface Snippet {
111
112
  id: string;
112
113
  name: string;
113
- /** תוכן הקטע. תומך במשתני `{{...}}` — ראו `renderSnippet`. */
114
+ /** Snippet content. Supports `{{...}}` variables see `renderSnippet`. */
114
115
  text: string;
115
- /** מילת הפעלה להשלמה אוטומטית: הקלדת המילה ואחריה רווח מחליפה אותה בתוכן. */
116
+ /** Auto-text trigger word: typing the word followed by a space replaces it with the content. */
116
117
  trigger?: string;
117
- /** קיצור מקלדת, למשל `Ctrl+Alt+1`. */
118
+ /** Keyboard shortcut, e.g. `Ctrl+Alt+1`. */
118
119
  shortcut?: string;
119
120
  }
package/dist/types.js CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
- * החוזים המשותפים של הערכה.
2
+ * Shared contracts.
3
3
  *
4
- * `MacroHost` הוא נקודת החיבור היחידה לעורך: כל שלוש היכולות (סקריפטים,
5
- * מקליט, קטעי טקסט) עובדות מולו ולא מול SuperDoc ישירות. כך אפשר לבדוק את
6
- * הערכה עם כפיל בזיכרון, וכך מארח אחר (גרסת מנוע אחרת, עורך אחר) מתחבר
7
- * במימוש אחד של הממשק הזה.
4
+ * `MacroHost` is the single connection point to the editor: all three
5
+ * capabilities (scripts, recorder, snippets) work against it rather than
6
+ * against SuperDoc directly. That is what makes the toolkit testable with an
7
+ * in-memory double, and what lets another host (a different engine version,
8
+ * a different editor) plug in with one implementation of this interface.
8
9
  */
9
10
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superdoc-macros",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Macro toolkit for SuperDoc-based editors: sandboxed scripted macros, a Word-style macro recorder, and snippets with auto-text expansion.",
5
5
  "license": "MIT",
6
6
  "type": "module",