@notectl/core 1.0.3 → 1.0.5

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 (312) hide show
  1. package/README.md +51 -148
  2. package/dist/chunks/AttrRegistry-DTsHyDVA.mjs +16 -0
  3. package/dist/chunks/AttrRegistry-DTsHyDVA.mjs.map +1 -0
  4. package/dist/chunks/Commands-DLP85Mp5.mjs +461 -0
  5. package/dist/chunks/Commands-DLP85Mp5.mjs.map +1 -0
  6. package/dist/chunks/Document-CI3iCwEP.mjs +177 -0
  7. package/dist/chunks/Document-CI3iCwEP.mjs.map +1 -0
  8. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs +7 -0
  9. package/dist/chunks/HTMLUtils-0wvCRvJc.mjs.map +1 -0
  10. package/dist/chunks/NodeResolver-D68ZLXti.mjs +81 -0
  11. package/dist/chunks/NodeResolver-D68ZLXti.mjs.map +1 -0
  12. package/dist/chunks/NodeSpec-NZVvcCuH.mjs +8 -0
  13. package/dist/chunks/NodeSpec-NZVvcCuH.mjs.map +1 -0
  14. package/dist/chunks/Plugin-B9OZ6Y4c.mjs +15 -0
  15. package/dist/chunks/Plugin-B9OZ6Y4c.mjs.map +1 -0
  16. package/dist/chunks/Selection-D5ZjXoB7.mjs +44 -0
  17. package/dist/chunks/Selection-D5ZjXoB7.mjs.map +1 -0
  18. package/dist/chunks/ToolbarItem-ugDymuXi.mjs +7 -0
  19. package/dist/chunks/ToolbarItem-ugDymuXi.mjs.map +1 -0
  20. package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs +398 -0
  21. package/dist/chunks/ToolbarPlugin-D5VqeBPT.mjs.map +1 -0
  22. package/dist/chunks/TypeBrands-C09nE2qO.mjs +27 -0
  23. package/dist/chunks/TypeBrands-C09nE2qO.mjs.map +1 -0
  24. package/dist/chunks/color-picker-Csf0wx5a.mjs +5 -0
  25. package/dist/chunks/color-picker-Csf0wx5a.mjs.map +1 -0
  26. package/dist/chunks/index-CPPb-Jah.mjs +569 -0
  27. package/dist/chunks/index-CPPb-Jah.mjs.map +1 -0
  28. package/dist/commands/Commands.d.ts +71 -0
  29. package/dist/commands/Commands.d.ts.map +1 -0
  30. package/dist/commands/PasteCommand.d.ts +9 -0
  31. package/dist/commands/PasteCommand.d.ts.map +1 -0
  32. package/dist/decorations/Decoration.d.ts +76 -0
  33. package/dist/decorations/Decoration.d.ts.map +1 -0
  34. package/dist/decorations/PositionMapping.d.ts +9 -0
  35. package/dist/decorations/PositionMapping.d.ts.map +1 -0
  36. package/dist/editor/Announcer.d.ts +12 -0
  37. package/dist/editor/Announcer.d.ts.map +1 -0
  38. package/dist/editor/DocumentParser.d.ts +5 -0
  39. package/dist/editor/DocumentParser.d.ts.map +1 -0
  40. package/dist/editor/DocumentSerializer.d.ts +5 -0
  41. package/dist/editor/DocumentSerializer.d.ts.map +1 -0
  42. package/dist/editor/EditorDOM.d.ts +18 -0
  43. package/dist/editor/EditorDOM.d.ts.map +1 -0
  44. package/dist/editor/EditorThemeController.d.ts +21 -0
  45. package/dist/editor/EditorThemeController.d.ts.map +1 -0
  46. package/dist/editor/NotectlEditor.d.ts +131 -0
  47. package/dist/editor/NotectlEditor.d.ts.map +1 -0
  48. package/dist/editor/styles/base.d.ts +3 -0
  49. package/dist/editor/styles/base.d.ts.map +1 -0
  50. package/dist/editor/styles/code-block.d.ts +3 -0
  51. package/dist/editor/styles/code-block.d.ts.map +1 -0
  52. package/dist/editor/styles/color-picker.d.ts +3 -0
  53. package/dist/editor/styles/color-picker.d.ts.map +1 -0
  54. package/dist/editor/styles/font-select.d.ts +3 -0
  55. package/dist/editor/styles/font-select.d.ts.map +1 -0
  56. package/dist/editor/styles/font-size-select.d.ts +3 -0
  57. package/dist/editor/styles/font-size-select.d.ts.map +1 -0
  58. package/dist/editor/styles/heading-select.d.ts +3 -0
  59. package/dist/editor/styles/heading-select.d.ts.map +1 -0
  60. package/dist/editor/styles/image.d.ts +3 -0
  61. package/dist/editor/styles/image.d.ts.map +1 -0
  62. package/dist/editor/styles/list.d.ts +3 -0
  63. package/dist/editor/styles/list.d.ts.map +1 -0
  64. package/dist/editor/styles/reduced-motion.d.ts +3 -0
  65. package/dist/editor/styles/reduced-motion.d.ts.map +1 -0
  66. package/dist/editor/styles/table.d.ts +3 -0
  67. package/dist/editor/styles/table.d.ts.map +1 -0
  68. package/dist/editor/styles/toolbar.d.ts +3 -0
  69. package/dist/editor/styles/toolbar.d.ts.map +1 -0
  70. package/dist/editor/styles.d.ts +12 -0
  71. package/dist/editor/styles.d.ts.map +1 -0
  72. package/dist/editor/theme/ThemeEngine.d.ts +6 -0
  73. package/dist/editor/theme/ThemeEngine.d.ts.map +1 -0
  74. package/dist/editor/theme/ThemeTokens.d.ts +73 -0
  75. package/dist/editor/theme/ThemeTokens.d.ts.map +1 -0
  76. package/dist/fonts.d.ts +17 -0
  77. package/dist/fonts.d.ts.map +1 -0
  78. package/dist/fonts.mjs +7 -0
  79. package/dist/fonts.mjs.map +1 -0
  80. package/dist/index.d.ts +81 -2360
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/input/ClipboardHandler.d.ts +29 -0
  83. package/dist/input/ClipboardHandler.d.ts.map +1 -0
  84. package/dist/input/InputHandler.d.ts +32 -0
  85. package/dist/input/InputHandler.d.ts.map +1 -0
  86. package/dist/input/InputRule.d.ts +9 -0
  87. package/dist/input/InputRule.d.ts.map +1 -0
  88. package/dist/input/InternalClipboard.d.ts +23 -0
  89. package/dist/input/InternalClipboard.d.ts.map +1 -0
  90. package/dist/input/KeyboardHandler.d.ts +42 -0
  91. package/dist/input/KeyboardHandler.d.ts.map +1 -0
  92. package/dist/input/Keymap.d.ts +11 -0
  93. package/dist/input/Keymap.d.ts.map +1 -0
  94. package/dist/input/PasteHandler.d.ts +38 -0
  95. package/dist/input/PasteHandler.d.ts.map +1 -0
  96. package/dist/input/SourceNormalizer.d.ts +7 -0
  97. package/dist/input/SourceNormalizer.d.ts.map +1 -0
  98. package/dist/model/AttrRegistry.d.ts +39 -0
  99. package/dist/model/AttrRegistry.d.ts.map +1 -0
  100. package/dist/model/BuiltinSpecs.d.ts +4 -0
  101. package/dist/model/BuiltinSpecs.d.ts.map +1 -0
  102. package/dist/model/ContentModel.d.ts +12 -0
  103. package/dist/model/ContentModel.d.ts.map +1 -0
  104. package/dist/model/ContentSlice.d.ts +17 -0
  105. package/dist/model/ContentSlice.d.ts.map +1 -0
  106. package/dist/model/Document.d.ts +127 -0
  107. package/dist/model/Document.d.ts.map +1 -0
  108. package/dist/model/HTMLParser.d.ts +36 -0
  109. package/dist/model/HTMLParser.d.ts.map +1 -0
  110. package/dist/model/HTMLUtils.d.ts +6 -0
  111. package/dist/model/HTMLUtils.d.ts.map +1 -0
  112. package/dist/model/InlineNodeSpec.d.ts +20 -0
  113. package/dist/model/InlineNodeSpec.d.ts.map +1 -0
  114. package/dist/model/MarkSpec.d.ts +22 -0
  115. package/dist/model/MarkSpec.d.ts.map +1 -0
  116. package/dist/model/NodeResolver.d.ts +36 -0
  117. package/dist/model/NodeResolver.d.ts.map +1 -0
  118. package/dist/model/NodeSpec.d.ts +67 -0
  119. package/dist/model/NodeSpec.d.ts.map +1 -0
  120. package/dist/model/ParseRule.d.ts +11 -0
  121. package/dist/model/ParseRule.d.ts.map +1 -0
  122. package/dist/model/SanitizeConfig.d.ts +9 -0
  123. package/dist/model/SanitizeConfig.d.ts.map +1 -0
  124. package/dist/model/Schema.d.ts +17 -0
  125. package/dist/model/Schema.d.ts.map +1 -0
  126. package/dist/model/SchemaRegistry.d.ts +81 -0
  127. package/dist/model/SchemaRegistry.d.ts.map +1 -0
  128. package/dist/model/Selection.d.ts +52 -0
  129. package/dist/model/Selection.d.ts.map +1 -0
  130. package/dist/model/TypeBrands.d.ts +28 -0
  131. package/dist/model/TypeBrands.d.ts.map +1 -0
  132. package/dist/notectl-core.mjs +2576 -11104
  133. package/dist/notectl-core.mjs.map +1 -1
  134. package/dist/notectl-core.umd.js +6810 -0
  135. package/dist/notectl-core.umd.js.map +1 -0
  136. package/dist/plugins/EventBus.d.ts +13 -0
  137. package/dist/plugins/EventBus.d.ts.map +1 -0
  138. package/dist/plugins/Plugin.d.ts +85 -0
  139. package/dist/plugins/Plugin.d.ts.map +1 -0
  140. package/dist/plugins/PluginManager.d.ts +66 -0
  141. package/dist/plugins/PluginManager.d.ts.map +1 -0
  142. package/dist/plugins/alignment/AlignmentPlugin.d.ts +48 -0
  143. package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -0
  144. package/dist/plugins/alignment/index.d.ts +2 -0
  145. package/dist/plugins/alignment/index.d.ts.map +1 -0
  146. package/dist/plugins/alignment.mjs +92 -0
  147. package/dist/plugins/alignment.mjs.map +1 -0
  148. package/dist/plugins/blockquote/BlockquotePlugin.d.ts +30 -0
  149. package/dist/plugins/blockquote/BlockquotePlugin.d.ts.map +1 -0
  150. package/dist/plugins/blockquote/index.d.ts +2 -0
  151. package/dist/plugins/blockquote/index.d.ts.map +1 -0
  152. package/dist/plugins/blockquote.mjs +58 -0
  153. package/dist/plugins/blockquote.mjs.map +1 -0
  154. package/dist/plugins/code-block/CodeBlockNodeView.d.ts +5 -0
  155. package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -0
  156. package/dist/plugins/code-block/CodeBlockPlugin.d.ts +135 -0
  157. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -0
  158. package/dist/plugins/code-block/index.d.ts +2 -0
  159. package/dist/plugins/code-block/index.d.ts.map +1 -0
  160. package/dist/plugins/code-block.mjs +6 -0
  161. package/dist/plugins/code-block.mjs.map +1 -0
  162. package/dist/plugins/font/FontPlugin.d.ts +85 -0
  163. package/dist/plugins/font/FontPlugin.d.ts.map +1 -0
  164. package/dist/plugins/font/StarterFonts.d.ts +10 -0
  165. package/dist/plugins/font/StarterFonts.d.ts.map +1 -0
  166. package/dist/plugins/font/index.d.ts +2 -0
  167. package/dist/plugins/font/index.d.ts.map +1 -0
  168. package/dist/plugins/font-size/FontSizePlugin.d.ts +65 -0
  169. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -0
  170. package/dist/plugins/font-size/index.d.ts +2 -0
  171. package/dist/plugins/font-size/index.d.ts.map +1 -0
  172. package/dist/plugins/font-size.mjs +220 -0
  173. package/dist/plugins/font-size.mjs.map +1 -0
  174. package/dist/plugins/font.mjs +186 -0
  175. package/dist/plugins/font.mjs.map +1 -0
  176. package/dist/plugins/hard-break/HardBreakPlugin.d.ts +16 -0
  177. package/dist/plugins/hard-break/HardBreakPlugin.d.ts.map +1 -0
  178. package/dist/plugins/hard-break/index.d.ts +2 -0
  179. package/dist/plugins/hard-break/index.d.ts.map +1 -0
  180. package/dist/plugins/hard-break.mjs +28 -0
  181. package/dist/plugins/hard-break.mjs.map +1 -0
  182. package/dist/plugins/heading/BlockTypePickerEntry.d.ts +20 -0
  183. package/dist/plugins/heading/BlockTypePickerEntry.d.ts.map +1 -0
  184. package/dist/plugins/heading/HeadingPlugin.d.ts +78 -0
  185. package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -0
  186. package/dist/plugins/heading/index.d.ts +3 -0
  187. package/dist/plugins/heading/index.d.ts.map +1 -0
  188. package/dist/plugins/heading.mjs +188 -0
  189. package/dist/plugins/heading.mjs.map +1 -0
  190. package/dist/plugins/highlight/HighlightPlugin.d.ts +37 -0
  191. package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -0
  192. package/dist/plugins/highlight/index.d.ts +2 -0
  193. package/dist/plugins/highlight/index.d.ts.map +1 -0
  194. package/dist/plugins/highlight.mjs +126 -0
  195. package/dist/plugins/highlight.mjs.map +1 -0
  196. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts +29 -0
  197. package/dist/plugins/horizontal-rule/HorizontalRulePlugin.d.ts.map +1 -0
  198. package/dist/plugins/horizontal-rule/index.d.ts +2 -0
  199. package/dist/plugins/horizontal-rule/index.d.ts.map +1 -0
  200. package/dist/plugins/horizontal-rule.mjs +59 -0
  201. package/dist/plugins/horizontal-rule.mjs.map +1 -0
  202. package/dist/plugins/image/ImageCommands.d.ts +26 -0
  203. package/dist/plugins/image/ImageCommands.d.ts.map +1 -0
  204. package/dist/plugins/image/ImageNodeView.d.ts +6 -0
  205. package/dist/plugins/image/ImageNodeView.d.ts.map +1 -0
  206. package/dist/plugins/image/ImagePlugin.d.ts +43 -0
  207. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -0
  208. package/dist/plugins/image/ImageUpload.d.ts +48 -0
  209. package/dist/plugins/image/ImageUpload.d.ts.map +1 -0
  210. package/dist/plugins/image/index.d.ts +3 -0
  211. package/dist/plugins/image/index.d.ts.map +1 -0
  212. package/dist/plugins/image.mjs +381 -0
  213. package/dist/plugins/image.mjs.map +1 -0
  214. package/dist/plugins/link/LinkPlugin.d.ts +32 -0
  215. package/dist/plugins/link/LinkPlugin.d.ts.map +1 -0
  216. package/dist/plugins/link/index.d.ts +2 -0
  217. package/dist/plugins/link/index.d.ts.map +1 -0
  218. package/dist/plugins/link.mjs +127 -0
  219. package/dist/plugins/link.mjs.map +1 -0
  220. package/dist/plugins/list/ListPlugin.d.ts +51 -0
  221. package/dist/plugins/list/ListPlugin.d.ts.map +1 -0
  222. package/dist/plugins/list/index.d.ts +2 -0
  223. package/dist/plugins/list/index.d.ts.map +1 -0
  224. package/dist/plugins/list.mjs +193 -0
  225. package/dist/plugins/list.mjs.map +1 -0
  226. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts +23 -0
  227. package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -0
  228. package/dist/plugins/strikethrough/index.d.ts +2 -0
  229. package/dist/plugins/strikethrough/index.d.ts.map +1 -0
  230. package/dist/plugins/strikethrough.mjs +35 -0
  231. package/dist/plugins/strikethrough.mjs.map +1 -0
  232. package/dist/plugins/super-sub/SuperSubPlugin.d.ts +44 -0
  233. package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -0
  234. package/dist/plugins/super-sub/index.d.ts +2 -0
  235. package/dist/plugins/super-sub/index.d.ts.map +1 -0
  236. package/dist/plugins/super-sub.mjs +81 -0
  237. package/dist/plugins/super-sub.mjs.map +1 -0
  238. package/dist/plugins/table/TableCommands.d.ts +50 -0
  239. package/dist/plugins/table/TableCommands.d.ts.map +1 -0
  240. package/dist/plugins/table/TableControls.d.ts +10 -0
  241. package/dist/plugins/table/TableControls.d.ts.map +1 -0
  242. package/dist/plugins/table/TableControlsDOM.d.ts +18 -0
  243. package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -0
  244. package/dist/plugins/table/TableControlsLayout.d.ts +34 -0
  245. package/dist/plugins/table/TableControlsLayout.d.ts.map +1 -0
  246. package/dist/plugins/table/TableHelpers.d.ts +39 -0
  247. package/dist/plugins/table/TableHelpers.d.ts.map +1 -0
  248. package/dist/plugins/table/TableNavigation.d.ts +4 -0
  249. package/dist/plugins/table/TableNavigation.d.ts.map +1 -0
  250. package/dist/plugins/table/TableNodeViews.d.ts +18 -0
  251. package/dist/plugins/table/TableNodeViews.d.ts.map +1 -0
  252. package/dist/plugins/table/TablePlugin.d.ts +39 -0
  253. package/dist/plugins/table/TablePlugin.d.ts.map +1 -0
  254. package/dist/plugins/table/TableSelection.d.ts +26 -0
  255. package/dist/plugins/table/TableSelection.d.ts.map +1 -0
  256. package/dist/plugins/table/TableTestUtils.d.ts +45 -0
  257. package/dist/plugins/table/TableTestUtils.d.ts.map +1 -0
  258. package/dist/plugins/table/index.d.ts +4 -0
  259. package/dist/plugins/table/index.d.ts.map +1 -0
  260. package/dist/plugins/table.mjs +663 -0
  261. package/dist/plugins/table.mjs.map +1 -0
  262. package/dist/plugins/text-color/TextColorPlugin.d.ts +37 -0
  263. package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -0
  264. package/dist/plugins/text-color/index.d.ts +2 -0
  265. package/dist/plugins/text-color/index.d.ts.map +1 -0
  266. package/dist/plugins/text-color.mjs +126 -0
  267. package/dist/plugins/text-color.mjs.map +1 -0
  268. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts +34 -0
  269. package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -0
  270. package/dist/plugins/text-formatting/index.d.ts +2 -0
  271. package/dist/plugins/text-formatting/index.d.ts.map +1 -0
  272. package/dist/plugins/text-formatting.mjs +52 -0
  273. package/dist/plugins/text-formatting.mjs.map +1 -0
  274. package/dist/plugins/toolbar/ToolbarItem.d.ts +66 -0
  275. package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -0
  276. package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts +25 -0
  277. package/dist/plugins/toolbar/ToolbarKeyboardNav.d.ts.map +1 -0
  278. package/dist/plugins/toolbar/ToolbarPlugin.d.ts +47 -0
  279. package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -0
  280. package/dist/plugins/toolbar/ToolbarPopupController.d.ts +25 -0
  281. package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -0
  282. package/dist/plugins/toolbar/ToolbarRenderers.d.ts +19 -0
  283. package/dist/plugins/toolbar/ToolbarRenderers.d.ts.map +1 -0
  284. package/dist/plugins/toolbar/ToolbarTooltip.d.ts +17 -0
  285. package/dist/plugins/toolbar/ToolbarTooltip.d.ts.map +1 -0
  286. package/dist/plugins/toolbar/index.d.ts +4 -0
  287. package/dist/plugins/toolbar/index.d.ts.map +1 -0
  288. package/dist/plugins/toolbar.mjs +8 -0
  289. package/dist/plugins/toolbar.mjs.map +1 -0
  290. package/dist/state/EditorState.d.ts +40 -0
  291. package/dist/state/EditorState.d.ts.map +1 -0
  292. package/dist/state/History.d.ts +38 -0
  293. package/dist/state/History.d.ts.map +1 -0
  294. package/dist/state/StepApplication.d.ts +5 -0
  295. package/dist/state/StepApplication.d.ts.map +1 -0
  296. package/dist/state/Transaction.d.ts +185 -0
  297. package/dist/state/Transaction.d.ts.map +1 -0
  298. package/dist/test/PluginTestUtils.d.ts +127 -0
  299. package/dist/test/PluginTestUtils.d.ts.map +1 -0
  300. package/dist/test/TestUtils.d.ts +153 -0
  301. package/dist/test/TestUtils.d.ts.map +1 -0
  302. package/dist/view/EditorView.d.ts +74 -0
  303. package/dist/view/EditorView.d.ts.map +1 -0
  304. package/dist/view/NodeView.d.ts +18 -0
  305. package/dist/view/NodeView.d.ts.map +1 -0
  306. package/dist/view/Reconciler.d.ts +23 -0
  307. package/dist/view/Reconciler.d.ts.map +1 -0
  308. package/dist/view/SelectionSync.d.ts +8 -0
  309. package/dist/view/SelectionSync.d.ts.map +1 -0
  310. package/package.json +112 -11
  311. package/dist/notectl-core.js +0 -1463
  312. package/dist/notectl-core.js.map +0 -1
@@ -0,0 +1,569 @@
1
+ import { p as t, g as e, b as o, j as n, k as r } from "./Document-CI3iCwEP.mjs";
2
+ import { e as c } from "./HTMLUtils-0wvCRvJc.mjs";
3
+ import { f as s } from "./NodeResolver-D68ZLXti.mjs";
4
+ import { c as l } from "./NodeSpec-NZVvcCuH.mjs";
5
+ import { i, a, c as d } from "./Selection-D5ZjXoB7.mjs";
6
+ import { n as u } from "./TypeBrands-C09nE2qO.mjs";
7
+ import { S as f } from "./Plugin-B9OZ6Y4c.mjs";
8
+ import { f as g } from "./ToolbarItem-ugDymuXi.mjs";
9
+ function h(t2, e2) {
10
+ switch (t2.type) {
11
+ case "inline":
12
+ return (function(t3, e3) {
13
+ switch (e3.type) {
14
+ case "insertText":
15
+ return (function(t4, e4) {
16
+ if (t4.blockId !== e4.blockId) return t4;
17
+ const o2 = e4.text.length, n2 = t4.from > e4.offset ? t4.from + o2 : t4.from, r2 = t4.to >= e4.offset ? t4.to + o2 : t4.to;
18
+ return n2 === t4.from && r2 === t4.to ? t4 : { ...t4, from: n2, to: r2 };
19
+ })(t3, e3);
20
+ case "deleteText":
21
+ return (function(t4, e4) {
22
+ if (t4.blockId !== e4.blockId) return t4;
23
+ const o2 = e4.to - e4.from, n2 = p(t4.from, e4.from, e4.to, o2), r2 = p(t4.to, e4.from, e4.to, o2);
24
+ return n2 >= r2 ? null : n2 === t4.from && r2 === t4.to ? t4 : { ...t4, from: n2, to: r2 };
25
+ })(t3, e3);
26
+ case "splitBlock":
27
+ return (function(t4, e4) {
28
+ if (t4.blockId !== e4.blockId) return t4;
29
+ if (t4.to <= e4.offset) return t4;
30
+ if (t4.from >= e4.offset) return { ...t4, blockId: e4.newBlockId, from: t4.from - e4.offset, to: t4.to - e4.offset };
31
+ return [{ ...t4, to: e4.offset }, { ...t4, blockId: e4.newBlockId, from: 0, to: t4.to - e4.offset }];
32
+ })(t3, e3);
33
+ case "mergeBlocks":
34
+ return (function(t4, e4) {
35
+ return t4.blockId !== e4.sourceBlockId ? t4 : { ...t4, blockId: e4.targetBlockId, from: t4.from + e4.targetLengthBefore, to: t4.to + e4.targetLengthBefore };
36
+ })(t3, e3);
37
+ case "removeNode":
38
+ return k(t3, e3);
39
+ default:
40
+ return t3;
41
+ }
42
+ })(t2, e2);
43
+ case "widget":
44
+ return (function(t3, e3) {
45
+ switch (e3.type) {
46
+ case "insertText":
47
+ return (function(t4, e4) {
48
+ if (t4.blockId !== e4.blockId) return t4;
49
+ const o2 = e4.text.length;
50
+ return t4.offset > e4.offset || t4.offset === e4.offset && t4.side >= 1 ? { ...t4, offset: t4.offset + o2 } : t4;
51
+ })(t3, e3);
52
+ case "deleteText":
53
+ return (function(t4, e4) {
54
+ if (t4.blockId !== e4.blockId) return t4;
55
+ if (t4.offset > e4.from && t4.offset < e4.to) return null;
56
+ const o2 = e4.to - e4.from;
57
+ return t4.offset >= e4.to ? { ...t4, offset: t4.offset - o2 } : t4;
58
+ })(t3, e3);
59
+ case "splitBlock":
60
+ return (function(t4, e4) {
61
+ return t4.blockId !== e4.blockId || t4.offset < e4.offset ? t4 : t4.offset > e4.offset ? { ...t4, blockId: e4.newBlockId, offset: t4.offset - e4.offset } : t4.side >= 1 ? { ...t4, blockId: e4.newBlockId, offset: 0 } : t4;
62
+ })(t3, e3);
63
+ case "mergeBlocks":
64
+ return (function(t4, e4) {
65
+ return t4.blockId !== e4.sourceBlockId ? t4 : { ...t4, blockId: e4.targetBlockId, offset: t4.offset + e4.targetLengthBefore };
66
+ })(t3, e3);
67
+ case "removeNode":
68
+ return k(t3, e3);
69
+ default:
70
+ return t3;
71
+ }
72
+ })(t2, e2);
73
+ case "node":
74
+ return (function(t3, e3) {
75
+ switch (e3.type) {
76
+ case "mergeBlocks":
77
+ return (function(t4, e4) {
78
+ return t4.blockId === e4.sourceBlockId ? null : t4;
79
+ })(t3, e3);
80
+ case "removeNode":
81
+ return k(t3, e3);
82
+ default:
83
+ return t3;
84
+ }
85
+ })(t2, e2);
86
+ }
87
+ }
88
+ function k(t2, e2) {
89
+ return t2.blockId === e2.removedNode.id ? null : t2;
90
+ }
91
+ function p(t2, e2, o2, n2) {
92
+ return t2 <= e2 ? t2 : t2 >= o2 ? t2 - n2 : e2;
93
+ }
94
+ function b(t2, e2, o2, n2) {
95
+ return { type: "inline", blockId: t2, from: e2, to: o2, attrs: n2 };
96
+ }
97
+ function m(t2, e2) {
98
+ return { type: "node", blockId: t2, attrs: e2 };
99
+ }
100
+ function y(t2, e2, o2, n2) {
101
+ return { type: "widget", blockId: t2, offset: e2, toDOM: o2, side: n2?.side ?? -1, key: n2?.key };
102
+ }
103
+ class B {
104
+ constructor(t2) {
105
+ this.byBlock = t2;
106
+ }
107
+ static empty = new B(/* @__PURE__ */ new Map());
108
+ static create(t2) {
109
+ if (0 === t2.length) return B.empty;
110
+ const e2 = /* @__PURE__ */ new Map();
111
+ for (const o2 of t2) {
112
+ const t3 = e2.get(o2.blockId);
113
+ t3 ? t3.push(o2) : e2.set(o2.blockId, [o2]);
114
+ }
115
+ return new B(e2);
116
+ }
117
+ find(t2) {
118
+ return this.byBlock.get(t2) ?? [];
119
+ }
120
+ findInline(t2) {
121
+ const e2 = this.byBlock.get(t2);
122
+ return e2 ? e2.filter((t3) => "inline" === t3.type) : [];
123
+ }
124
+ findNode(t2) {
125
+ const e2 = this.byBlock.get(t2);
126
+ return e2 ? e2.filter((t3) => "node" === t3.type) : [];
127
+ }
128
+ findWidget(t2) {
129
+ const e2 = this.byBlock.get(t2);
130
+ return e2 ? e2.filter((t3) => "widget" === t3.type) : [];
131
+ }
132
+ add(t2) {
133
+ if (0 === t2.length) return this;
134
+ if (this.isEmpty) return B.create(t2);
135
+ const e2 = /* @__PURE__ */ new Map();
136
+ for (const [t3, o2] of this.byBlock) e2.set(t3, [...o2]);
137
+ for (const o2 of t2) {
138
+ const t3 = e2.get(o2.blockId);
139
+ t3 ? t3.push(o2) : e2.set(o2.blockId, [o2]);
140
+ }
141
+ return new B(e2);
142
+ }
143
+ remove(t2) {
144
+ const e2 = /* @__PURE__ */ new Map();
145
+ let o2 = false;
146
+ for (const [n2, r2] of this.byBlock) {
147
+ const c2 = r2.filter((e3) => !t2(e3));
148
+ c2.length !== r2.length && (o2 = true), c2.length > 0 && e2.set(n2, c2);
149
+ }
150
+ return o2 ? 0 === e2.size ? B.empty : new B(e2) : this;
151
+ }
152
+ merge(t2) {
153
+ if (t2.isEmpty) return this;
154
+ if (this.isEmpty) return t2;
155
+ const e2 = /* @__PURE__ */ new Map();
156
+ for (const [t3, o2] of this.byBlock) e2.set(t3, [...o2]);
157
+ for (const [o2, n2] of t2.byBlock) {
158
+ const t3 = e2.get(o2);
159
+ t3 ? t3.push(...n2) : e2.set(o2, [...n2]);
160
+ }
161
+ return new B(e2);
162
+ }
163
+ equals(t2) {
164
+ if (this === t2) return true;
165
+ if (this.byBlock.size !== t2.byBlock.size) return false;
166
+ for (const [e2, o2] of this.byBlock) {
167
+ const n2 = t2.byBlock.get(e2);
168
+ if (!n2) return false;
169
+ if (!I(o2, n2)) return false;
170
+ }
171
+ return true;
172
+ }
173
+ get isEmpty() {
174
+ return 0 === this.byBlock.size;
175
+ }
176
+ map(t2) {
177
+ if (this.isEmpty || 0 === t2.steps.length) return this;
178
+ let e2 = [];
179
+ for (const t3 of this.byBlock.values()) for (const o2 of t3) e2.push(o2);
180
+ for (const o2 of t2.steps) {
181
+ const t3 = [];
182
+ for (const n2 of e2) {
183
+ const e3 = h(n2, o2);
184
+ if (null !== e3) if (Array.isArray(e3)) for (const o3 of e3) t3.push(o3);
185
+ else t3.push(e3);
186
+ }
187
+ e2 = t3;
188
+ }
189
+ return 0 === e2.length ? B.empty : B.create(e2);
190
+ }
191
+ }
192
+ function I(t2, e2) {
193
+ if (t2 === e2) return true;
194
+ if (t2.length !== e2.length) return false;
195
+ for (let o2 = 0; o2 < t2.length; o2++) {
196
+ const n2 = t2[o2], r2 = e2[o2];
197
+ if (!n2 || !r2 || !x(n2, r2)) return false;
198
+ }
199
+ return true;
200
+ }
201
+ function x(t2, e2) {
202
+ if (t2.type !== e2.type) return false;
203
+ if (t2.blockId !== e2.blockId) return false;
204
+ switch (t2.type) {
205
+ case "inline": {
206
+ const o2 = e2;
207
+ return t2.from === o2.from && t2.to === o2.to && w(t2.attrs, o2.attrs);
208
+ }
209
+ case "node": {
210
+ const o2 = e2;
211
+ return w(t2.attrs, o2.attrs);
212
+ }
213
+ case "widget": {
214
+ const o2 = e2;
215
+ return t2.offset === o2.offset && t2.side === o2.side && t2.key === o2.key && t2.toDOM === o2.toDOM;
216
+ }
217
+ }
218
+ }
219
+ function w(t2, e2) {
220
+ if (t2 === e2) return true;
221
+ const o2 = Object.keys(t2), n2 = Object.keys(e2);
222
+ if (o2.length !== n2.length) return false;
223
+ for (const n3 of o2) if (t2[n3] !== e2[n3]) return false;
224
+ return true;
225
+ }
226
+ const C = { insertAfter: "Mod-Enter", toggle: "Mod-Shift-M" }, S = { defaultLanguage: "", useSpaces: false, spaceCount: 2, showCopyButton: true }, _ = new f("codeBlock");
227
+ class v {
228
+ id = "code-block";
229
+ name = "Code Block";
230
+ priority = 36;
231
+ config;
232
+ resolvedKeymap;
233
+ context = null;
234
+ constructor(t2) {
235
+ this.config = { ...S, ...t2 }, this.resolvedKeymap = { ...C, ...t2?.keymap };
236
+ }
237
+ init(t2) {
238
+ t2.registerStyleSheet("\n/* Code Block — uses theme custom properties */\n.notectl-code-block {\n position: relative;\n margin: 8px 0;\n border-radius: 6px;\n background: var(--notectl-code-block-bg);\n color: var(--notectl-code-block-color);\n font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;\n font-size: 14px;\n line-height: 1.5;\n overflow: hidden;\n}\n\n.notectl-code-block__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n background: var(--notectl-code-block-header-bg);\n border-bottom: 1px solid var(--notectl-code-block-header-border);\n font-size: 12px;\n color: var(--notectl-code-block-header-color);\n user-select: none;\n}\n\n.notectl-code-block__language {\n font-weight: 500;\n letter-spacing: 0.02em;\n}\n\n.notectl-code-block__copy {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--notectl-code-block-header-color);\n cursor: pointer;\n padding: 0;\n transition: background 0.15s, color 0.15s;\n}\n\n.notectl-code-block__copy:hover {\n background: rgba(128, 128, 128, 0.15);\n color: var(--notectl-code-block-color);\n}\n\n.notectl-code-block__copy svg {\n fill: currentColor;\n}\n\n.notectl-code-block__content {\n display: block;\n padding: 12px 16px;\n white-space: pre-wrap;\n word-wrap: break-word;\n tab-size: 4;\n -moz-tab-size: 4;\n outline: none;\n min-height: 1.5em;\n}\n\n.notectl-code-block--selected {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n}\n\n.notectl-code-block__esc-hint {\n display: none;\n position: absolute;\n bottom: 4px;\n right: 8px;\n font-size: 11px;\n color: var(--notectl-code-block-header-color);\n opacity: 0.5;\n pointer-events: none;\n user-select: none;\n font-family: system-ui, sans-serif;\n}\n\n.notectl-code-block--focused .notectl-code-block__esc-hint {\n display: block;\n}\n"), this.context = t2, this.registerNodeSpec(t2), this.registerNodeView(t2), this.registerCommands(t2), this.registerKeymaps(t2), this.registerInputRule(t2), this.registerToolbarItem(t2), this.registerMiddleware(t2), this.registerService(t2), this.patchTableCellContent(t2);
239
+ }
240
+ destroy() {
241
+ this.context = null;
242
+ }
243
+ onStateChange(t2, e2, o2) {
244
+ if (!this.context) return;
245
+ const n2 = i(t2.selection) ? null : t2.selection.anchor.blockId, r2 = i(e2.selection) ? null : e2.selection.anchor.blockId, c2 = n2 ? t2.getBlock(n2) : void 0, s2 = r2 ? e2.getBlock(r2) : void 0, l2 = "code_block" === c2?.type, a2 = "code_block" === s2?.type;
246
+ l2 && n2 && this.setBlockFocused(n2, false), a2 && r2 && this.setBlockFocused(r2, true), !l2 && a2 ? this.context.announce("Entered code block. Press Escape to exit.") : l2 && !a2 && this.context.announce("Left code block.");
247
+ }
248
+ decorations(e2) {
249
+ if (!this.config.highlighter) return B.empty;
250
+ const o2 = [], n2 = this.config.highlighter;
251
+ for (const r2 of e2.getBlockOrder()) {
252
+ const c2 = e2.getBlock(r2);
253
+ if (!c2 || "code_block" !== c2.type) continue;
254
+ const s2 = c2.attrs?.language ?? "";
255
+ if (!s2) continue;
256
+ const l2 = t(c2);
257
+ if (!l2) continue;
258
+ const i2 = n2.tokenize(l2, s2);
259
+ for (const t2 of i2) o2.push(b(r2, t2.from, t2.to, { class: `notectl-token--${t2.type}` }));
260
+ }
261
+ return B.create(o2);
262
+ }
263
+ registerNodeSpec(t2) {
264
+ t2.registerNodeSpec({ type: "code_block", group: "block", content: { allow: ["text"] }, selectable: true, attrs: { language: { default: "" }, backgroundColor: { default: "" } }, toDOM(t3) {
265
+ const e2 = l("pre", t3.id);
266
+ e2.className = "notectl-code-block";
267
+ const o2 = document.createElement("code");
268
+ return o2.className = "notectl-code-block__content", e2.appendChild(o2), e2;
269
+ }, toHTML(t3, e2) {
270
+ const o2 = c(t3.attrs?.language ?? ""), n2 = c(t3.attrs?.backgroundColor ?? "");
271
+ return `<pre${n2 ? ` style="background-color: ${n2}"` : ""}><code${o2 ? ` data-language="${o2}"` : ""}>${e2 || ""}</code></pre>`;
272
+ }, parseHTML: [{ tag: "pre", getAttrs(t3) {
273
+ const e2 = t3.querySelector("code"), o2 = e2?.className.match(/language-(\S+)/)?.[1] ?? "";
274
+ return { language: (e2?.getAttribute("data-language") ?? "") || o2 };
275
+ } }], sanitize: { tags: ["pre", "code"], attrs: ["data-language", "class", "style"] } });
276
+ }
277
+ registerNodeView(e2) {
278
+ var o2;
279
+ e2.registerNodeView("code_block", (o2 = this.config, (e3, n2, r2) => {
280
+ const c2 = document.createElement("pre");
281
+ c2.className = "notectl-code-block", c2.setAttribute("data-block-id", e3.id), c2.setAttribute("role", "group"), c2.setAttribute("aria-roledescription", "code block");
282
+ const s2 = document.createElement("div");
283
+ s2.className = "notectl-code-block__header", s2.setAttribute("contenteditable", "false");
284
+ const l2 = document.createElement("span");
285
+ l2.className = "notectl-code-block__language";
286
+ let i2 = null;
287
+ false !== o2.showCopyButton && (i2 = document.createElement("button"), i2.className = "notectl-code-block__copy", i2.setAttribute("aria-label", "Copy code"), i2.type = "button", i2.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>');
288
+ const a2 = document.createElement("span");
289
+ a2.className = "notectl-sr-only", a2.setAttribute("aria-live", "assertive"), a2.setAttribute("aria-atomic", "true"), s2.appendChild(l2), i2 && s2.appendChild(i2), s2.appendChild(a2);
290
+ const d2 = document.createElement("code");
291
+ d2.className = "notectl-code-block__content";
292
+ const u2 = document.createElement("div");
293
+ u2.className = "notectl-code-block__esc-hint", u2.setAttribute("contenteditable", "false"), u2.setAttribute("aria-hidden", "true"), u2.textContent = "Esc to exit", c2.appendChild(s2), c2.appendChild(d2), c2.appendChild(u2), o2.background && c2.style.setProperty("--notectl-code-block-bg", o2.background), o2.headerBackground && c2.style.setProperty("--notectl-code-block-header-bg", o2.headerBackground), o2.textColor && c2.style.setProperty("--notectl-code-block-color", o2.textColor), o2.headerColor && c2.style.setProperty("--notectl-code-block-header-color", o2.headerColor);
294
+ let f2 = e3.id;
295
+ function g2(t2) {
296
+ const e4 = t2.attrs?.language ?? "", o3 = e4 || "plain";
297
+ l2.textContent = o3, c2.setAttribute("aria-label", `${o3} code block. Press Escape to exit.`), e4 ? d2.setAttribute("data-language", e4) : d2.removeAttribute("data-language");
298
+ const n3 = t2.attrs?.backgroundColor ?? "";
299
+ c2.style.backgroundColor = n3 || "";
300
+ }
301
+ return g2(e3), i2 && i2.addEventListener("click", (e4) => {
302
+ e4.preventDefault(), e4.stopPropagation();
303
+ const o3 = n2().getBlock(f2);
304
+ if (!o3) return;
305
+ const r3 = t(o3);
306
+ navigator.clipboard.writeText(r3), a2.textContent = "Copied to clipboard", setTimeout(() => {
307
+ a2.textContent = "";
308
+ }, 1e3);
309
+ }), { dom: c2, contentDOM: d2, update: (t2) => "code_block" === t2.type && (f2 = t2.id, c2.setAttribute("data-block-id", t2.id), g2(t2), true), selectNode() {
310
+ c2.classList.add("notectl-code-block--selected");
311
+ }, deselectNode() {
312
+ c2.classList.remove("notectl-code-block--selected");
313
+ }, destroy() {
314
+ } };
315
+ }));
316
+ }
317
+ registerCommands(t2) {
318
+ t2.registerCommand("toggleCodeBlock", () => this.toggleCodeBlock(t2)), t2.registerCommand("insertCodeBlock", () => this.insertCodeBlock(t2)), t2.registerCommand("setCodeBlockLanguage", () => false), t2.registerCommand("setCodeBlockBackground", () => false), t2.registerCommand("exitCodeBlock", () => this.handleEscape(t2));
319
+ }
320
+ registerKeymaps(t2) {
321
+ const e2 = { Enter: () => this.handleEnter(t2), Backspace: () => this.handleBackspace(t2), Tab: () => this.handleTab(t2), "Shift-Tab": () => this.handleShiftTab(t2), Escape: () => this.handleEscape(t2), ArrowDown: () => this.handleArrowDown(t2), ArrowUp: () => this.handleArrowUp(t2), ArrowRight: () => this.handleArrowRight(t2), ArrowLeft: () => this.handleArrowLeft(t2) }, { insertAfter: o2, toggle: n2 } = this.resolvedKeymap;
322
+ o2 && (e2[o2] = () => this.handleModEnter(t2)), n2 && (e2[n2] = () => t2.executeCommand("toggleCodeBlock")), t2.registerKeymap(e2);
323
+ }
324
+ registerInputRule(t2) {
325
+ t2.registerInputRule({ pattern: /^```(\w*) $/, handler: (t3, e2, o2, n2) => {
326
+ const r2 = t3.selection;
327
+ if (i(r2)) return null;
328
+ if (!a(r2)) return null;
329
+ const c2 = t3.getBlock(r2.anchor.blockId);
330
+ if (!c2 || "paragraph" !== c2.type) return null;
331
+ const s2 = { language: e2[1] ?? "", backgroundColor: "" };
332
+ return t3.transaction("input").deleteTextAt(r2.anchor.blockId, o2, o2 + e2[0].length).setBlockType(r2.anchor.blockId, u("code_block"), s2).setSelection(d(r2.anchor.blockId, 0)).build();
333
+ } });
334
+ }
335
+ registerToolbarItem(t2) {
336
+ t2.registerToolbarItem({ id: "code_block", group: "block", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>', label: "Code Block", tooltip: this.resolvedKeymap.toggle ? `Code Block (${g(this.resolvedKeymap.toggle)})` : "Code Block", command: "toggleCodeBlock", priority: 56, separatorAfter: this.config.separatorAfter, isActive: (t3) => {
337
+ if (i(t3.selection)) return false;
338
+ const e2 = t3.getBlock(t3.selection.anchor.blockId);
339
+ return "code_block" === e2?.type;
340
+ } });
341
+ }
342
+ registerMiddleware(t2) {
343
+ t2.registerMiddleware((t3, e2, o2) => {
344
+ if (!t3.steps.some((t4) => {
345
+ if ("addMark" !== t4.type) return false;
346
+ const o3 = e2.getBlock(t4.blockId);
347
+ return "code_block" === o3?.type;
348
+ })) return void o2(t3);
349
+ const n2 = t3.steps.filter((t4) => {
350
+ if ("addMark" !== t4.type) return true;
351
+ const o3 = e2.getBlock(t4.blockId);
352
+ return "code_block" !== o3?.type;
353
+ });
354
+ o2({ ...t3, steps: n2 });
355
+ }, 50);
356
+ }
357
+ registerService(t2) {
358
+ const e2 = this;
359
+ t2.registerService(_, { setLanguage(o2, n2) {
360
+ e2.setAttr(t2, o2, "language", n2);
361
+ }, getLanguage(t3) {
362
+ const o2 = e2.context;
363
+ if (!o2) return "";
364
+ const n2 = o2.getState().getBlock(t3);
365
+ return n2 && "code_block" === n2.type ? n2.attrs?.language ?? "" : "";
366
+ }, setBackground(o2, n2) {
367
+ e2.setAttr(t2, o2, "backgroundColor", n2);
368
+ }, getBackground(t3) {
369
+ const o2 = e2.context;
370
+ if (!o2) return "";
371
+ const n2 = o2.getState().getBlock(t3);
372
+ return n2 && "code_block" === n2.type ? n2.attrs?.backgroundColor ?? "" : "";
373
+ }, isCodeBlock(t3) {
374
+ const o2 = e2.context;
375
+ if (!o2) return false;
376
+ const n2 = o2.getState().getBlock(t3);
377
+ return "code_block" === n2?.type;
378
+ }, getSupportedLanguages: () => e2.config.highlighter ? e2.config.highlighter.getSupportedLanguages() : [] });
379
+ }
380
+ patchTableCellContent(t2) {
381
+ const e2 = t2.getSchemaRegistry(), o2 = e2.getNodeSpec("table_cell");
382
+ if (!o2?.content) return;
383
+ const n2 = o2.content.allow ?? [];
384
+ n2.includes("code_block") || (e2.removeNodeSpec("table_cell"), e2.registerNodeSpec({ ...o2, content: { ...o2.content, allow: [...n2, "code_block"] } }));
385
+ }
386
+ handleBackspace(t2) {
387
+ const e2 = t2.getState(), o2 = e2.selection;
388
+ if (i(o2)) return false;
389
+ if (!a(o2)) return false;
390
+ const n2 = e2.getBlock(o2.anchor.blockId);
391
+ if (!n2 || "code_block" !== n2.type) return false;
392
+ if (0 !== o2.anchor.offset) return false;
393
+ const r2 = e2.transaction("input").setBlockType(o2.anchor.blockId, u("paragraph")).setSelection(o2).build();
394
+ return t2.dispatch(r2), true;
395
+ }
396
+ handleEnter(e2) {
397
+ const o2 = e2.getState(), n2 = o2.selection;
398
+ if (i(n2)) return false;
399
+ if (!a(n2)) return false;
400
+ const r2 = o2.getBlock(n2.anchor.blockId);
401
+ if (!r2 || "code_block" !== r2.type) return false;
402
+ const c2 = t(r2), s2 = n2.anchor.offset;
403
+ if (c2.endsWith("\n") && s2 === c2.length) return this.exitOnDoubleEnter(e2, n2.anchor.blockId, c2);
404
+ const l2 = o2.transaction("input").insertText(n2.anchor.blockId, s2, "\n", []).setSelection(d(n2.anchor.blockId, s2 + 1)).build();
405
+ return e2.dispatch(l2), true;
406
+ }
407
+ handleTab(t2) {
408
+ const e2 = t2.getState(), o2 = e2.selection;
409
+ if (i(o2)) return false;
410
+ const n2 = e2.getBlock(o2.anchor.blockId);
411
+ if (!n2 || "code_block" !== n2.type) return false;
412
+ const r2 = this.config.useSpaces ? " ".repeat(this.config.spaceCount ?? 2) : " ", c2 = o2.anchor.offset, s2 = e2.transaction("input").insertText(o2.anchor.blockId, c2, r2, []).setSelection(d(o2.anchor.blockId, c2 + r2.length)).build();
413
+ return t2.dispatch(s2), true;
414
+ }
415
+ handleShiftTab(e2) {
416
+ const o2 = e2.getState(), n2 = o2.selection;
417
+ if (i(n2)) return false;
418
+ const r2 = o2.getBlock(n2.anchor.blockId);
419
+ if (!r2 || "code_block" !== r2.type) return false;
420
+ const c2 = t(r2), s2 = n2.anchor.offset, l2 = c2.lastIndexOf("\n", s2 - 1) + 1;
421
+ if (this.config.useSpaces) {
422
+ const t2 = this.config.spaceCount ?? 2;
423
+ if (c2.slice(l2, l2 + t2) === " ".repeat(t2)) {
424
+ const r3 = o2.transaction("input").deleteTextAt(n2.anchor.blockId, l2, l2 + t2).setSelection(d(n2.anchor.blockId, Math.max(l2, s2 - t2))).build();
425
+ return e2.dispatch(r3), true;
426
+ }
427
+ } else if (" " === c2[l2]) {
428
+ const t2 = o2.transaction("input").deleteTextAt(n2.anchor.blockId, l2, l2 + 1).setSelection(d(n2.anchor.blockId, Math.max(l2, s2 - 1))).build();
429
+ return e2.dispatch(t2), true;
430
+ }
431
+ return true;
432
+ }
433
+ handleEscape(t2) {
434
+ const e2 = t2.getState(), o2 = e2.selection;
435
+ if (i(o2)) return false;
436
+ const n2 = e2.getBlock(o2.anchor.blockId);
437
+ if (!n2 || "code_block" !== n2.type) return false;
438
+ const r2 = e2.getBlockOrder(), c2 = r2.indexOf(o2.anchor.blockId);
439
+ if (c2 < r2.length - 1) {
440
+ const o3 = r2[c2 + 1], n3 = e2.transaction("command").setSelection(d(o3, 0)).build();
441
+ t2.dispatch(n3);
442
+ } else this.insertParagraphAfter(t2, o2.anchor.blockId);
443
+ return true;
444
+ }
445
+ handleArrowDown(e2) {
446
+ const o2 = e2.getState(), n2 = o2.selection;
447
+ if (i(n2)) return false;
448
+ if (!a(n2)) return false;
449
+ const r2 = o2.getBlock(n2.anchor.blockId);
450
+ if (!r2 || "code_block" !== r2.type) return false;
451
+ const c2 = t(r2), s2 = n2.anchor.offset;
452
+ if (-1 !== c2.indexOf("\n", s2)) return false;
453
+ const l2 = o2.getBlockOrder(), u2 = l2.indexOf(n2.anchor.blockId);
454
+ if (u2 < l2.length - 1) {
455
+ const t2 = l2[u2 + 1], n3 = o2.transaction("command").setSelection(d(t2, 0)).build();
456
+ e2.dispatch(n3);
457
+ } else this.insertParagraphAfter(e2, n2.anchor.blockId);
458
+ return true;
459
+ }
460
+ handleArrowUp(o2) {
461
+ const n2 = o2.getState(), r2 = n2.selection;
462
+ if (i(r2)) return false;
463
+ if (!a(r2)) return false;
464
+ const c2 = n2.getBlock(r2.anchor.blockId);
465
+ if (!c2 || "code_block" !== c2.type) return false;
466
+ const s2 = t(c2), l2 = r2.anchor.offset, u2 = s2.indexOf("\n");
467
+ if (-1 !== u2 && l2 > u2) return false;
468
+ const f2 = n2.getBlockOrder(), g2 = f2.indexOf(r2.anchor.blockId);
469
+ if (g2 > 0) {
470
+ const t2 = f2[g2 - 1], r3 = n2.getBlock(t2), c3 = r3 ? e(r3) : 0, s3 = n2.transaction("command").setSelection(d(t2, c3)).build();
471
+ return o2.dispatch(s3), true;
472
+ }
473
+ return false;
474
+ }
475
+ handleArrowRight(e2) {
476
+ const o2 = e2.getState(), n2 = o2.selection;
477
+ if (i(n2)) return false;
478
+ if (!a(n2)) return false;
479
+ const r2 = o2.getBlock(n2.anchor.blockId);
480
+ if (!r2 || "code_block" !== r2.type) return false;
481
+ const c2 = t(r2);
482
+ if (n2.anchor.offset !== c2.length) return false;
483
+ const s2 = o2.getBlockOrder(), l2 = s2.indexOf(n2.anchor.blockId);
484
+ if (l2 < s2.length - 1) {
485
+ const t2 = s2[l2 + 1], n3 = o2.transaction("command").setSelection(d(t2, 0)).build();
486
+ e2.dispatch(n3);
487
+ } else this.insertParagraphAfter(e2, n2.anchor.blockId);
488
+ return true;
489
+ }
490
+ handleArrowLeft(t2) {
491
+ const o2 = t2.getState(), n2 = o2.selection;
492
+ if (i(n2)) return false;
493
+ if (!a(n2)) return false;
494
+ const r2 = o2.getBlock(n2.anchor.blockId);
495
+ if (!r2 || "code_block" !== r2.type) return false;
496
+ if (0 !== n2.anchor.offset) return false;
497
+ const c2 = o2.getBlockOrder(), s2 = c2.indexOf(n2.anchor.blockId);
498
+ if (s2 > 0) {
499
+ const n3 = c2[s2 - 1], r3 = o2.getBlock(n3), l2 = r3 ? e(r3) : 0, i2 = o2.transaction("command").setSelection(d(n3, l2)).build();
500
+ return t2.dispatch(i2), true;
501
+ }
502
+ return false;
503
+ }
504
+ handleModEnter(t2) {
505
+ const e2 = t2.getState(), o2 = e2.selection;
506
+ if (i(o2)) return false;
507
+ const n2 = e2.getBlock(o2.anchor.blockId);
508
+ return !(!n2 || "code_block" !== n2.type || (this.insertParagraphAfter(t2, o2.anchor.blockId), 0));
509
+ }
510
+ setBlockFocused(t2, e2) {
511
+ if (!this.context) return;
512
+ const o2 = this.context.getContainer().querySelector(`[data-block-id="${t2}"]`);
513
+ o2 && o2.classList.toggle("notectl-code-block--focused", e2);
514
+ }
515
+ toggleCodeBlock(t2) {
516
+ const e2 = t2.getState();
517
+ if (i(e2.selection)) return false;
518
+ const o2 = e2.getBlock(e2.selection.anchor.blockId);
519
+ if (!o2) return false;
520
+ if ("code_block" === o2.type) {
521
+ const o3 = e2.transaction("command").setBlockType(e2.selection.anchor.blockId, u("paragraph")).setSelection(e2.selection).build();
522
+ return t2.dispatch(o3), true;
523
+ }
524
+ return this.insertCodeBlock(t2);
525
+ }
526
+ insertCodeBlock(t2) {
527
+ const e2 = t2.getState(), o2 = e2.selection;
528
+ if (i(o2)) return false;
529
+ const n2 = e2.getBlock(o2.anchor.blockId);
530
+ if (!n2 || "code_block" === n2.type) return false;
531
+ const r2 = { language: this.config.defaultLanguage ?? "", backgroundColor: "" }, c2 = e2.transaction("command");
532
+ return this.stripAllMarks(c2, n2), c2.setBlockType(o2.anchor.blockId, u("code_block"), r2).setSelection(d(o2.anchor.blockId, 0)), t2.dispatch(c2.build()), true;
533
+ }
534
+ exitOnDoubleEnter(t2, e2, n2) {
535
+ const r2 = t2.getState(), c2 = n2.length - 1, s2 = o(), l2 = r2.transaction("input").deleteTextAt(e2, c2, n2.length).splitBlock(e2, c2, s2).setBlockType(s2, u("paragraph")).setSelection(d(s2, 0)).build();
536
+ return t2.dispatch(l2), true;
537
+ }
538
+ insertParagraphAfter(t2, n2) {
539
+ const r2 = t2.getState(), c2 = e(r2.getBlock(n2)), s2 = o(), l2 = r2.transaction("command").splitBlock(n2, c2, s2).setBlockType(s2, u("paragraph")).setSelection(d(s2, 0)).build();
540
+ t2.dispatch(l2);
541
+ }
542
+ setAttr(t2, e2, o2, n2) {
543
+ const r2 = t2.getState(), c2 = r2.getBlock(e2);
544
+ if (!c2 || "code_block" !== c2.type) return;
545
+ const l2 = s(r2.doc, e2);
546
+ if (!l2) return;
547
+ const i2 = { ...c2.attrs, [o2]: n2 }, a2 = r2.transaction("command").setNodeAttr(l2, i2).build();
548
+ t2.dispatch(a2);
549
+ }
550
+ stripAllMarks(t2, o2) {
551
+ if (0 === e(o2)) return;
552
+ const c2 = n(o2);
553
+ let s2 = 0;
554
+ for (const e2 of c2) if (r(e2)) {
555
+ if (e2.text.length > 0) for (const n2 of e2.marks) t2.removeMark(o2.id, s2, s2 + e2.text.length, n2);
556
+ s2 += e2.text.length;
557
+ } else s2 += 1;
558
+ }
559
+ }
560
+ export {
561
+ _ as C,
562
+ B as D,
563
+ v as a,
564
+ I as d,
565
+ b as i,
566
+ m as n,
567
+ y as w
568
+ };
569
+ //# sourceMappingURL=index-CPPb-Jah.mjs.map