tiptap-apcore 0.1.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.
Files changed (70) hide show
  1. package/README.md +407 -0
  2. package/dist/builder/AnnotationCatalog.d.ts +22 -0
  3. package/dist/builder/AnnotationCatalog.d.ts.map +1 -0
  4. package/dist/builder/AnnotationCatalog.js +269 -0
  5. package/dist/builder/AnnotationCatalog.js.map +1 -0
  6. package/dist/builder/ModuleBuilder.d.ts +42 -0
  7. package/dist/builder/ModuleBuilder.d.ts.map +1 -0
  8. package/dist/builder/ModuleBuilder.js +106 -0
  9. package/dist/builder/ModuleBuilder.js.map +1 -0
  10. package/dist/builder/SchemaCatalog.d.ts +20 -0
  11. package/dist/builder/SchemaCatalog.d.ts.map +1 -0
  12. package/dist/builder/SchemaCatalog.js +352 -0
  13. package/dist/builder/SchemaCatalog.js.map +1 -0
  14. package/dist/builder/index.d.ts +4 -0
  15. package/dist/builder/index.d.ts.map +1 -0
  16. package/dist/builder/index.js +5 -0
  17. package/dist/builder/index.js.map +1 -0
  18. package/dist/discovery/ExtensionScanner.d.ts +25 -0
  19. package/dist/discovery/ExtensionScanner.d.ts.map +1 -0
  20. package/dist/discovery/ExtensionScanner.js +61 -0
  21. package/dist/discovery/ExtensionScanner.js.map +1 -0
  22. package/dist/discovery/index.d.ts +2 -0
  23. package/dist/discovery/index.d.ts.map +1 -0
  24. package/dist/discovery/index.js +3 -0
  25. package/dist/discovery/index.js.map +1 -0
  26. package/dist/errors/TiptapModuleError.d.ts +18 -0
  27. package/dist/errors/TiptapModuleError.d.ts.map +1 -0
  28. package/dist/errors/TiptapModuleError.js +23 -0
  29. package/dist/errors/TiptapModuleError.js.map +1 -0
  30. package/dist/errors/index.d.ts +2 -0
  31. package/dist/errors/index.d.ts.map +1 -0
  32. package/dist/errors/index.js +2 -0
  33. package/dist/errors/index.js.map +1 -0
  34. package/dist/index.d.ts +19 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +17 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/runtime/TiptapExecutor.d.ts +20 -0
  39. package/dist/runtime/TiptapExecutor.d.ts.map +1 -0
  40. package/dist/runtime/TiptapExecutor.js +327 -0
  41. package/dist/runtime/TiptapExecutor.js.map +1 -0
  42. package/dist/runtime/TiptapRegistry.d.ts +35 -0
  43. package/dist/runtime/TiptapRegistry.d.ts.map +1 -0
  44. package/dist/runtime/TiptapRegistry.js +100 -0
  45. package/dist/runtime/TiptapRegistry.js.map +1 -0
  46. package/dist/runtime/index.d.ts +3 -0
  47. package/dist/runtime/index.d.ts.map +1 -0
  48. package/dist/runtime/index.js +4 -0
  49. package/dist/runtime/index.js.map +1 -0
  50. package/dist/security/AclGuard.d.ts +10 -0
  51. package/dist/security/AclGuard.d.ts.map +1 -0
  52. package/dist/security/AclGuard.js +96 -0
  53. package/dist/security/AclGuard.js.map +1 -0
  54. package/dist/security/index.d.ts +2 -0
  55. package/dist/security/index.d.ts.map +1 -0
  56. package/dist/security/index.js +2 -0
  57. package/dist/security/index.js.map +1 -0
  58. package/dist/server.d.ts +10 -0
  59. package/dist/server.d.ts.map +1 -0
  60. package/dist/server.js +9 -0
  61. package/dist/server.js.map +1 -0
  62. package/dist/types.d.ts +116 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +8 -0
  65. package/dist/types.js.map +1 -0
  66. package/dist/withApcore.d.ts +14 -0
  67. package/dist/withApcore.d.ts.map +1 -0
  68. package/dist/withApcore.js +81 -0
  69. package/dist/withApcore.js.map +1 -0
  70. package/package.json +79 -0
@@ -0,0 +1,269 @@
1
+ /**
2
+ * AnnotationCatalog: Static mapping of TipTap command names to safety annotations.
3
+ *
4
+ * Maps all 79 known TipTap commands across 6 categories (query, format, content,
5
+ * destructive, selection, history) to their APCore annotation metadata.
6
+ */
7
+ // ------------------------------------------------------------------
8
+ // Shared annotation templates per category
9
+ // ------------------------------------------------------------------
10
+ const QUERY_ANNOTATIONS = Object.freeze({
11
+ readonly: true,
12
+ destructive: false,
13
+ idempotent: true,
14
+ requiresApproval: false,
15
+ openWorld: false,
16
+ streaming: false,
17
+ });
18
+ const FORMAT_ANNOTATIONS = Object.freeze({
19
+ readonly: false,
20
+ destructive: false,
21
+ idempotent: true,
22
+ requiresApproval: false,
23
+ openWorld: false,
24
+ streaming: false,
25
+ });
26
+ const FORMAT_NON_IDEMPOTENT_ANNOTATIONS = Object.freeze({
27
+ readonly: false,
28
+ destructive: false,
29
+ idempotent: false,
30
+ requiresApproval: false,
31
+ openWorld: false,
32
+ streaming: false,
33
+ });
34
+ const CONTENT_ANNOTATIONS = Object.freeze({
35
+ readonly: false,
36
+ destructive: false,
37
+ idempotent: false,
38
+ requiresApproval: false,
39
+ openWorld: false,
40
+ streaming: false,
41
+ });
42
+ const DESTRUCTIVE_ANNOTATIONS = Object.freeze({
43
+ readonly: false,
44
+ destructive: true,
45
+ idempotent: false,
46
+ requiresApproval: true,
47
+ openWorld: false,
48
+ streaming: false,
49
+ });
50
+ const SELECTION_ANNOTATIONS = Object.freeze({
51
+ readonly: false,
52
+ destructive: false,
53
+ idempotent: true,
54
+ requiresApproval: false,
55
+ openWorld: false,
56
+ streaming: false,
57
+ });
58
+ const HISTORY_ANNOTATIONS = Object.freeze({
59
+ readonly: false,
60
+ destructive: false,
61
+ idempotent: false,
62
+ requiresApproval: false,
63
+ openWorld: false,
64
+ streaming: false,
65
+ });
66
+ // ------------------------------------------------------------------
67
+ // Helper to build an AnnotationEntry
68
+ // ------------------------------------------------------------------
69
+ function entry(annotations, tags, category, selectionEffect = "preserve") {
70
+ return { annotations, tags, category, selectionEffect };
71
+ }
72
+ // ------------------------------------------------------------------
73
+ // Command lists per category
74
+ // ------------------------------------------------------------------
75
+ const QUERY_COMMANDS = [
76
+ "getHTML",
77
+ "getJSON",
78
+ "getText",
79
+ "isActive",
80
+ "getAttributes",
81
+ "isEmpty",
82
+ "isEditable",
83
+ "isFocused",
84
+ "getCharacterCount",
85
+ "getWordCount",
86
+ ];
87
+ const FORMAT_COMMANDS = [
88
+ "toggleBold",
89
+ "toggleItalic",
90
+ "toggleStrike",
91
+ "toggleCode",
92
+ "toggleUnderline",
93
+ "toggleSubscript",
94
+ "toggleSuperscript",
95
+ "toggleHighlight",
96
+ "toggleHeading",
97
+ "toggleBulletList",
98
+ "toggleOrderedList",
99
+ "toggleTaskList",
100
+ "toggleCodeBlock",
101
+ "toggleBlockquote",
102
+ "setTextAlign",
103
+ "setMark",
104
+ "unsetMark",
105
+ "unsetAllMarks",
106
+ "clearNodes",
107
+ "updateAttributes",
108
+ "setLink",
109
+ "unsetLink",
110
+ "setBold",
111
+ "setItalic",
112
+ "setStrike",
113
+ "setCode",
114
+ "unsetBold",
115
+ "unsetItalic",
116
+ "unsetStrike",
117
+ "unsetCode",
118
+ "setBlockquote",
119
+ "unsetBlockquote",
120
+ "setHeading",
121
+ "setParagraph",
122
+ ];
123
+ /** Format commands that are NOT idempotent (they insert new elements). */
124
+ const FORMAT_NON_IDEMPOTENT_COMMANDS = [
125
+ "setHardBreak",
126
+ "setHorizontalRule",
127
+ ];
128
+ const CONTENT_COMMANDS = [
129
+ "insertContent",
130
+ "insertContentAt",
131
+ "setNode",
132
+ "splitBlock",
133
+ "liftListItem",
134
+ "sinkListItem",
135
+ "wrapIn",
136
+ "joinBackward",
137
+ "joinForward",
138
+ "lift",
139
+ "splitListItem",
140
+ "wrapInList",
141
+ "toggleList",
142
+ "exitCode",
143
+ "deleteNode",
144
+ ];
145
+ const DESTRUCTIVE_COMMANDS = [
146
+ "clearContent",
147
+ "setContent",
148
+ "deleteSelection",
149
+ "deleteRange",
150
+ "deleteCurrentNode",
151
+ "cut",
152
+ ];
153
+ const SELECTION_COMMANDS = [
154
+ "setTextSelection",
155
+ "setNodeSelection",
156
+ "selectAll",
157
+ "selectParentNode",
158
+ "selectTextblockStart",
159
+ "selectTextblockEnd",
160
+ "selectText", // Custom APCore command (not native TipTap)
161
+ "focus",
162
+ "blur",
163
+ "scrollIntoView",
164
+ ];
165
+ const HISTORY_COMMANDS = ["undo", "redo"];
166
+ // ------------------------------------------------------------------
167
+ // Build the full catalog map
168
+ // ------------------------------------------------------------------
169
+ // ------------------------------------------------------------------
170
+ // Per-command selection effect overrides.
171
+ // Default: category-level (query=preserve, format=require, content=destroy,
172
+ // destructive=destroy, selection=preserve, history=preserve).
173
+ // Commands listed here override the category default.
174
+ // ------------------------------------------------------------------
175
+ /** Mark-level format commands that require an active text selection */
176
+ const MARK_FORMAT_COMMANDS = new Set([
177
+ "toggleBold", "toggleItalic", "toggleStrike", "toggleCode",
178
+ "toggleUnderline", "toggleSubscript", "toggleSuperscript", "toggleHighlight",
179
+ "setBold", "setItalic", "setStrike", "setCode", "setLink",
180
+ "setMark", "unsetMark", "unsetAllMarks",
181
+ "unsetBold", "unsetItalic", "unsetStrike", "unsetCode", "unsetLink",
182
+ ]);
183
+ /** Node-level format commands that operate on block at cursor (no selection needed) */
184
+ const NODE_FORMAT_COMMANDS = new Set([
185
+ "toggleHeading", "setHeading", "setParagraph",
186
+ "toggleBlockquote", "setBlockquote", "unsetBlockquote",
187
+ "toggleBulletList", "toggleOrderedList", "toggleTaskList", "toggleCodeBlock",
188
+ "setTextAlign", "clearNodes", "updateAttributes",
189
+ ]);
190
+ /** Category-level defaults for selectionEffect */
191
+ const CATEGORY_SELECTION_DEFAULTS = {
192
+ query: "preserve",
193
+ format: "require", // overridden per-command below
194
+ content: "destroy",
195
+ destructive: "destroy",
196
+ selection: "preserve",
197
+ history: "preserve",
198
+ };
199
+ function getSelectionEffect(cmd, category) {
200
+ // Per-command overrides for format category
201
+ if (category === "format") {
202
+ if (MARK_FORMAT_COMMANDS.has(cmd))
203
+ return "require";
204
+ if (NODE_FORMAT_COMMANDS.has(cmd))
205
+ return "none";
206
+ // Non-idempotent formats (setHardBreak, setHorizontalRule) insert content
207
+ return "destroy";
208
+ }
209
+ // Content commands that don't destroy selection
210
+ if (category === "content") {
211
+ // List manipulation and structural commands preserve cursor context
212
+ if (["splitBlock", "liftListItem", "sinkListItem", "wrapIn",
213
+ "joinBackward", "joinForward", "lift", "splitListItem",
214
+ "wrapInList", "toggleList", "exitCode", "setNode"].includes(cmd)) {
215
+ return "none";
216
+ }
217
+ return "destroy";
218
+ }
219
+ return CATEGORY_SELECTION_DEFAULTS[category] ?? "preserve";
220
+ }
221
+ function buildCatalog() {
222
+ const map = new Map();
223
+ for (const cmd of QUERY_COMMANDS) {
224
+ map.set(cmd, entry(QUERY_ANNOTATIONS, ["query"], "query", getSelectionEffect(cmd, "query")));
225
+ }
226
+ for (const cmd of FORMAT_COMMANDS) {
227
+ map.set(cmd, entry(FORMAT_ANNOTATIONS, ["format"], "format", getSelectionEffect(cmd, "format")));
228
+ }
229
+ for (const cmd of FORMAT_NON_IDEMPOTENT_COMMANDS) {
230
+ map.set(cmd, entry(FORMAT_NON_IDEMPOTENT_ANNOTATIONS, ["format"], "format", getSelectionEffect(cmd, "format")));
231
+ }
232
+ for (const cmd of CONTENT_COMMANDS) {
233
+ map.set(cmd, entry(CONTENT_ANNOTATIONS, ["content"], "content", getSelectionEffect(cmd, "content")));
234
+ }
235
+ for (const cmd of DESTRUCTIVE_COMMANDS) {
236
+ map.set(cmd, entry(DESTRUCTIVE_ANNOTATIONS, ["destructive"], "destructive", getSelectionEffect(cmd, "destructive")));
237
+ }
238
+ for (const cmd of SELECTION_COMMANDS) {
239
+ map.set(cmd, entry(SELECTION_ANNOTATIONS, ["selection"], "selection", getSelectionEffect(cmd, "selection")));
240
+ }
241
+ for (const cmd of HISTORY_COMMANDS) {
242
+ map.set(cmd, entry(HISTORY_ANNOTATIONS, ["history"], "history", getSelectionEffect(cmd, "history")));
243
+ }
244
+ return map;
245
+ }
246
+ // ------------------------------------------------------------------
247
+ // Public API
248
+ // ------------------------------------------------------------------
249
+ export class AnnotationCatalog {
250
+ catalog;
251
+ constructor() {
252
+ this.catalog = buildCatalog();
253
+ }
254
+ /**
255
+ * Look up the annotation entry for a command name.
256
+ * Returns `null` when the command is not in the catalog.
257
+ */
258
+ get(commandName) {
259
+ return this.catalog.get(commandName) ?? null;
260
+ }
261
+ /**
262
+ * Convenience helper that returns the category string for a command,
263
+ * or `"unknown"` when the command is not in the catalog.
264
+ */
265
+ getCategory(commandName) {
266
+ return this.catalog.get(commandName)?.category ?? "unknown";
267
+ }
268
+ }
269
+ //# sourceMappingURL=AnnotationCatalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationCatalog.js","sourceRoot":"","sources":["../../src/builder/AnnotationCatalog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,qEAAqE;AACrE,2CAA2C;AAC3C,qEAAqE;AAErE,MAAM,iBAAiB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACzD,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,IAAI;IAChB,gBAAgB,EAAE,KAAK;IACvB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;CACjB,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC1D,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,IAAI;IAChB,gBAAgB,EAAE,KAAK;IACvB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;CACjB,CAAC,CAAC;AAEH,MAAM,iCAAiC,GAAsB,MAAM,CAAC,MAAM,CAAC;IACzE,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,KAAK;IACvB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;CACjB,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC3D,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,KAAK;IACvB,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EACH,KAAK,CAAC,uBAAuB,EAAE,CAAC,aAAa,CAAC,EAAE,aAAa,EAAE,kBAAkB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CACvG,CAAC;IACJ,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACrC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,qBAAqB,EAAE,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,kBAAkB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC/G,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACnC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,mBAAmB,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,kBAAkB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACvG,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,qEAAqE;AACrE,aAAa;AACb,qEAAqE;AAErE,MAAM,OAAO,iBAAiB;IACpB,OAAO,CAA+B;IAE9C;QACE,IAAI,CAAC,OAAO,GAAG,YAAY,EAAE,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,WAAmB;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,WAAmB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,QAAQ,IAAI,SAAS,CAAC;IAC9D,CAAC;CACF"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * ModuleBuilder: Transforms TipTap command names into APCore ModuleDescriptor objects.
3
+ *
4
+ * Combines metadata from the AnnotationCatalog (safety annotations, tags, categories)
5
+ * and SchemaCatalog (input/output JSON schemas) to produce complete ModuleDescriptor
6
+ * objects suitable for registration in an APCore Registry.
7
+ */
8
+ import type { ModuleDescriptor, ExtensionCommandInfo } from "../types.js";
9
+ export declare class ModuleBuilder {
10
+ private annotationCatalog;
11
+ private schemaCatalog;
12
+ private prefix;
13
+ constructor(prefix?: string);
14
+ /**
15
+ * Build a complete ModuleDescriptor for the given TipTap command.
16
+ */
17
+ build(commandName: string, extensionInfo: ExtensionCommandInfo): ModuleDescriptor;
18
+ /**
19
+ * Build the dot-separated module ID for a command.
20
+ *
21
+ * @example buildModuleId("toggleBold") → "tiptap.format.toggleBold"
22
+ * @example buildModuleId("getHTML") → "tiptap.query.getHTML"
23
+ * @example buildModuleId("clearContent") → "tiptap.destructive.clearContent"
24
+ * @example buildModuleId("customCmd") → "tiptap.unknown.customCmd"
25
+ */
26
+ buildModuleId(commandName: string, category?: string): string;
27
+ /**
28
+ * Generate a human-readable description string.
29
+ *
30
+ * Template: "<Verb> <humanized command name> (from <Extension> extension)"
31
+ */
32
+ private generateDescription;
33
+ /**
34
+ * Convert a camelCase command name into a human-readable phrase.
35
+ *
36
+ * "toggleBold" → "toggle bold"
37
+ * "getHTML" → "get HTML"
38
+ * "insertContentAt" → "insert content at"
39
+ */
40
+ private humanize;
41
+ }
42
+ //# sourceMappingURL=ModuleBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModuleBuilder.d.ts","sourceRoot":"","sources":["../../src/builder/ModuleBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAmC1E,qBAAa,aAAa;IACxB,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,GAAE,MAAiB;IAMrC;;OAEG;IACH,KAAK,CACH,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,oBAAoB,GAClC,gBAAgB;IAyBnB;;;;;;;OAOG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAM7D;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;CAUjB"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * ModuleBuilder: Transforms TipTap command names into APCore ModuleDescriptor objects.
3
+ *
4
+ * Combines metadata from the AnnotationCatalog (safety annotations, tags, categories)
5
+ * and SchemaCatalog (input/output JSON schemas) to produce complete ModuleDescriptor
6
+ * objects suitable for registration in an APCore Registry.
7
+ */
8
+ import { AnnotationCatalog } from "./AnnotationCatalog.js";
9
+ import { SchemaCatalog } from "./SchemaCatalog.js";
10
+ // ------------------------------------------------------------------
11
+ // Description templates per category
12
+ // ------------------------------------------------------------------
13
+ const CATEGORY_VERB = {
14
+ query: "Query",
15
+ format: "Apply",
16
+ content: "Modify content via",
17
+ destructive: "Destructively perform",
18
+ selection: "Adjust selection via",
19
+ history: "Perform history action",
20
+ unknown: "Execute",
21
+ };
22
+ // ------------------------------------------------------------------
23
+ // Default annotations for unknown commands
24
+ // ------------------------------------------------------------------
25
+ const DEFAULT_ANNOTATIONS = {
26
+ readonly: false,
27
+ destructive: false,
28
+ idempotent: false,
29
+ requiresApproval: false,
30
+ openWorld: false,
31
+ streaming: false,
32
+ };
33
+ // ------------------------------------------------------------------
34
+ // Public API
35
+ // ------------------------------------------------------------------
36
+ export class ModuleBuilder {
37
+ annotationCatalog;
38
+ schemaCatalog;
39
+ prefix;
40
+ constructor(prefix = "tiptap") {
41
+ this.annotationCatalog = new AnnotationCatalog();
42
+ this.schemaCatalog = new SchemaCatalog();
43
+ this.prefix = prefix;
44
+ }
45
+ /**
46
+ * Build a complete ModuleDescriptor for the given TipTap command.
47
+ */
48
+ build(commandName, extensionInfo) {
49
+ const annotationEntry = this.annotationCatalog.get(commandName);
50
+ const schemaEntry = this.schemaCatalog.get(commandName);
51
+ const category = annotationEntry?.category ?? "unknown";
52
+ const moduleId = this.buildModuleId(commandName, category);
53
+ return {
54
+ moduleId,
55
+ description: this.generateDescription(commandName, extensionInfo, category),
56
+ inputSchema: schemaEntry.inputSchema,
57
+ outputSchema: schemaEntry.outputSchema,
58
+ annotations: annotationEntry?.annotations ?? { ...DEFAULT_ANNOTATIONS },
59
+ tags: annotationEntry?.tags ?? ["unknown"],
60
+ version: "0.1.0",
61
+ documentation: `https://tiptap.dev/docs/editor/api/commands/${commandName}`,
62
+ metadata: {
63
+ selectionEffect: annotationEntry?.selectionEffect ?? "preserve",
64
+ },
65
+ };
66
+ }
67
+ /**
68
+ * Build the dot-separated module ID for a command.
69
+ *
70
+ * @example buildModuleId("toggleBold") → "tiptap.format.toggleBold"
71
+ * @example buildModuleId("getHTML") → "tiptap.query.getHTML"
72
+ * @example buildModuleId("clearContent") → "tiptap.destructive.clearContent"
73
+ * @example buildModuleId("customCmd") → "tiptap.unknown.customCmd"
74
+ */
75
+ buildModuleId(commandName, category) {
76
+ const cat = category ?? this.annotationCatalog.getCategory(commandName);
77
+ return `${this.prefix}.${cat}.${commandName}`;
78
+ }
79
+ /**
80
+ * Generate a human-readable description string.
81
+ *
82
+ * Template: "<Verb> <humanized command name> (from <Extension> extension)"
83
+ */
84
+ generateDescription(commandName, extensionInfo, category) {
85
+ const verb = CATEGORY_VERB[category] ?? CATEGORY_VERB.unknown;
86
+ const humanized = this.humanize(commandName);
87
+ return `${verb} ${humanized} (from ${extensionInfo.extensionName} extension)`;
88
+ }
89
+ /**
90
+ * Convert a camelCase command name into a human-readable phrase.
91
+ *
92
+ * "toggleBold" → "toggle bold"
93
+ * "getHTML" → "get HTML"
94
+ * "insertContentAt" → "insert content at"
95
+ */
96
+ humanize(commandName) {
97
+ // Insert a space before each uppercase letter that follows a lowercase letter,
98
+ // or before a sequence of uppercase letters followed by a lowercase letter.
99
+ const spaced = commandName
100
+ .replace(/([a-z])([A-Z])/g, "$1 $2")
101
+ .replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2");
102
+ // Lowercase the first character and preserve acronym casing
103
+ return spaced.charAt(0).toLowerCase() + spaced.slice(1);
104
+ }
105
+ }
106
+ //# sourceMappingURL=ModuleBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModuleBuilder.js","sourceRoot":"","sources":["../../src/builder/ModuleBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qEAAqE;AACrE,qCAAqC;AACrC,qEAAqE;AAErE,MAAM,aAAa,GAA2B;IAC5C,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,oBAAoB;IAC7B,WAAW,EAAE,uBAAuB;IACpC,SAAS,EAAE,sBAAsB;IACjC,OAAO,EAAE,wBAAwB;IACjC,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,qEAAqE;AACrE,2CAA2C;AAC3C,qEAAqE;AAErE,MAAM,mBAAmB,GAAG;IAC1B,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,KAAK;IACvB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;CACR,CAAC;AAEX,qEAAqE;AACrE,aAAa;AACb,qEAAqE;AAErE,MAAM,OAAO,aAAa;IAChB,iBAAiB,CAAoB;IACrC,aAAa,CAAgB;IAC7B,MAAM,CAAS;IAEvB,YAAY,SAAiB,QAAQ;QACnC,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CACH,WAAmB,EACnB,aAAmC;QAEnC,MAA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AAI,SAAS,UAAU,aAAa,CAAC,aAAa,aAAa,CAAC;IAChF,CAAC;IAED;;;;;;OAMG;IACK,QAAQ,CAAC,WAAmB;QAClC,+EAA+E;QAC/E,4EAA4E;QAC5E,MAAM,MAAM,GAAG,WAAW;aACvB,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;aACnC,OAAO,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;QAE7C,4DAA4D;QAC5D,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * SchemaCatalog: Static mapping of TipTap command names to JSON Schema
3
+ * input/output definitions.
4
+ *
5
+ * Every known command has explicit schemas with additionalProperties: false.
6
+ * Unknown commands fall back to a permissive default schema.
7
+ */
8
+ import type { SchemaEntry } from "../types.js";
9
+ export declare class SchemaCatalog {
10
+ private catalog;
11
+ private static readonly DEFAULT_ENTRY;
12
+ constructor();
13
+ /**
14
+ * Returns the SchemaEntry for the given command name.
15
+ * Falls back to a permissive default for unknown commands.
16
+ */
17
+ get(commandName: string): SchemaEntry;
18
+ private populate;
19
+ }
20
+ //# sourceMappingURL=SchemaCatalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaCatalog.d.ts","sourceRoot":"","sources":["../../src/builder/SchemaCatalog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AAoF3D,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAA2B;IAE1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAGnC;;IAOF;;;OAGG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW;IAMrC,OAAO,CAAC,QAAQ;CAiiBjB"}