@rtif-sdk/web 1.0.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 (215) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -0
  3. package/dist/block-drag-handler.d.ts +189 -0
  4. package/dist/block-drag-handler.d.ts.map +1 -0
  5. package/dist/block-drag-handler.js +745 -0
  6. package/dist/block-drag-handler.js.map +1 -0
  7. package/dist/block-renderer.d.ts +402 -0
  8. package/dist/block-renderer.d.ts.map +1 -0
  9. package/dist/block-renderer.js +424 -0
  10. package/dist/block-renderer.js.map +1 -0
  11. package/dist/clipboard.d.ts +178 -0
  12. package/dist/clipboard.d.ts.map +1 -0
  13. package/dist/clipboard.js +432 -0
  14. package/dist/clipboard.js.map +1 -0
  15. package/dist/command-bus.d.ts +113 -0
  16. package/dist/command-bus.d.ts.map +1 -0
  17. package/dist/command-bus.js +70 -0
  18. package/dist/command-bus.js.map +1 -0
  19. package/dist/composition.d.ts +220 -0
  20. package/dist/composition.d.ts.map +1 -0
  21. package/dist/composition.js +271 -0
  22. package/dist/composition.js.map +1 -0
  23. package/dist/content-extraction.d.ts +69 -0
  24. package/dist/content-extraction.d.ts.map +1 -0
  25. package/dist/content-extraction.js +228 -0
  26. package/dist/content-extraction.js.map +1 -0
  27. package/dist/content-handler-file.d.ts +40 -0
  28. package/dist/content-handler-file.d.ts.map +1 -0
  29. package/dist/content-handler-file.js +91 -0
  30. package/dist/content-handler-file.js.map +1 -0
  31. package/dist/content-handler-image.d.ts +82 -0
  32. package/dist/content-handler-image.d.ts.map +1 -0
  33. package/dist/content-handler-image.js +120 -0
  34. package/dist/content-handler-image.js.map +1 -0
  35. package/dist/content-handler-url.d.ts +129 -0
  36. package/dist/content-handler-url.d.ts.map +1 -0
  37. package/dist/content-handler-url.js +244 -0
  38. package/dist/content-handler-url.js.map +1 -0
  39. package/dist/content-handlers.d.ts +67 -0
  40. package/dist/content-handlers.d.ts.map +1 -0
  41. package/dist/content-handlers.js +263 -0
  42. package/dist/content-handlers.js.map +1 -0
  43. package/dist/content-pipeline.d.ts +383 -0
  44. package/dist/content-pipeline.d.ts.map +1 -0
  45. package/dist/content-pipeline.js +232 -0
  46. package/dist/content-pipeline.js.map +1 -0
  47. package/dist/cursor-nav.d.ts +149 -0
  48. package/dist/cursor-nav.d.ts.map +1 -0
  49. package/dist/cursor-nav.js +230 -0
  50. package/dist/cursor-nav.js.map +1 -0
  51. package/dist/cursor-rect.d.ts +65 -0
  52. package/dist/cursor-rect.d.ts.map +1 -0
  53. package/dist/cursor-rect.js +98 -0
  54. package/dist/cursor-rect.js.map +1 -0
  55. package/dist/drop-indicator.d.ts +108 -0
  56. package/dist/drop-indicator.d.ts.map +1 -0
  57. package/dist/drop-indicator.js +236 -0
  58. package/dist/drop-indicator.js.map +1 -0
  59. package/dist/editor.d.ts +41 -0
  60. package/dist/editor.d.ts.map +1 -0
  61. package/dist/editor.js +710 -0
  62. package/dist/editor.js.map +1 -0
  63. package/dist/floating-toolbar.d.ts +93 -0
  64. package/dist/floating-toolbar.d.ts.map +1 -0
  65. package/dist/floating-toolbar.js +159 -0
  66. package/dist/floating-toolbar.js.map +1 -0
  67. package/dist/index.d.ts +62 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +119 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/input-bridge.d.ts +273 -0
  72. package/dist/input-bridge.d.ts.map +1 -0
  73. package/dist/input-bridge.js +884 -0
  74. package/dist/input-bridge.js.map +1 -0
  75. package/dist/link-popover.d.ts +38 -0
  76. package/dist/link-popover.d.ts.map +1 -0
  77. package/dist/link-popover.js +278 -0
  78. package/dist/link-popover.js.map +1 -0
  79. package/dist/mark-renderer.d.ts +275 -0
  80. package/dist/mark-renderer.d.ts.map +1 -0
  81. package/dist/mark-renderer.js +210 -0
  82. package/dist/mark-renderer.js.map +1 -0
  83. package/dist/perf.d.ts +145 -0
  84. package/dist/perf.d.ts.map +1 -0
  85. package/dist/perf.js +260 -0
  86. package/dist/perf.js.map +1 -0
  87. package/dist/plugin-kit.d.ts +265 -0
  88. package/dist/plugin-kit.d.ts.map +1 -0
  89. package/dist/plugin-kit.js +234 -0
  90. package/dist/plugin-kit.js.map +1 -0
  91. package/dist/plugins/alignment-plugin.d.ts +68 -0
  92. package/dist/plugins/alignment-plugin.d.ts.map +1 -0
  93. package/dist/plugins/alignment-plugin.js +98 -0
  94. package/dist/plugins/alignment-plugin.js.map +1 -0
  95. package/dist/plugins/block-utils.d.ts +113 -0
  96. package/dist/plugins/block-utils.d.ts.map +1 -0
  97. package/dist/plugins/block-utils.js +191 -0
  98. package/dist/plugins/block-utils.js.map +1 -0
  99. package/dist/plugins/blockquote-plugin.d.ts +39 -0
  100. package/dist/plugins/blockquote-plugin.d.ts.map +1 -0
  101. package/dist/plugins/blockquote-plugin.js +88 -0
  102. package/dist/plugins/blockquote-plugin.js.map +1 -0
  103. package/dist/plugins/bold-plugin.d.ts +37 -0
  104. package/dist/plugins/bold-plugin.d.ts.map +1 -0
  105. package/dist/plugins/bold-plugin.js +48 -0
  106. package/dist/plugins/bold-plugin.js.map +1 -0
  107. package/dist/plugins/callout-plugin.d.ts +100 -0
  108. package/dist/plugins/callout-plugin.d.ts.map +1 -0
  109. package/dist/plugins/callout-plugin.js +200 -0
  110. package/dist/plugins/callout-plugin.js.map +1 -0
  111. package/dist/plugins/code-block-plugin.d.ts +62 -0
  112. package/dist/plugins/code-block-plugin.d.ts.map +1 -0
  113. package/dist/plugins/code-block-plugin.js +176 -0
  114. package/dist/plugins/code-block-plugin.js.map +1 -0
  115. package/dist/plugins/code-plugin.d.ts +37 -0
  116. package/dist/plugins/code-plugin.d.ts.map +1 -0
  117. package/dist/plugins/code-plugin.js +48 -0
  118. package/dist/plugins/code-plugin.js.map +1 -0
  119. package/dist/plugins/embed-plugin.d.ts +90 -0
  120. package/dist/plugins/embed-plugin.d.ts.map +1 -0
  121. package/dist/plugins/embed-plugin.js +147 -0
  122. package/dist/plugins/embed-plugin.js.map +1 -0
  123. package/dist/plugins/font-family-plugin.d.ts +58 -0
  124. package/dist/plugins/font-family-plugin.d.ts.map +1 -0
  125. package/dist/plugins/font-family-plugin.js +57 -0
  126. package/dist/plugins/font-family-plugin.js.map +1 -0
  127. package/dist/plugins/font-size-plugin.d.ts +57 -0
  128. package/dist/plugins/font-size-plugin.d.ts.map +1 -0
  129. package/dist/plugins/font-size-plugin.js +56 -0
  130. package/dist/plugins/font-size-plugin.js.map +1 -0
  131. package/dist/plugins/heading-plugin.d.ts +52 -0
  132. package/dist/plugins/heading-plugin.d.ts.map +1 -0
  133. package/dist/plugins/heading-plugin.js +114 -0
  134. package/dist/plugins/heading-plugin.js.map +1 -0
  135. package/dist/plugins/hr-plugin.d.ts +33 -0
  136. package/dist/plugins/hr-plugin.d.ts.map +1 -0
  137. package/dist/plugins/hr-plugin.js +75 -0
  138. package/dist/plugins/hr-plugin.js.map +1 -0
  139. package/dist/plugins/image-plugin.d.ts +115 -0
  140. package/dist/plugins/image-plugin.d.ts.map +1 -0
  141. package/dist/plugins/image-plugin.js +199 -0
  142. package/dist/plugins/image-plugin.js.map +1 -0
  143. package/dist/plugins/indent-plugin.d.ts +62 -0
  144. package/dist/plugins/indent-plugin.d.ts.map +1 -0
  145. package/dist/plugins/indent-plugin.js +128 -0
  146. package/dist/plugins/indent-plugin.js.map +1 -0
  147. package/dist/plugins/index.d.ts +45 -0
  148. package/dist/plugins/index.d.ts.map +1 -0
  149. package/dist/plugins/index.js +42 -0
  150. package/dist/plugins/index.js.map +1 -0
  151. package/dist/plugins/italic-plugin.d.ts +37 -0
  152. package/dist/plugins/italic-plugin.d.ts.map +1 -0
  153. package/dist/plugins/italic-plugin.js +48 -0
  154. package/dist/plugins/italic-plugin.js.map +1 -0
  155. package/dist/plugins/link-plugin.d.ts +129 -0
  156. package/dist/plugins/link-plugin.d.ts.map +1 -0
  157. package/dist/plugins/link-plugin.js +212 -0
  158. package/dist/plugins/link-plugin.js.map +1 -0
  159. package/dist/plugins/list-plugin.d.ts +53 -0
  160. package/dist/plugins/list-plugin.d.ts.map +1 -0
  161. package/dist/plugins/list-plugin.js +309 -0
  162. package/dist/plugins/list-plugin.js.map +1 -0
  163. package/dist/plugins/mark-utils.d.ts +173 -0
  164. package/dist/plugins/mark-utils.d.ts.map +1 -0
  165. package/dist/plugins/mark-utils.js +425 -0
  166. package/dist/plugins/mark-utils.js.map +1 -0
  167. package/dist/plugins/mention-plugin.d.ts +191 -0
  168. package/dist/plugins/mention-plugin.d.ts.map +1 -0
  169. package/dist/plugins/mention-plugin.js +295 -0
  170. package/dist/plugins/mention-plugin.js.map +1 -0
  171. package/dist/plugins/strikethrough-plugin.d.ts +37 -0
  172. package/dist/plugins/strikethrough-plugin.d.ts.map +1 -0
  173. package/dist/plugins/strikethrough-plugin.js +48 -0
  174. package/dist/plugins/strikethrough-plugin.js.map +1 -0
  175. package/dist/plugins/text-color-plugin.d.ts +57 -0
  176. package/dist/plugins/text-color-plugin.d.ts.map +1 -0
  177. package/dist/plugins/text-color-plugin.js +56 -0
  178. package/dist/plugins/text-color-plugin.js.map +1 -0
  179. package/dist/plugins/underline-plugin.d.ts +37 -0
  180. package/dist/plugins/underline-plugin.d.ts.map +1 -0
  181. package/dist/plugins/underline-plugin.js +48 -0
  182. package/dist/plugins/underline-plugin.js.map +1 -0
  183. package/dist/presets.d.ts +95 -0
  184. package/dist/presets.d.ts.map +1 -0
  185. package/dist/presets.js +159 -0
  186. package/dist/presets.js.map +1 -0
  187. package/dist/renderer.d.ts +125 -0
  188. package/dist/renderer.d.ts.map +1 -0
  189. package/dist/renderer.js +415 -0
  190. package/dist/renderer.js.map +1 -0
  191. package/dist/scroll-to-cursor.d.ts +25 -0
  192. package/dist/scroll-to-cursor.d.ts.map +1 -0
  193. package/dist/scroll-to-cursor.js +59 -0
  194. package/dist/scroll-to-cursor.js.map +1 -0
  195. package/dist/selection-sync.d.ts +159 -0
  196. package/dist/selection-sync.d.ts.map +1 -0
  197. package/dist/selection-sync.js +527 -0
  198. package/dist/selection-sync.js.map +1 -0
  199. package/dist/shortcut-handler.d.ts +98 -0
  200. package/dist/shortcut-handler.d.ts.map +1 -0
  201. package/dist/shortcut-handler.js +155 -0
  202. package/dist/shortcut-handler.js.map +1 -0
  203. package/dist/toolbar.d.ts +103 -0
  204. package/dist/toolbar.d.ts.map +1 -0
  205. package/dist/toolbar.js +134 -0
  206. package/dist/toolbar.js.map +1 -0
  207. package/dist/trigger-manager.d.ts +205 -0
  208. package/dist/trigger-manager.d.ts.map +1 -0
  209. package/dist/trigger-manager.js +466 -0
  210. package/dist/trigger-manager.js.map +1 -0
  211. package/dist/types.d.ts +216 -0
  212. package/dist/types.d.ts.map +1 -0
  213. package/dist/types.js +2 -0
  214. package/dist/types.js.map +1 -0
  215. package/package.json +30 -0
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Plugin presets for the RTIF web editor.
3
+ *
4
+ * Each preset is a factory function that returns an array of instantiated
5
+ * plugins ready to be registered via `engine.use()`. Presets are ordered
6
+ * from lightest (plain text) to heaviest (all features).
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import type { Plugin } from '@rtif-sdk/engine';
11
+ /**
12
+ * Plain text preset — no plugins.
13
+ *
14
+ * Use this for editors that need only unformatted text input with no
15
+ * inline marks, block types, or other extensions.
16
+ *
17
+ * @returns An empty plugin array
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { PRESET_PLAINTEXT } from '@rtif-sdk/web';
22
+ * import { createEngine } from '@rtif-sdk/engine';
23
+ *
24
+ * const engine = createEngine(initialDoc);
25
+ * for (const plugin of PRESET_PLAINTEXT) {
26
+ * engine.use(plugin);
27
+ * }
28
+ * ```
29
+ */
30
+ export declare const PRESET_PLAINTEXT: ReadonlyArray<Plugin>;
31
+ /**
32
+ * Basic preset — essential inline formatting.
33
+ *
34
+ * Includes bold, italic, underline, and link plugins. Suitable for
35
+ * simple rich text fields (comments, chat messages, short-form content).
36
+ *
37
+ * @returns An array of basic formatting plugins
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { PRESET_BASIC } from '@rtif-sdk/web';
42
+ * import { createEngine } from '@rtif-sdk/engine';
43
+ *
44
+ * const engine = createEngine(initialDoc);
45
+ * for (const plugin of PRESET_BASIC) {
46
+ * engine.use(plugin);
47
+ * }
48
+ * ```
49
+ */
50
+ export declare const PRESET_BASIC: ReadonlyArray<Plugin>;
51
+ /**
52
+ * Standard preset — common rich text editing features.
53
+ *
54
+ * Includes everything in {@link PRESET_BASIC}, plus strikethrough,
55
+ * inline code, headings, lists, blockquotes, code blocks, and
56
+ * horizontal rules. Suitable for blog posts, documentation, and
57
+ * general-purpose content editing.
58
+ *
59
+ * @returns An array of standard editing plugins
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * import { PRESET_STANDARD } from '@rtif-sdk/web';
64
+ * import { createEngine } from '@rtif-sdk/engine';
65
+ *
66
+ * const engine = createEngine(initialDoc);
67
+ * for (const plugin of PRESET_STANDARD) {
68
+ * engine.use(plugin);
69
+ * }
70
+ * ```
71
+ */
72
+ export declare const PRESET_STANDARD: ReadonlyArray<Plugin>;
73
+ /**
74
+ * Full preset — all available plugins.
75
+ *
76
+ * Includes everything in {@link PRESET_STANDARD}, plus text color,
77
+ * font size, font family, alignment, indentation, callouts, images,
78
+ * and embeds. Suitable for full-featured document editors and CMS
79
+ * authoring tools.
80
+ *
81
+ * @returns An array of all available plugins
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * import { PRESET_FULL } from '@rtif-sdk/web';
86
+ * import { createEngine } from '@rtif-sdk/engine';
87
+ *
88
+ * const engine = createEngine(initialDoc);
89
+ * for (const plugin of PRESET_FULL) {
90
+ * engine.use(plugin);
91
+ * }
92
+ * ```
93
+ */
94
+ export declare const PRESET_FULL: ReadonlyArray<Plugin>;
95
+ //# sourceMappingURL=presets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAsB/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAM,CAAC;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC,MAAM,CAK9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,MAAM,CAiBjD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,MAAM,CA+B7C,CAAC"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Plugin presets for the RTIF web editor.
3
+ *
4
+ * Each preset is a factory function that returns an array of instantiated
5
+ * plugins ready to be registered via `engine.use()`. Presets are ordered
6
+ * from lightest (plain text) to heaviest (all features).
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { boldPlugin } from './plugins/bold-plugin.js';
11
+ import { italicPlugin } from './plugins/italic-plugin.js';
12
+ import { underlinePlugin } from './plugins/underline-plugin.js';
13
+ import { linkPlugin } from './plugins/link-plugin.js';
14
+ import { strikethroughPlugin } from './plugins/strikethrough-plugin.js';
15
+ import { codePlugin } from './plugins/code-plugin.js';
16
+ import { headingPlugin } from './plugins/heading-plugin.js';
17
+ import { listPlugin } from './plugins/list-plugin.js';
18
+ import { blockquotePlugin } from './plugins/blockquote-plugin.js';
19
+ import { codeBlockPlugin } from './plugins/code-block-plugin.js';
20
+ import { hrPlugin } from './plugins/hr-plugin.js';
21
+ import { textColorPlugin } from './plugins/text-color-plugin.js';
22
+ import { fontSizePlugin } from './plugins/font-size-plugin.js';
23
+ import { fontFamilyPlugin } from './plugins/font-family-plugin.js';
24
+ import { alignmentPlugin } from './plugins/alignment-plugin.js';
25
+ import { indentPlugin } from './plugins/indent-plugin.js';
26
+ import { calloutPlugin } from './plugins/callout-plugin.js';
27
+ import { imagePlugin } from './plugins/image-plugin.js';
28
+ import { embedPlugin } from './plugins/embed-plugin.js';
29
+ /**
30
+ * Plain text preset — no plugins.
31
+ *
32
+ * Use this for editors that need only unformatted text input with no
33
+ * inline marks, block types, or other extensions.
34
+ *
35
+ * @returns An empty plugin array
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { PRESET_PLAINTEXT } from '@rtif-sdk/web';
40
+ * import { createEngine } from '@rtif-sdk/engine';
41
+ *
42
+ * const engine = createEngine(initialDoc);
43
+ * for (const plugin of PRESET_PLAINTEXT) {
44
+ * engine.use(plugin);
45
+ * }
46
+ * ```
47
+ */
48
+ export const PRESET_PLAINTEXT = [];
49
+ /**
50
+ * Basic preset — essential inline formatting.
51
+ *
52
+ * Includes bold, italic, underline, and link plugins. Suitable for
53
+ * simple rich text fields (comments, chat messages, short-form content).
54
+ *
55
+ * @returns An array of basic formatting plugins
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { PRESET_BASIC } from '@rtif-sdk/web';
60
+ * import { createEngine } from '@rtif-sdk/engine';
61
+ *
62
+ * const engine = createEngine(initialDoc);
63
+ * for (const plugin of PRESET_BASIC) {
64
+ * engine.use(plugin);
65
+ * }
66
+ * ```
67
+ */
68
+ export const PRESET_BASIC = [
69
+ boldPlugin(),
70
+ italicPlugin(),
71
+ underlinePlugin(),
72
+ linkPlugin(),
73
+ ];
74
+ /**
75
+ * Standard preset — common rich text editing features.
76
+ *
77
+ * Includes everything in {@link PRESET_BASIC}, plus strikethrough,
78
+ * inline code, headings, lists, blockquotes, code blocks, and
79
+ * horizontal rules. Suitable for blog posts, documentation, and
80
+ * general-purpose content editing.
81
+ *
82
+ * @returns An array of standard editing plugins
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * import { PRESET_STANDARD } from '@rtif-sdk/web';
87
+ * import { createEngine } from '@rtif-sdk/engine';
88
+ *
89
+ * const engine = createEngine(initialDoc);
90
+ * for (const plugin of PRESET_STANDARD) {
91
+ * engine.use(plugin);
92
+ * }
93
+ * ```
94
+ */
95
+ export const PRESET_STANDARD = [
96
+ // Inline marks (from BASIC)
97
+ boldPlugin(),
98
+ italicPlugin(),
99
+ underlinePlugin(),
100
+ linkPlugin(),
101
+ // Additional inline marks
102
+ strikethroughPlugin(),
103
+ codePlugin(),
104
+ // Block types
105
+ headingPlugin(),
106
+ listPlugin(),
107
+ blockquotePlugin(),
108
+ codeBlockPlugin(),
109
+ hrPlugin(),
110
+ ];
111
+ /**
112
+ * Full preset — all available plugins.
113
+ *
114
+ * Includes everything in {@link PRESET_STANDARD}, plus text color,
115
+ * font size, font family, alignment, indentation, callouts, images,
116
+ * and embeds. Suitable for full-featured document editors and CMS
117
+ * authoring tools.
118
+ *
119
+ * @returns An array of all available plugins
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import { PRESET_FULL } from '@rtif-sdk/web';
124
+ * import { createEngine } from '@rtif-sdk/engine';
125
+ *
126
+ * const engine = createEngine(initialDoc);
127
+ * for (const plugin of PRESET_FULL) {
128
+ * engine.use(plugin);
129
+ * }
130
+ * ```
131
+ */
132
+ export const PRESET_FULL = [
133
+ // Inline marks (from BASIC)
134
+ boldPlugin(),
135
+ italicPlugin(),
136
+ underlinePlugin(),
137
+ linkPlugin(),
138
+ // Additional inline marks (from STANDARD)
139
+ strikethroughPlugin(),
140
+ codePlugin(),
141
+ // Block types (from STANDARD)
142
+ headingPlugin(),
143
+ listPlugin(),
144
+ blockquotePlugin(),
145
+ codeBlockPlugin(),
146
+ hrPlugin(),
147
+ // Parameterized text styling
148
+ textColorPlugin(),
149
+ fontSizePlugin(),
150
+ fontFamilyPlugin(),
151
+ // Paragraph formatting
152
+ alignmentPlugin(),
153
+ indentPlugin(),
154
+ // Advanced block types
155
+ calloutPlugin(),
156
+ imagePlugin(),
157
+ embedPlugin(),
158
+ ];
159
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA0B,EAAE,CAAC;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,YAAY,GAA0B;IACjD,UAAU,EAAE;IACZ,YAAY,EAAE;IACd,eAAe,EAAE;IACjB,UAAU,EAAE;CACb,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,eAAe,GAA0B;IACpD,4BAA4B;IAC5B,UAAU,EAAE;IACZ,YAAY,EAAE;IACd,eAAe,EAAE;IACjB,UAAU,EAAE;IAEZ,0BAA0B;IAC1B,mBAAmB,EAAE;IACrB,UAAU,EAAE;IAEZ,cAAc;IACd,aAAa,EAAE;IACf,UAAU,EAAE;IACZ,gBAAgB,EAAE;IAClB,eAAe,EAAE;IACjB,QAAQ,EAAE;CACX,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,WAAW,GAA0B;IAChD,4BAA4B;IAC5B,UAAU,EAAE;IACZ,YAAY,EAAE;IACd,eAAe,EAAE;IACjB,UAAU,EAAE;IAEZ,0CAA0C;IAC1C,mBAAmB,EAAE;IACrB,UAAU,EAAE;IAEZ,8BAA8B;IAC9B,aAAa,EAAE;IACf,UAAU,EAAE;IACZ,gBAAgB,EAAE;IAClB,eAAe,EAAE;IACjB,QAAQ,EAAE;IAEV,6BAA6B;IAC7B,eAAe,EAAE;IACjB,cAAc,EAAE;IAChB,gBAAgB,EAAE;IAElB,uBAAuB;IACvB,eAAe,EAAE;IACjB,YAAY,EAAE;IAEd,uBAAuB;IACvB,aAAa,EAAE;IACf,WAAW,EAAE;IACb,WAAW,EAAE;CACd,CAAC"}
@@ -0,0 +1,125 @@
1
+ import type { Document, Block, Span } from '@rtif-sdk/core';
2
+ import type { MarkRendererRegistry } from './mark-renderer.js';
3
+ import type { BlockRendererRegistry } from './block-renderer.js';
4
+ /**
5
+ * Create a DOM element for an RTIF span.
6
+ *
7
+ * When a `markRenderers` registry is provided and the span has a mark with a
8
+ * registered {@link SpanReplacer}, the replacer's `createElement()` is called
9
+ * to produce a fully custom element. Otherwise, a default `<span>` is created
10
+ * with mark renderers applied.
11
+ *
12
+ * Non-empty spans contain a single Text node. Empty spans (text === '')
13
+ * contain a `<br>` element so the block has layout height in the browser.
14
+ *
15
+ * @param span - The RTIF span to render
16
+ * @param markRenderers - Optional registry of mark renderers for visual styling
17
+ * @returns An `HTMLElement` with `data-rtif-span` attribute and appropriate child node
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const el = createSpanElement({ text: 'hello' });
22
+ * // <span data-rtif-span>hello</span>
23
+ *
24
+ * const boldEl = createSpanElement(
25
+ * { text: 'bold', marks: { bold: true } },
26
+ * markRegistry,
27
+ * );
28
+ * // <span data-rtif-span class="rtif-bold">bold</span>
29
+ * ```
30
+ */
31
+ export declare function createSpanElement(span: Span, markRenderers?: MarkRendererRegistry): HTMLElement;
32
+ /**
33
+ * Create a DOM block element for an RTIF block.
34
+ *
35
+ * Each block renders as a `<div>` with `data-rtif-block` set to the block ID
36
+ * and `data-block-type` set to the block type. Child span elements are created
37
+ * for each span in the block.
38
+ *
39
+ * When a `blockRenderers` registry is provided, the renderer for the block's
40
+ * type is applied to the element (adding CSS classes, ARIA roles, etc.).
41
+ *
42
+ * @param block - The RTIF block to render
43
+ * @param markRenderers - Optional registry of mark renderers for visual styling
44
+ * @param blockRenderers - Optional registry of block renderers for block-type styling
45
+ * @returns A `<div data-rtif-block="{id}" data-block-type="{type}">` element
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const el = createBlockElement({
50
+ * id: 'b1',
51
+ * type: 'text',
52
+ * spans: [{ text: 'Hello world' }],
53
+ * });
54
+ * // <div data-rtif-block="b1" data-block-type="text">
55
+ * // <span data-rtif-span>Hello world</span>
56
+ * // </div>
57
+ * ```
58
+ */
59
+ export declare function createBlockElement(block: Block, markRenderers?: MarkRendererRegistry, blockRenderers?: BlockRendererRegistry): HTMLDivElement;
60
+ /**
61
+ * Find a block DOM element within a root by its RTIF block ID.
62
+ *
63
+ * @param root - The root element to search within
64
+ * @param blockId - The block ID to find (matches `data-rtif-block` attribute)
65
+ * @returns The matching element, or `null` if not found
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const blockEl = findBlockElement(root, 'b1');
70
+ * if (blockEl) {
71
+ * console.log(blockEl.textContent);
72
+ * }
73
+ * ```
74
+ */
75
+ export declare function findBlockElement(root: HTMLElement, blockId: string): HTMLElement | null;
76
+ /**
77
+ * Perform a full initial render of an RTIF document into a root element.
78
+ *
79
+ * Clears all existing content in the root, then creates block and span
80
+ * elements for the entire document. Use this for the first render; use
81
+ * {@link reconcile} for subsequent updates.
82
+ *
83
+ * @param root - The root DOM element (typically `contenteditable`)
84
+ * @param doc - The RTIF document to render
85
+ * @param markRenderers - Optional registry of mark renderers for visual styling
86
+ * @param blockRenderers - Optional registry of block renderers for block-type styling
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const root = document.getElementById('editor')!;
91
+ * renderInitial(root, {
92
+ * version: 1,
93
+ * blocks: [{ id: 'b1', type: 'text', spans: [{ text: 'Hello' }] }],
94
+ * });
95
+ * ```
96
+ */
97
+ export declare function renderInitial(root: HTMLElement, doc: Document, markRenderers?: MarkRendererRegistry, blockRenderers?: BlockRendererRegistry): void;
98
+ /**
99
+ * Efficiently reconcile the DOM to match a new RTIF document state.
100
+ *
101
+ * Only touches blocks that have changed (detected by object reference
102
+ * comparison). Handles block additions, removals, reordering, and
103
+ * span-level content updates within changed blocks. When a block's type
104
+ * or attrs change (by reference), the entire block element is replaced
105
+ * to ensure block-renderer styling is re-applied cleanly.
106
+ *
107
+ * **Critical**: When `composingBlockId` is set (IME composition active),
108
+ * the block with that ID is skipped entirely to avoid disrupting the
109
+ * browser's native composition rendering.
110
+ *
111
+ * @param root - The root DOM element containing block elements
112
+ * @param prevDoc - The previous RTIF document state
113
+ * @param nextDoc - The new RTIF document state to reconcile toward
114
+ * @param composingBlockId - Block ID currently under IME composition, or `null`
115
+ * @param markRenderers - Optional registry of mark renderers for visual styling
116
+ * @param blockRenderers - Optional registry of block renderers for block-type styling
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * // After an engine dispatch produces a new document:
121
+ * reconcile(root, prevDoc, nextDoc, composingBlockId, markRenderers, blockRenderers);
122
+ * ```
123
+ */
124
+ export declare function reconcile(root: HTMLElement, prevDoc: Document, nextDoc: Document, composingBlockId: string | null, markRenderers?: MarkRendererRegistry, blockRenderers?: BlockRendererRegistry): void;
125
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAoCjE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,aAAa,CAAC,EAAE,oBAAoB,GACnC,WAAW,CA6Bb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,aAAa,CAAC,EAAE,oBAAoB,EACpC,cAAc,CAAC,EAAE,qBAAqB,GACrC,cAAc,CAgBhB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,MAAM,GACd,WAAW,GAAG,IAAI,CAEpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,QAAQ,EACb,aAAa,CAAC,EAAE,oBAAoB,EACpC,cAAc,CAAC,EAAE,qBAAqB,GACrC,IAAI,CASN;AA4HD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,QAAQ,EACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,EAC/B,aAAa,CAAC,EAAE,oBAAoB,EACpC,cAAc,CAAC,EAAE,qBAAqB,GACrC,IAAI,CA4GN"}