smartrte-core 0.2.1 → 1.0.0-beta.1

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 (329) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +23 -0
  3. package/dist/command.d.ts +8 -8
  4. package/dist/editor.d.ts +32 -0
  5. package/dist/editor.js +121 -0
  6. package/dist/foundation/annotations/index.d.ts +2 -0
  7. package/dist/foundation/annotations/index.js +2 -0
  8. package/dist/foundation/annotations/range.d.ts +54 -0
  9. package/dist/foundation/annotations/range.js +158 -0
  10. package/dist/foundation/annotations/types.d.ts +33 -0
  11. package/dist/foundation/annotations/types.js +1 -0
  12. package/dist/foundation/atom/commands.d.ts +11 -0
  13. package/dist/foundation/atom/commands.js +118 -0
  14. package/dist/foundation/atom/composition.d.ts +8 -0
  15. package/dist/foundation/atom/composition.js +22 -0
  16. package/dist/foundation/atom/declarations.d.ts +2 -0
  17. package/dist/foundation/atom/declarations.js +17 -0
  18. package/dist/foundation/atom/formats.d.ts +21 -0
  19. package/dist/foundation/atom/formats.js +77 -0
  20. package/dist/foundation/atom/index.d.ts +10 -0
  21. package/dist/foundation/atom/index.js +10 -0
  22. package/dist/foundation/atom/lifecycle.d.ts +12 -0
  23. package/dist/foundation/atom/lifecycle.js +41 -0
  24. package/dist/foundation/atom/persistence.d.ts +3 -0
  25. package/dist/foundation/atom/persistence.js +20 -0
  26. package/dist/foundation/atom/plugin.d.ts +20 -0
  27. package/dist/foundation/atom/plugin.js +55 -0
  28. package/dist/foundation/atom/schema.d.ts +3 -0
  29. package/dist/foundation/atom/schema.js +29 -0
  30. package/dist/foundation/atom/security.d.ts +10 -0
  31. package/dist/foundation/atom/security.js +20 -0
  32. package/dist/foundation/atom/selection.d.ts +3 -0
  33. package/dist/foundation/atom/selection.js +4 -0
  34. package/dist/foundation/atom/types.d.ts +47 -0
  35. package/dist/foundation/atom/types.js +1 -0
  36. package/dist/foundation/block/commands.d.ts +17 -0
  37. package/dist/foundation/block/commands.js +197 -0
  38. package/dist/foundation/block/formats.d.ts +33 -0
  39. package/dist/foundation/block/formats.js +57 -0
  40. package/dist/foundation/block/index.d.ts +5 -0
  41. package/dist/foundation/block/index.js +5 -0
  42. package/dist/foundation/block/input.d.ts +19 -0
  43. package/dist/foundation/block/input.js +67 -0
  44. package/dist/foundation/block/plugin.d.ts +26 -0
  45. package/dist/foundation/block/plugin.js +79 -0
  46. package/dist/foundation/block/schema.d.ts +49 -0
  47. package/dist/foundation/block/schema.js +27 -0
  48. package/dist/foundation/block/types.d.ts +40 -0
  49. package/dist/foundation/block/types.js +1 -0
  50. package/dist/foundation/boundaries.d.ts +11 -0
  51. package/dist/foundation/boundaries.js +117 -0
  52. package/dist/foundation/clipboard/detection.d.ts +3 -0
  53. package/dist/foundation/clipboard/detection.js +29 -0
  54. package/dist/foundation/clipboard/diagnostics.d.ts +24 -0
  55. package/dist/foundation/clipboard/diagnostics.js +59 -0
  56. package/dist/foundation/clipboard/index.d.ts +8 -0
  57. package/dist/foundation/clipboard/index.js +8 -0
  58. package/dist/foundation/clipboard/insertion.d.ts +22 -0
  59. package/dist/foundation/clipboard/insertion.js +210 -0
  60. package/dist/foundation/clipboard/normalizers.d.ts +8 -0
  61. package/dist/foundation/clipboard/normalizers.js +229 -0
  62. package/dist/foundation/clipboard/pipeline.d.ts +13 -0
  63. package/dist/foundation/clipboard/pipeline.js +58 -0
  64. package/dist/foundation/clipboard/sanitizer.d.ts +3 -0
  65. package/dist/foundation/clipboard/sanitizer.js +58 -0
  66. package/dist/foundation/clipboard/serialization.d.ts +5 -0
  67. package/dist/foundation/clipboard/serialization.js +33 -0
  68. package/dist/foundation/clipboard/transfer.d.ts +11 -0
  69. package/dist/foundation/clipboard/transfer.js +108 -0
  70. package/dist/foundation/clipboard/types.d.ts +65 -0
  71. package/dist/foundation/clipboard/types.js +1 -0
  72. package/dist/foundation/collab/index.d.ts +3 -0
  73. package/dist/foundation/collab/index.js +3 -0
  74. package/dist/foundation/collab/rebase.d.ts +28 -0
  75. package/dist/foundation/collab/rebase.js +82 -0
  76. package/dist/foundation/collab/transform.d.ts +73 -0
  77. package/dist/foundation/collab/transform.js +251 -0
  78. package/dist/foundation/collab/types.d.ts +52 -0
  79. package/dist/foundation/collab/types.js +1 -0
  80. package/dist/foundation/comments/fromSelection.d.ts +16 -0
  81. package/dist/foundation/comments/fromSelection.js +24 -0
  82. package/dist/foundation/comments/index.d.ts +3 -0
  83. package/dist/foundation/comments/index.js +3 -0
  84. package/dist/foundation/comments/rebase.d.ts +31 -0
  85. package/dist/foundation/comments/rebase.js +43 -0
  86. package/dist/foundation/comments/types.d.ts +37 -0
  87. package/dist/foundation/comments/types.js +1 -0
  88. package/dist/foundation/diff/documentDiff.d.ts +12 -0
  89. package/dist/foundation/diff/documentDiff.js +148 -0
  90. package/dist/foundation/diff/index.d.ts +3 -0
  91. package/dist/foundation/diff/index.js +3 -0
  92. package/dist/foundation/diff/textDiff.d.ts +12 -0
  93. package/dist/foundation/diff/textDiff.js +114 -0
  94. package/dist/foundation/diff/types.d.ts +74 -0
  95. package/dist/foundation/diff/types.js +1 -0
  96. package/dist/foundation/editor.d.ts +138 -0
  97. package/dist/foundation/editor.js +398 -0
  98. package/dist/foundation/formats/codec.d.ts +45 -0
  99. package/dist/foundation/formats/codec.js +1 -0
  100. package/dist/foundation/formats/docx/export.d.ts +4 -0
  101. package/dist/foundation/formats/docx/export.js +285 -0
  102. package/dist/foundation/formats/docx/import.d.ts +9 -0
  103. package/dist/foundation/formats/docx/import.js +37 -0
  104. package/dist/foundation/formats/docx/nestingGuard.d.ts +40 -0
  105. package/dist/foundation/formats/docx/nestingGuard.js +66 -0
  106. package/dist/foundation/formats/docx/portableAtoms.d.ts +4 -0
  107. package/dist/foundation/formats/docx/portableAtoms.js +66 -0
  108. package/dist/foundation/formats/docx/styledImport.d.ts +10 -0
  109. package/dist/foundation/formats/docx/styledImport.js +205 -0
  110. package/dist/foundation/formats/featureCodecs.d.ts +37 -0
  111. package/dist/foundation/formats/featureCodecs.js +69 -0
  112. package/dist/foundation/formats/fidelity.d.ts +31 -0
  113. package/dist/foundation/formats/fidelity.js +123 -0
  114. package/dist/foundation/formats/index.d.ts +7 -0
  115. package/dist/foundation/formats/index.js +7 -0
  116. package/dist/foundation/formats/pdf/format.d.ts +29 -0
  117. package/dist/foundation/formats/pdf/format.js +190 -0
  118. package/dist/foundation/history.d.ts +20 -0
  119. package/dist/foundation/history.js +121 -0
  120. package/dist/foundation/identity.d.ts +8 -0
  121. package/dist/foundation/identity.js +30 -0
  122. package/dist/foundation/index.d.ts +30 -0
  123. package/dist/foundation/index.js +30 -0
  124. package/dist/foundation/list/commands.d.ts +28 -0
  125. package/dist/foundation/list/commands.js +422 -0
  126. package/dist/foundation/list/formats.d.ts +20 -0
  127. package/dist/foundation/list/formats.js +795 -0
  128. package/dist/foundation/list/index.d.ts +8 -0
  129. package/dist/foundation/list/index.js +8 -0
  130. package/dist/foundation/list/input.d.ts +35 -0
  131. package/dist/foundation/list/input.js +320 -0
  132. package/dist/foundation/list/plugin.d.ts +21 -0
  133. package/dist/foundation/list/plugin.js +71 -0
  134. package/dist/foundation/list/presets.d.ts +16 -0
  135. package/dist/foundation/list/presets.js +21 -0
  136. package/dist/foundation/list/schema.d.ts +35 -0
  137. package/dist/foundation/list/schema.js +29 -0
  138. package/dist/foundation/list/shadow.d.ts +54 -0
  139. package/dist/foundation/list/shadow.js +75 -0
  140. package/dist/foundation/list/shadowCorpus.d.ts +10 -0
  141. package/dist/foundation/list/shadowCorpus.js +41 -0
  142. package/dist/foundation/list/types.d.ts +50 -0
  143. package/dist/foundation/list/types.js +1 -0
  144. package/dist/foundation/mapping.d.ts +11 -0
  145. package/dist/foundation/mapping.js +40 -0
  146. package/dist/foundation/marks/canonical.d.ts +9 -0
  147. package/dist/foundation/marks/canonical.js +72 -0
  148. package/dist/foundation/marks/commands.d.ts +21 -0
  149. package/dist/foundation/marks/commands.js +136 -0
  150. package/dist/foundation/marks/dom.d.ts +2 -0
  151. package/dist/foundation/marks/dom.js +46 -0
  152. package/dist/foundation/marks/editor.d.ts +8 -0
  153. package/dist/foundation/marks/editor.js +50 -0
  154. package/dist/foundation/marks/formats.d.ts +37 -0
  155. package/dist/foundation/marks/formats.js +49 -0
  156. package/dist/foundation/marks/hardBreak.d.ts +8 -0
  157. package/dist/foundation/marks/hardBreak.js +80 -0
  158. package/dist/foundation/marks/index.d.ts +11 -0
  159. package/dist/foundation/marks/index.js +11 -0
  160. package/dist/foundation/marks/normalization.d.ts +2 -0
  161. package/dist/foundation/marks/normalization.js +49 -0
  162. package/dist/foundation/marks/plugin.d.ts +14 -0
  163. package/dist/foundation/marks/plugin.js +63 -0
  164. package/dist/foundation/marks/resolveMarkRun.d.ts +8 -0
  165. package/dist/foundation/marks/resolveMarkRun.js +47 -0
  166. package/dist/foundation/marks/schema.d.ts +167 -0
  167. package/dist/foundation/marks/schema.js +50 -0
  168. package/dist/foundation/marks/stored.d.ts +2 -0
  169. package/dist/foundation/marks/stored.js +31 -0
  170. package/dist/foundation/marks/types.d.ts +40 -0
  171. package/dist/foundation/marks/types.js +1 -0
  172. package/dist/foundation/modelDom.d.ts +38 -0
  173. package/dist/foundation/modelDom.js +327 -0
  174. package/dist/foundation/normalization.d.ts +22 -0
  175. package/dist/foundation/normalization.js +132 -0
  176. package/dist/foundation/operations.d.ts +28 -0
  177. package/dist/foundation/operations.js +568 -0
  178. package/dist/foundation/plugin/builtins.d.ts +10 -0
  179. package/dist/foundation/plugin/builtins.js +27 -0
  180. package/dist/foundation/plugin/dispatch.d.ts +33 -0
  181. package/dist/foundation/plugin/dispatch.js +34 -0
  182. package/dist/foundation/plugin/index.d.ts +4 -0
  183. package/dist/foundation/plugin/index.js +4 -0
  184. package/dist/foundation/plugin/registry.d.ts +36 -0
  185. package/dist/foundation/plugin/registry.js +115 -0
  186. package/dist/foundation/plugin/types.d.ts +141 -0
  187. package/dist/foundation/plugin/types.js +13 -0
  188. package/dist/foundation/positions.d.ts +20 -0
  189. package/dist/foundation/positions.js +121 -0
  190. package/dist/foundation/schema.d.ts +57 -0
  191. package/dist/foundation/schema.js +371 -0
  192. package/dist/foundation/schemaBuilder.d.ts +41 -0
  193. package/dist/foundation/schemaBuilder.js +96 -0
  194. package/dist/foundation/scope/index.d.ts +2 -0
  195. package/dist/foundation/scope/index.js +2 -0
  196. package/dist/foundation/scope/resolveScope.d.ts +13 -0
  197. package/dist/foundation/scope/resolveScope.js +860 -0
  198. package/dist/foundation/scope/types.d.ts +122 -0
  199. package/dist/foundation/scope/types.js +1 -0
  200. package/dist/foundation/security/urlPolicy.d.ts +21 -0
  201. package/dist/foundation/security/urlPolicy.js +75 -0
  202. package/dist/foundation/structural/contentTarget.d.ts +21 -0
  203. package/dist/foundation/structural/contentTarget.js +51 -0
  204. package/dist/foundation/structural/index.d.ts +2 -0
  205. package/dist/foundation/structural/index.js +2 -0
  206. package/dist/foundation/structural/move.d.ts +7 -0
  207. package/dist/foundation/structural/move.js +35 -0
  208. package/dist/foundation/suggestions/index.d.ts +3 -0
  209. package/dist/foundation/suggestions/index.js +3 -0
  210. package/dist/foundation/suggestions/inline.d.ts +64 -0
  211. package/dist/foundation/suggestions/inline.js +116 -0
  212. package/dist/foundation/suggestions/structural.d.ts +40 -0
  213. package/dist/foundation/suggestions/structural.js +47 -0
  214. package/dist/foundation/suggestions/types.d.ts +19 -0
  215. package/dist/foundation/suggestions/types.js +1 -0
  216. package/dist/foundation/surface/index.d.ts +3 -0
  217. package/dist/foundation/surface/index.js +3 -0
  218. package/dist/foundation/surface/input.d.ts +127 -0
  219. package/dist/foundation/surface/input.js +1761 -0
  220. package/dist/foundation/surface/renderer.d.ts +84 -0
  221. package/dist/foundation/surface/renderer.js +974 -0
  222. package/dist/foundation/surface/types.d.ts +48 -0
  223. package/dist/foundation/surface/types.js +1 -0
  224. package/dist/foundation/table/commands.d.ts +31 -0
  225. package/dist/foundation/table/commands.js +470 -0
  226. package/dist/foundation/table/formats.d.ts +26 -0
  227. package/dist/foundation/table/formats.js +40 -0
  228. package/dist/foundation/table/grid.d.ts +8 -0
  229. package/dist/foundation/table/grid.js +178 -0
  230. package/dist/foundation/table/index.d.ts +6 -0
  231. package/dist/foundation/table/index.js +6 -0
  232. package/dist/foundation/table/plugin.d.ts +23 -0
  233. package/dist/foundation/table/plugin.js +119 -0
  234. package/dist/foundation/table/schema.d.ts +2 -0
  235. package/dist/foundation/table/schema.js +38 -0
  236. package/dist/foundation/table/selection.d.ts +7 -0
  237. package/dist/foundation/table/selection.js +35 -0
  238. package/dist/foundation/table/types.d.ts +109 -0
  239. package/dist/foundation/table/types.js +1 -0
  240. package/dist/foundation/transactions.d.ts +41 -0
  241. package/dist/foundation/transactions.js +90 -0
  242. package/dist/foundation/types.d.ts +261 -0
  243. package/dist/foundation/types.js +1 -0
  244. package/dist/foundation/versioning/diffVersions.d.ts +5 -0
  245. package/dist/foundation/versioning/diffVersions.js +3 -0
  246. package/dist/foundation/versioning/index.d.ts +2 -0
  247. package/dist/foundation/versioning/index.js +2 -0
  248. package/dist/foundation/versioning/types.d.ts +17 -0
  249. package/dist/foundation/versioning/types.js +1 -0
  250. package/dist/history.d.ts +20 -0
  251. package/dist/history.js +165 -0
  252. package/dist/html/compatibility.js +7 -1
  253. package/dist/index.d.ts +1 -14
  254. package/dist/index.js +9 -14
  255. package/dist/legacy/index.d.ts +45 -0
  256. package/dist/legacy/index.js +45 -0
  257. package/dist/legacyCommands/alignment.d.ts +20 -0
  258. package/dist/{commands → legacyCommands}/alignment.js +17 -0
  259. package/dist/legacyCommands/blocks.d.ts +14 -0
  260. package/dist/legacyCommands/blocks.js +105 -0
  261. package/dist/legacyCommands/checklist.d.ts +11 -0
  262. package/dist/legacyCommands/checklist.js +45 -0
  263. package/dist/legacyCommands/code.d.ts +15 -0
  264. package/dist/{commands → legacyCommands}/code.js +25 -1
  265. package/dist/legacyCommands/formula.d.ts +7 -0
  266. package/dist/legacyCommands/formula.js +67 -0
  267. package/dist/legacyCommands/inlineAtoms.d.ts +7 -0
  268. package/dist/legacyCommands/inlineAtoms.js +58 -0
  269. package/dist/legacyCommands/list.d.ts +38 -0
  270. package/dist/legacyCommands/list.js +477 -0
  271. package/dist/{commands → legacyCommands}/marks.d.ts +3 -0
  272. package/dist/{commands → legacyCommands}/marks.js +28 -11
  273. package/dist/legacyCommands/media.d.ts +31 -0
  274. package/dist/legacyCommands/media.js +205 -0
  275. package/dist/legacyCommands/move.d.ts +14 -0
  276. package/dist/legacyCommands/move.js +91 -0
  277. package/dist/legacyCommands/table.d.ts +91 -0
  278. package/dist/legacyCommands/table.js +547 -0
  279. package/dist/listPresets.d.ts +12 -0
  280. package/dist/listPresets.js +6 -0
  281. package/dist/listScope.d.ts +27 -0
  282. package/dist/listScope.js +104 -0
  283. package/dist/markdown/compatibility.d.ts +2 -0
  284. package/dist/markdown/compatibility.js +94 -2
  285. package/dist/marks.d.ts +5 -5
  286. package/dist/model.d.ts +65 -9
  287. package/dist/plugin.d.ts +15 -0
  288. package/dist/plugin.js +31 -0
  289. package/dist/plugins/alignment.d.ts +3 -0
  290. package/dist/plugins/alignment.js +6 -0
  291. package/dist/plugins/basicFormatting.d.ts +9 -0
  292. package/dist/plugins/basicFormatting.js +24 -0
  293. package/dist/plugins/blockType.d.ts +3 -0
  294. package/dist/plugins/blockType.js +6 -0
  295. package/dist/plugins/blockquote.d.ts +3 -0
  296. package/dist/plugins/blockquote.js +6 -0
  297. package/dist/plugins/checklist.d.ts +3 -0
  298. package/dist/plugins/checklist.js +10 -0
  299. package/dist/plugins/codeBlock.d.ts +3 -0
  300. package/dist/plugins/codeBlock.js +6 -0
  301. package/dist/plugins/formula.d.ts +3 -0
  302. package/dist/plugins/formula.js +9 -0
  303. package/dist/plugins/list.d.ts +3 -0
  304. package/dist/plugins/list.js +10 -0
  305. package/dist/plugins/media.d.ts +3 -0
  306. package/dist/plugins/media.js +12 -0
  307. package/dist/plugins/move.d.ts +3 -0
  308. package/dist/plugins/move.js +9 -0
  309. package/dist/plugins/table.d.ts +3 -0
  310. package/dist/plugins/table.js +22 -0
  311. package/dist/preset.d.ts +12 -0
  312. package/dist/preset.js +40 -0
  313. package/dist/schema.d.ts +22 -0
  314. package/dist/schema.js +333 -0
  315. package/dist/security/urlPolicy.d.ts +1 -17
  316. package/dist/security/urlPolicy.js +3 -69
  317. package/dist/selection.d.ts +1 -1
  318. package/dist/selectionMapping.d.ts +4 -0
  319. package/dist/selectionMapping.js +222 -0
  320. package/dist/table.d.ts +3 -3
  321. package/dist/transaction.d.ts +35 -12
  322. package/dist/transaction.js +174 -28
  323. package/dist/tree.d.ts +8 -2
  324. package/dist/tree.js +44 -0
  325. package/package.json +27 -8
  326. package/dist/commands/alignment.d.ts +0 -18
  327. package/dist/commands/code.d.ts +0 -13
  328. package/dist/commands/list.d.ts +0 -20
  329. package/dist/commands/list.js +0 -52
@@ -0,0 +1,104 @@
1
+ import { getNodeAtPath } from "./model.js";
2
+ const samePath = (left, right) => left.length === right.length && left.every((part, index) => part === right[index]);
3
+ const isBlock = (node) => Boolean(node) && typeof node === "object" &&
4
+ ["paragraph", "heading", "list", "blockquote", "codeBlock", "table"].includes(node.type || "");
5
+ const structuralUnit = (document, path) => {
6
+ let firstBlockPath = null;
7
+ let deepestList = null;
8
+ for (let depth = 1; depth <= path.length; depth += 1) {
9
+ const candidatePath = path.slice(0, depth);
10
+ const node = getNodeAtPath(document, candidatePath);
11
+ if (!isBlock(node))
12
+ continue;
13
+ if (!firstBlockPath)
14
+ firstBlockPath = candidatePath;
15
+ if (node.type === "list") {
16
+ const itemIndex = path[depth];
17
+ deepestList = {
18
+ path: candidatePath,
19
+ listItemIndex: Number.isInteger(itemIndex) ? itemIndex : undefined,
20
+ };
21
+ continue;
22
+ }
23
+ if (node.type === "table")
24
+ firstBlockPath = null;
25
+ }
26
+ return deepestList || (firstBlockPath ? { path: firstBlockPath, listItemIndex: undefined } : null);
27
+ };
28
+ /** Resolves the semantic list scope without inspecting DOM details. */
29
+ export const resolveListSelectionScope = (document, selection) => {
30
+ if (selection.type === "all")
31
+ return { kind: "all", containerPath: [] };
32
+ if (selection.type !== "text" && selection.type !== "node")
33
+ return { kind: "none" };
34
+ const paths = selection.type === "text"
35
+ ? [selection.anchor.path, selection.focus.path]
36
+ : [selection.path, selection.path];
37
+ const anchor = structuralUnit(document, paths[0]);
38
+ const focus = structuralUnit(document, paths[1]);
39
+ if (!anchor || !focus)
40
+ return { kind: "none" };
41
+ if (samePath(anchor.path, focus.path) && anchor.listItemIndex !== undefined && focus.listItemIndex !== undefined) {
42
+ return {
43
+ kind: "list",
44
+ listPath: anchor.path,
45
+ start: Math.min(anchor.listItemIndex, focus.listItemIndex),
46
+ end: Math.max(anchor.listItemIndex, focus.listItemIndex),
47
+ };
48
+ }
49
+ // A range whose endpoints are list content at different depths belongs to
50
+ // the nearest common containing list. For example, selecting a parent item
51
+ // through one of its nested items changes the parent list while preserving
52
+ // the nested descendants. A nested-only range is handled by the same-path
53
+ // branch above and therefore remains scoped to the nested list.
54
+ if (anchor.listItemIndex !== undefined && focus.listItemIndex !== undefined) {
55
+ const listPaths = [anchor.path, focus.path];
56
+ const ancestor = listPaths.find((candidate) => listPaths.every((path) => path.length >= candidate.length && candidate.every((part, index) => path[index] === part)));
57
+ if (ancestor) {
58
+ const indices = [
59
+ samePath(anchor.path, ancestor) ? anchor.listItemIndex : anchor.path[ancestor.length],
60
+ samePath(focus.path, ancestor) ? focus.listItemIndex : focus.path[ancestor.length],
61
+ ]
62
+ .filter((index) => Number.isInteger(index));
63
+ if (indices.length === 2) {
64
+ return {
65
+ kind: "list",
66
+ listPath: ancestor,
67
+ start: Math.min(...indices),
68
+ end: Math.max(...indices),
69
+ };
70
+ }
71
+ }
72
+ }
73
+ const mixed = [anchor, focus].find((unit) => unit.listItemIndex !== undefined);
74
+ const plain = [anchor, focus].find((unit) => unit.listItemIndex === undefined);
75
+ if (mixed && plain) {
76
+ let outerListPath = null;
77
+ for (let depth = 1; depth <= mixed.path.length; depth += 1) {
78
+ if (getNodeAtPath(document, mixed.path.slice(0, depth))?.type === "list") {
79
+ outerListPath = mixed.path.slice(0, depth);
80
+ break;
81
+ }
82
+ }
83
+ if (!outerListPath || !samePath(outerListPath.slice(0, -1), plain.path.slice(0, -1)))
84
+ return { kind: "none" };
85
+ return {
86
+ kind: "mixed",
87
+ containerPath: plain.path.slice(0, -1),
88
+ blockIndex: plain.path[plain.path.length - 1],
89
+ listPath: outerListPath,
90
+ itemStart: mixed.path[outerListPath.length],
91
+ itemEnd: mixed.path[outerListPath.length],
92
+ };
93
+ }
94
+ const anchorParent = anchor.path.slice(0, -1);
95
+ const focusParent = focus.path.slice(0, -1);
96
+ if (!samePath(anchorParent, focusParent))
97
+ return { kind: "none" };
98
+ return {
99
+ kind: "blocks",
100
+ containerPath: anchorParent,
101
+ start: Math.min(anchor.path[anchor.path.length - 1], focus.path[focus.path.length - 1]),
102
+ end: Math.max(anchor.path[anchor.path.length - 1], focus.path[focus.path.length - 1]),
103
+ };
104
+ };
@@ -5,3 +5,5 @@
5
5
  * indentation and table syntax that no HTML repair pass can recover once lost.
6
6
  */
7
7
  export declare const markdownToCompatibilityHtml: (markdown: string) => string;
8
+ /** Converts canonical HTML to portable GFM with Smart RTE formula syntax. */
9
+ export declare const compatibilityHtmlToMarkdown: (html: string) => string;
@@ -4,6 +4,19 @@ import remarkParse from "remark-parse";
4
4
  import remarkRehype from "remark-rehype";
5
5
  import { unified } from "unified";
6
6
  import { normalizeCompatibilityHtml } from "../html/compatibility.js";
7
+ import { parseCompatibilityHtml } from "../html/compatibility.js";
8
+ const escapeAttribute = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
9
+ const extractFormulaPlaceholders = (markdown) => {
10
+ const formulas = [];
11
+ const source = markdown.replace(/\$\$([\s\S]+?)\$\$|\$([^$\n]+?)\$/g, (_match, block, inline) => {
12
+ const value = String(block ?? inline ?? "").trim();
13
+ if (!value)
14
+ return _match;
15
+ const index = formulas.push(value) - 1;
16
+ return `SMART_RTE_FORMULA_${index}_TOKEN`;
17
+ });
18
+ return { source, formulas };
19
+ };
7
20
  /**
8
21
  * Converts CommonMark/GFM input to canonical Smart RTE HTML.
9
22
  *
@@ -11,11 +24,90 @@ import { normalizeCompatibilityHtml } from "../html/compatibility.js";
11
24
  * indentation and table syntax that no HTML repair pass can recover once lost.
12
25
  */
13
26
  export const markdownToCompatibilityHtml = (markdown) => {
27
+ const { source, formulas } = extractFormulaPlaceholders(markdown);
14
28
  const html = String(unified()
15
29
  .use(remarkParse)
16
30
  .use(remarkGfm)
17
31
  .use(remarkRehype)
18
32
  .use(rehypeStringify)
19
- .processSync(markdown));
20
- return normalizeCompatibilityHtml(html);
33
+ .processSync(source));
34
+ const withFormulas = formulas.reduce((current, formula, index) => current.replace(new RegExp(`SMART_RTE_FORMULA_${index}_TOKEN`, "g"), `<span data-formula="${escapeAttribute(formula)}">$${escapeAttribute(formula)}$</span>`), html);
35
+ const withChecklists = withFormulas
36
+ .replace(/<ul class="contains-task-list">/g, '<ul data-srte-checklist="true">')
37
+ .replace(/<li class="task-list-item"><input type="checkbox"([^>]*)>\s*/g, (_match, attributes) => `<li data-srte-checked="${/\bchecked(?:\s|=|$)/.test(attributes) ? "true" : "false"}">`);
38
+ return normalizeCompatibilityHtml(withChecklists);
39
+ };
40
+ const attr = (node, name) => node.attrs?.find((candidate) => candidate.name === name)?.value || "";
41
+ const markdownEscapeText = (value) => value.replace(/\\/g, "\\\\").replace(/([*_`[\]])/g, "\\$1");
42
+ const descendantsByTag = (node, tagName) => (node.childNodes || []).flatMap((child) => [
43
+ ...(child.tagName === tagName ? [child] : []),
44
+ ...descendantsByTag(child, tagName),
45
+ ]);
46
+ /** Converts canonical HTML to portable GFM with Smart RTE formula syntax. */
47
+ export const compatibilityHtmlToMarkdown = (html) => {
48
+ const { fragment } = parseCompatibilityHtml(html);
49
+ const walk = (node, listDepth = 0) => {
50
+ if (node.nodeName === "#text")
51
+ return markdownEscapeText(node.value || "");
52
+ const tag = node.tagName || "";
53
+ if (tag === "span" && attr(node, "data-formula"))
54
+ return `$${attr(node, "data-formula")}$`;
55
+ if (tag === "img")
56
+ return `![${markdownEscapeText(attr(node, "alt"))}](${attr(node, "src")})`;
57
+ const content = (node.childNodes || []).map((child) => walk(child, listDepth)).join("");
58
+ if (tag === "strong" || tag === "b")
59
+ return `**${content}**`;
60
+ if (tag === "em" || tag === "i")
61
+ return `*${content}*`;
62
+ if (tag === "s" || tag === "del" || tag === "strike")
63
+ return `~~${content}~~`;
64
+ if (tag === "code")
65
+ return `\`${content}\``;
66
+ if (tag === "a")
67
+ return `[${content}](${attr(node, "href")})`;
68
+ if (tag === "br")
69
+ return " \n";
70
+ if (/^h[1-6]$/.test(tag))
71
+ return `${"#".repeat(Number(tag.slice(1)))} ${content.trim()}\n\n`;
72
+ if (tag === "p")
73
+ return `${content.trim()}\n\n`;
74
+ if (tag === "blockquote") {
75
+ return `${content.trim().split("\n").map((line) => `> ${line}`).join("\n")}\n\n`;
76
+ }
77
+ if (tag === "li") {
78
+ return `${" ".repeat(listDepth)}- ${content.trim()}\n`;
79
+ }
80
+ if (tag === "ul" || tag === "ol") {
81
+ const ordered = tag === "ol";
82
+ const checklist = attr(node, "data-srte-checklist") === "true";
83
+ return (node.childNodes || []).map((child, index) => {
84
+ if (child.tagName !== "li")
85
+ return walk(child, listDepth + 1);
86
+ const item = (child.childNodes || []).map((nested) => walk(nested, listDepth + 1)).join("").trim();
87
+ const marker = checklist
88
+ ? `- [${attr(child, "data-srte-checked") === "true" ? "x" : " "}]`
89
+ : ordered ? `${index + 1}.` : "-";
90
+ return `${" ".repeat(listDepth)}${marker} ${item}\n`;
91
+ }).join("") + (listDepth === 0 ? "\n" : "");
92
+ }
93
+ if (tag === "table") {
94
+ const rows = descendantsByTag(node, "tr").map((row) => (row.childNodes || [])
95
+ .filter((cell) => cell.tagName === "td" || cell.tagName === "th")
96
+ .map((cell) => (cell.childNodes || []).map((child) => walk(child, listDepth)).join("")
97
+ .replace(/\n+/g, " ").trim().replace(/\|/g, "\\|")));
98
+ if (!rows.length)
99
+ return "";
100
+ const columns = Math.max(...rows.map((row) => row.length));
101
+ const normalized = rows.map((row) => [...row, ...Array(Math.max(0, columns - row.length)).fill("")]);
102
+ return [
103
+ `| ${normalized[0].join(" | ")} |`,
104
+ `| ${Array(columns).fill("---").join(" | ")} |`,
105
+ ...normalized.slice(1).map((row) => `| ${row.join(" | ")} |`),
106
+ "",
107
+ "",
108
+ ].join("\n");
109
+ }
110
+ return content;
111
+ };
112
+ return walk(fragment).replace(/\n{3,}/g, "\n\n").trim();
21
113
  };
package/dist/marks.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { SmartMark } from "./model.js";
2
- export type InlineMarkType = Extract<SmartMark, {
1
+ import type { LegacySmartMark } from "./model.js";
2
+ export type InlineMarkType = Extract<LegacySmartMark, {
3
3
  type: string;
4
4
  }>['type'];
5
- export declare const hasMark: (marks: readonly SmartMark[] | undefined, type: InlineMarkType) => boolean;
6
- export declare const addMark: (marks: readonly SmartMark[] | undefined, mark: SmartMark) => SmartMark[];
7
- export declare const removeMark: (marks: readonly SmartMark[] | undefined, type: InlineMarkType) => SmartMark[] | undefined;
5
+ export declare const hasMark: (marks: readonly LegacySmartMark[] | undefined, type: InlineMarkType) => boolean;
6
+ export declare const addMark: (marks: readonly LegacySmartMark[] | undefined, mark: LegacySmartMark) => LegacySmartMark[];
7
+ export declare const removeMark: (marks: readonly LegacySmartMark[] | undefined, type: InlineMarkType) => LegacySmartMark[] | undefined;
package/dist/model.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type Path = readonly number[];
2
2
  export type TextAlignment = "left" | "center" | "right" | "justify";
3
- export type SmartMark = {
3
+ export type LegacySmartMark = {
4
4
  type: "bold";
5
5
  } | {
6
6
  type: "italic";
@@ -23,45 +23,95 @@ export type SmartMark = {
23
23
  } | {
24
24
  type: "fontSize";
25
25
  valuePx: number;
26
+ } | {
27
+ type: "fontFamily";
28
+ value: string;
29
+ } | {
30
+ type: "formula";
31
+ value: string;
26
32
  } | {
27
33
  type: "link";
28
34
  href: string;
29
35
  target?: string;
30
36
  };
31
- export interface SmartTextNode {
37
+ export interface LegacySmartTextNode {
32
38
  type: "text";
33
39
  text: string;
34
- marks?: SmartMark[];
40
+ marks?: LegacySmartMark[];
35
41
  }
42
+ /** An indivisible inline node. Text commands must treat these as length-one atoms. */
43
+ export interface SmartFormulaNode {
44
+ type: "formula";
45
+ value: string;
46
+ displayText?: string;
47
+ }
48
+ export interface SmartInlineImageNode {
49
+ type: "inlineImage";
50
+ src: string;
51
+ alt?: string;
52
+ title?: string;
53
+ width?: number;
54
+ height?: number;
55
+ }
56
+ export type SmartInlineNode = LegacySmartTextNode | SmartFormulaNode | SmartInlineImageNode;
36
57
  export interface SmartParagraphNode {
37
58
  type: "paragraph";
38
59
  alignment?: TextAlignment;
39
- children: SmartTextNode[];
60
+ indent?: number;
61
+ children: SmartInlineNode[];
40
62
  }
41
63
  export interface SmartHeadingNode {
42
64
  type: "heading";
43
65
  level: 1 | 2 | 3 | 4 | 5 | 6;
44
66
  alignment?: TextAlignment;
45
- children: SmartTextNode[];
67
+ indent?: number;
68
+ children: SmartInlineNode[];
46
69
  }
47
70
  export interface SmartListItemNode {
48
71
  type: "listItem";
49
72
  alignment?: TextAlignment;
73
+ checked?: boolean;
50
74
  children: SmartBlockNode[];
51
75
  }
76
+ export type SmartListStyle = "disc" | "circle" | "square" | "decimal" | "decimal-leading-zero" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
77
+ export type SmartListPreset = "bullet-disc" | "bullet-diamond" | "bullet-square" | "bullet-arrow" | "bullet-star" | "bullet-arrow-circle" | "ordered-decimal" | "ordered-decimal-paren" | "ordered-outline" | "ordered-upper-alpha" | "ordered-upper-roman" | "ordered-leading-zero";
52
78
  export interface SmartListNode {
53
79
  type: "list";
54
- style: "disc" | "circle" | "square" | "decimal" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
80
+ indent?: number;
81
+ style: SmartListStyle;
82
+ /** Marker family applied to this list hierarchy. `style` remains the portable fallback. */
83
+ preset?: SmartListPreset;
84
+ checklist?: boolean;
85
+ strikeCompleted?: boolean;
55
86
  children: SmartListItemNode[];
56
87
  }
88
+ export interface SmartImageNode {
89
+ type: "image";
90
+ indent?: number;
91
+ src: string;
92
+ alt?: string;
93
+ title?: string;
94
+ width?: number;
95
+ height?: number;
96
+ }
97
+ export interface SmartMediaNode {
98
+ type: "media";
99
+ indent?: number;
100
+ src: string;
101
+ mediaType: "audio" | "video" | "file";
102
+ title?: string;
103
+ mimeType?: string;
104
+ }
57
105
  export interface SmartBlockquoteNode {
58
106
  type: "blockquote";
59
107
  alignment?: TextAlignment;
108
+ indent?: number;
60
109
  children: SmartBlockNode[];
61
110
  }
62
111
  export interface SmartCodeBlockNode {
63
112
  type: "codeBlock";
64
113
  alignment?: TextAlignment;
114
+ indent?: number;
65
115
  text: string;
66
116
  language?: string;
67
117
  }
@@ -69,20 +119,26 @@ export interface SmartTableCellNode {
69
119
  type: "tableCell" | "tableHeaderCell";
70
120
  colspan?: number;
71
121
  rowspan?: number;
122
+ backgroundColor?: string;
123
+ textColor?: string;
124
+ border?: string;
72
125
  children: SmartBlockNode[];
73
126
  }
74
127
  export interface SmartTableRowNode {
75
128
  type: "tableRow";
129
+ heightPx?: number;
76
130
  children: SmartTableCellNode[];
77
131
  }
78
132
  export interface SmartTableNode {
79
133
  type: "table";
134
+ indent?: number;
135
+ columnWidths?: number[];
80
136
  children: SmartTableRowNode[];
81
137
  }
82
- export type SmartBlockNode = SmartParagraphNode | SmartHeadingNode | SmartListNode | SmartBlockquoteNode | SmartCodeBlockNode | SmartTableNode;
83
- export interface SmartDocument {
138
+ export type SmartBlockNode = SmartParagraphNode | SmartHeadingNode | SmartListNode | SmartBlockquoteNode | SmartCodeBlockNode | SmartImageNode | SmartMediaNode | SmartTableNode;
139
+ export interface LegacySmartDocument {
84
140
  type: "doc";
85
141
  children: SmartBlockNode[];
86
142
  }
87
143
  export declare const paragraph: (text?: string) => SmartParagraphNode;
88
- export declare const getNodeAtPath: (document: SmartDocument, path: Path) => unknown;
144
+ export declare const getNodeAtPath: (document: LegacySmartDocument, path: Path) => unknown;
@@ -0,0 +1,15 @@
1
+ import type { SmartCommand } from "./command.js";
2
+ import type { LegacySmartDocument } from "./model.js";
3
+ import type { SmartSchemaExtension } from "./schema.js";
4
+ import type { LegacySmartTransaction } from "./transaction.js";
5
+ export type SmartPluginCommand = SmartCommand<any>;
6
+ export type SmartNormalizer = (document: LegacySmartDocument) => LegacySmartDocument;
7
+ export interface SmartRtePlugin {
8
+ id: string;
9
+ dependencies?: string[];
10
+ commands?: Record<string, SmartPluginCommand>;
11
+ schema?: Omit<SmartSchemaExtension, "id">;
12
+ normalizers?: SmartNormalizer[];
13
+ onTransaction?: (transaction: LegacySmartTransaction) => void;
14
+ }
15
+ export declare const orderPlugins: (plugins: readonly SmartRtePlugin[]) => SmartRtePlugin[];
package/dist/plugin.js ADDED
@@ -0,0 +1,31 @@
1
+ export const orderPlugins = (plugins) => {
2
+ const byId = new Map();
3
+ plugins.forEach((plugin) => {
4
+ if (!plugin.id.trim())
5
+ throw new Error("Plugin id cannot be empty.");
6
+ if (byId.has(plugin.id))
7
+ throw new Error(`Duplicate plugin id "${plugin.id}".`);
8
+ byId.set(plugin.id, plugin);
9
+ });
10
+ const ordered = [];
11
+ const visiting = new Set();
12
+ const visited = new Set();
13
+ const visit = (plugin) => {
14
+ if (visited.has(plugin.id))
15
+ return;
16
+ if (visiting.has(plugin.id))
17
+ throw new Error(`Circular plugin dependency involving "${plugin.id}".`);
18
+ visiting.add(plugin.id);
19
+ (plugin.dependencies || []).forEach((dependency) => {
20
+ const required = byId.get(dependency);
21
+ if (!required)
22
+ throw new Error(`Plugin "${plugin.id}" requires missing plugin "${dependency}".`);
23
+ visit(required);
24
+ });
25
+ visiting.delete(plugin.id);
26
+ visited.add(plugin.id);
27
+ ordered.push(plugin);
28
+ };
29
+ plugins.forEach(visit);
30
+ return ordered;
31
+ };
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createAlignmentPlugin: () => SmartRtePlugin;
3
+ export declare const alignmentPlugin: SmartRtePlugin;
@@ -0,0 +1,6 @@
1
+ import { setAlignment } from "../legacyCommands/alignment.js";
2
+ export const createAlignmentPlugin = () => ({
3
+ id: "alignment",
4
+ commands: { [setAlignment.id]: setAlignment },
5
+ });
6
+ export const alignmentPlugin = createAlignmentPlugin();
@@ -0,0 +1,9 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ /**
3
+ * Inline formatting as an independently selectable feature bundle.
4
+ *
5
+ * Applications may use the singleton or create a fresh plugin descriptor when
6
+ * composing an editor preset. Commands remain model-only and UI-framework-free.
7
+ */
8
+ export declare const createBasicFormattingPlugin: () => SmartRtePlugin;
9
+ export declare const basicFormattingPlugin: SmartRtePlugin;
@@ -0,0 +1,24 @@
1
+ import { applyBackgroundColor, applyFontSize, applyFontFamily, applyTextColor, toggleBold, toggleInlineCode, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, } from "../legacyCommands/marks.js";
2
+ /**
3
+ * Inline formatting as an independently selectable feature bundle.
4
+ *
5
+ * Applications may use the singleton or create a fresh plugin descriptor when
6
+ * composing an editor preset. Commands remain model-only and UI-framework-free.
7
+ */
8
+ export const createBasicFormattingPlugin = () => ({
9
+ id: "basic-formatting",
10
+ commands: {
11
+ [toggleBold.id]: toggleBold,
12
+ [toggleItalic.id]: toggleItalic,
13
+ [toggleUnderline.id]: toggleUnderline,
14
+ [toggleStrike.id]: toggleStrike,
15
+ [toggleInlineCode.id]: toggleInlineCode,
16
+ [toggleSuperscript.id]: toggleSuperscript,
17
+ [toggleSubscript.id]: toggleSubscript,
18
+ [applyTextColor.id]: applyTextColor,
19
+ [applyBackgroundColor.id]: applyBackgroundColor,
20
+ [applyFontSize.id]: applyFontSize,
21
+ [applyFontFamily.id]: applyFontFamily,
22
+ },
23
+ });
24
+ export const basicFormattingPlugin = createBasicFormattingPlugin();
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createBlockTypePlugin: () => SmartRtePlugin;
3
+ export declare const blockTypePlugin: SmartRtePlugin;
@@ -0,0 +1,6 @@
1
+ import { setBlockType } from "../legacyCommands/blocks.js";
2
+ export const createBlockTypePlugin = () => ({
3
+ id: "block-type",
4
+ commands: { [setBlockType.id]: setBlockType },
5
+ });
6
+ export const blockTypePlugin = createBlockTypePlugin();
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createBlockquotePlugin: () => SmartRtePlugin;
3
+ export declare const blockquotePlugin: SmartRtePlugin;
@@ -0,0 +1,6 @@
1
+ import { toggleBlockquote } from "../legacyCommands/blocks.js";
2
+ export const createBlockquotePlugin = () => ({
3
+ id: "blockquote",
4
+ commands: { [toggleBlockquote.id]: toggleBlockquote },
5
+ });
6
+ export const blockquotePlugin = createBlockquotePlugin();
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createChecklistPlugin: () => SmartRtePlugin;
3
+ export declare const checklistPlugin: SmartRtePlugin;
@@ -0,0 +1,10 @@
1
+ import { setChecklistItemChecked, toggleChecklist } from "../legacyCommands/checklist.js";
2
+ export const createChecklistPlugin = () => ({
3
+ id: "checklist",
4
+ dependencies: ["list"],
5
+ commands: {
6
+ [toggleChecklist.id]: toggleChecklist,
7
+ [setChecklistItemChecked.id]: setChecklistItemChecked,
8
+ },
9
+ });
10
+ export const checklistPlugin = createChecklistPlugin();
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createCodeBlockPlugin: () => SmartRtePlugin;
3
+ export declare const codeBlockPlugin: SmartRtePlugin;
@@ -0,0 +1,6 @@
1
+ import { toggleCodeBlock } from "../legacyCommands/code.js";
2
+ export const createCodeBlockPlugin = () => ({
3
+ id: "code-block",
4
+ commands: { [toggleCodeBlock.id]: toggleCodeBlock },
5
+ });
6
+ export const codeBlockPlugin = createCodeBlockPlugin();
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createFormulaPlugin: () => SmartRtePlugin;
3
+ export declare const formulaPlugin: SmartRtePlugin;
@@ -0,0 +1,9 @@
1
+ import { deleteFormula, insertFormula } from "../legacyCommands/formula.js";
2
+ export const createFormulaPlugin = () => ({
3
+ id: "formula",
4
+ commands: {
5
+ [insertFormula.id]: insertFormula,
6
+ [deleteFormula.id]: deleteFormula,
7
+ },
8
+ });
9
+ export const formulaPlugin = createFormulaPlugin();
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createListPlugin: () => SmartRtePlugin;
3
+ export declare const listPlugin: SmartRtePlugin;
@@ -0,0 +1,10 @@
1
+ import { indentListItems, outdentListItems, toggleList } from "../legacyCommands/list.js";
2
+ export const createListPlugin = () => ({
3
+ id: "list",
4
+ commands: {
5
+ [toggleList.id]: toggleList,
6
+ [indentListItems.id]: indentListItems,
7
+ [outdentListItems.id]: outdentListItems,
8
+ },
9
+ });
10
+ export const listPlugin = createListPlugin();
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createMediaPlugin: () => SmartRtePlugin;
3
+ export declare const mediaPlugin: SmartRtePlugin;
@@ -0,0 +1,12 @@
1
+ import { deleteInlineImage, insertImage, insertInlineImage, insertMedia, updateInlineImage, } from "../legacyCommands/media.js";
2
+ export const createMediaPlugin = () => ({
3
+ id: "media",
4
+ commands: {
5
+ [insertImage.id]: insertImage,
6
+ [insertInlineImage.id]: insertInlineImage,
7
+ [deleteInlineImage.id]: deleteInlineImage,
8
+ [updateInlineImage.id]: updateInlineImage,
9
+ [insertMedia.id]: insertMedia,
10
+ },
11
+ });
12
+ export const mediaPlugin = createMediaPlugin();
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createMovePlugin: () => SmartRtePlugin;
3
+ export declare const movePlugin: SmartRtePlugin;
@@ -0,0 +1,9 @@
1
+ import { indentBlocks, moveBlocks } from "../legacyCommands/move.js";
2
+ export const createMovePlugin = () => ({
3
+ id: "move",
4
+ commands: {
5
+ [moveBlocks.id]: moveBlocks,
6
+ [indentBlocks.id]: indentBlocks,
7
+ },
8
+ });
9
+ export const movePlugin = createMovePlugin();
@@ -0,0 +1,3 @@
1
+ import type { SmartRtePlugin } from "../plugin.js";
2
+ export declare const createTablePlugin: () => SmartRtePlugin;
3
+ export declare const tablePlugin: SmartRtePlugin;
@@ -0,0 +1,22 @@
1
+ import { addTableColumn, addTableRow, insertTable, mergeTableCells, removeTable, removeTableColumn, removeTableRow, setTableCellStyle, setTableColumnWidth, setTableRowHeight, splitTableCell, toggleTableHeaderCell, toggleTableHeaderColumn, toggleTableHeaderRow, toggleTableCellBorder, } from "../legacyCommands/table.js";
2
+ export const createTablePlugin = () => ({
3
+ id: "table",
4
+ commands: {
5
+ [insertTable.id]: insertTable,
6
+ [removeTable.id]: removeTable,
7
+ [addTableRow.id]: addTableRow,
8
+ [removeTableRow.id]: removeTableRow,
9
+ [addTableColumn.id]: addTableColumn,
10
+ [removeTableColumn.id]: removeTableColumn,
11
+ [setTableCellStyle.id]: setTableCellStyle,
12
+ [setTableColumnWidth.id]: setTableColumnWidth,
13
+ [setTableRowHeight.id]: setTableRowHeight,
14
+ [mergeTableCells.id]: mergeTableCells,
15
+ [splitTableCell.id]: splitTableCell,
16
+ [toggleTableHeaderCell.id]: toggleTableHeaderCell,
17
+ [toggleTableHeaderRow.id]: toggleTableHeaderRow,
18
+ [toggleTableHeaderColumn.id]: toggleTableHeaderColumn,
19
+ [toggleTableCellBorder.id]: toggleTableCellBorder,
20
+ },
21
+ });
22
+ export const tablePlugin = createTablePlugin();
@@ -0,0 +1,12 @@
1
+ import type { SmartRtePlugin } from "./plugin.js";
2
+ export type CoreFeatureId = "basicFormatting" | "blockType" | "alignment" | "list" | "checklist" | "blockquote" | "codeBlock" | "table" | "media" | "formula" | "move";
3
+ export type CoreFeatureConfig = Partial<Record<CoreFeatureId, boolean>>;
4
+ /**
5
+ * Creates the standard model plugin set.
6
+ *
7
+ * Features default to enabled. Disabling `list` also disables `checklist`,
8
+ * because checklist commands depend on list structure. Applications can append
9
+ * custom plugins to the returned array before constructing an editor.
10
+ */
11
+ export declare const createCorePlugins: (config?: CoreFeatureConfig) => SmartRtePlugin[];
12
+ export declare const corePlugins: SmartRtePlugin[];