@notectl/core 1.0.5 → 1.0.8

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 (250) hide show
  1. package/README.md +78 -55
  2. package/custom-elements.json +344 -0
  3. package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs → AttrRegistry-D-przlzb.mjs} +4 -4
  4. package/dist/chunks/{AttrRegistry-DTsHyDVA.mjs.map → AttrRegistry-D-przlzb.mjs.map} +1 -1
  5. package/dist/chunks/ColorNames-iaWsSZx1.mjs +35 -0
  6. package/dist/chunks/ColorNames-iaWsSZx1.mjs.map +1 -0
  7. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs +140 -0
  8. package/dist/chunks/ColorValidation-Dyy4Bye8.mjs.map +1 -0
  9. package/dist/chunks/{Commands-DLP85Mp5.mjs → Commands-CSpSwGXv.mjs} +13 -13
  10. package/dist/chunks/{Commands-DLP85Mp5.mjs.map → Commands-CSpSwGXv.mjs.map} +1 -1
  11. package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs +46 -0
  12. package/dist/chunks/ToolbarKeyboardNav-B32OMv8r.mjs.map +1 -0
  13. package/dist/chunks/{ToolbarPlugin-D5VqeBPT.mjs → ToolbarPlugin-DY2xaJiu.mjs} +63 -93
  14. package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +1 -0
  15. package/dist/chunks/index-BAk1EG1x.mjs +541 -0
  16. package/dist/chunks/index-BAk1EG1x.mjs.map +1 -0
  17. package/dist/chunks/index-BRYzYOYC.mjs +63 -0
  18. package/dist/chunks/index-BRYzYOYC.mjs.map +1 -0
  19. package/dist/chunks/index-BSFLNveF.mjs +953 -0
  20. package/dist/chunks/index-BSFLNveF.mjs.map +1 -0
  21. package/dist/chunks/index-BYgspns5.mjs +209 -0
  22. package/dist/chunks/index-BYgspns5.mjs.map +1 -0
  23. package/dist/chunks/index-B_3qDrUN.mjs +64 -0
  24. package/dist/chunks/index-B_3qDrUN.mjs.map +1 -0
  25. package/dist/chunks/index-Bsp4LC5t.mjs +130 -0
  26. package/dist/chunks/index-Bsp4LC5t.mjs.map +1 -0
  27. package/dist/chunks/index-C-YWHOcC.mjs +100 -0
  28. package/dist/chunks/index-C-YWHOcC.mjs.map +1 -0
  29. package/dist/chunks/index-C2GQoHot.mjs +92 -0
  30. package/dist/chunks/index-C2GQoHot.mjs.map +1 -0
  31. package/dist/chunks/index-CT3HGdQt.mjs +39 -0
  32. package/dist/chunks/index-CT3HGdQt.mjs.map +1 -0
  33. package/dist/chunks/index-Ct0ivLhO.mjs +407 -0
  34. package/dist/chunks/index-Ct0ivLhO.mjs.map +1 -0
  35. package/dist/chunks/index-CxiWyUho.mjs +191 -0
  36. package/dist/chunks/index-CxiWyUho.mjs.map +1 -0
  37. package/dist/chunks/index-D3CQWJiw.mjs +200 -0
  38. package/dist/chunks/index-D3CQWJiw.mjs.map +1 -0
  39. package/dist/chunks/index-DC1EK22F.mjs +41 -0
  40. package/dist/chunks/index-DC1EK22F.mjs.map +1 -0
  41. package/dist/chunks/index-Dh76rR13.mjs +196 -0
  42. package/dist/chunks/index-Dh76rR13.mjs.map +1 -0
  43. package/dist/chunks/index-o6hDR07y.mjs +41 -0
  44. package/dist/chunks/index-o6hDR07y.mjs.map +1 -0
  45. package/dist/chunks/index-uTnc9y7M.mjs +62 -0
  46. package/dist/chunks/index-uTnc9y7M.mjs.map +1 -0
  47. package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs +34 -0
  48. package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -0
  49. package/dist/editor/EditorDOM.d.ts.map +1 -1
  50. package/dist/editor/NotectlEditor.d.ts +15 -1
  51. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  52. package/dist/editor/PaperLayoutController.d.ts +27 -0
  53. package/dist/editor/PaperLayoutController.d.ts.map +1 -0
  54. package/dist/editor/PaperSize.d.ts +35 -0
  55. package/dist/editor/PaperSize.d.ts.map +1 -0
  56. package/dist/editor/styles/color-picker.d.ts +1 -1
  57. package/dist/editor/styles/color-picker.d.ts.map +1 -1
  58. package/dist/editor/styles/paper.d.ts +3 -0
  59. package/dist/editor/styles/paper.d.ts.map +1 -0
  60. package/dist/editor/styles/table.d.ts +1 -1
  61. package/dist/editor/styles/table.d.ts.map +1 -1
  62. package/dist/editor/styles/toolbar.d.ts +1 -1
  63. package/dist/editor/styles/toolbar.d.ts.map +1 -1
  64. package/dist/editor/styles.d.ts.map +1 -1
  65. package/dist/i18n/Locale.d.ts +17 -0
  66. package/dist/i18n/Locale.d.ts.map +1 -0
  67. package/dist/i18n/LocaleService.d.ts +8 -0
  68. package/dist/i18n/LocaleService.d.ts.map +1 -0
  69. package/dist/i18n/index.d.ts +4 -0
  70. package/dist/i18n/index.d.ts.map +1 -0
  71. package/dist/i18n/resolvePluginLocale.d.ts +3 -0
  72. package/dist/i18n/resolvePluginLocale.d.ts.map +1 -0
  73. package/dist/index.d.ts +44 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/input/ClipboardHandler.d.ts.map +1 -1
  76. package/dist/input/InputHandler.d.ts.map +1 -1
  77. package/dist/input/KeyboardHandler.d.ts.map +1 -1
  78. package/dist/input/PasteHandler.d.ts.map +1 -1
  79. package/dist/notectl-core.mjs +1145 -837
  80. package/dist/notectl-core.mjs.map +1 -1
  81. package/dist/notectl-core.umd.js +2368 -1826
  82. package/dist/notectl-core.umd.js.map +1 -1
  83. package/dist/plugins/PluginManager.d.ts +8 -1
  84. package/dist/plugins/PluginManager.d.ts.map +1 -1
  85. package/dist/plugins/alignment/AlignmentLocale.d.ts +19 -0
  86. package/dist/plugins/alignment/AlignmentLocale.d.ts.map +1 -0
  87. package/dist/plugins/alignment/AlignmentPlugin.d.ts +4 -0
  88. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
  89. package/dist/plugins/alignment.mjs +3 -89
  90. package/dist/plugins/alignment.mjs.map +1 -1
  91. package/dist/plugins/blockquote/BlockquoteLocale.d.ts +17 -0
  92. package/dist/plugins/blockquote/BlockquoteLocale.d.ts.map +1 -0
  93. package/dist/plugins/blockquote/BlockquotePlugin.d.ts +3 -0
  94. package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -1
  95. package/dist/plugins/blockquote.mjs +2 -55
  96. package/dist/plugins/blockquote.mjs.map +1 -1
  97. package/dist/plugins/code-block/CodeBlockCommands.d.ts +5 -0
  98. package/dist/plugins/code-block/CodeBlockCommands.d.ts.map +1 -0
  99. package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts +10 -0
  100. package/dist/plugins/code-block/CodeBlockKeyboardHandlers.d.ts.map +1 -0
  101. package/dist/plugins/code-block/CodeBlockLocale.d.ts +17 -0
  102. package/dist/plugins/code-block/CodeBlockLocale.d.ts.map +1 -0
  103. package/dist/plugins/code-block/CodeBlockNodeView.d.ts +1 -1
  104. package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
  105. package/dist/plugins/code-block/CodeBlockPlugin.d.ts +4 -111
  106. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
  107. package/dist/plugins/code-block/CodeBlockService.d.ts +5 -0
  108. package/dist/plugins/code-block/CodeBlockService.d.ts.map +1 -0
  109. package/dist/plugins/code-block/CodeBlockTypes.d.ts +71 -0
  110. package/dist/plugins/code-block/CodeBlockTypes.d.ts.map +1 -0
  111. package/dist/plugins/code-block.mjs +3 -3
  112. package/dist/plugins/font/FontLocale.d.ts +15 -0
  113. package/dist/plugins/font/FontLocale.d.ts.map +1 -0
  114. package/dist/plugins/font/FontPlugin.d.ts +3 -0
  115. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  116. package/dist/plugins/font-size/FontSizeLocale.d.ts +17 -0
  117. package/dist/plugins/font-size/FontSizeLocale.d.ts.map +1 -0
  118. package/dist/plugins/font-size/FontSizeOperations.d.ts +22 -0
  119. package/dist/plugins/font-size/FontSizeOperations.d.ts.map +1 -0
  120. package/dist/plugins/font-size/FontSizePlugin.d.ts +4 -10
  121. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  122. package/dist/plugins/font-size/FontSizePopup.d.ts +11 -0
  123. package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -0
  124. package/dist/plugins/font-size.mjs +2 -217
  125. package/dist/plugins/font-size.mjs.map +1 -1
  126. package/dist/plugins/font.mjs +2 -183
  127. package/dist/plugins/font.mjs.map +1 -1
  128. package/dist/plugins/hard-break.mjs +1 -1
  129. package/dist/plugins/heading/HeadingLocale.d.ts +26 -0
  130. package/dist/plugins/heading/HeadingLocale.d.ts.map +1 -0
  131. package/dist/plugins/heading/HeadingPlugin.d.ts +4 -0
  132. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
  133. package/dist/plugins/heading.mjs +1 -184
  134. package/dist/plugins/heading.mjs.map +1 -1
  135. package/dist/plugins/highlight/HighlightLocale.d.ts +17 -0
  136. package/dist/plugins/highlight/HighlightLocale.d.ts.map +1 -0
  137. package/dist/plugins/highlight/HighlightPlugin.d.ts +3 -5
  138. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
  139. package/dist/plugins/highlight.mjs +2 -123
  140. package/dist/plugins/highlight.mjs.map +1 -1
  141. package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts +15 -0
  142. package/dist/plugins/horizontal-rule/HorizontalRuleLocale.d.ts.map +1 -0
  143. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +4 -0
  144. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -1
  145. package/dist/plugins/horizontal-rule.mjs +2 -56
  146. package/dist/plugins/horizontal-rule.mjs.map +1 -1
  147. package/dist/plugins/image/ImageLocale.d.ts +25 -0
  148. package/dist/plugins/image/ImageLocale.d.ts.map +1 -0
  149. package/dist/plugins/image/ImageNodeView.d.ts.map +1 -1
  150. package/dist/plugins/image/ImagePlugin.d.ts +1 -0
  151. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  152. package/dist/plugins/image/ImageUpload.d.ts +3 -0
  153. package/dist/plugins/image/ImageUpload.d.ts.map +1 -1
  154. package/dist/plugins/image.mjs +4 -378
  155. package/dist/plugins/image.mjs.map +1 -1
  156. package/dist/plugins/link/LinkLocale.d.ts +23 -0
  157. package/dist/plugins/link/LinkLocale.d.ts.map +1 -0
  158. package/dist/plugins/link/LinkPlugin.d.ts +3 -0
  159. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -1
  160. package/dist/plugins/link.mjs +2 -124
  161. package/dist/plugins/link.mjs.map +1 -1
  162. package/dist/plugins/list/ListLocale.d.ts +18 -0
  163. package/dist/plugins/list/ListLocale.d.ts.map +1 -0
  164. package/dist/plugins/list/ListPlugin.d.ts +4 -0
  165. package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
  166. package/dist/plugins/list.mjs +2 -190
  167. package/dist/plugins/list.mjs.map +1 -1
  168. package/dist/plugins/print/PrintContentPreparer.d.ts +12 -0
  169. package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -0
  170. package/dist/plugins/print/PrintLocale.d.ts +16 -0
  171. package/dist/plugins/print/PrintLocale.d.ts.map +1 -0
  172. package/dist/plugins/print/PrintPlugin.d.ts +13 -0
  173. package/dist/plugins/print/PrintPlugin.d.ts.map +1 -0
  174. package/dist/plugins/print/PrintServiceImpl.d.ts +7 -0
  175. package/dist/plugins/print/PrintServiceImpl.d.ts.map +1 -0
  176. package/dist/plugins/print/PrintStyleCollector.d.ts +17 -0
  177. package/dist/plugins/print/PrintStyleCollector.d.ts.map +1 -0
  178. package/dist/plugins/print/PrintTypes.d.ts +61 -0
  179. package/dist/plugins/print/PrintTypes.d.ts.map +1 -0
  180. package/dist/plugins/shared/ColorMarkOperations.d.ts +28 -0
  181. package/dist/plugins/shared/ColorMarkOperations.d.ts.map +1 -0
  182. package/dist/plugins/shared/ColorNames.d.ts +22 -0
  183. package/dist/plugins/shared/ColorNames.d.ts.map +1 -0
  184. package/dist/plugins/shared/ColorPickerPopup.d.ts +31 -0
  185. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -0
  186. package/dist/plugins/shared/ColorValidation.d.ts +14 -0
  187. package/dist/plugins/shared/ColorValidation.d.ts.map +1 -0
  188. package/dist/plugins/strikethrough/StrikethroughLocale.d.ts +17 -0
  189. package/dist/plugins/strikethrough/StrikethroughLocale.d.ts.map +1 -0
  190. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +3 -0
  191. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
  192. package/dist/plugins/strikethrough.mjs +2 -32
  193. package/dist/plugins/strikethrough.mjs.map +1 -1
  194. package/dist/plugins/super-sub/SuperSubLocale.d.ts +19 -0
  195. package/dist/plugins/super-sub/SuperSubLocale.d.ts.map +1 -0
  196. package/dist/plugins/super-sub/SuperSubPlugin.d.ts +3 -0
  197. package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
  198. package/dist/plugins/super-sub.mjs +2 -78
  199. package/dist/plugins/super-sub.mjs.map +1 -1
  200. package/dist/plugins/table/TableBorderColor.d.ts +24 -0
  201. package/dist/plugins/table/TableBorderColor.d.ts.map +1 -0
  202. package/dist/plugins/table/TableCommands.d.ts +9 -8
  203. package/dist/plugins/table/TableCommands.d.ts.map +1 -1
  204. package/dist/plugins/table/TableContextMenu.d.ts +14 -0
  205. package/dist/plugins/table/TableContextMenu.d.ts.map +1 -0
  206. package/dist/plugins/table/TableControls.d.ts +3 -1
  207. package/dist/plugins/table/TableControls.d.ts.map +1 -1
  208. package/dist/plugins/table/TableControlsDOM.d.ts +13 -1
  209. package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
  210. package/dist/plugins/table/TableLocale.d.ts +48 -0
  211. package/dist/plugins/table/TableLocale.d.ts.map +1 -0
  212. package/dist/plugins/table/TableNavigation.d.ts +2 -1
  213. package/dist/plugins/table/TableNavigation.d.ts.map +1 -1
  214. package/dist/plugins/table/TableNodeViews.d.ts +3 -1
  215. package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
  216. package/dist/plugins/table/TablePlugin.d.ts +7 -1
  217. package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
  218. package/dist/plugins/table/index.d.ts +3 -0
  219. package/dist/plugins/table/index.d.ts.map +1 -1
  220. package/dist/plugins/table.mjs +18 -660
  221. package/dist/plugins/table.mjs.map +1 -1
  222. package/dist/plugins/text-color/TextColorLocale.d.ts +17 -0
  223. package/dist/plugins/text-color/TextColorLocale.d.ts.map +1 -0
  224. package/dist/plugins/text-color/TextColorPlugin.d.ts +3 -5
  225. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
  226. package/dist/plugins/text-color.mjs +2 -123
  227. package/dist/plugins/text-color.mjs.map +1 -1
  228. package/dist/plugins/text-formatting/TextFormattingLocale.d.ts +18 -0
  229. package/dist/plugins/text-formatting/TextFormattingLocale.d.ts.map +1 -0
  230. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +4 -0
  231. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
  232. package/dist/plugins/text-formatting.mjs +2 -49
  233. package/dist/plugins/text-formatting.mjs.map +1 -1
  234. package/dist/plugins/toolbar/ToolbarLocale.d.ts +14 -0
  235. package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -0
  236. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +1 -0
  237. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
  238. package/dist/plugins/toolbar.mjs +1 -1
  239. package/dist/state/EditorState.d.ts +4 -1
  240. package/dist/state/EditorState.d.ts.map +1 -1
  241. package/dist/view/EditorView.d.ts.map +1 -1
  242. package/dist/view/Reconciler.d.ts.map +1 -1
  243. package/package.json +3 -2
  244. package/dist/chunks/Plugin-B9OZ6Y4c.mjs +0 -15
  245. package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +0 -1
  246. package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs.map +0 -1
  247. package/dist/chunks/color-picker-Csf0wx5a.mjs +0 -5
  248. package/dist/chunks/color-picker-Csf0wx5a.mjs.map +0 -1
  249. package/dist/chunks/index-CPPb-Jah.mjs +0 -569
  250. package/dist/chunks/index-CPPb-Jah.mjs.map +0 -1
@@ -2,7 +2,7 @@ import { DecorationSet } from '../decorations/Decoration.js';
2
2
  import { SchemaRegistry } from '../model/SchemaRegistry.js';
3
3
  import { EditorState } from '../state/EditorState.js';
4
4
  import { Transaction } from '../state/Transaction.js';
5
- import { Plugin, PluginConfig, ServiceKey } from './Plugin.js';
5
+ import { EventKey, Plugin, PluginConfig, PluginEventCallback, ServiceKey } from './Plugin.js';
6
6
  export interface PluginManagerInitOptions {
7
7
  getState(): EditorState;
8
8
  dispatch(transaction: Transaction): void;
@@ -26,6 +26,11 @@ export declare class PluginManager {
26
26
  private initOrder;
27
27
  private initialized;
28
28
  private initializing;
29
+ /**
30
+ * Registers a system-level service before plugin init.
31
+ * Used by the editor to provide global services (e.g. LocaleService).
32
+ */
33
+ registerService<T>(key: ServiceKey<T>, service: T): void;
29
34
  /** Registers a plugin. Must be called before init(). */
30
35
  register(plugin: Plugin): void;
31
36
  /** Initializes all registered plugins in dependency/priority order. */
@@ -49,6 +54,8 @@ export declare class PluginManager {
49
54
  get(id: string): Plugin | undefined;
50
55
  /** Gets a registered service by typed key. */
51
56
  getService<T>(key: ServiceKey<T>): T | undefined;
57
+ /** Subscribes to a plugin event from outside the plugin system. Returns an unsubscribe function. */
58
+ onEvent<T>(key: EventKey<T>, callback: PluginEventCallback<T>): () => void;
52
59
  /** Returns all plugin-registered stylesheets. */
53
60
  getPluginStyleSheets(): readonly CSSStyleSheet[];
54
61
  /** Destroys all plugins in reverse init order. */
@@ -1 +1 @@
1
- {"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../src/plugins/PluginManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,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AAO,CAAC,aAAa;IA4IrB;;;OAGG;IACH,OAAO,CAAC,YAAY;CAgEpB"}
@@ -0,0 +1,19 @@
1
+ /** Locale interface and default English locale for the AlignmentPlugin. */
2
+ export interface AlignmentLocale {
3
+ readonly alignLeft: string;
4
+ readonly alignCenter: string;
5
+ readonly alignRight: string;
6
+ readonly justify: string;
7
+ readonly toolbarLabel: string;
8
+ readonly toolbarTooltip: string;
9
+ }
10
+ export declare const ALIGNMENT_LOCALE_EN: AlignmentLocale;
11
+ export declare const ALIGNMENT_LOCALE_DE: AlignmentLocale;
12
+ export declare const ALIGNMENT_LOCALE_ES: AlignmentLocale;
13
+ export declare const ALIGNMENT_LOCALE_FR: AlignmentLocale;
14
+ export declare const ALIGNMENT_LOCALE_ZH: AlignmentLocale;
15
+ export declare const ALIGNMENT_LOCALE_RU: AlignmentLocale;
16
+ export declare const ALIGNMENT_LOCALE_AR: AlignmentLocale;
17
+ export declare const ALIGNMENT_LOCALE_HI: AlignmentLocale;
18
+ export declare const ALIGNMENT_LOCALES: Record<string, AlignmentLocale>;
19
+ //# sourceMappingURL=AlignmentLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlignmentLocale.d.ts","sourceRoot":"","sources":["../../../src/plugins/alignment/AlignmentLocale.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CAChC;AAID,eAAO,MAAM,mBAAmB,EAAE,eAOjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,eAOjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,eAOjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,eAOjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,eAOjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,eAOjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,eAOjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,eAOjC,CAAC;AAIF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAS7D,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Plugin, PluginContext } from '../Plugin.js';
2
+ import { AlignmentLocale } from './AlignmentLocale.js';
2
3
  export type BlockAlignment = 'left' | 'center' | 'right' | 'justify';
3
4
  export interface AlignmentConfig {
4
5
  /** Which alignments to expose. Defaults to all four. */
@@ -9,6 +10,7 @@ export interface AlignmentConfig {
9
10
  readonly defaults: Readonly<Record<string, BlockAlignment>>;
10
11
  /** When true, a separator is rendered after the toolbar item. */
11
12
  readonly separatorAfter?: boolean;
13
+ readonly locale?: AlignmentLocale;
12
14
  }
13
15
  export declare const ALIGNMENT_ICONS: Readonly<Record<BlockAlignment, string>>;
14
16
  export declare class AlignmentPlugin implements Plugin {
@@ -16,6 +18,7 @@ export declare class AlignmentPlugin implements Plugin {
16
18
  readonly name = "Alignment";
17
19
  readonly priority = 90;
18
20
  private readonly config;
21
+ private locale;
19
22
  private alignableTypes;
20
23
  constructor(config?: Partial<AlignmentConfig>);
21
24
  init(context: PluginContext): void;
@@ -28,6 +31,7 @@ export declare class AlignmentPlugin implements Plugin {
28
31
  private registerCommands;
29
32
  private registerKeymaps;
30
33
  private registerToolbarItem;
34
+ private getAlignmentLabel;
31
35
  /**
32
36
  * Preserves the `align` attribute when other plugins change the block
33
37
  * type (e.g. paragraph → heading) via `setBlockType`, which replaces attrs.
@@ -1 +1 @@
1
- {"version":3,"file":"AlignmentPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/alignment/Al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IA+BtB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,mBAAmB;IAuB3B,OAAO,CAAC,iBAAiB;IAYzB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAyB1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,WAAW;CAInB"}
@@ -1,92 +1,6 @@
1
- import { f as t } from "../chunks/NodeResolver-D68ZLXti.mjs";
2
- import { i as e, f as i } from "../chunks/Selection-D5ZjXoB7.mjs";
3
- const n = { alignments: ["left", "center", "right", "justify"], alignableTypes: ["paragraph", "heading", "title", "subtitle", "table_cell", "image"], defaults: { image: "center" } }, s = { left: "Align Left", center: "Align Center", right: "Align Right", justify: "Justify" }, l = { left: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"/></svg>', center: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"/></svg>', right: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"/></svg>', justify: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zM3 3v2h18V3H3z"/></svg>' };
4
- class o {
5
- id = "alignment";
6
- name = "Alignment";
7
- priority = 90;
8
- config;
9
- alignableTypes;
10
- constructor(t2) {
11
- this.config = { ...n, ...t2, defaults: { ...n.defaults, ...t2?.defaults } };
12
- }
13
- init(t2) {
14
- this.alignableTypes = new Set(this.config.alignableTypes), this.patchNodeSpecs(t2), this.registerCommands(t2), this.registerKeymaps(t2), this.registerToolbarItem(t2), this.registerMiddleware(t2);
15
- }
16
- patchNodeSpecs(t2) {
17
- const e2 = t2.getSchemaRegistry();
18
- for (const t3 of this.config.alignableTypes) {
19
- const i2 = e2.getNodeSpec(t3);
20
- if (!i2) continue;
21
- if (i2.attrs?.align) continue;
22
- const n2 = i2.toDOM, s2 = this.config.defaults[t3] ?? "left";
23
- e2.removeNodeSpec(t3), e2.registerNodeSpec({ ...i2, attrs: { ...i2.attrs, align: { default: s2 } }, toDOM(t4) {
24
- const e3 = n2.call(i2, t4);
25
- return a(e3, t4), e3;
26
- } });
27
- }
28
- }
29
- registerCommands(t2) {
30
- for (const e2 of this.config.alignments) t2.registerCommand(`align${r(e2)}`, () => this.setAlignment(t2, e2));
31
- }
32
- registerKeymaps(t2) {
33
- const e2 = {};
34
- this.config.alignments.includes("left") && (e2["Mod-Shift-L"] = () => t2.executeCommand("alignLeft")), this.config.alignments.includes("center") && (e2["Mod-Shift-E"] = () => t2.executeCommand("alignCenter")), this.config.alignments.includes("right") && (e2["Mod-Shift-R"] = () => t2.executeCommand("alignRight")), this.config.alignments.includes("justify") && (e2["Mod-Shift-J"] = () => t2.executeCommand("alignJustify")), Object.keys(e2).length > 0 && t2.registerKeymap(e2);
35
- }
36
- registerToolbarItem(t2) {
37
- const e2 = this.config.alignments.map((t3) => ({ label: s[t3], command: `align${r(t3)}`, icon: l[t3] }));
38
- t2.registerToolbarItem({ id: "alignment", group: "block", icon: l.left, label: "Alignment", tooltip: "Alignment", command: "alignLeft", priority: 60, popupType: "dropdown", popupConfig: { items: e2 }, separatorAfter: this.config.separatorAfter, isActive: (t3) => this.isNonDefaultAlignment(t3), isEnabled: (t3) => this.isAlignable(t3) });
39
- }
40
- registerMiddleware(t2) {
41
- t2.registerMiddleware((t3, e2, i2) => {
42
- let n2 = false;
43
- const s2 = t3.steps.map((t4) => {
44
- if ("setBlockType" !== t4.type) return t4;
45
- if (!this.alignableTypes.has(t4.nodeType)) return t4;
46
- const e3 = t4.previousAttrs?.align;
47
- return e3 && "left" !== e3 ? (n2 = true, { ...t4, attrs: { ...t4.attrs, align: e3 } }) : t4;
48
- });
49
- i2(n2 ? { ...t3, steps: s2 } : t3);
50
- });
51
- }
52
- getSelectedBlock(t2) {
53
- const n2 = t2.selection;
54
- return e(n2) ? t2.getBlock(n2.nodeId) : i(n2) ? t2.getBlock(n2.anchor.blockId) : void 0;
55
- }
56
- getSelectedBlockId(t2) {
57
- const n2 = t2.selection;
58
- return e(n2) ? n2.nodeId : i(n2) ? n2.anchor.blockId : void 0;
59
- }
60
- setAlignment(e2, i2) {
61
- const n2 = e2.getState(), s2 = this.getSelectedBlock(n2);
62
- if (!s2 || !this.alignableTypes.has(s2.type)) return false;
63
- const l2 = this.getSelectedBlockId(n2);
64
- if (!l2) return false;
65
- const o2 = t(n2.doc, l2);
66
- if (!o2) return false;
67
- const a2 = { ...s2.attrs, align: i2 }, r2 = n2.transaction("command").setNodeAttr(o2, a2).setSelection(n2.selection).build();
68
- return e2.dispatch(r2), true;
69
- }
70
- isNonDefaultAlignment(t2) {
71
- const e2 = this.getSelectedBlock(t2);
72
- if (!e2 || !this.alignableTypes.has(e2.type)) return false;
73
- const i2 = e2.attrs?.align, n2 = this.config.defaults[e2.type] ?? "left";
74
- return null != i2 && i2 !== n2;
75
- }
76
- isAlignable(t2) {
77
- const e2 = this.getSelectedBlock(t2);
78
- return null != e2 && this.alignableTypes.has(e2.type);
79
- }
80
- }
81
- function a(t2, e2) {
82
- const i2 = e2.attrs?.align;
83
- "string" == typeof i2 && "left" !== i2 && (t2.style.textAlign = i2);
84
- }
85
- function r(t2) {
86
- return t2.charAt(0).toUpperCase() + t2.slice(1);
87
- }
1
+ import { A, d } from "../chunks/index-C-YWHOcC.mjs";
88
2
  export {
89
- l as ALIGNMENT_ICONS,
90
- o as AlignmentPlugin
3
+ A as ALIGNMENT_ICONS,
4
+ d as AlignmentPlugin
91
5
  };
92
6
  //# sourceMappingURL=alignment.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"alignment.mjs","sources":["../../src/plugins/alignment/AlignmentPlugin.ts"],"sourcesContent":["/**\n * AlignmentPlugin: adds left/center/right/justify alignment as a block\n * attribute on paragraphs, headings, images, and other alignable types.\n * Patches their NodeSpecs to render the `align` attribute via inline\n * `text-align` style and provides toggle commands, keyboard shortcuts,\n * and a toolbar dropdown. Handles both TextSelection and NodeSelection.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { findNodePath } from '../../model/NodeResolver.js';\nimport { isNodeSelection, isTextSelection } from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\n\n// --- Public Types ---\n\nexport type BlockAlignment = 'left' | 'center' | 'right' | 'justify';\n\nexport interface AlignmentConfig {\n\t/** Which alignments to expose. Defaults to all four. */\n\treadonly alignments: readonly BlockAlignment[];\n\t/** Block types that support alignment. Defaults to paragraph + heading + title + subtitle + table_cell + image. */\n\treadonly alignableTypes: readonly string[];\n\t/** Per-type default alignment (e.g. `{ image: 'center' }`). Falls back to `'left'`. */\n\treadonly defaults: Readonly<Record<string, BlockAlignment>>;\n\t/** When true, a separator is rendered after the toolbar item. */\n\treadonly separatorAfter?: boolean;\n}\n\n// --- Constants ---\n\nconst DEFAULT_CONFIG: AlignmentConfig = {\n\talignments: ['left', 'center', 'right', 'justify'],\n\talignableTypes: ['paragraph', 'heading', 'title', 'subtitle', 'table_cell', 'image'],\n\tdefaults: { image: 'center' },\n};\n\nconst ALIGNMENT_LABELS: Readonly<Record<BlockAlignment, string>> = {\n\tleft: 'Align Left',\n\tcenter: 'Align Center',\n\tright: 'Align Right',\n\tjustify: 'Justify',\n};\n\nexport const ALIGNMENT_ICONS: Readonly<Record<BlockAlignment, string>> = {\n\tleft: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z\"/></svg>',\n\tcenter:\n\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z\"/></svg>',\n\tright:\n\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z\"/></svg>',\n\tjustify:\n\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zM3 3v2h18V3H3z\"/></svg>',\n};\n\n// --- Plugin ---\n\nexport class AlignmentPlugin implements Plugin {\n\treadonly id = 'alignment';\n\treadonly name = 'Alignment';\n\treadonly priority = 90;\n\n\tprivate readonly config: AlignmentConfig;\n\tprivate alignableTypes!: ReadonlySet<string>;\n\n\tconstructor(config?: Partial<AlignmentConfig>) {\n\t\tthis.config = {\n\t\t\t...DEFAULT_CONFIG,\n\t\t\t...config,\n\t\t\tdefaults: { ...DEFAULT_CONFIG.defaults, ...config?.defaults },\n\t\t};\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.alignableTypes = new Set(this.config.alignableTypes);\n\t\tthis.patchNodeSpecs(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymaps(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.registerMiddleware(context);\n\t}\n\n\t// --- NodeSpec Patching ---\n\n\t/**\n\t * Patches existing NodeSpecs for alignable block types to support the\n\t * `align` attribute and render it as an inline style. Skips types\n\t * that already define an `align` attribute in their spec.\n\t */\n\tprivate patchNodeSpecs(context: PluginContext): void {\n\t\tconst registry = context.getSchemaRegistry();\n\n\t\tfor (const type of this.config.alignableTypes) {\n\t\t\tconst spec = registry.getNodeSpec(type);\n\t\t\tif (!spec) continue;\n\n\t\t\t// Skip types that already declare an `align` attr (e.g. image)\n\t\t\tif (spec.attrs?.align) continue;\n\n\t\t\tconst originalToDOM = spec.toDOM;\n\t\t\tconst defaultAlign: BlockAlignment = this.config.defaults[type] ?? 'left';\n\n\t\t\tregistry.removeNodeSpec(type);\n\t\t\tregistry.registerNodeSpec({\n\t\t\t\t...spec,\n\t\t\t\tattrs: {\n\t\t\t\t\t...spec.attrs,\n\t\t\t\t\talign: { default: defaultAlign },\n\t\t\t\t},\n\t\t\t\ttoDOM(node) {\n\t\t\t\t\tconst el = originalToDOM.call(spec, node);\n\t\t\t\t\tapplyAlignment(el, node);\n\t\t\t\t\treturn el;\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- Commands ---\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tfor (const alignment of this.config.alignments) {\n\t\t\tcontext.registerCommand(`align${capitalize(alignment)}`, () => {\n\t\t\t\treturn this.setAlignment(context, alignment);\n\t\t\t});\n\t\t}\n\t}\n\n\t// --- Keymaps ---\n\n\tprivate registerKeymaps(context: PluginContext): void {\n\t\tconst bindings: Record<string, () => boolean> = {};\n\n\t\tif (this.config.alignments.includes('left')) {\n\t\t\tbindings['Mod-Shift-L'] = () => context.executeCommand('alignLeft');\n\t\t}\n\t\tif (this.config.alignments.includes('center')) {\n\t\t\tbindings['Mod-Shift-E'] = () => context.executeCommand('alignCenter');\n\t\t}\n\t\tif (this.config.alignments.includes('right')) {\n\t\t\tbindings['Mod-Shift-R'] = () => context.executeCommand('alignRight');\n\t\t}\n\t\tif (this.config.alignments.includes('justify')) {\n\t\t\tbindings['Mod-Shift-J'] = () => context.executeCommand('alignJustify');\n\t\t}\n\n\t\tif (Object.keys(bindings).length > 0) {\n\t\t\tcontext.registerKeymap(bindings);\n\t\t}\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst dropdownItems = this.config.alignments.map((alignment) => ({\n\t\t\tlabel: ALIGNMENT_LABELS[alignment],\n\t\t\tcommand: `align${capitalize(alignment)}`,\n\t\t\ticon: ALIGNMENT_ICONS[alignment],\n\t\t}));\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'alignment',\n\t\t\tgroup: 'block',\n\t\t\ticon: ALIGNMENT_ICONS.left,\n\t\t\tlabel: 'Alignment',\n\t\t\ttooltip: 'Alignment',\n\t\t\tcommand: 'alignLeft',\n\t\t\tpriority: 60,\n\t\t\tpopupType: 'dropdown',\n\t\t\tpopupConfig: { items: dropdownItems },\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\tisActive: (state) => this.isNonDefaultAlignment(state),\n\t\t\tisEnabled: (state) => this.isAlignable(state),\n\t\t});\n\t}\n\n\t// --- Middleware ---\n\n\t/**\n\t * Preserves the `align` attribute when other plugins change the block\n\t * type (e.g. paragraph → heading) via `setBlockType`, which replaces attrs.\n\t */\n\tprivate registerMiddleware(context: PluginContext): void {\n\t\tcontext.registerMiddleware((tr, _state, next) => {\n\t\t\tlet patched = false;\n\n\t\t\tconst patchedSteps = tr.steps.map((step) => {\n\t\t\t\tif (step.type !== 'setBlockType') return step;\n\t\t\t\tif (!this.alignableTypes.has(step.nodeType)) return step;\n\n\t\t\t\tconst prevAlign = step.previousAttrs?.align;\n\t\t\t\tif (!prevAlign || prevAlign === 'left') return step;\n\n\t\t\t\t// Carry forward align into new attrs\n\t\t\t\tpatched = true;\n\t\t\t\treturn {\n\t\t\t\t\t...step,\n\t\t\t\t\tattrs: { ...step.attrs, align: prevAlign },\n\t\t\t\t};\n\t\t\t});\n\n\t\t\tnext(patched ? { ...tr, steps: patchedSteps } : tr);\n\t\t});\n\t}\n\n\t// --- Alignment Logic ---\n\n\t/**\n\t * Gets the selected block, handling both TextSelection and NodeSelection.\n\t */\n\tprivate getSelectedBlock(state: EditorState): BlockNode | undefined {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) {\n\t\t\treturn state.getBlock(sel.nodeId);\n\t\t}\n\t\tif (isTextSelection(sel)) {\n\t\t\treturn state.getBlock(sel.anchor.blockId);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Gets the block ID of the selected block, handling both selection types.\n\t */\n\tprivate getSelectedBlockId(state: EditorState): BlockId | undefined {\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return sel.nodeId;\n\t\tif (isTextSelection(sel)) return sel.anchor.blockId;\n\t\treturn undefined;\n\t}\n\n\tprivate setAlignment(context: PluginContext, alignment: BlockAlignment): boolean {\n\t\tconst state = context.getState();\n\t\tconst block = this.getSelectedBlock(state);\n\t\tif (!block || !this.alignableTypes.has(block.type)) return false;\n\n\t\tconst blockId = this.getSelectedBlockId(state);\n\t\tif (!blockId) return false;\n\n\t\tconst path = findNodePath(state.doc, blockId);\n\t\tif (!path) return false;\n\n\t\tconst newAttrs = { ...block.attrs, align: alignment };\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setNodeAttr(path as BlockId[], newAttrs)\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\tprivate isNonDefaultAlignment(state: EditorState): boolean {\n\t\tconst block = this.getSelectedBlock(state);\n\t\tif (!block || !this.alignableTypes.has(block.type)) return false;\n\t\tconst align = block.attrs?.align;\n\t\tconst defaultAlign: BlockAlignment = this.config.defaults[block.type] ?? 'left';\n\t\treturn align != null && align !== defaultAlign;\n\t}\n\n\tprivate isAlignable(state: EditorState): boolean {\n\t\tconst block = this.getSelectedBlock(state);\n\t\treturn block != null && this.alignableTypes.has(block.type);\n\t}\n}\n\n// --- Helpers ---\n\nfunction applyAlignment(el: HTMLElement, node: BlockNode): void {\n\tconst align = node.attrs?.align;\n\tif (typeof align === 'string' && align !== 'left') {\n\t\tel.style.textAlign = align;\n\t}\n}\n\nfunction capitalize(s: string): string {\n\treturn s.charAt(0).toUpperCase() + s.slice(1);\n}\n"],"names":["DEFAULT_CONFIG","alignments","alignableTypes","defaults","image","ALIGNMENT_LABELS","left","center","right","justify","ALIGNMENT_ICONS","AlignmentPlugin","id","name","priority","config","this","context","Set","patchNodeSpecs","registerCommands","registerKeymaps","registerToolbarItem","registerMiddleware","registry","getSchemaRegistry","type","spec","getNodeSpec","attrs","align","originalToDOM","toDOM","defaultAlign","removeNodeSpec","registerNodeSpec","default","node","el","call","applyAlignment","alignment","registerCommand","capitalize","setAlignment","bindings","includes","executeCommand","Object","keys","length","registerKeymap","dropdownItems","map","label","command","icon","group","tooltip","popupType","popupConfig","items","separatorAfter","isActive","state","isNonDefaultAlignment","isEnabled","isAlignable","tr","_state","next","patched","patchedSteps","steps","step","has","nodeType","prevAlign","previousAttrs","sel","selection","isNodeSelection","getBlock","nodeId","isTextSelection","anchor","blockId","getState","block","getSelectedBlock","getSelectedBlockId","path","findNodePath","doc","newAttrs","transaction","setNodeAttr","setSelection","build","dispatch","style","textAlign","s","charAt","toUpperCase","slice"],"mappings":";;AAgCA,MAAMA,IAAkC,EACvCC,YAAY,CAAC,QAAQ,UAAU,SAAS,YACxCC,gBAAgB,CAAC,aAAa,WAAW,SAAS,YAAY,cAAc,OAAA,GAC5EC,UAAU,EAAEC,OAAO,SAAA,EAAA,GAGdC,IAA6D,EAClEC,MAAM,cACNC,QAAQ,gBACRC,OAAO,eACPC,SAAS,UAAA,GAGGC,IAA4D,EACxEJ,MAAM,8JACNC,QACC,6JACDC,OACC,6JACDC,SACC,2JAAA;AAKK,MAAME;EACHC,KAAK;AAAA,EACLC,OAAO;AAAA,EACPC,WAAW;AAAA,EAEHC;AAAAA,EACTb;AAAAA,EAER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,GAAAA,GAEpC2B,KAAKJ,GACT+B,YAAY,SAAA,EACZC,YAAYL,IAAmBG,EAAAA,EAC/BG,aAAajC,GAAMgB,SAAAA,EACnBkB;AAGF,WADAjF,GAAQkF,SAAS/B,EAAAA,GAAAA;AAAAA,EAElB;AAAA,EAEQ,sBAAsBJ;AAC7B,UAAMwB,KAAQxE,KAAKyE,iBAAiBzB,EAAAA;AACpC,QAAA,CAAKwB,MAAAA,CAAUxE,KAAKd,eAAeyE,IAAIa,GAAM9D,IAAAA,EAAO,QAAA;AACpD,UAAMI,KAAQ0D,GAAM3D,OAAOC,OACrBG,KAA+BjB,KAAKD,OAAOZ,SAASqF,GAAM9D,IAAAA,KAAS;AACzE,WAAgB,QAATI,MAAiBA,OAAUG;AAAAA,EACnC;AAAA,EAEQ,YAAY+B;AACnB,UAAMwB,KAAQxE,KAAKyE,iBAAiBzB,EAAAA;AACpC,WAAgB,QAATwB,MAAiBxE,KAAKd,eAAeyE,IAAIa,GAAM9D,IAAAA;AAAAA,EACvD;AAAA;AAKD,SAASc,EAAeF,IAAiBD,IAAAA;AACxC,QAAMP,KAAQO,GAAKR,OAAOC;AACL,cAAA,OAAVA,MAAgC,WAAVA,OAChCQ,GAAG8D,MAAMC,YAAYvE;AAEvB;AAEA,SAASa,EAAW2D;AACnB,SAAOA,GAAEC,OAAO,CAAA,EAAGC,YAAAA,IAAgBF,GAAEG,MAAM,CAAA;AAC5C;"}
1
+ {"version":3,"file":"alignment.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Locale interface and default English locale for the BlockquotePlugin.
3
+ */
4
+ export interface BlockquoteLocale {
5
+ readonly label: string;
6
+ readonly tooltip: (shortcut: string) => string;
7
+ }
8
+ export declare const BLOCKQUOTE_LOCALE_EN: BlockquoteLocale;
9
+ export declare const BLOCKQUOTE_LOCALE_DE: BlockquoteLocale;
10
+ export declare const BLOCKQUOTE_LOCALE_ES: BlockquoteLocale;
11
+ export declare const BLOCKQUOTE_LOCALE_FR: BlockquoteLocale;
12
+ export declare const BLOCKQUOTE_LOCALE_ZH: BlockquoteLocale;
13
+ export declare const BLOCKQUOTE_LOCALE_RU: BlockquoteLocale;
14
+ export declare const BLOCKQUOTE_LOCALE_AR: BlockquoteLocale;
15
+ export declare const BLOCKQUOTE_LOCALE_HI: BlockquoteLocale;
16
+ export declare const BLOCKQUOTE_LOCALES: Record<string, BlockquoteLocale>;
17
+ //# sourceMappingURL=BlockquoteLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockquoteLocale.d.ts","sourceRoot":"","sources":["../../../src/plugins/blockquote/BlockquoteLocale.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/C;AAID,eAAO,MAAM,oBAAoB,EAAE,gBAGlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,gBAGlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,gBAGlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,gBAGlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,gBAGlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,gBAGlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,gBAGlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,gBAGlC,CAAC;AAIF,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAS/D,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Plugin, PluginContext } from '../Plugin.js';
2
+ import { BlockquoteLocale } from './BlockquoteLocale.js';
2
3
  declare module '../../model/AttrRegistry.js' {
3
4
  interface NodeAttrRegistry {
4
5
  blockquote: Record<string, never>;
@@ -7,12 +8,14 @@ declare module '../../model/AttrRegistry.js' {
7
8
  export interface BlockquoteConfig {
8
9
  /** When true, a separator is rendered after the blockquote toolbar item. */
9
10
  readonly separatorAfter?: boolean;
11
+ readonly locale?: BlockquoteLocale;
10
12
  }
11
13
  export declare class BlockquotePlugin implements Plugin {
12
14
  readonly id = "blockquote";
13
15
  readonly name = "Blockquote";
14
16
  readonly priority = 35;
15
17
  private readonly config;
18
+ private locale;
16
19
  constructor(config?: Partial<BlockquoteConfig>);
17
20
  init(context: PluginContext): void;
18
21
  private registerNodeSpec;
@@ -1 +1 @@
1
- {"version":3,"file":"BlockquotePlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/blockquote/BlockquotePlugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK1D,OAAO,QAAQ,6BAA6B,CAAC;IAC5C,UAAU,gBAAgB;QACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;KAClC;CACD;AAID,MAAM,WAAW,gBAAgB;IAChC,4EAA4E;IAC5E,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CAClC;AAMD,qBAAa,gBAAiB,YAAW,MAAM;IAC9C,QAAQ,CAAC,EAAE,gBAAgB;IAC3B,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,QAAQ,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;gBAE9B,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAI9C,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAQlC,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,mBAAmB;IAqB3B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,YAAY;CAkBpB"}
1
+ {"version":3,"file":"BlockquotePlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/blockquote/BlockquotePlugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIlF,OAAO,QAAQ,6BAA6B,CAAC;IAC5C,UAAU,gBAAgB;QACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;KAClC;CACD;AAID,MAAM,WAAW,gBAAgB;IAChC,4EAA4E;IAC5E,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAMD,qBAAa,gBAAiB,YAAW,MAAM;IAC9C,QAAQ,CAAC,EAAE,gBAAgB;IAC3B,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,QAAQ,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,MAAM,CAAoB;gBAEtB,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAI9C,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IASlC,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,mBAAmB;IAqB3B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,YAAY;CAkBpB"}
@@ -1,58 +1,5 @@
1
- import { c as e } from "../chunks/NodeSpec-NZVvcCuH.mjs";
2
- import { i as t, a as o } from "../chunks/Selection-D5ZjXoB7.mjs";
3
- import { n as r } from "../chunks/TypeBrands-C09nE2qO.mjs";
4
- import { f as c } from "../chunks/ToolbarItem-ugDymuXi.mjs";
5
- const s = {};
6
- class l {
7
- id = "blockquote";
8
- name = "Blockquote";
9
- priority = 35;
10
- config;
11
- constructor(e2) {
12
- this.config = { ...s, ...e2 };
13
- }
14
- init(e2) {
15
- this.registerNodeSpec(e2), this.registerCommands(e2), this.registerKeymap(e2), this.registerInputRule(e2), this.registerToolbarItem(e2);
16
- }
17
- registerNodeSpec(t2) {
18
- t2.registerNodeSpec({ type: "blockquote", group: "block", content: { allow: ["text"] }, toDOM: (t3) => e("blockquote", t3.id), toHTML: (e2, t3) => `<blockquote>${t3 || "<br>"}</blockquote>`, parseHTML: [{ tag: "blockquote" }], sanitize: { tags: ["blockquote"] } });
19
- }
20
- registerCommands(e2) {
21
- e2.registerCommand("toggleBlockquote", () => this.toggleBlockquote(e2)), e2.registerCommand("setBlockquote", () => this.setBlockType(e2, r("blockquote")));
22
- }
23
- registerKeymap(e2) {
24
- e2.registerKeymap({ "Mod-Shift->": () => e2.executeCommand("toggleBlockquote") });
25
- }
26
- registerInputRule(e2) {
27
- e2.registerInputRule({ pattern: /^> $/, handler(e3, c2, s2, l2) {
28
- const i = e3.selection;
29
- if (t(i)) return null;
30
- if (!o(i)) return null;
31
- const n = e3.getBlock(i.anchor.blockId);
32
- return n && "paragraph" === n.type ? e3.transaction("input").deleteTextAt(i.anchor.blockId, s2, s2 + 2).setBlockType(i.anchor.blockId, r("blockquote")).setSelection(i).build() : null;
33
- } });
34
- }
35
- registerToolbarItem(e2) {
36
- e2.registerToolbarItem({ id: "blockquote", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"/></svg>', label: "Blockquote", tooltip: `Blockquote (${c("Mod-Shift->")})`, command: "toggleBlockquote", priority: 55, separatorAfter: this.config.separatorAfter, isActive: (e3) => {
37
- if (t(e3.selection)) return false;
38
- const o2 = e3.getBlock(e3.selection.anchor.blockId);
39
- return "blockquote" === o2?.type;
40
- } });
41
- }
42
- toggleBlockquote(e2) {
43
- const o2 = e2.getState();
44
- if (t(o2.selection)) return false;
45
- const c2 = o2.getBlock(o2.selection.anchor.blockId);
46
- return !!c2 && ("blockquote" === c2.type ? this.setBlockType(e2, r("paragraph")) : this.setBlockType(e2, r("blockquote")));
47
- }
48
- setBlockType(e2, o2, r2) {
49
- const c2 = e2.getState(), s2 = c2.selection;
50
- if (t(s2)) return false;
51
- const l2 = c2.transaction("command").setBlockType(s2.anchor.blockId, o2, r2).setSelection(s2).build();
52
- return e2.dispatch(l2), true;
53
- }
54
- }
1
+ import { b } from "../chunks/index-uTnc9y7M.mjs";
55
2
  export {
56
- l as BlockquotePlugin
3
+ b as BlockquotePlugin
57
4
  };
58
5
  //# sourceMappingURL=blockquote.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"blockquote.mjs","sources":["../../src/plugins/blockquote/BlockquotePlugin.ts"],"sourcesContent":["/**\n * BlockquotePlugin: registers a blockquote block type with NodeSpec,\n * toggle command, keyboard shortcut, input rule, and a toolbar button.\n */\n\nimport { createBlockElement } from '../../model/NodeSpec.js';\nimport { isCollapsed, isNodeSelection } from '../../model/Selection.js';\nimport { type NodeTypeName, nodeType } from '../../model/TypeBrands.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\tblockquote: Record<string, never>;\n\t}\n}\n\n// --- Configuration ---\n\nexport interface BlockquoteConfig {\n\t/** When true, a separator is rendered after the blockquote toolbar item. */\n\treadonly separatorAfter?: boolean;\n}\n\nconst DEFAULT_CONFIG: BlockquoteConfig = {};\n\n// --- Plugin ---\n\nexport class BlockquotePlugin implements Plugin {\n\treadonly id = 'blockquote';\n\treadonly name = 'Blockquote';\n\treadonly priority = 35;\n\n\tprivate readonly config: BlockquoteConfig;\n\n\tconstructor(config?: Partial<BlockquoteConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.registerNodeSpec(context);\n\t\tthis.registerCommands(context);\n\t\tthis.registerKeymap(context);\n\t\tthis.registerInputRule(context);\n\t\tthis.registerToolbarItem(context);\n\t}\n\n\tprivate registerNodeSpec(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'blockquote',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\ttoDOM(node) {\n\t\t\t\treturn createBlockElement('blockquote', node.id);\n\t\t\t},\n\t\t\ttoHTML(_node, content) {\n\t\t\t\treturn `<blockquote>${content || '<br>'}</blockquote>`;\n\t\t\t},\n\t\t\tparseHTML: [{ tag: 'blockquote' }],\n\t\t\tsanitize: { tags: ['blockquote'] },\n\t\t});\n\t}\n\n\tprivate registerCommands(context: PluginContext): void {\n\t\tcontext.registerCommand('toggleBlockquote', () => {\n\t\t\treturn this.toggleBlockquote(context);\n\t\t});\n\n\t\tcontext.registerCommand('setBlockquote', () => {\n\t\t\treturn this.setBlockType(context, nodeType('blockquote'));\n\t\t});\n\t}\n\n\tprivate registerKeymap(context: PluginContext): void {\n\t\tcontext.registerKeymap({\n\t\t\t'Mod-Shift->': () => context.executeCommand('toggleBlockquote'),\n\t\t});\n\t}\n\n\tprivate registerInputRule(context: PluginContext): void {\n\t\tcontext.registerInputRule({\n\t\t\tpattern: /^> $/,\n\t\t\thandler(state, _match, start, _end) {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (isNodeSelection(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\treturn state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(sel.anchor.blockId, start, start + 2)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('blockquote'))\n\t\t\t\t\t.setSelection(sel)\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tconst icon =\n\t\t\t'<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z\"/></svg>';\n\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'blockquote',\n\t\t\tgroup: 'block',\n\t\t\ticon,\n\t\t\tlabel: 'Blockquote',\n\t\t\ttooltip: `Blockquote (${formatShortcut('Mod-Shift->')})`,\n\t\t\tcommand: 'toggleBlockquote',\n\t\t\tpriority: 55,\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\tisActive: (state) => {\n\t\t\t\tif (isNodeSelection(state.selection)) return false;\n\t\t\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\t\t\treturn block?.type === 'blockquote';\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Toggles between blockquote and paragraph.\n\t * If the block is already a blockquote, resets to paragraph.\n\t */\n\tprivate toggleBlockquote(context: PluginContext): boolean {\n\t\tconst state = context.getState();\n\t\tif (isNodeSelection(state.selection)) return false;\n\t\tconst block = state.getBlock(state.selection.anchor.blockId);\n\t\tif (!block) return false;\n\n\t\tif (block.type === 'blockquote') {\n\t\t\treturn this.setBlockType(context, nodeType('paragraph'));\n\t\t}\n\n\t\treturn this.setBlockType(context, nodeType('blockquote'));\n\t}\n\n\tprivate setBlockType(\n\t\tcontext: PluginContext,\n\t\ttype: NodeTypeName,\n\t\tattrs?: Record<string, string | number | boolean>,\n\t): boolean {\n\t\tconst state = context.getState();\n\t\tconst sel = state.selection;\n\t\tif (isNodeSelection(sel)) return false;\n\n\t\tconst tr = state\n\t\t\t.transaction('command')\n\t\t\t.setBlockType(sel.anchor.blockId, type, attrs)\n\t\t\t.setSelection(sel)\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n}\n"],"names":["DEFAULT_CONFIG","BlockquotePlugin","id","name","priority","config","this","context","registerNodeSpec","registerCommands","registerKeymap","registerInputRule","registerToolbarItem","type","group","content","allow","toDOM","node","createBlockElement","toHTML","_node","parseHTML","tag","sanitize","tags","registerCommand","toggleBlockquote","setBlockType","nodeType","executeCommand","pattern","state","_match","start","_end","sel","selection","isNodeSelection","isCollapsed","block","getBlock","anchor","blockId","transaction","deleteTextAt","setSelection","build","icon","label","tooltip","formatShortcut","command","separatorAfter","isActive","getState","attrs","tr","dispatch"],"mappings":";;;;AA0BA,MAAMA,IAAmC,CAAA;AAIlC,MAAMC,EAAAA;AAAAA,EACHC,KAAK;AAAA,EACLC,OAAO;AAAA,EACPC,WAAW;AAAA,EAEHC;AAAAA,EAEjB,YAAYA;AACXC,SAAKD,SAAS,EAAA,GAAKL,GAAAA,GAAmBK;EACvC;AAAA,EAEA,KAAKE,IAAAA;AACJD,SAAKE,iBAAiBD,EAAAA,GACtBD,KAAKG,iBAAiBF,EAAAA,GACtBD,KAAKI,eAAeH,EAAAA,GACpBD,KAAKK,kBAAkBJ,EAAAA,GACvBD,KAAKM,oBAAoBL;EAC1B;AAAA,EAEQ,iBAAiBA,IAAAA;AACxBA,IAAAA,GAAQC,iBAAiB,EACxBK,MAAM,cACNC,OAAO,SACPC,SAAS,EAAEC,OAAO,CAAC,MAAA,EAAA,GACnBC,OAAMC,CAAAA,OACEC,EAAmB,cAAcD,GAAKhB,EAAAA,GAE9CkB,QAAA,CAAOC,IAAON,OACN,eAAeA,MAAW,MAAA,iBAElCO,WAAW,CAAC,EAAEC,KAAK,aAAA,CAAA,GACnBC,UAAU,EAAEC,MAAM,CAAC,YAAA,EAAA,EAAA,CAAA;AAAA,EAErB;AAAA,EAEQ,iBAAiBlB;AACxBA,IAAAA,GAAQmB,gBAAgB,oBAAoB,MACpCpB,KAAKqB,iBAAiBpB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tB,QAAIjB,EAAgBN,GAAMK,SAAAA,EAAY,QAAA;AACtC,UAAMG,KAAQR,GAAMS,SAAST,GAAMK,UAAUK,OAAOC,OAAAA;AACpD,WAAA,CAAA,CAAKH,OAEc,iBAAfA,GAAM3B,OACFP,KAAKsB,aAAarB,IAASsB,EAAS,WAAA,CAAA,IAGrCvB,KAAKsB,aAAarB,IAASsB,EAAS,YAAA,CAAA;AAAA,EAC5C;AAAA,EAEQ,aACPtB,IACAM,IACA2C,IAAAA;AAEA,UAAMxB,KAAQzB,GAAQgD,SAAAA,GAChBnB,KAAMJ,GAAMK;AAClB,QAAIC,EAAgBF,EAAAA,EAAM;AAE1B,UAAMqB,KAAKzB,GACTY,YAAY,SAAA,EACZhB,aAAaQ,GAAIM,OAAOC,SAAS9B,IAAM2C,EAAAA,EACvCV,aAAaV,EAAAA,EACbW;AAGF,WADAxC,GAAQmD,SAASD,EAAAA,GAAAA;AAAAA,EAElB;AAAA;"}
1
+ {"version":3,"file":"blockquote.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,5 @@
1
+ import { PluginContext } from '../Plugin.js';
2
+ import { CodeBlockConfig } from './CodeBlockTypes.js';
3
+ /** Registers all code-block commands. */
4
+ export declare function registerCodeBlockCommands(context: PluginContext, config: CodeBlockConfig): void;
5
+ //# sourceMappingURL=CodeBlockCommands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeBlockCommands.d.ts","sourceRoot":"","sources":["../../../src/plugins/code-block/CodeBlockCommands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,yCAAyC;AACzC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CAU/F"}
@@ -0,0 +1,10 @@
1
+ import { PluginContext } from '../Plugin.js';
2
+ import { CodeBlockConfig, CodeBlockKeymap } from './CodeBlockTypes.js';
3
+ /** Registers all code-block keyboard handlers. */
4
+ export declare function registerCodeBlockKeymaps(context: PluginContext, config: CodeBlockConfig, resolvedKeymap: Readonly<Record<keyof CodeBlockKeymap, string | null>>): void;
5
+ /**
6
+ * Exits the code block to the next block or creates a new paragraph.
7
+ * Exported for use by the `exitCodeBlock` command.
8
+ */
9
+ export declare function handleEscape(context: PluginContext): boolean;
10
+ //# sourceMappingURL=CodeBlockKeyboardHandlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeBlockKeyboardHandlers.d.ts","sourceRoot":"","sources":["../../../src/plugins/code-block/CodeBlockKeyboardHandlers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAkC5E,kDAAkD;AAClD,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,eAAe,EACvB,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,GACpE,IAAI,CAuBN;AAsFD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAkB5D"}
@@ -0,0 +1,17 @@
1
+ /** Locale interface and default English locale for the CodeBlockPlugin. */
2
+ export interface CodeBlockLocale {
3
+ readonly label: string;
4
+ readonly tooltip: (shortcut?: string) => string;
5
+ readonly enteredCodeBlock: string;
6
+ readonly leftCodeBlock: string;
7
+ }
8
+ export declare const CODE_BLOCK_LOCALE_EN: CodeBlockLocale;
9
+ export declare const CODE_BLOCK_LOCALE_DE: CodeBlockLocale;
10
+ export declare const CODE_BLOCK_LOCALE_ES: CodeBlockLocale;
11
+ export declare const CODE_BLOCK_LOCALE_FR: CodeBlockLocale;
12
+ export declare const CODE_BLOCK_LOCALE_ZH: CodeBlockLocale;
13
+ export declare const CODE_BLOCK_LOCALE_RU: CodeBlockLocale;
14
+ export declare const CODE_BLOCK_LOCALE_AR: CodeBlockLocale;
15
+ export declare const CODE_BLOCK_LOCALE_HI: CodeBlockLocale;
16
+ export declare const CODE_BLOCK_LOCALES: Record<string, CodeBlockLocale>;
17
+ //# sourceMappingURL=CodeBlockLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeBlockLocale.d.ts","sourceRoot":"","sources":["../../../src/plugins/code-block/CodeBlockLocale.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAI3E,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAChD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAC/B;AAID,eAAO,MAAM,oBAAoB,EAAE,eAKlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,eAKlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,eAMlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,eAKlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,eAKlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,eAKlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,eAKlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,eAKlC,CAAC;AAIF,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAS9D,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { NodeViewFactory } from '../../view/NodeView.js';
2
- import { CodeBlockConfig } from './CodeBlockPlugin.js';
2
+ import { CodeBlockConfig } from './CodeBlockTypes.js';
3
3
  /** Creates a NodeViewFactory for code_block nodes. */
4
4
  export declare function createCodeBlockNodeViewFactory(config: CodeBlockConfig): NodeViewFactory;
5
5
  //# sourceMappingURL=CodeBlockNodeView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlockNodeView.d.ts","sourceRoot":"","sources":["../../../src/plugins/code-block/CodeBlockNodeView.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAK5D,sDAAsD;AACtD,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAgJvF"}
1
+ {"version":3,"file":"CodeBlockNodeView.d.ts","sourceRoot":"","sources":["../../../src/plugins/code-block/CodeBlockNodeView.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,sDAAsD;AACtD,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAkJvF"}
@@ -1,71 +1,9 @@
1
1
  import { DecorationSet } from '../../decorations/Decoration.js';
2
- import { BlockId } from '../../model/TypeBrands.js';
3
2
  import { EditorState } from '../../state/EditorState.js';
4
3
  import { Transaction } from '../../state/Transaction.js';
5
- import { Plugin, PluginContext, ServiceKey } from '../Plugin.js';
6
- declare module '../../model/AttrRegistry.js' {
7
- interface NodeAttrRegistry {
8
- code_block: {
9
- language: string;
10
- backgroundColor: string;
11
- };
12
- }
13
- }
14
- export interface SyntaxToken {
15
- readonly from: number;
16
- readonly to: number;
17
- readonly type: string;
18
- }
19
- export interface SyntaxHighlighter {
20
- tokenize(code: string, language: string): readonly SyntaxToken[];
21
- getSupportedLanguages(): readonly string[];
22
- }
23
- /**
24
- * Configurable keyboard bindings for CodeBlockPlugin actions.
25
- * Omit a slot to use the default; set to `null` to disable the binding.
26
- *
27
- * Key descriptor format: `'Mod-Enter'`, `'Mod-Shift-M'`, etc.
28
- * `Mod` resolves to Cmd on macOS, Ctrl on Windows/Linux.
29
- */
30
- export interface CodeBlockKeymap {
31
- /**
32
- * Insert a new paragraph below the code block and move the cursor there.
33
- * @default 'Mod-Enter'
34
- */
35
- readonly insertAfter?: string | null;
36
- /**
37
- * Toggle the current block between code block and paragraph.
38
- * @default 'Mod-Shift-M'
39
- */
40
- readonly toggle?: string | null;
41
- }
42
- export interface CodeBlockConfig {
43
- readonly highlighter?: SyntaxHighlighter;
44
- readonly defaultLanguage?: string;
45
- readonly useSpaces?: boolean;
46
- readonly spaceCount?: number;
47
- readonly showCopyButton?: boolean;
48
- readonly separatorAfter?: boolean;
49
- /** Default body background color (overrides --notectl-code-block-bg). */
50
- readonly background?: string;
51
- /** Default header background color (overrides --notectl-code-block-header-bg). */
52
- readonly headerBackground?: string;
53
- /** Default text color (overrides --notectl-code-block-color). */
54
- readonly textColor?: string;
55
- /** Default header/label text color (overrides --notectl-code-block-header-color). */
56
- readonly headerColor?: string;
57
- /** Customize keyboard bindings for code block actions. */
58
- readonly keymap?: CodeBlockKeymap;
59
- }
60
- export interface CodeBlockService {
61
- setLanguage(blockId: BlockId, language: string): void;
62
- getLanguage(blockId: BlockId): string;
63
- setBackground(blockId: BlockId, color: string): void;
64
- getBackground(blockId: BlockId): string;
65
- isCodeBlock(blockId: BlockId): boolean;
66
- getSupportedLanguages(): readonly string[];
67
- }
68
- export declare const CODE_BLOCK_SERVICE_KEY: ServiceKey<CodeBlockService>;
4
+ import { Plugin, PluginContext } from '../Plugin.js';
5
+ import { CodeBlockConfig } from './CodeBlockTypes.js';
6
+ export { CODE_BLOCK_SERVICE_KEY, type CodeBlockConfig, type CodeBlockKeymap, type CodeBlockService, type SyntaxHighlighter, type SyntaxToken, } from './CodeBlockTypes.js';
69
7
  export declare class CodeBlockPlugin implements Plugin {
70
8
  readonly id = "code-block";
71
9
  readonly name = "Code Block";
@@ -73,6 +11,7 @@ export declare class CodeBlockPlugin implements Plugin {
73
11
  private readonly config;
74
12
  private readonly resolvedKeymap;
75
13
  private context;
14
+ private locale;
76
15
  constructor(config?: Partial<CodeBlockConfig>);
77
16
  init(context: PluginContext): void;
78
17
  destroy(): void;
@@ -80,56 +19,10 @@ export declare class CodeBlockPlugin implements Plugin {
80
19
  decorations(state: EditorState): DecorationSet;
81
20
  private registerNodeSpec;
82
21
  private registerNodeView;
83
- private registerCommands;
84
- private registerKeymaps;
85
22
  private registerInputRule;
86
23
  private registerToolbarItem;
87
24
  private registerMiddleware;
88
- private registerService;
89
25
  private patchTableCellContent;
90
- /**
91
- * Handles Backspace at the start of a code block.
92
- * Converts the code block back to a paragraph, preserving text.
93
- */
94
- private handleBackspace;
95
- private handleEnter;
96
- private handleTab;
97
- private handleShiftTab;
98
- private handleEscape;
99
- /**
100
- * Handles ArrowDown at the last line of a code block.
101
- * Exits to the next block or creates a paragraph below.
102
- */
103
- private handleArrowDown;
104
- /**
105
- * Handles ArrowUp at the first line of a code block.
106
- * Exits to the previous block.
107
- */
108
- private handleArrowUp;
109
- /**
110
- * Handles ArrowRight at the end of a code block.
111
- * Exits to the next block or creates a paragraph below.
112
- */
113
- private handleArrowRight;
114
- /**
115
- * Handles ArrowLeft at the start of a code block.
116
- * Exits to the previous block at end.
117
- */
118
- private handleArrowLeft;
119
- /**
120
- * Handles Mod+Enter: always creates a paragraph below and moves cursor there.
121
- */
122
- private handleModEnter;
123
26
  private setBlockFocused;
124
- private toggleCodeBlock;
125
- private insertCodeBlock;
126
- private exitOnDoubleEnter;
127
- private insertParagraphAfter;
128
- private setAttr;
129
- /**
130
- * Strips all marks from a block's inline content.
131
- * Used when converting to code_block so no formatting carries over.
132
- */
133
- private stripAllMarks;
134
27
  }
135
28
  //# sourceMappingURL=CodeBlockPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version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
+ import { PluginContext } from '../Plugin.js';
2
+ import { CodeBlockConfig } from './CodeBlockTypes.js';
3
+ /** Registers the CodeBlockService on the given context. */
4
+ export declare function registerCodeBlockService(context: PluginContext, config: CodeBlockConfig, getContext: () => PluginContext | null): void;
5
+ //# sourceMappingURL=CodeBlockService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeBlockService.d.ts","sourceRoot":"","sources":["../../../src/plugins/code-block/CodeBlockService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,2DAA2D;AAC3D,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,MAAM,aAAa,GAAG,IAAI,GACpC,IAAI,CAwCN"}