@notectl/core 1.7.2 → 1.7.3

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 (125) hide show
  1. package/dist/chunks/{ColorGrid-Dneqb8if.mjs → ColorGrid--lBQ7jCK.mjs} +2 -2
  2. package/dist/chunks/{ColorGrid-Dneqb8if.mjs.map → ColorGrid--lBQ7jCK.mjs.map} +1 -1
  3. package/dist/chunks/{ColorPickerPopup-CiCLBbe9.mjs → ColorPickerPopup-TpIRlXc8.mjs} +8 -8
  4. package/dist/chunks/ColorPickerPopup-TpIRlXc8.mjs.map +1 -0
  5. package/dist/chunks/Document-Brtw2jL1.mjs.map +1 -1
  6. package/dist/chunks/MarkCommands-6RUJ4L3r.mjs.map +1 -1
  7. package/dist/chunks/NodeSpec-NZVvcCuH.mjs.map +1 -1
  8. package/dist/chunks/PopupPositioning-CgjgAKjp.mjs +34 -0
  9. package/dist/chunks/PopupPositioning-CgjgAKjp.mjs.map +1 -0
  10. package/dist/chunks/{StyleRuntime-ChRjVQwL.mjs → StyleRuntime-CP4NCwKT.mjs} +49 -53
  11. package/dist/chunks/StyleRuntime-CP4NCwKT.mjs.map +1 -0
  12. package/dist/chunks/ToolbarItem-BpZggUGo.mjs.map +1 -1
  13. package/dist/chunks/{index-D515iymW.mjs → index--7pBhSF4.mjs} +5 -5
  14. package/dist/chunks/index--7pBhSF4.mjs.map +1 -0
  15. package/dist/chunks/index-BXCkjDax.mjs +161 -0
  16. package/dist/chunks/index-BXCkjDax.mjs.map +1 -0
  17. package/dist/chunks/{ToolbarPlugin-DpLVJ71w.mjs → index-BcDRT4K2.mjs} +81 -93
  18. package/dist/chunks/index-BcDRT4K2.mjs.map +1 -0
  19. package/dist/chunks/{index--n1RGpq-.mjs → index-BjFBWBOC.mjs} +46 -49
  20. package/dist/chunks/index-BjFBWBOC.mjs.map +1 -0
  21. package/dist/chunks/{index-BqNUfq-y.mjs → index-CCyqQ0Dz.mjs} +2 -2
  22. package/dist/chunks/{index-BqNUfq-y.mjs.map → index-CCyqQ0Dz.mjs.map} +1 -1
  23. package/dist/chunks/{index-DyzigvbZ.mjs → index-DSAuGP4n.mjs} +50 -50
  24. package/dist/chunks/index-DSAuGP4n.mjs.map +1 -0
  25. package/dist/chunks/{index-BhDXjueu.mjs → index-DtRfqsq5.mjs} +14 -14
  26. package/dist/chunks/{index-BhDXjueu.mjs.map → index-DtRfqsq5.mjs.map} +1 -1
  27. package/dist/chunks/{index-Dk49P9N4.mjs → index-Dum8yE_t.mjs} +11 -11
  28. package/dist/chunks/{index-Dk49P9N4.mjs.map → index-Dum8yE_t.mjs.map} +1 -1
  29. package/dist/chunks/{index-CluzpB2b.mjs → index-DxbQirny.mjs} +7 -7
  30. package/dist/chunks/{index-CluzpB2b.mjs.map → index-DxbQirny.mjs.map} +1 -1
  31. package/dist/chunks/{index-CWltg1wK.mjs → index-WpbK_s_H.mjs} +20 -25
  32. package/dist/chunks/index-WpbK_s_H.mjs.map +1 -0
  33. package/dist/chunks/{index-D3NlpmT1.mjs → index-WrqH1wG8.mjs} +3 -3
  34. package/dist/chunks/{index-D3NlpmT1.mjs.map → index-WrqH1wG8.mjs.map} +1 -1
  35. package/dist/chunks/{index-BvqkuEY1.mjs → index-fx3KIap3.mjs} +3 -3
  36. package/dist/chunks/{index-BvqkuEY1.mjs.map → index-fx3KIap3.mjs.map} +1 -1
  37. package/dist/chunks/{index-BAke7kNL.mjs → index-oOJo-ywB.mjs} +41 -41
  38. package/dist/chunks/{index-BAke7kNL.mjs.map → index-oOJo-ywB.mjs.map} +1 -1
  39. package/dist/chunks/{index-ABlTDvEX.mjs → index-toj88jtL.mjs} +2 -2
  40. package/dist/chunks/{index-ABlTDvEX.mjs.map → index-toj88jtL.mjs.map} +1 -1
  41. package/dist/commands/MarkCommands.d.ts +3 -3
  42. package/dist/commands/MarkCommands.d.ts.map +1 -1
  43. package/dist/editor/CSSClassCollector.d.ts +36 -0
  44. package/dist/editor/CSSClassCollector.d.ts.map +1 -0
  45. package/dist/editor/ContentHTMLTypes.d.ts +29 -0
  46. package/dist/editor/ContentHTMLTypes.d.ts.map +1 -0
  47. package/dist/editor/ContentStyleInjector.d.ts +69 -0
  48. package/dist/editor/ContentStyleInjector.d.ts.map +1 -0
  49. package/dist/editor/DocumentParser.d.ts +9 -1
  50. package/dist/editor/DocumentParser.d.ts.map +1 -1
  51. package/dist/editor/DocumentSerializer.d.ts +6 -0
  52. package/dist/editor/DocumentSerializer.d.ts.map +1 -1
  53. package/dist/editor/MarkSerializer.d.ts +7 -0
  54. package/dist/editor/MarkSerializer.d.ts.map +1 -1
  55. package/dist/editor/NotectlEditor.d.ts +8 -11
  56. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  57. package/dist/editor/styles/font-select.d.ts +1 -1
  58. package/dist/editor/styles/font-select.d.ts.map +1 -1
  59. package/dist/editor/styles/font-size-select.d.ts +1 -1
  60. package/dist/editor/styles/font-size-select.d.ts.map +1 -1
  61. package/dist/editor/styles/heading-select.d.ts +1 -1
  62. package/dist/editor/styles/heading-select.d.ts.map +1 -1
  63. package/dist/editor/styles/toolbar.d.ts +1 -1
  64. package/dist/editor/styles/toolbar.d.ts.map +1 -1
  65. package/dist/index.d.ts +10 -13
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/model/Document.d.ts +0 -4
  68. package/dist/model/Document.d.ts.map +1 -1
  69. package/dist/model/NodeSpec.d.ts +19 -2
  70. package/dist/model/NodeSpec.d.ts.map +1 -1
  71. package/dist/notectl-core.mjs +460 -336
  72. package/dist/notectl-core.mjs.map +1 -1
  73. package/dist/notectl-core.umd.js +676 -587
  74. package/dist/notectl-core.umd.js.map +1 -1
  75. package/dist/plugins/alignment.mjs +1 -1
  76. package/dist/plugins/blockquote.mjs +1 -1
  77. package/dist/plugins/caret-navigation.mjs +1 -1
  78. package/dist/plugins/code-block/CodeBlockPlugin.d.ts +0 -1
  79. package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
  80. package/dist/plugins/code-block/index.d.ts +2 -1
  81. package/dist/plugins/code-block/index.d.ts.map +1 -1
  82. package/dist/plugins/code-block.mjs +1 -1
  83. package/dist/plugins/font/FontPlugin.d.ts +0 -1
  84. package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
  85. package/dist/plugins/font-size/FontSizePlugin.d.ts +0 -2
  86. package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
  87. package/dist/plugins/font-size/FontSizePopup.d.ts +3 -1
  88. package/dist/plugins/font-size/FontSizePopup.d.ts.map +1 -1
  89. package/dist/plugins/font-size.mjs +1 -1
  90. package/dist/plugins/font.mjs +1 -1
  91. package/dist/plugins/heading.mjs +1 -1
  92. package/dist/plugins/highlight.mjs +1 -1
  93. package/dist/plugins/horizontal-rule.mjs +1 -1
  94. package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
  95. package/dist/plugins/image.mjs +1 -1
  96. package/dist/plugins/list.mjs +1 -1
  97. package/dist/plugins/shared/ColorPickerPopup.d.ts +2 -1
  98. package/dist/plugins/shared/ColorPickerPopup.d.ts.map +1 -1
  99. package/dist/plugins/shared/PopupManager.d.ts +12 -2
  100. package/dist/plugins/shared/PopupManager.d.ts.map +1 -1
  101. package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -1
  102. package/dist/plugins/table/TablePlugin.d.ts.map +1 -1
  103. package/dist/plugins/table.mjs +1 -1
  104. package/dist/plugins/text-color.mjs +1 -1
  105. package/dist/plugins/toolbar/ToolbarItem.d.ts +3 -2
  106. package/dist/plugins/toolbar/ToolbarItem.d.ts.map +1 -1
  107. package/dist/plugins/toolbar/ToolbarPopupController.d.ts +0 -3
  108. package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
  109. package/dist/plugins/toolbar.mjs +2 -2
  110. package/dist/presets/PresetTypes.d.ts +1 -1
  111. package/dist/presets/PresetTypes.d.ts.map +1 -1
  112. package/dist/style/StyleRuntime.d.ts +3 -7
  113. package/dist/style/StyleRuntime.d.ts.map +1 -1
  114. package/package.json +1 -1
  115. package/dist/chunks/ColorPickerPopup-CiCLBbe9.mjs.map +0 -1
  116. package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs +0 -32
  117. package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs.map +0 -1
  118. package/dist/chunks/StyleRuntime-ChRjVQwL.mjs.map +0 -1
  119. package/dist/chunks/ToolbarPlugin-DpLVJ71w.mjs.map +0 -1
  120. package/dist/chunks/index--n1RGpq-.mjs.map +0 -1
  121. package/dist/chunks/index-4or5UzNO.mjs +0 -168
  122. package/dist/chunks/index-4or5UzNO.mjs.map +0 -1
  123. package/dist/chunks/index-CWltg1wK.mjs.map +0 -1
  124. package/dist/chunks/index-D515iymW.mjs.map +0 -1
  125. package/dist/chunks/index-DyzigvbZ.mjs.map +0 -1
@@ -9,71 +9,68 @@ function s() {
9
9
  }
10
10
  function o(e2, s2) {
11
11
  const o2 = n.get(e2);
12
- o2 && (o2.destroy(), n.delete(e2)), t.set(e2, { mode: s2.mode, nonce: s2.nonce, sheet: s2.sheet ?? null });
12
+ o2 && (o2.destroy(), n.delete(e2)), t.set(e2, { nonce: s2.nonce, sheet: s2.sheet ?? null });
13
13
  }
14
14
  function i(e2) {
15
15
  const s2 = n.get(e2);
16
16
  s2 && (s2.destroy(), n.delete(e2)), t.delete(e2);
17
17
  }
18
- function l(e2, t2, n2) {
19
- const s2 = y(e2);
20
- s2 && "inline" !== s2.mode ? S(s2.root, s2.settings).setProperty(e2, t2, n2) : f(e2, t2, n2);
18
+ function r(e2, t2, n2) {
19
+ const s2 = f(e2);
20
+ s2 ? y(s2.root, s2.settings).setProperty(e2, t2, n2) : d(e2, t2, n2);
21
21
  }
22
- function r(e2, t2) {
23
- l(e2, t2, "");
22
+ function l(e2, t2) {
23
+ r(e2, t2, "");
24
24
  }
25
25
  function c(e2, t2) {
26
- const n2 = y(e2);
27
- if (n2 && "inline" !== n2.mode) S(n2.root, n2.settings).setProperties(e2, t2);
28
- else for (const [n3, s2] of Object.entries(t2)) f(e2, n3, s2 ?? "");
26
+ const n2 = f(e2);
27
+ if (n2) y(n2.root, n2.settings).setProperties(e2, t2);
28
+ else for (const [n3, s2] of Object.entries(t2)) d(e2, n3, s2 ?? "");
29
29
  }
30
30
  function a(e2, t2) {
31
- const n2 = y(e2);
32
- n2 && "inline" !== n2.mode ? S(n2.root, n2.settings).setStyleText(e2, t2) : e2.style.cssText = t2;
31
+ const n2 = f(e2);
32
+ n2 ? y(n2.root, n2.settings).setStyleText(e2, t2) : e2.style.cssText = t2;
33
33
  }
34
34
  function h(e2, t2) {
35
- const n2 = y(e2);
36
- if (!n2 || "inline" === n2.mode) {
35
+ const n2 = f(e2);
36
+ if (!n2) {
37
37
  const n3 = e2.style.cssText;
38
38
  return void (e2.style.cssText = n3 ? `${n3}; ${t2}` : t2);
39
39
  }
40
- S(n2.root, n2.settings).appendStyleText(e2, t2);
40
+ y(n2.root, n2.settings).appendStyleText(e2, t2);
41
41
  }
42
- function u(e2, t2) {
43
- a(e2, t2);
44
- }
45
- function d(e2) {
46
- const n2 = p(e2);
42
+ function u(e2) {
43
+ const n2 = m(e2);
47
44
  if (n2) return t.get(n2)?.nonce;
48
45
  }
49
- function f(e2, t2, n2) {
46
+ function d(e2, t2, n2) {
50
47
  t2.startsWith("--") || t2.includes("-") ? n2 ? e2.style.setProperty(t2, n2) : e2.style.removeProperty(t2) : e2.style[t2] = n2;
51
48
  }
52
- function y(e2) {
49
+ function f(e2) {
53
50
  const n2 = (function(e3) {
54
- return p(e3);
51
+ return m(e3);
55
52
  })(e2);
56
53
  if (!n2) return null;
57
54
  const s2 = t.get(n2);
58
- return s2 ? { root: n2, mode: s2.mode, settings: s2 } : null;
55
+ return s2 ? { root: n2, settings: s2 } : null;
59
56
  }
60
- function S(e2, t2) {
57
+ function y(e2, t2) {
61
58
  const s2 = n.get(e2);
62
59
  if (s2) return s2;
63
- const o2 = new g(e2, t2);
60
+ const o2 = new p(e2, t2);
64
61
  return n.set(e2, o2), o2;
65
62
  }
66
- function m(e2) {
63
+ function S(e2) {
67
64
  return "undefined" != typeof ShadowRoot && e2 instanceof ShadowRoot;
68
65
  }
69
66
  function k(e2) {
70
67
  return "undefined" != typeof Document && e2 instanceof Document;
71
68
  }
72
- function p(e2) {
73
- const t2 = m(e2) || k(e2) ? e2 : e2.getRootNode();
74
- return m(t2) || k(t2) ? t2 : "undefined" != typeof document ? document : null;
69
+ function m(e2) {
70
+ const t2 = S(e2) || k(e2) ? e2 : e2.getRootNode();
71
+ return S(t2) || k(t2) ? t2 : "undefined" != typeof document ? document : null;
75
72
  }
76
- class g {
73
+ class p {
77
74
  declarationByElement = /* @__PURE__ */ new WeakMap();
78
75
  tokenByDeclaration = /* @__PURE__ */ new Map();
79
76
  declarationByToken = /* @__PURE__ */ new Map();
@@ -92,23 +89,23 @@ class g {
92
89
  this.clearRuntimeRules(), this.ownsAdoptedSheet && this.sheet && "adoptedStyleSheets" in this.root && (this.root.adoptedStyleSheets = this.root.adoptedStyleSheets.filter((e2) => e2 !== this.sheet)), this.fallbackStyleElement?.remove(), this.fallbackStyleElement = null, this.sheet = null, this.ownsAdoptedSheet = false, this.tokenByDeclaration.clear(), this.declarationByToken.clear(), this.tokenRefCount.clear(), this.tokenCounter = 0;
93
90
  }
94
91
  setProperty(e2, t2, n2) {
95
- const s2 = this.getOrCreateDeclarations(e2), o2 = C(t2);
92
+ const s2 = this.getOrCreateDeclarations(e2), o2 = R(t2);
96
93
  n2 ? s2.set(o2, n2) : s2.delete(o2), this.syncElementToken(e2, s2);
97
94
  }
98
95
  setProperties(e2, t2) {
99
96
  const n2 = this.getOrCreateDeclarations(e2);
100
97
  for (const [e3, s2] of Object.entries(t2)) {
101
- const t3 = C(e3);
98
+ const t3 = R(e3);
102
99
  s2 ? n2.set(t3, s2) : n2.delete(t3);
103
100
  }
104
101
  this.syncElementToken(e2, n2);
105
102
  }
106
103
  setStyleText(e2, t2) {
107
- const n2 = E(t2);
104
+ const n2 = g(t2);
108
105
  0 !== n2.size ? (this.declarationByElement.set(e2, n2), this.syncElementToken(e2, n2)) : this.clearElementStyles(e2);
109
106
  }
110
107
  appendStyleText(e2, t2) {
111
- const n2 = E(t2);
108
+ const n2 = g(t2);
112
109
  if (0 === n2.size) return;
113
110
  const s2 = this.getOrCreateDeclarations(e2);
114
111
  for (const [e3, t3] of n2) s2.set(e3, t3);
@@ -116,7 +113,7 @@ class g {
116
113
  }
117
114
  getStyleText(e2) {
118
115
  const t2 = this.declarationByElement.get(e2);
119
- return t2 && 0 !== t2.size ? R(t2) : "";
116
+ return t2 && 0 !== t2.size ? E(t2) : "";
120
117
  }
121
118
  getOrCreateDeclarations(e2) {
122
119
  const t2 = this.declarationByElement.get(e2);
@@ -127,12 +124,12 @@ class g {
127
124
  syncElementToken(t2, n2) {
128
125
  const s2 = this.tokenByElement.get(t2);
129
126
  if (0 === n2.size) return void this.clearElementStyles(t2);
130
- const o2 = R(n2);
127
+ const o2 = E(n2);
131
128
  let i2 = this.tokenByDeclaration.get(o2);
132
129
  i2 || (i2 = `s${this.tokenCounter.toString(36)}`, this.tokenCounter += 1, this.tokenByDeclaration.set(o2, i2), this.declarationByToken.set(i2, o2), this.insertRule(i2, o2)), s2 !== i2 && (this.retainToken(i2), s2 && this.releaseToken(s2), this.tokenByElement.set(t2, i2)), t2.setAttribute(e, i2);
133
130
  }
134
131
  insertRule(e2, t2) {
135
- const n2 = `${T(e2)} { ${t2}; }`, s2 = this.ensureSheet();
132
+ const n2 = `${C(e2)} { ${t2}; }`, s2 = this.ensureSheet();
136
133
  if (s2) try {
137
134
  s2.insertRule(n2, s2.cssRules.length);
138
135
  } catch {
@@ -171,10 +168,10 @@ class g {
171
168
  deleteRule(e2) {
172
169
  const t2 = this.sheet;
173
170
  if (!t2) return;
174
- const n2 = T(e2);
171
+ const n2 = C(e2);
175
172
  for (let e3 = t2.cssRules.length - 1; e3 >= 0; e3 -= 1) {
176
173
  const s2 = t2.cssRules[e3];
177
- if (s2 && w(s2, n2)) {
174
+ if (s2 && T(s2, n2)) {
178
175
  try {
179
176
  t2.deleteRule(e3);
180
177
  } catch {
@@ -196,44 +193,43 @@ class g {
196
193
  ensureFallbackStyleElement() {
197
194
  if (this.fallbackStyleElement) return this.fallbackStyleElement;
198
195
  const e2 = document.createElement("style");
199
- return e2.setAttribute("data-notectl-runtime-styles", ""), this.nonce && e2.setAttribute("nonce", this.nonce), m(this.root) ? this.root.appendChild(e2) : (this.root.head ?? this.root.documentElement).appendChild(e2), this.fallbackStyleElement = e2, e2;
196
+ return e2.setAttribute("data-notectl-runtime-styles", ""), this.nonce && e2.setAttribute("nonce", this.nonce), S(this.root) ? this.root.appendChild(e2) : (this.root.head ?? this.root.documentElement).appendChild(e2), this.fallbackStyleElement = e2, e2;
200
197
  }
201
198
  }
202
- function E(e2) {
199
+ function g(e2) {
203
200
  const t2 = /* @__PURE__ */ new Map();
204
201
  for (const n2 of e2.split(";")) {
205
202
  const e3 = n2.trim();
206
203
  if (!e3) continue;
207
204
  const s2 = e3.indexOf(":");
208
205
  if (s2 <= 0) continue;
209
- const o2 = C(e3.slice(0, s2)), i2 = e3.slice(s2 + 1).trim();
206
+ const o2 = R(e3.slice(0, s2)), i2 = e3.slice(s2 + 1).trim();
210
207
  i2 ? t2.set(o2, i2) : t2.delete(o2);
211
208
  }
212
209
  return t2;
213
210
  }
214
- function R(e2) {
211
+ function E(e2) {
215
212
  return Array.from(e2.entries()).sort(([e3], [t2]) => e3.localeCompare(t2)).map(([e3, t2]) => `${e3}: ${t2}`).join("; ");
216
213
  }
217
- function C(e2) {
214
+ function R(e2) {
218
215
  const t2 = e2.trim();
219
216
  return t2 ? t2.startsWith("--") ? t2 : t2.includes("-") ? t2.toLowerCase() : t2.replace(/[A-Z]/g, (e3) => `-${e3.toLowerCase()}`).toLowerCase() : "";
220
217
  }
221
- function T(t2) {
218
+ function C(t2) {
222
219
  return `[${e}="${t2}"]`;
223
220
  }
224
- function w(e2, t2) {
221
+ function T(e2, t2) {
225
222
  return "undefined" != typeof CSSStyleRule && e2 instanceof CSSStyleRule ? e2.selectorText === t2 : e2.cssText.includes(t2);
226
223
  }
227
224
  export {
228
- l as a,
229
- u as b,
225
+ r as a,
226
+ a as b,
230
227
  h as c,
231
- a as d,
232
- s as e,
233
- r as f,
234
- d as g,
228
+ s as d,
229
+ l as e,
230
+ u as g,
235
231
  o as r,
236
232
  c as s,
237
233
  i as u
238
234
  };
239
- //# sourceMappingURL=StyleRuntime-ChRjVQwL.mjs.map
235
+ //# sourceMappingURL=StyleRuntime-CP4NCwKT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StyleRuntime-CP4NCwKT.mjs","sources":["../../src/style/StyleRuntime.ts"],"sourcesContent":["/**\n * Runtime style abstraction.\n *\n * Writes no inline styles and instead assigns token attributes\n * backed by dynamic CSS rules in a stylesheet.\n * Elements outside a registered root fall back to inline styles.\n */\n\nexport interface StyleRootOptions {\n\treadonly nonce?: string;\n\treadonly sheet?: CSSStyleSheet | null;\n}\n\ntype StyleRoot = ShadowRoot | Document;\n\ninterface RootConfig {\n\treadonly nonce?: string;\n\treadonly sheet: CSSStyleSheet | null;\n}\n\nconst STYLE_TOKEN_ATTR = 'data-notectl-style-token';\nconst STYLE_ELEMENT_ATTR = 'data-notectl-runtime-styles';\n\nconst rootConfigs: WeakMap<StyleRoot, RootConfig> = new WeakMap();\nconst strictEngines: WeakMap<StyleRoot, StrictStyleEngine> = new WeakMap();\n\n/** Creates a constructable stylesheet when the environment supports it. */\nexport function createRuntimeStyleSheet(): CSSStyleSheet | null {\n\tif (typeof CSSStyleSheet === 'undefined') return null;\n\ttry {\n\t\treturn new CSSStyleSheet();\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** Registers styling mode for a root (shadow root or document). */\nexport function registerStyleRoot(root: StyleRoot, options: StyleRootOptions): void {\n\tconst previous = strictEngines.get(root);\n\tif (previous) {\n\t\tprevious.destroy();\n\t\tstrictEngines.delete(root);\n\t}\n\trootConfigs.set(root, {\n\t\tnonce: options.nonce,\n\t\tsheet: options.sheet ?? null,\n\t});\n}\n\n/** Unregisters root styling and tears down strict runtime state if present. */\nexport function unregisterStyleRoot(root: StyleRoot): void {\n\tconst engine = strictEngines.get(root);\n\tif (engine) {\n\t\tengine.destroy();\n\t\tstrictEngines.delete(root);\n\t}\n\trootConfigs.delete(root);\n}\n\n/** Sets a single style property. Empty value removes the property. */\nexport function setStyleProperty(el: HTMLElement, property: string, value: string): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tsetInlineProperty(el, property, value);\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).setProperty(el, property, value);\n}\n\n/** Removes a single style property. */\nexport function removeStyleProperty(el: HTMLElement, property: string): void {\n\tsetStyleProperty(el, property, '');\n}\n\n/** Sets multiple style properties in one call. */\nexport function setStyleProperties(\n\tel: HTMLElement,\n\tproperties: Readonly<Record<string, string | undefined | null>>,\n): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tfor (const [property, value] of Object.entries(properties)) {\n\t\t\tsetInlineProperty(el, property, value ?? '');\n\t\t}\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).setProperties(el, properties);\n}\n\n/** Replaces the element style text. */\nexport function setStyleText(el: HTMLElement, cssText: string): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tel.style.cssText = cssText;\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).setStyleText(el, cssText);\n}\n\n/** Merges a cssText fragment into current element styles. */\nexport function appendStyleText(el: HTMLElement, cssText: string): void {\n\tconst config = resolveConfig(el);\n\tif (!config) {\n\t\tconst current = el.style.cssText;\n\t\tel.style.cssText = current ? `${current}; ${cssText}` : cssText;\n\t\treturn;\n\t}\n\tgetStrictEngine(config.root, config.settings).appendStyleText(el, cssText);\n}\n\n/** Returns serialized styles for an element. */\nexport function getStyleText(el: HTMLElement): string {\n\tconst config = resolveConfig(el);\n\tif (!config) return el.style.cssText;\n\treturn getStrictEngine(config.root, config.settings).getStyleText(el);\n}\n\n/** Returns the configured CSP nonce for the node's style root (if any). */\nexport function getStyleNonceForNode(node: Node): string | undefined {\n\tconst root = resolveStyleRootFromNode(node);\n\tif (!root) return undefined;\n\treturn rootConfigs.get(root)?.nonce;\n}\n\nfunction setInlineProperty(el: HTMLElement, property: string, value: string): void {\n\tif (property.startsWith('--')) {\n\t\tif (value) {\n\t\t\tel.style.setProperty(property, value);\n\t\t} else {\n\t\t\tel.style.removeProperty(property);\n\t\t}\n\t\treturn;\n\t}\n\tif (property.includes('-')) {\n\t\tif (value) {\n\t\t\tel.style.setProperty(property, value);\n\t\t} else {\n\t\t\tel.style.removeProperty(property);\n\t\t}\n\t\treturn;\n\t}\n\t(el.style as CSSStyleDeclaration & Record<string, string>)[property] = value;\n}\n\nfunction resolveConfig(el: HTMLElement): { root: StyleRoot; settings: RootConfig } | null {\n\tconst root = resolveStyleRoot(el);\n\tif (!root) return null;\n\tconst settings = rootConfigs.get(root);\n\tif (!settings) return null;\n\treturn { root, settings };\n}\n\nfunction resolveStyleRoot(el: HTMLElement): StyleRoot | null {\n\treturn resolveStyleRootFromNode(el);\n}\n\nfunction getStrictEngine(root: StyleRoot, config: RootConfig): StrictStyleEngine {\n\tconst cached = strictEngines.get(root);\n\tif (cached) return cached;\n\tconst engine = new StrictStyleEngine(root, config);\n\tstrictEngines.set(root, engine);\n\treturn engine;\n}\n\nfunction isShadowRoot(value: unknown): value is ShadowRoot {\n\treturn typeof ShadowRoot !== 'undefined' && value instanceof ShadowRoot;\n}\n\nfunction isDocument(value: unknown): value is Document {\n\treturn typeof Document !== 'undefined' && value instanceof Document;\n}\n\nfunction resolveStyleRootFromNode(node: Node): StyleRoot | null {\n\tconst rootNode: Node = isShadowRoot(node) || isDocument(node) ? node : node.getRootNode();\n\tif (isShadowRoot(rootNode)) return rootNode;\n\tif (isDocument(rootNode)) return rootNode;\n\tif (typeof document !== 'undefined') return document;\n\treturn null;\n}\n\nclass StrictStyleEngine {\n\tprivate readonly declarationByElement: WeakMap<HTMLElement, Map<string, string>> = new WeakMap();\n\tprivate readonly tokenByDeclaration: Map<string, string> = new Map();\n\tprivate readonly declarationByToken: Map<string, string> = new Map();\n\tprivate readonly tokenRefCount: Map<string, number> = new Map();\n\tprivate readonly tokenByElement: WeakMap<HTMLElement, string> = new WeakMap();\n\tprivate tokenCounter = 0;\n\tprivate readonly root: StyleRoot;\n\tprivate readonly nonce?: string;\n\tprivate sheet: CSSStyleSheet | null;\n\tprivate fallbackStyleElement: HTMLStyleElement | null = null;\n\tprivate ownsAdoptedSheet = false;\n\n\tconstructor(root: StyleRoot, config: RootConfig) {\n\t\tthis.root = root;\n\t\tthis.nonce = config.nonce;\n\t\tthis.sheet = config.sheet ?? null;\n\t}\n\n\tdestroy(): void {\n\t\tthis.clearRuntimeRules();\n\t\tif (this.ownsAdoptedSheet && this.sheet && 'adoptedStyleSheets' in this.root) {\n\t\t\tthis.root.adoptedStyleSheets = this.root.adoptedStyleSheets.filter(\n\t\t\t\t(adoptedSheet: CSSStyleSheet): boolean => adoptedSheet !== this.sheet,\n\t\t\t);\n\t\t}\n\t\tthis.fallbackStyleElement?.remove();\n\t\tthis.fallbackStyleElement = null;\n\t\tthis.sheet = null;\n\t\tthis.ownsAdoptedSheet = false;\n\t\tthis.tokenByDeclaration.clear();\n\t\tthis.declarationByToken.clear();\n\t\tthis.tokenRefCount.clear();\n\t\tthis.tokenCounter = 0;\n\t}\n\n\tsetProperty(el: HTMLElement, property: string, value: string): void {\n\t\tconst declarations = this.getOrCreateDeclarations(el);\n\t\tconst name = normalizePropertyName(property);\n\t\tif (!value) {\n\t\t\tdeclarations.delete(name);\n\t\t} else {\n\t\t\tdeclarations.set(name, value);\n\t\t}\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tsetProperties(\n\t\tel: HTMLElement,\n\t\tproperties: Readonly<Record<string, string | undefined | null>>,\n\t): void {\n\t\tconst declarations = this.getOrCreateDeclarations(el);\n\t\tfor (const [property, value] of Object.entries(properties)) {\n\t\t\tconst name = normalizePropertyName(property);\n\t\t\tif (!value) {\n\t\t\t\tdeclarations.delete(name);\n\t\t\t} else {\n\t\t\t\tdeclarations.set(name, value);\n\t\t\t}\n\t\t}\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tsetStyleText(el: HTMLElement, cssText: string): void {\n\t\tconst declarations = parseStyleText(cssText);\n\t\tif (declarations.size === 0) {\n\t\t\tthis.clearElementStyles(el);\n\t\t\treturn;\n\t\t}\n\t\tthis.declarationByElement.set(el, declarations);\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tappendStyleText(el: HTMLElement, cssText: string): void {\n\t\tconst parsed = parseStyleText(cssText);\n\t\tif (parsed.size === 0) return;\n\t\tconst declarations = this.getOrCreateDeclarations(el);\n\t\tfor (const [property, value] of parsed) {\n\t\t\tdeclarations.set(property, value);\n\t\t}\n\t\tthis.syncElementToken(el, declarations);\n\t}\n\n\tgetStyleText(el: HTMLElement): string {\n\t\tconst declarations = this.declarationByElement.get(el);\n\t\tif (!declarations || declarations.size === 0) return '';\n\t\treturn serializeDeclarations(declarations);\n\t}\n\n\tprivate getOrCreateDeclarations(el: HTMLElement): Map<string, string> {\n\t\tconst existing = this.declarationByElement.get(el);\n\t\tif (existing) return existing;\n\t\tconst created = new Map<string, string>();\n\t\tthis.declarationByElement.set(el, created);\n\t\treturn created;\n\t}\n\n\tprivate syncElementToken(el: HTMLElement, declarations: Map<string, string>): void {\n\t\tconst previousToken = this.tokenByElement.get(el);\n\t\tif (declarations.size === 0) {\n\t\t\tthis.clearElementStyles(el);\n\t\t\treturn;\n\t\t}\n\n\t\tconst declarationText = serializeDeclarations(declarations);\n\t\tlet token = this.tokenByDeclaration.get(declarationText);\n\t\tif (!token) {\n\t\t\ttoken = `s${this.tokenCounter.toString(36)}`;\n\t\t\tthis.tokenCounter += 1;\n\t\t\tthis.tokenByDeclaration.set(declarationText, token);\n\t\t\tthis.declarationByToken.set(token, declarationText);\n\t\t\tthis.insertRule(token, declarationText);\n\t\t}\n\t\tif (previousToken !== token) {\n\t\t\tthis.retainToken(token);\n\t\t\tif (previousToken) {\n\t\t\t\tthis.releaseToken(previousToken);\n\t\t\t}\n\t\t\tthis.tokenByElement.set(el, token);\n\t\t}\n\t\tel.setAttribute(STYLE_TOKEN_ATTR, token);\n\t}\n\n\tprivate insertRule(token: string, declarationText: string): void {\n\t\tconst rule = `${buildTokenSelector(token)} { ${declarationText}; }`;\n\t\tconst sheet = this.ensureSheet();\n\t\tif (!sheet) return;\n\t\ttry {\n\t\t\tsheet.insertRule(rule, sheet.cssRules.length);\n\t\t} catch {\n\t\t\t// Ignore malformed declarations from third-party plugin attrs.\n\t\t}\n\t}\n\n\tprivate ensureSheet(): CSSStyleSheet | null {\n\t\tif (this.sheet) return this.sheet;\n\n\t\tif (typeof CSSStyleSheet !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tconst sheet = new CSSStyleSheet();\n\t\t\t\tif ('adoptedStyleSheets' in this.root) {\n\t\t\t\t\tconst adopted = this.root.adoptedStyleSheets;\n\t\t\t\t\tthis.root.adoptedStyleSheets = [...adopted, sheet];\n\t\t\t\t\tthis.sheet = sheet;\n\t\t\t\t\tthis.ownsAdoptedSheet = true;\n\t\t\t\t\treturn sheet;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Fall through to style element fallback.\n\t\t\t}\n\t\t}\n\n\t\tconst style = this.ensureFallbackStyleElement();\n\t\tthis.sheet = (style.sheet as CSSStyleSheet | null) ?? null;\n\t\treturn this.sheet;\n\t}\n\n\tprivate clearElementStyles(el: HTMLElement): void {\n\t\tthis.declarationByElement.delete(el);\n\t\tconst token = this.tokenByElement.get(el);\n\t\tif (token) {\n\t\t\tthis.tokenByElement.delete(el);\n\t\t\tthis.releaseToken(token);\n\t\t}\n\t\tel.removeAttribute(STYLE_TOKEN_ATTR);\n\t}\n\n\tprivate retainToken(token: string): void {\n\t\tconst current = this.tokenRefCount.get(token) ?? 0;\n\t\tthis.tokenRefCount.set(token, current + 1);\n\t}\n\n\tprivate releaseToken(token: string): void {\n\t\tconst current = this.tokenRefCount.get(token);\n\t\tif (!current) return;\n\t\tif (current > 1) {\n\t\t\tthis.tokenRefCount.set(token, current - 1);\n\t\t\treturn;\n\t\t}\n\t\tthis.tokenRefCount.delete(token);\n\t\tconst declaration = this.declarationByToken.get(token);\n\t\tif (declaration) {\n\t\t\tthis.declarationByToken.delete(token);\n\t\t\tthis.tokenByDeclaration.delete(declaration);\n\t\t}\n\t\tthis.deleteRule(token);\n\t}\n\n\tprivate deleteRule(token: string): void {\n\t\tconst sheet = this.sheet;\n\t\tif (!sheet) return;\n\t\tconst selector = buildTokenSelector(token);\n\t\tfor (let index = sheet.cssRules.length - 1; index >= 0; index -= 1) {\n\t\t\tconst rule = sheet.cssRules[index];\n\t\t\tif (!rule || !isTokenSelectorMatch(rule, selector)) continue;\n\t\t\ttry {\n\t\t\t\tsheet.deleteRule(index);\n\t\t\t} catch {\n\t\t\t\t// Ignore parser/runtime discrepancies in unsupported environments.\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate clearRuntimeRules(): void {\n\t\tconst sheet = this.sheet;\n\t\tif (!sheet) return;\n\t\tfor (let index = sheet.cssRules.length - 1; index >= 0; index -= 1) {\n\t\t\tconst rule = sheet.cssRules[index];\n\t\t\tif (!rule || !rule.cssText.includes(`[${STYLE_TOKEN_ATTR}=\"`)) continue;\n\t\t\ttry {\n\t\t\t\tsheet.deleteRule(index);\n\t\t\t} catch {\n\t\t\t\t// Ignore parser/runtime discrepancies in unsupported environments.\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureFallbackStyleElement(): HTMLStyleElement {\n\t\tif (this.fallbackStyleElement) return this.fallbackStyleElement;\n\t\tconst style: HTMLStyleElement = document.createElement('style');\n\t\tstyle.setAttribute(STYLE_ELEMENT_ATTR, '');\n\t\tif (this.nonce) {\n\t\t\tstyle.setAttribute('nonce', this.nonce);\n\t\t}\n\t\tif (isShadowRoot(this.root)) {\n\t\t\tthis.root.appendChild(style);\n\t\t} else {\n\t\t\tconst host = this.root.head ?? this.root.documentElement;\n\t\t\thost.appendChild(style);\n\t\t}\n\t\tthis.fallbackStyleElement = style;\n\t\treturn style;\n\t}\n}\n\nfunction parseStyleText(styleText: string): Map<string, string> {\n\tconst declarations = new Map<string, string>();\n\tfor (const rawPart of styleText.split(';')) {\n\t\tconst part = rawPart.trim();\n\t\tif (!part) continue;\n\t\tconst separator = part.indexOf(':');\n\t\tif (separator <= 0) continue;\n\t\tconst property = normalizePropertyName(part.slice(0, separator));\n\t\tconst value = part.slice(separator + 1).trim();\n\t\tif (!value) {\n\t\t\tdeclarations.delete(property);\n\t\t} else {\n\t\t\tdeclarations.set(property, value);\n\t\t}\n\t}\n\treturn declarations;\n}\n\nfunction serializeDeclarations(declarations: Map<string, string>): string {\n\tconst ordered: [string, string][] = Array.from(declarations.entries()).sort(([a], [b]) =>\n\t\ta.localeCompare(b),\n\t);\n\treturn ordered.map(([property, value]) => `${property}: ${value}`).join('; ');\n}\n\nfunction normalizePropertyName(property: string): string {\n\tconst trimmed = property.trim();\n\tif (!trimmed) return '';\n\tif (trimmed.startsWith('--')) return trimmed;\n\tif (trimmed.includes('-')) return trimmed.toLowerCase();\n\treturn trimmed.replace(/[A-Z]/g, (char: string) => `-${char.toLowerCase()}`).toLowerCase();\n}\n\nfunction buildTokenSelector(token: string): string {\n\treturn `[${STYLE_TOKEN_ATTR}=\"${token}\"]`;\n}\n\nfunction isTokenSelectorMatch(rule: CSSRule, selector: string): boolean {\n\tif (typeof CSSStyleRule !== 'undefined' && rule instanceof CSSStyleRule) {\n\t\treturn rule.selectorText === selector;\n\t}\n\treturn rule.cssText.includes(selector);\n}\n"],"names":["STYLE_TOKEN_ATTR","rootConfigs","WeakMap","strictEngines","createRuntimeStyleSheet","CSSStyleSheet","registerStyleRoot","root","options","previous","get","destroy","delete","set","nonce","sheet","unregisterStyleRoot","engine","setStyleProperty","el","property","value","config","resolveConfig","getStrictEngine","settings","setProperty","setInlineProperty","removeStyleProperty","setStyleProperties","properties","setProperties","Object","entries","setStyleText","cssText","style","appendStyleText","current","getStyleNonceForNode","node","resolveStyleRootFromNode","startsWith","includes","removeProperty","cached","StrictStyleEngine","isShadowRoot","ShadowRoot","isDocument","Document","rootNode","getRootNode","document","declarationByElement","tokenByDeclaration","Map","declarationByToken","tokenRefCount","tokenByElement","tokenCounter","fallbackStyleElement","ownsAdoptedSheet","this","clearRuntimeRules","adoptedStyleSheets","filter","adoptedSheet","remove","clear","declarations","getOrCreateDeclarations","name","normalizePropertyName","syncElementToken","parseStyleText","size","clearElementStyles","parsed","serializeDeclarations","existing","created","previousToken","declarationText","token","toString","insertRule","retainToken","releaseToken","setAttribute","rule","buildTokenSelector","ensureSheet","cssRules","length","adopted","ensureFallbackStyleElement","removeAttribute","declaration","deleteRule","selector","index","isTokenSelectorMatch","createElement","appendChild","head","documentElement","styleText","rawPart","split","part","trim","separator","indexOf","slice","Array","from","sort","a","b","localeCompare","map","join","trimmed","toLowerCase","replace","char","CSSStyleRule","selectorText"],"mappings":"AAoBA,MAAMA,IAAmB,4BAGnBC,wBAAkDC,WAClDC,wBAA2DD;AAG1D,SAASE,IAAAA;AACf,MAA6B,eAAA,OAAlBC,cAA+B,QAAO;AACjD,MAAA;AACC,WAAO,IAAIA;AAAAA,EACZ,QAAA;AACC,WAAO;AAAA,EACR;AACD;AAGO,SAASC,EAAkBC,IAAiBC,IAAAA;AAClD,QAAMC,KAAWN,EAAcO,IAAIH,EAAAA;AAC/BE,EAAAA,OACHA,GAASE,QAAAA,GACTR,EAAcS,OAAOL,EAAAA,IAEtBN,EAAYY,IAAIN,IAAM,EACrBO,OAAON,GAAQM,OACfC,OAAOP,GAAQO,SAAS,KAAA,CAAA;AAE1B;AAGO,SAASC,EAAoBT,IAAAA;AACnC,QAAMU,KAASd,EAAcO,IAAIH,EAAAA;AAC7BU,EAAAA,OACHA,GA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AA;AAI9B,SAHoC6C,MAAMC,KAAK9C,GAAarC,QAAAA,CAAAA,EAAWoF,KAAK,CAAA,CAAEC,EAAAA,GAAAA,CAAKC,EAAAA,MAClFD,GAAEE,cAAcD,EAAAA,CAAAA,EAEFE,IAAI,CAAA,CAAErG,IAAUC,EAAAA,MAAW,GAAGD,EAAAA,KAAaC,EAAAA,EAAAA,EAASqG,KAAK,IAAA;AACzE;AAEA,SAASjD,EAAsBrD,IAAAA;AAC9B,QAAMuG,KAAUvG,GAAS2F,KAAAA;AACzB,SAAKY,KACDA,GAAQjF,WAAW,IAAA,IAAciF,KACjCA,GAAQhF,SAAS,GAAA,IAAagF,GAAQC,YAAAA,IACnCD,GAAQE,QAAQ,UAAWC,CAAAA,OAAiB,IAAIA,GAAKF,iBAAiBA,YAAAA,IAHxD;AAItB;AAEA,SAASjC,EAAmBP,IAAAA;AAC3B,SAAO,IAAIpF,CAAAA,KAAqBoF,EAAAA;AACjC;AAEA,SAASkB,EAAqBZ,IAAeU,IAAAA;AAC5C,SAA4B,sBAAjB2B,gBAAgCrC,cAAgBqC,eACnDrC,GAAKsC,iBAAiB5B,KAEvBV,GAAKvD,QAAQQ,SAASyD,EAAAA;AAC9B;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarItem-BpZggUGo.mjs","sources":["../../src/plugins/toolbar/ToolbarItem.ts"],"sourcesContent":["/**\n * ToolbarItem: describes a toolbar button registered by a plugin.\n */\n\nimport type { EditorState } from '../../state/EditorState.js';\nimport { isMac } from '../../view/Platform.js';\nimport type { PluginContext } from '../Plugin.js';\n\nexport interface GridPickerConfig {\n\treadonly maxRows: number;\n\treadonly maxCols: number;\n\tonSelect(rows: number, cols: number): void;\n}\n\nexport interface DropdownConfig {\n\treadonly items: readonly { label: string; command: string; icon?: string }[];\n}\n\nexport type ToolbarGroup = 'format' | 'block' | 'insert' | (string & {});\nexport type PopupType = 'gridPicker' | 'dropdown' | 'custom' | 'combobox';\n\ninterface ToolbarItemBase {\n\treadonly id: string;\n\t/** Grouping key: 'format' | 'insert' | 'block' or custom. */\n\treadonly group: ToolbarGroup;\n\t/** Icon content: inline SVG markup or plain text. Rendered via innerHTML. */\n\treadonly icon: string;\n\treadonly label: string;\n\t/** Tooltip shown on hover, e.g. \"Bold (Ctrl+B)\". Falls back to label. */\n\treadonly tooltip?: string;\n\t/** Command name to execute on click. */\n\treadonly command: string;\n\t/**\n\t * Lower priority renders further left.\n\t * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.\n\t */\n\treadonly priority?: number;\n\t/**\n\t * When true, a visual separator is rendered after this item.\n\t * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.\n\t */\n\treadonly separatorAfter?: boolean;\n\tisActive?(state: EditorState): boolean;\n\tisEnabled?(state: EditorState): boolean;\n}\n\ninterface ToolbarItemNoPopup extends ToolbarItemBase {\n\treadonly popupType?: undefined;\n}\n\ninterface ToolbarItemGridPicker extends ToolbarItemBase {\n\treadonly popupType: 'gridPicker';\n\treadonly popupConfig: GridPickerConfig;\n}\n\ninterface ToolbarItemDropdown extends ToolbarItemBase {\n\treadonly popupType: 'dropdown';\n\treadonly popupConfig: DropdownConfig;\n}\n\ninterface ToolbarItemCustomPopup extends ToolbarItemBase {\n\treadonly popupType: 'custom';\n\trenderPopup(container: HTMLElement, context: PluginContext, onClose: () => void): void;\n}\n\nexport interface ToolbarItemCombobox extends Omit<ToolbarItemBase, 'icon'> {\n\treadonly popupType: 'combobox';\n\t/** Optional icon — combobox items typically display a text label instead. */\n\treadonly icon?: string;\n\t/** Pure function returning the current label text. Called on every state change. */\n\tgetLabel(state: EditorState): string;\n\t/** Renders the popup content when the combobox is opened. */\n\trenderPopup(container: HTMLElement, context: PluginContext, onClose: () => void): void;\n}\n\nexport type ToolbarItem =\n\t| ToolbarItemNoPopup\n\t| ToolbarItemGridPicker\n\t| ToolbarItemDropdown\n\t| ToolbarItemCustomPopup\n\t| ToolbarItemCombobox;\n\n/**\n * Formats a keymap binding string into a human-readable shortcut,\n * using platform-appropriate modifier symbols (⌘ on Mac, Ctrl on others).\n *\n * @example formatShortcut('Mod-B') → \"Ctrl+B\" or \"⌘B\"\n * @example formatShortcut('Mod-Shift-X') → \"Ctrl+Shift+X\" or \"⌘⇧X\"\n */\nexport function formatShortcut(binding: string): string {\n\tif (isMac()) {\n\t\treturn binding\n\t\t\t.replace(/Mod/g, '⌘')\n\t\t\t.replace(/Shift/g, '⇧')\n\t\t\t.replace(/Alt/g, '⌥')\n\t\t\t.replace(/-/g, '');\n\t}\n\treturn binding.replace(/Mod/g, 'Ctrl').replace(/-/g, '+');\n}\n"],"names":["formatShortcut","binding","isMac","replace"],"mappings":";AAyFO,SAASA,EAAeC,IAAAA;AAC9B,SAAIC,EAAAA,IACID,GACLE,QAAQ,QAAQ,GAAA,EAChBA,QAAQ,UAAU,GAAA,EAClBA,QAAQ,QAAQ,GAAA,EAChBA,QAAQ,MAAM,EAAA,IAEVF,GAAQE,QAAQ,QAAQ,MAAA,EAAQA,QAAQ,MAAM,GAAA;AACtD;"}
1
+ {"version":3,"file":"ToolbarItem-BpZggUGo.mjs","sources":["../../src/plugins/toolbar/ToolbarItem.ts"],"sourcesContent":["/**\n * ToolbarItem: describes a toolbar button registered by a plugin.\n */\n\nimport type { EditorState } from '../../state/EditorState.js';\nimport { isMac } from '../../view/Platform.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { PopupCloseOptions } from '../shared/PopupManager.js';\n\nexport interface GridPickerConfig {\n\treadonly maxRows: number;\n\treadonly maxCols: number;\n\tonSelect(rows: number, cols: number): void;\n}\n\nexport interface DropdownConfig {\n\treadonly items: readonly { label: string; command: string; icon?: string }[];\n}\n\nexport type ToolbarGroup = 'format' | 'block' | 'insert' | (string & {});\nexport type PopupType = 'gridPicker' | 'dropdown' | 'custom' | 'combobox';\n\ninterface ToolbarItemBase {\n\treadonly id: string;\n\t/** Grouping key: 'format' | 'insert' | 'block' or custom. */\n\treadonly group: ToolbarGroup;\n\t/** Icon content: inline SVG markup or plain text. Rendered via innerHTML. */\n\treadonly icon: string;\n\treadonly label: string;\n\t/** Tooltip shown on hover, e.g. \"Bold (Ctrl+B)\". Falls back to label. */\n\treadonly tooltip?: string;\n\t/** Command name to execute on click. */\n\treadonly command: string;\n\t/**\n\t * Lower priority renders further left.\n\t * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.\n\t */\n\treadonly priority?: number;\n\t/**\n\t * When true, a visual separator is rendered after this item.\n\t * @deprecated Use the declarative `toolbar` config on `createEditor()` instead.\n\t */\n\treadonly separatorAfter?: boolean;\n\tisActive?(state: EditorState): boolean;\n\tisEnabled?(state: EditorState): boolean;\n}\n\ninterface ToolbarItemNoPopup extends ToolbarItemBase {\n\treadonly popupType?: undefined;\n}\n\ninterface ToolbarItemGridPicker extends ToolbarItemBase {\n\treadonly popupType: 'gridPicker';\n\treadonly popupConfig: GridPickerConfig;\n}\n\ninterface ToolbarItemDropdown extends ToolbarItemBase {\n\treadonly popupType: 'dropdown';\n\treadonly popupConfig: DropdownConfig;\n}\n\ninterface ToolbarItemCustomPopup extends ToolbarItemBase {\n\treadonly popupType: 'custom';\n\trenderPopup(\n\t\tcontainer: HTMLElement,\n\t\tcontext: PluginContext,\n\t\tonClose: (options?: PopupCloseOptions) => void,\n\t): void;\n}\n\nexport interface ToolbarItemCombobox extends Omit<ToolbarItemBase, 'icon'> {\n\treadonly popupType: 'combobox';\n\t/** Optional icon — combobox items typically display a text label instead. */\n\treadonly icon?: string;\n\t/** Pure function returning the current label text. Called on every state change. */\n\tgetLabel(state: EditorState): string;\n\t/** Renders the popup content when the combobox is opened. */\n\trenderPopup(\n\t\tcontainer: HTMLElement,\n\t\tcontext: PluginContext,\n\t\tonClose: (options?: PopupCloseOptions) => void,\n\t): void;\n}\n\nexport type ToolbarItem =\n\t| ToolbarItemNoPopup\n\t| ToolbarItemGridPicker\n\t| ToolbarItemDropdown\n\t| ToolbarItemCustomPopup\n\t| ToolbarItemCombobox;\n\n/**\n * Formats a keymap binding string into a human-readable shortcut,\n * using platform-appropriate modifier symbols (⌘ on Mac, Ctrl on others).\n *\n * @example formatShortcut('Mod-B') → \"Ctrl+B\" or \"⌘B\"\n * @example formatShortcut('Mod-Shift-X') → \"Ctrl+Shift+X\" or \"⌘⇧X\"\n */\nexport function formatShortcut(binding: string): string {\n\tif (isMac()) {\n\t\treturn binding\n\t\t\t.replace(/Mod/g, '⌘')\n\t\t\t.replace(/Shift/g, '⇧')\n\t\t\t.replace(/Alt/g, '⌥')\n\t\t\t.replace(/-/g, '');\n\t}\n\treturn binding.replace(/Mod/g, 'Ctrl').replace(/-/g, '+');\n}\n"],"names":["formatShortcut","binding","isMac","replace"],"mappings":";AAkGO,SAASA,EAAeC,IAAAA;AAC9B,SAAIC,EAAAA,IACID,GACLE,QAAQ,QAAQ,GAAA,EAChBA,QAAQ,UAAU,GAAA,EAClBA,QAAQ,QAAQ,GAAA,EAChBA,QAAQ,MAAM,EAAA,IAEVF,GAAQE,QAAQ,QAAQ,MAAA,EAAQA,QAAQ,MAAM,GAAA;AACtD;"}
@@ -5,7 +5,7 @@ import { c as i } from "./NodeSpec-NZVvcCuH.mjs";
5
5
  import { i as a, a as d, b as u, d as f } from "./Selection-BRTab5hO.mjs";
6
6
  import { n as k } from "./TypeBrands-C09nE2qO.mjs";
7
7
  import { f as g } from "./ToolbarItem-BpZggUGo.mjs";
8
- import { a as p } from "./StyleRuntime-ChRjVQwL.mjs";
8
+ import { a as p } from "./StyleRuntime-CP4NCwKT.mjs";
9
9
  import { f as b } from "./NodeResolver-C2XYkeOi.mjs";
10
10
  function h(t2, e2) {
11
11
  switch (t2.type) {
@@ -435,9 +435,9 @@ class j {
435
435
  e2.className = "notectl-code-block";
436
436
  const o2 = document.createElement("code");
437
437
  return o2.className = "notectl-code-block__content", e2.appendChild(o2), e2;
438
- }, toHTML(t3, e2) {
439
- const o2 = s(t3.attrs?.language ?? ""), n2 = s(t3.attrs?.backgroundColor ?? "");
440
- return `<pre${n2 ? ` style="background-color: ${n2}"` : ""}><code${o2 ? ` class="language-${o2}"` : ""}>${e2 || ""}</code></pre>`;
438
+ }, toHTML(t3, e2, o2) {
439
+ const n2 = s(t3.attrs?.language ?? ""), c2 = s(t3.attrs?.backgroundColor ?? ""), r2 = n2 ? ` class="language-${n2}"` : "";
440
+ return `<pre${c2 ? o2?.styleAttr(`background-color: ${c2}`) ?? ` style="background-color: ${c2}"` : ""}><code${r2}>${e2 || ""}</code></pre>`;
441
441
  }, parseHTML: [{ tag: "pre", getAttrs(t3) {
442
442
  const e2 = t3.querySelector("code"), o2 = e2?.className.match(/language-(\S+)/)?.[1] ?? "";
443
443
  return { language: (e2?.getAttribute("data-language") ?? "") || o2 };
@@ -539,4 +539,4 @@ export {
539
539
  C as n,
540
540
  I as w
541
541
  };
542
- //# sourceMappingURL=index-D515iymW.mjs.map
542
+ //# sourceMappingURL=index--7pBhSF4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index--7pBhSF4.mjs","sources":["../../src/decorations/PositionMapping.ts","../../src/decorations/Decoration.ts","../../src/plugins/code-block/CodeBlockKeyboardHandlers.ts","../../src/plugins/code-block/CodeBlockCommands.ts","../../src/plugins/code-block/CodeBlockLocale.ts","../../src/plugins/code-block/CodeBlockTypes.ts","../../src/plugins/code-block/CodeBlockService.ts","../../src/plugins/code-block/CodeBlockPlugin.ts","../../src/editor/styles/code-block.ts","../../src/plugins/code-block/CodeBlockNodeView.ts"],"sourcesContent":["/**\n * Pure functions for mapping decorations through transaction steps.\n * Handles position adjustments when the document changes — insertions,\n * deletions, splits, merges, and structural node removal.\n */\n\nimport type {\n\tDeleteTextStep,\n\tInsertTextStep,\n\tMergeBlocksStep,\n\tRemoveNodeStep,\n\tSplitBlockStep,\n\tStep,\n} from '../state/Transaction.js';\nimport type {\n\tDecoration,\n\tInlineDecoration,\n\tNodeDecoration,\n\tWidgetDecoration,\n} from './Decoration.js';\n\n/**\n * Maps a single decoration through a step.\n * Returns the mapped decoration, an array (when a split produces two),\n * or null if the decoration was deleted by the step.\n */\nexport function mapDecorationThroughStep(\n\tdeco: Decoration,\n\tstep: Step,\n): Decoration | readonly Decoration[] | null {\n\tswitch (deco.type) {\n\t\tcase 'inline':\n\t\t\treturn mapInline(deco, step);\n\t\tcase 'widget':\n\t\t\treturn mapWidget(deco, step);\n\t\tcase 'node':\n\t\t\treturn mapNode(deco, step);\n\t}\n}\n\nfunction mapInline(\n\tdeco: InlineDecoration,\n\tstep: Step,\n): InlineDecoration | readonly InlineDecoration[] | null {\n\tswitch (step.type) {\n\t\tcase 'insertText':\n\t\t\treturn mapInlineInsert(deco, step);\n\t\tcase 'deleteText':\n\t\t\treturn mapInlineDelete(deco, step);\n\t\tcase 'splitBlock':\n\t\t\treturn mapInlineSplit(deco, step);\n\t\tcase 'mergeBlocks':\n\t\t\treturn mapInlineMerge(deco, step);\n\t\tcase 'removeNode':\n\t\t\treturn removeIfBlockDeleted(deco, step);\n\t\tdefault:\n\t\t\treturn deco;\n\t}\n}\n\nfunction mapWidget(deco: WidgetDecoration, step: Step): WidgetDecoration | null {\n\tswitch (step.type) {\n\t\tcase 'insertText':\n\t\t\treturn mapWidgetInsert(deco, step);\n\t\tcase 'deleteText':\n\t\t\treturn mapWidgetDelete(deco, step);\n\t\tcase 'splitBlock':\n\t\t\treturn mapWidgetSplit(deco, step);\n\t\tcase 'mergeBlocks':\n\t\t\treturn mapWidgetMerge(deco, step);\n\t\tcase 'removeNode':\n\t\t\treturn removeIfBlockDeleted(deco, step);\n\t\tdefault:\n\t\t\treturn deco;\n\t}\n}\n\nfunction mapNode(deco: NodeDecoration, step: Step): NodeDecoration | null {\n\tswitch (step.type) {\n\t\tcase 'mergeBlocks':\n\t\t\treturn mapNodeMerge(deco, step);\n\t\tcase 'removeNode':\n\t\t\treturn removeIfBlockDeleted(deco, step);\n\t\tdefault:\n\t\t\treturn deco;\n\t}\n}\n\n// --- InsertText ---\n\nfunction mapInlineInsert(deco: InlineDecoration, step: InsertTextStep): InlineDecoration {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\tconst len: number = step.text.length;\n\t// from: assoc=-1 (stays at boundary — only shifts if insertion is strictly before)\n\tconst newFrom: number = deco.from > step.offset ? deco.from + len : deco.from;\n\t// to: assoc=1 (moves past insertion — shifts if insertion is at or before)\n\tconst newTo: number = deco.to >= step.offset ? deco.to + len : deco.to;\n\n\tif (newFrom === deco.from && newTo === deco.to) return deco;\n\treturn { ...deco, from: newFrom, to: newTo };\n}\n\nfunction mapWidgetInsert(deco: WidgetDecoration, step: InsertTextStep): WidgetDecoration {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\tconst len: number = step.text.length;\n\t// At boundary: side=-1 means \"before insertion\" (assoc=-1, stays), side=1 means \"after\" (moves)\n\tif (deco.offset > step.offset) {\n\t\treturn { ...deco, offset: deco.offset + len };\n\t}\n\tif (deco.offset === step.offset && deco.side >= 1) {\n\t\treturn { ...deco, offset: deco.offset + len };\n\t}\n\treturn deco;\n}\n\n// --- DeleteText ---\n\nfunction mapInlineDelete(deco: InlineDecoration, step: DeleteTextStep): InlineDecoration | null {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\tconst delLen: number = step.to - step.from;\n\tconst newFrom: number = clampAndShift(deco.from, step.from, step.to, delLen);\n\tconst newTo: number = clampAndShift(deco.to, step.from, step.to, delLen);\n\n\tif (newFrom >= newTo) return null;\n\tif (newFrom === deco.from && newTo === deco.to) return deco;\n\treturn { ...deco, from: newFrom, to: newTo };\n}\n\nfunction mapWidgetDelete(deco: WidgetDecoration, step: DeleteTextStep): WidgetDecoration | null {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\t// Widget strictly inside deleted range → deleted\n\tif (deco.offset > step.from && deco.offset < step.to) return null;\n\n\tconst delLen: number = step.to - step.from;\n\tif (deco.offset >= step.to) {\n\t\treturn { ...deco, offset: deco.offset - delLen };\n\t}\n\treturn deco;\n}\n\n// --- SplitBlock ---\n\nfunction mapInlineSplit(\n\tdeco: InlineDecoration,\n\tstep: SplitBlockStep,\n): InlineDecoration | readonly InlineDecoration[] {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\t// Entirely before split point → unchanged\n\tif (deco.to <= step.offset) return deco;\n\n\t// Entirely after split point → move to new block, adjust offsets\n\tif (deco.from >= step.offset) {\n\t\treturn {\n\t\t\t...deco,\n\t\t\tblockId: step.newBlockId,\n\t\t\tfrom: deco.from - step.offset,\n\t\t\tto: deco.to - step.offset,\n\t\t};\n\t}\n\n\t// Spanning the split point → split into two decorations\n\tconst left: InlineDecoration = { ...deco, to: step.offset };\n\tconst right: InlineDecoration = {\n\t\t...deco,\n\t\tblockId: step.newBlockId,\n\t\tfrom: 0,\n\t\tto: deco.to - step.offset,\n\t};\n\treturn [left, right];\n}\n\nfunction mapWidgetSplit(deco: WidgetDecoration, step: SplitBlockStep): WidgetDecoration {\n\tif (deco.blockId !== step.blockId) return deco;\n\n\t// Before split → stays\n\tif (deco.offset < step.offset) return deco;\n\n\t// After split → new block\n\tif (deco.offset > step.offset) {\n\t\treturn {\n\t\t\t...deco,\n\t\t\tblockId: step.newBlockId,\n\t\t\toffset: deco.offset - step.offset,\n\t\t};\n\t}\n\n\t// At boundary: side determines which block\n\tif (deco.side >= 1) {\n\t\treturn {\n\t\t\t...deco,\n\t\t\tblockId: step.newBlockId,\n\t\t\toffset: 0,\n\t\t};\n\t}\n\treturn deco;\n}\n\n// --- MergeBlocks ---\n\nfunction mapInlineMerge(deco: InlineDecoration, step: MergeBlocksStep): InlineDecoration {\n\tif (deco.blockId !== step.sourceBlockId) return deco;\n\n\treturn {\n\t\t...deco,\n\t\tblockId: step.targetBlockId,\n\t\tfrom: deco.from + step.targetLengthBefore,\n\t\tto: deco.to + step.targetLengthBefore,\n\t};\n}\n\nfunction mapWidgetMerge(deco: WidgetDecoration, step: MergeBlocksStep): WidgetDecoration {\n\tif (deco.blockId !== step.sourceBlockId) return deco;\n\n\treturn {\n\t\t...deco,\n\t\tblockId: step.targetBlockId,\n\t\toffset: deco.offset + step.targetLengthBefore,\n\t};\n}\n\nfunction mapNodeMerge(deco: NodeDecoration, step: MergeBlocksStep): NodeDecoration | null {\n\t// Source block disappears → delete its node decoration\n\tif (deco.blockId === step.sourceBlockId) return null;\n\treturn deco;\n}\n\n// --- RemoveNode ---\n\nfunction removeIfBlockDeleted<T extends Decoration>(deco: T, step: RemoveNodeStep): T | null {\n\tif (deco.blockId === step.removedNode.id) return null;\n\treturn deco;\n}\n\n// --- Helpers ---\n\nfunction clampAndShift(pos: number, delFrom: number, delTo: number, delLen: number): number {\n\tif (pos <= delFrom) return pos;\n\tif (pos >= delTo) return pos - delLen;\n\treturn delFrom;\n}\n","/**\n * Decoration types and DecorationSet for transient, view-only annotations.\n * Decorations are NOT part of the document model and do NOT affect undo/redo.\n */\n\nimport type { BlockId } from '../model/TypeBrands.js';\nimport type { Transaction } from '../state/Transaction.js';\nimport { mapDecorationThroughStep } from './PositionMapping.js';\n\n// --- Decoration Attrs ---\n\nexport interface DecorationAttrs {\n\treadonly class?: string;\n\treadonly style?: string;\n\treadonly nodeName?: string;\n\treadonly [key: string]: string | undefined;\n}\n\n// --- Decoration Types ---\n\nexport interface InlineDecoration {\n\treadonly type: 'inline';\n\treadonly blockId: BlockId;\n\treadonly from: number;\n\treadonly to: number;\n\treadonly attrs: DecorationAttrs;\n}\n\nexport interface NodeDecoration {\n\treadonly type: 'node';\n\treadonly blockId: BlockId;\n\treadonly attrs: DecorationAttrs;\n}\n\nexport interface WidgetDecoration {\n\treadonly type: 'widget';\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n\treadonly toDOM: () => HTMLElement;\n\treadonly side: -1 | 1;\n\treadonly key?: string;\n}\n\nexport type Decoration = InlineDecoration | NodeDecoration | WidgetDecoration;\n\n// --- Factory Functions ---\n\n/** Creates an inline decoration for a text range within a block. */\nexport function inline(\n\tblockId: BlockId,\n\tfrom: number,\n\tto: number,\n\tattrs: DecorationAttrs,\n): InlineDecoration {\n\treturn { type: 'inline', blockId, from, to, attrs };\n}\n\n/** Creates a node decoration that applies to a whole block element. */\nexport function node(blockId: BlockId, attrs: DecorationAttrs): NodeDecoration {\n\treturn { type: 'node', blockId, attrs };\n}\n\n/** Creates a widget decoration that inserts a DOM element at a position. */\nexport function widget(\n\tblockId: BlockId,\n\toffset: number,\n\ttoDOM: () => HTMLElement,\n\toptions?: { readonly side?: -1 | 1; readonly key?: string },\n): WidgetDecoration {\n\treturn {\n\t\ttype: 'widget',\n\t\tblockId,\n\t\toffset,\n\t\ttoDOM,\n\t\tside: options?.side ?? -1,\n\t\tkey: options?.key,\n\t};\n}\n\n// --- DecorationSet ---\n\n/**\n * Immutable set of decorations indexed by block ID.\n * Provides efficient lookup and merging of decoration collections.\n */\nexport class DecorationSet {\n\tstatic readonly empty: DecorationSet = new DecorationSet(new Map());\n\n\tprivate constructor(private readonly byBlock: ReadonlyMap<BlockId, readonly Decoration[]>) {}\n\n\t/** Creates a DecorationSet from a flat array of decorations. */\n\tstatic create(decorations: readonly Decoration[]): DecorationSet {\n\t\tif (decorations.length === 0) return DecorationSet.empty;\n\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const deco of decorations) {\n\t\t\tconst existing = map.get(deco.blockId);\n\t\t\tif (existing) {\n\t\t\t\texisting.push(deco);\n\t\t\t} else {\n\t\t\t\tmap.set(deco.blockId, [deco]);\n\t\t\t}\n\t\t}\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Returns all decorations for a given block. */\n\tfind(blockId: BlockId): readonly Decoration[] {\n\t\treturn this.byBlock.get(blockId) ?? [];\n\t}\n\n\t/** Returns only inline decorations for a given block. */\n\tfindInline(blockId: BlockId): readonly InlineDecoration[] {\n\t\tconst decos = this.byBlock.get(blockId);\n\t\tif (!decos) return [];\n\t\treturn decos.filter((d): d is InlineDecoration => d.type === 'inline');\n\t}\n\n\t/** Returns only node decorations for a given block. */\n\tfindNode(blockId: BlockId): readonly NodeDecoration[] {\n\t\tconst decos = this.byBlock.get(blockId);\n\t\tif (!decos) return [];\n\t\treturn decos.filter((d): d is NodeDecoration => d.type === 'node');\n\t}\n\n\t/** Returns only widget decorations for a given block. */\n\tfindWidget(blockId: BlockId): readonly WidgetDecoration[] {\n\t\tconst decos = this.byBlock.get(blockId);\n\t\tif (!decos) return [];\n\t\treturn decos.filter((d): d is WidgetDecoration => d.type === 'widget');\n\t}\n\n\t/** Returns a new DecorationSet with the given decorations added. */\n\tadd(decorations: readonly Decoration[]): DecorationSet {\n\t\tif (decorations.length === 0) return this;\n\t\tif (this.isEmpty) return DecorationSet.create(decorations);\n\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tmap.set(bid, [...decos]);\n\t\t}\n\t\tfor (const deco of decorations) {\n\t\t\tconst existing = map.get(deco.blockId);\n\t\t\tif (existing) {\n\t\t\t\texisting.push(deco);\n\t\t\t} else {\n\t\t\t\tmap.set(deco.blockId, [deco]);\n\t\t\t}\n\t\t}\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Returns a new DecorationSet with decorations matching the predicate removed. */\n\tremove(predicate: (d: Decoration) => boolean): DecorationSet {\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tlet changed = false;\n\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tconst filtered = decos.filter((d) => !predicate(d));\n\t\t\tif (filtered.length !== decos.length) changed = true;\n\t\t\tif (filtered.length > 0) {\n\t\t\t\tmap.set(bid, filtered);\n\t\t\t}\n\t\t}\n\n\t\tif (!changed) return this;\n\t\tif (map.size === 0) return DecorationSet.empty;\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Returns a new DecorationSet merging this set with another. */\n\tmerge(other: DecorationSet): DecorationSet {\n\t\tif (other.isEmpty) return this;\n\t\tif (this.isEmpty) return other;\n\n\t\tconst map = new Map<BlockId, Decoration[]>();\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tmap.set(bid, [...decos]);\n\t\t}\n\t\tfor (const [bid, decos] of other.byBlock) {\n\t\t\tconst existing = map.get(bid);\n\t\t\tif (existing) {\n\t\t\t\texisting.push(...decos);\n\t\t\t} else {\n\t\t\t\tmap.set(bid, [...decos]);\n\t\t\t}\n\t\t}\n\t\treturn new DecorationSet(map);\n\t}\n\n\t/** Checks equality — reference first, then structural comparison. */\n\tequals(other: DecorationSet): boolean {\n\t\tif (this === other) return true;\n\t\tif (this.byBlock.size !== other.byBlock.size) return false;\n\n\t\tfor (const [bid, decos] of this.byBlock) {\n\t\t\tconst otherDecos = other.byBlock.get(bid);\n\t\t\tif (!otherDecos) return false;\n\t\t\tif (!decorationArraysEqual(decos, otherDecos)) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** True if the set contains no decorations. */\n\tget isEmpty(): boolean {\n\t\treturn this.byBlock.size === 0;\n\t}\n\n\t/**\n\t * Maps decorations through document changes described by a transaction.\n\t * Decorations that become invalid (e.g. fully deleted range) are removed.\n\t * Decorations that span a split point are split into two.\n\t */\n\tmap(tr: Transaction): DecorationSet {\n\t\tif (this.isEmpty || tr.steps.length === 0) return this;\n\n\t\tlet mapped: Decoration[] = [];\n\t\tfor (const decos of this.byBlock.values()) {\n\t\t\tfor (const d of decos) {\n\t\t\t\tmapped.push(d);\n\t\t\t}\n\t\t}\n\n\t\tfor (const step of tr.steps) {\n\t\t\tconst next: Decoration[] = [];\n\t\t\tfor (const deco of mapped) {\n\t\t\t\tconst result = mapDecorationThroughStep(deco, step);\n\t\t\t\tif (result === null) continue;\n\t\t\t\tif (Array.isArray(result)) {\n\t\t\t\t\tfor (const r of result) {\n\t\t\t\t\t\tnext.push(r);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnext.push(result as Decoration);\n\t\t\t\t}\n\t\t\t}\n\t\t\tmapped = next;\n\t\t}\n\n\t\tif (mapped.length === 0) return DecorationSet.empty;\n\t\treturn DecorationSet.create(mapped);\n\t}\n}\n\n// --- Helpers ---\n\n/** Compares two decoration arrays for structural equality. */\nexport function decorationArraysEqual(a: readonly Decoration[], b: readonly Decoration[]): boolean {\n\tif (a === b) return true;\n\tif (a.length !== b.length) return false;\n\n\tfor (let i = 0; i < a.length; i++) {\n\t\tconst ai = a[i];\n\t\tconst bi = b[i];\n\t\tif (!ai || !bi || !decorationsEqual(ai, bi)) return false;\n\t}\n\treturn true;\n}\n\n/** Compares two individual decorations for structural equality. */\nfunction decorationsEqual(a: Decoration, b: Decoration): boolean {\n\tif (a.type !== b.type) return false;\n\tif (a.blockId !== b.blockId) return false;\n\n\tswitch (a.type) {\n\t\tcase 'inline': {\n\t\t\tconst bi = b as InlineDecoration;\n\t\t\treturn a.from === bi.from && a.to === bi.to && attrsEqual(a.attrs, bi.attrs);\n\t\t}\n\t\tcase 'node': {\n\t\t\tconst bn = b as NodeDecoration;\n\t\t\treturn attrsEqual(a.attrs, bn.attrs);\n\t\t}\n\t\tcase 'widget': {\n\t\t\tconst bw = b as WidgetDecoration;\n\t\t\treturn (\n\t\t\t\ta.offset === bw.offset && a.side === bw.side && a.key === bw.key && a.toDOM === bw.toDOM\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Compares two DecorationAttrs objects. */\nfunction attrsEqual(a: DecorationAttrs, b: DecorationAttrs): boolean {\n\tif (a === b) return true;\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\tif (aKeys.length !== bKeys.length) return false;\n\tfor (const key of aKeys) {\n\t\tif (a[key] !== b[key]) return false;\n\t}\n\treturn true;\n}\n","/**\n * Keyboard handlers for code-block navigation and editing.\n * Handles Enter, Backspace, Tab, Shift-Tab, Escape, Arrow keys,\n * and configurable shortcuts (Mod+Enter, toggle).\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { generateBlockId, getBlockLength, getBlockText } from '../../model/Document.js';\nimport {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { CodeBlockConfig, CodeBlockKeymap } from './CodeBlockTypes.js';\n\n// --- Context Guard ---\n\ninterface CodeBlockContext {\n\treadonly state: EditorState;\n\treadonly block: BlockNode;\n\treadonly blockId: BlockId;\n\treadonly offset: number;\n}\n\n/**\n * Guards against NodeSelection and non-code-block blocks.\n * Returns false (not handled) if the cursor is not inside a code block.\n */\nfunction withCodeBlockContext(\n\tcontext: PluginContext,\n\thandler: (ctx: CodeBlockContext) => boolean,\n): boolean {\n\tconst state: EditorState = context.getState();\n\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\n\tconst sel = state.selection;\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block || block.type !== 'code_block') return false;\n\n\treturn handler({\n\t\tstate,\n\t\tblock,\n\t\tblockId: sel.anchor.blockId,\n\t\toffset: sel.anchor.offset,\n\t});\n}\n\n/** Registers all code-block keyboard handlers. */\nexport function registerCodeBlockKeymaps(\n\tcontext: PluginContext,\n\tconfig: CodeBlockConfig,\n\tresolvedKeymap: Readonly<Record<keyof CodeBlockKeymap, string | null>>,\n): void {\n\tconst keymap: Record<string, () => boolean> = {\n\t\tEnter: () => handleEnter(context),\n\t\tBackspace: () => handleBackspace(context),\n\t\tTab: () => handleTab(context, config),\n\t\t'Shift-Tab': () => handleShiftTab(context, config),\n\t\tEscape: () => handleEscape(context),\n\t\tArrowDown: () => handleArrowDown(context),\n\t\tArrowUp: () => handleArrowUp(context),\n\t\tArrowRight: () => handleArrowRight(context),\n\t\tArrowLeft: () => handleArrowLeft(context),\n\t};\n\n\tconst { insertAfter, toggle } = resolvedKeymap;\n\n\tif (insertAfter) {\n\t\tkeymap[insertAfter] = () => handleModEnter(context);\n\t}\n\tif (toggle) {\n\t\tkeymap[toggle] = () => context.executeCommand('toggleCodeBlock');\n\t}\n\n\tcontext.registerKeymap(keymap, { priority: 'context' });\n}\n\n// --- Handler Functions ---\n\nfunction handleBackspace(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\t\tif (offset !== 0) return false;\n\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('input')\n\t\t\t.setBlockType(blockId, nodeType('paragraph'))\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\nfunction handleEnter(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\n\t\tif (text.endsWith('\\n') && offset === text.length) {\n\t\t\treturn exitOnDoubleEnter(context, blockId, text);\n\t\t}\n\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('input')\n\t\t\t.insertText(blockId, offset, '\\n', [])\n\t\t\t.setSelection(createCollapsedSelection(blockId, offset + 1))\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\nfunction handleTab(context: PluginContext, config: CodeBlockConfig): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId, offset }) => {\n\t\tconst indent: string = config.useSpaces ? ' '.repeat(config.spaceCount ?? 2) : '\\t';\n\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('input')\n\t\t\t.insertText(blockId, offset, indent, [])\n\t\t\t.setSelection(createCollapsedSelection(blockId, offset + indent.length))\n\t\t\t.build();\n\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t});\n}\n\nfunction handleShiftTab(context: PluginContext, config: CodeBlockConfig): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tconst text: string = getBlockText(block);\n\t\tconst lineStart: number = text.lastIndexOf('\\n', offset - 1) + 1;\n\n\t\tif (config.useSpaces) {\n\t\t\tconst spaceCount: number = config.spaceCount ?? 2;\n\t\t\tconst linePrefix: string = text.slice(lineStart, lineStart + spaceCount);\n\t\t\tif (linePrefix === ' '.repeat(spaceCount)) {\n\t\t\t\tconst tr: Transaction = state\n\t\t\t\t\t.transaction('input')\n\t\t\t\t\t.deleteTextAt(blockId, lineStart, lineStart + spaceCount)\n\t\t\t\t\t.setSelection(createCollapsedSelection(blockId, Math.max(lineStart, offset - spaceCount)))\n\t\t\t\t\t.build();\n\t\t\t\tcontext.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (text[lineStart] === '\\t') {\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('input')\n\t\t\t\t.deleteTextAt(blockId, lineStart, lineStart + 1)\n\t\t\t\t.setSelection(createCollapsedSelection(blockId, Math.max(lineStart, offset - 1)))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn true; // Consume event even if no dedent possible\n\t});\n}\n\n/**\n * Exits the code block to the next block or creates a new paragraph.\n * Exported for use by the `exitCodeBlock` command.\n */\nexport function handleEscape(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId }) => {\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx < blockOrder.length - 1) {\n\t\t\tconst nextId: BlockId = blockOrder[idx + 1] as BlockId;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(nextId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t} else {\n\t\t\tinsertParagraphAfter(context, blockId);\n\t\t}\n\n\t\treturn true;\n\t});\n}\n\nfunction handleArrowDown(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tconst nextNewline: number = text.indexOf('\\n', offset);\n\t\tif (nextNewline !== -1) return false;\n\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx < blockOrder.length - 1) {\n\t\t\tconst nextId: BlockId = blockOrder[idx + 1] as BlockId;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(nextId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t} else {\n\t\t\tinsertParagraphAfter(context, blockId);\n\t\t}\n\n\t\treturn true;\n\t});\n}\n\nfunction handleArrowUp(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tconst firstNewline: number = text.indexOf('\\n');\n\t\tif (firstNewline !== -1 && offset > firstNewline) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx > 0) {\n\t\t\tconst prevId: BlockId = blockOrder[idx - 1] as BlockId;\n\t\t\tconst prevBlock: BlockNode | undefined = state.getBlock(prevId);\n\t\t\tconst prevLen: number = prevBlock ? getBlockLength(prevBlock) : 0;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(prevId, prevLen))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\nfunction handleArrowRight(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, block, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\n\t\tconst text: string = getBlockText(block);\n\t\tif (offset !== text.length) return false;\n\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx < blockOrder.length - 1) {\n\t\t\tconst nextId: BlockId = blockOrder[idx + 1] as BlockId;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(nextId, 0))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t} else {\n\t\t\tinsertParagraphAfter(context, blockId);\n\t\t}\n\n\t\treturn true;\n\t});\n}\n\nfunction handleArrowLeft(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ state, blockId, offset }) => {\n\t\tif (!isCollapsed(state.selection)) return false;\n\t\tif (offset !== 0) return false;\n\n\t\tconst blockOrder: readonly BlockId[] = state.getBlockOrder();\n\t\tconst idx: number = blockOrder.indexOf(blockId);\n\n\t\tif (idx > 0) {\n\t\t\tconst prevId: BlockId = blockOrder[idx - 1] as BlockId;\n\t\t\tconst prevBlock: BlockNode | undefined = state.getBlock(prevId);\n\t\t\tconst prevLen: number = prevBlock ? getBlockLength(prevBlock) : 0;\n\t\t\tconst tr: Transaction = state\n\t\t\t\t.transaction('command')\n\t\t\t\t.setSelection(createCollapsedSelection(prevId, prevLen))\n\t\t\t\t.build();\n\t\t\tcontext.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n}\n\nfunction handleModEnter(context: PluginContext): boolean {\n\treturn withCodeBlockContext(context, ({ blockId }) => {\n\t\tinsertParagraphAfter(context, blockId);\n\t\treturn true;\n\t});\n}\n\n// --- Shared Helpers ---\n\nfunction insertParagraphAfter(context: PluginContext, bid: BlockId): void {\n\tconst state: EditorState = context.getState();\n\tconst block: BlockNode | undefined = state.getBlock(bid);\n\tif (!block) return;\n\n\tconst blockLength: number = getBlockLength(block);\n\tconst newId: BlockId = generateBlockId();\n\n\tconst tr: Transaction = state\n\t\t.transaction('command')\n\t\t.splitBlock(bid, blockLength, newId)\n\t\t.setBlockType(newId, nodeType('paragraph'))\n\t\t.setSelection(createCollapsedSelection(newId, 0))\n\t\t.build();\n\n\tcontext.dispatch(tr);\n}\n\nfunction exitOnDoubleEnter(context: PluginContext, bid: BlockId, text: string): boolean {\n\tconst state: EditorState = context.getState();\n\tconst trimmedLen: number = text.length - 1;\n\tconst newId: BlockId = generateBlockId();\n\n\tconst tr: Transaction = state\n\t\t.transaction('input')\n\t\t.deleteTextAt(bid, trimmedLen, text.length)\n\t\t.splitBlock(bid, trimmedLen, newId)\n\t\t.setBlockType(newId, nodeType('paragraph'))\n\t\t.setSelection(createCollapsedSelection(newId, 0))\n\t\t.build();\n\n\tcontext.dispatch(tr);\n\treturn true;\n}\n","/**\n * Command registration and implementations for code blocks.\n * Handles toggle, insert, exit, and mark stripping.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockLength, getInlineChildren, isTextNode } from '../../model/Document.js';\nimport { createCollapsedSelection, isGapCursor, isNodeSelection } from '../../model/Selection.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { Transaction, TransactionBuilder } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport { handleEscape } from './CodeBlockKeyboardHandlers.js';\nimport type { CodeBlockConfig } from './CodeBlockTypes.js';\n\n/** Registers all code-block commands. */\nexport function registerCodeBlockCommands(context: PluginContext, config: CodeBlockConfig): void {\n\tcontext.registerCommand('toggleCodeBlock', () => toggleCodeBlock(context, config));\n\n\tcontext.registerCommand('insertCodeBlock', () => insertCodeBlock(context, config));\n\n\tcontext.registerCommand('setCodeBlockLanguage', () => false);\n\n\tcontext.registerCommand('setCodeBlockBackground', () => false);\n\n\tcontext.registerCommand('exitCodeBlock', () => handleEscape(context));\n}\n\n// --- Command Implementations ---\n\nfunction toggleCodeBlock(context: PluginContext, config: CodeBlockConfig): boolean {\n\tconst state = context.getState();\n\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\tif (!block) return false;\n\n\tif (block.type === 'code_block') {\n\t\tconst tr: Transaction = state\n\t\t\t.transaction('command')\n\t\t\t.setBlockType(state.selection.anchor.blockId, nodeType('paragraph'))\n\t\t\t.setSelection(state.selection)\n\t\t\t.build();\n\t\tcontext.dispatch(tr);\n\t\treturn true;\n\t}\n\n\treturn insertCodeBlock(context, config);\n}\n\nfunction insertCodeBlock(context: PluginContext, config: CodeBlockConfig): boolean {\n\tconst state = context.getState();\n\tconst sel = state.selection;\n\tif (isNodeSelection(sel) || isGapCursor(sel)) return false;\n\n\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\tif (!block || block.type === 'code_block') return false;\n\n\tconst attrs: Record<string, string | number | boolean> = {\n\t\tlanguage: config.defaultLanguage ?? '',\n\t\tbackgroundColor: '',\n\t};\n\n\tconst builder: TransactionBuilder = state.transaction('command');\n\tstripAllMarks(builder, block);\n\tbuilder\n\t\t.setBlockType(sel.anchor.blockId, nodeType('code_block'), attrs)\n\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0));\n\n\tcontext.dispatch(builder.build());\n\treturn true;\n}\n\n/**\n * Strips all marks from a block's inline content.\n * Used when converting to code_block so no formatting carries over.\n */\nfunction stripAllMarks(builder: TransactionBuilder, block: BlockNode): void {\n\tconst blockLength: number = getBlockLength(block);\n\tif (blockLength === 0) return;\n\n\tconst inlineChildren = getInlineChildren(block);\n\tlet offset = 0;\n\n\tfor (const child of inlineChildren) {\n\t\tif (isTextNode(child)) {\n\t\t\tif (child.text.length > 0) {\n\t\t\t\tfor (const mark of child.marks) {\n\t\t\t\t\tbuilder.removeMark(block.id, offset, offset + child.text.length, mark);\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset += child.text.length;\n\t\t} else {\n\t\t\toffset += 1;\n\t\t}\n\t}\n}\n","/** Locale interface and default English locale for the CodeBlockPlugin. */\n\n// --- Locale Interface ---\n\nexport interface CodeBlockLocale {\n\treadonly label: string;\n\treadonly tooltip: (shortcut?: string) => string;\n\treadonly enteredCodeBlock: string;\n\treadonly leftCodeBlock: string;\n}\n\n// --- Default English Locale ---\n\nexport const CODE_BLOCK_LOCALE_EN: CodeBlockLocale = {\n\tlabel: 'Code Block',\n\ttooltip: (shortcut?: string) => (shortcut ? `Code Block (${shortcut})` : 'Code Block'),\n\tenteredCodeBlock: 'Entered code block. Press Escape to exit.',\n\tleftCodeBlock: 'Left code block.',\n};\n\n// --- German Locale ---\n\nexport const CODE_BLOCK_LOCALE_DE: CodeBlockLocale = {\n\tlabel: 'Codeblock',\n\ttooltip: (shortcut?: string) => (shortcut ? `Codeblock (${shortcut})` : 'Codeblock'),\n\tenteredCodeBlock: 'Codeblock betreten. Escape zum Verlassen drücken.',\n\tleftCodeBlock: 'Codeblock verlassen.',\n};\n\n// --- Spanish Locale ---\n\nexport const CODE_BLOCK_LOCALE_ES: CodeBlockLocale = {\n\tlabel: 'Bloque de código',\n\ttooltip: (shortcut?: string) =>\n\t\tshortcut ? `Bloque de código (${shortcut})` : 'Bloque de código',\n\tenteredCodeBlock: 'Bloque de código activado. Pulse Escape para salir.',\n\tleftCodeBlock: 'Bloque de código desactivado.',\n};\n\n// --- French Locale ---\n\nexport const CODE_BLOCK_LOCALE_FR: CodeBlockLocale = {\n\tlabel: 'Bloc de code',\n\ttooltip: (shortcut?: string) => (shortcut ? `Bloc de code (${shortcut})` : 'Bloc de code'),\n\tenteredCodeBlock: 'Bloc de code activé. Appuyez sur Échap pour quitter.',\n\tleftCodeBlock: 'Bloc de code quitté.',\n};\n\n// --- Chinese (Simplified) Locale ---\n\nexport const CODE_BLOCK_LOCALE_ZH: CodeBlockLocale = {\n\tlabel: '代码块',\n\ttooltip: (shortcut?: string) => (shortcut ? `代码块 (${shortcut})` : '代码块'),\n\tenteredCodeBlock: '已进入代码块。按 Escape 退出。',\n\tleftCodeBlock: '已离开代码块。',\n};\n\n// --- Russian Locale ---\n\nexport const CODE_BLOCK_LOCALE_RU: CodeBlockLocale = {\n\tlabel: 'Блок кода',\n\ttooltip: (shortcut?: string) => (shortcut ? `Блок кода (${shortcut})` : 'Блок кода'),\n\tenteredCodeBlock: 'Вход в блок кода. Нажмите Escape для выхода.',\n\tleftCodeBlock: 'Выход из блока кода.',\n};\n\n// --- Arabic Locale ---\n\nexport const CODE_BLOCK_LOCALE_AR: CodeBlockLocale = {\n\tlabel: 'كتلة كود',\n\ttooltip: (shortcut?: string) => (shortcut ? `كتلة كود (${shortcut})` : 'كتلة كود'),\n\tenteredCodeBlock: 'تم الدخول إلى كتلة الكود. اضغط Escape للخروج.',\n\tleftCodeBlock: 'تم الخروج من كتلة الكود.',\n};\n\n// --- Hindi Locale ---\n\nexport const CODE_BLOCK_LOCALE_HI: CodeBlockLocale = {\n\tlabel: 'कोड ब्लॉक',\n\ttooltip: (shortcut?: string) => (shortcut ? `कोड ब्लॉक (${shortcut})` : 'कोड ब्लॉक'),\n\tenteredCodeBlock: 'कोड ब्लॉक में प्रवेश किया। बाहर निकलने के लिए Escape दबाएँ।',\n\tleftCodeBlock: 'कोड ब्लॉक से बाहर।',\n};\n\n// --- Locale Map ---\n\nexport const CODE_BLOCK_LOCALES: Record<string, CodeBlockLocale> = {\n\ten: CODE_BLOCK_LOCALE_EN,\n\tde: CODE_BLOCK_LOCALE_DE,\n\tes: CODE_BLOCK_LOCALE_ES,\n\tfr: CODE_BLOCK_LOCALE_FR,\n\tzh: CODE_BLOCK_LOCALE_ZH,\n\tru: CODE_BLOCK_LOCALE_RU,\n\tar: CODE_BLOCK_LOCALE_AR,\n\thi: CODE_BLOCK_LOCALE_HI,\n};\n","/**\n * Types, interfaces, and constants for the code-block plugin.\n */\n\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { ServiceKey } from '../Plugin.js';\n\n// --- Attribute Registry Augmentation ---\n\ndeclare module '../../model/AttrRegistry.js' {\n\tinterface NodeAttrRegistry {\n\t\tcode_block: {\n\t\t\tlanguage: string;\n\t\t\tbackgroundColor: string;\n\t\t};\n\t}\n}\n\n// --- Syntax Highlighting Types ---\n\nexport interface SyntaxToken {\n\treadonly from: number;\n\treadonly to: number;\n\treadonly type: string;\n}\n\nexport interface SyntaxHighlighter {\n\ttokenize(code: string, language: string): readonly SyntaxToken[];\n\tgetSupportedLanguages(): readonly string[];\n}\n\n// --- Configuration ---\n\n/**\n * Configurable keyboard bindings for CodeBlockPlugin actions.\n * Omit a slot to use the default; set to `null` to disable the binding.\n *\n * Key descriptor format: `'Mod-Enter'`, `'Mod-Shift-M'`, etc.\n * `Mod` resolves to Cmd on macOS, Ctrl on Windows/Linux.\n */\nexport interface CodeBlockKeymap {\n\t/**\n\t * Insert a new paragraph below the code block and move the cursor there.\n\t * @default 'Mod-Enter'\n\t */\n\treadonly insertAfter?: string | null;\n\n\t/**\n\t * Toggle the current block between code block and paragraph.\n\t * @default 'Mod-Shift-M'\n\t */\n\treadonly toggle?: string | null;\n}\n\nexport const DEFAULT_KEYMAP: Readonly<Record<keyof CodeBlockKeymap, string>> = {\n\tinsertAfter: 'Mod-Enter',\n\ttoggle: 'Mod-Shift-M',\n};\n\nexport interface CodeBlockConfig {\n\treadonly highlighter?: SyntaxHighlighter;\n\treadonly defaultLanguage?: string;\n\treadonly useSpaces?: boolean;\n\treadonly spaceCount?: number;\n\treadonly showCopyButton?: boolean;\n\treadonly separatorAfter?: boolean;\n\t/** Default body background color (overrides --notectl-code-block-bg). */\n\treadonly background?: string;\n\t/** Default header background color (overrides --notectl-code-block-header-bg). */\n\treadonly headerBackground?: string;\n\t/** Default text color (overrides --notectl-code-block-color). */\n\treadonly textColor?: string;\n\t/** Default header/label text color (overrides --notectl-code-block-header-color). */\n\treadonly headerColor?: string;\n\t/** Customize keyboard bindings for code block actions. */\n\treadonly keymap?: CodeBlockKeymap;\n\t/** Locale override for user-facing strings. */\n\treadonly locale?: import('./CodeBlockLocale.js').CodeBlockLocale;\n}\n\nexport const DEFAULT_CONFIG: CodeBlockConfig = {\n\tdefaultLanguage: '',\n\tuseSpaces: false,\n\tspaceCount: 2,\n\tshowCopyButton: true,\n};\n\n// --- Service Types ---\n\nexport interface CodeBlockService {\n\tsetLanguage(blockId: BlockId, language: string): void;\n\tgetLanguage(blockId: BlockId): string;\n\tsetBackground(blockId: BlockId, color: string): void;\n\tgetBackground(blockId: BlockId): string;\n\tisCodeBlock(blockId: BlockId): boolean;\n\tgetSupportedLanguages(): readonly string[];\n}\n\nexport const CODE_BLOCK_SERVICE_KEY = new ServiceKey<CodeBlockService>('codeBlock');\n\n// --- SVG Icon ---\n\nexport const CODE_BLOCK_ICON =\n\t'<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>';\n","/**\n * Service API for code blocks.\n * Provides language/background getters and setters.\n */\n\nimport type { BlockAttrs, BlockNode } from '../../model/Document.js';\nimport { findNodePath } from '../../model/NodeResolver.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { PluginContext } from '../Plugin.js';\nimport type { CodeBlockConfig } from './CodeBlockTypes.js';\nimport { CODE_BLOCK_SERVICE_KEY } from './CodeBlockTypes.js';\n\n/** Registers the CodeBlockService on the given context. */\nexport function registerCodeBlockService(\n\tcontext: PluginContext,\n\tconfig: CodeBlockConfig,\n\tgetContext: () => PluginContext | null,\n): void {\n\tcontext.registerService(CODE_BLOCK_SERVICE_KEY, {\n\t\tsetLanguage(bid: BlockId, language: string): void {\n\t\t\tsetAttr(context, bid, 'language', language);\n\t\t},\n\n\t\tgetLanguage(bid: BlockId): string {\n\t\t\tconst ctx: PluginContext | null = getContext();\n\t\t\tif (!ctx) return '';\n\t\t\tconst block: BlockNode | undefined = ctx.getState().getBlock(bid);\n\t\t\tif (!block || block.type !== 'code_block') return '';\n\t\t\treturn (block.attrs?.language as string) ?? '';\n\t\t},\n\n\t\tsetBackground(bid: BlockId, color: string): void {\n\t\t\tsetAttr(context, bid, 'backgroundColor', color);\n\t\t},\n\n\t\tgetBackground(bid: BlockId): string {\n\t\t\tconst ctx: PluginContext | null = getContext();\n\t\t\tif (!ctx) return '';\n\t\t\tconst block: BlockNode | undefined = ctx.getState().getBlock(bid);\n\t\t\tif (!block || block.type !== 'code_block') return '';\n\t\t\treturn (block.attrs?.backgroundColor as string) ?? '';\n\t\t},\n\n\t\tisCodeBlock(bid: BlockId): boolean {\n\t\t\tconst ctx: PluginContext | null = getContext();\n\t\t\tif (!ctx) return false;\n\t\t\tconst block: BlockNode | undefined = ctx.getState().getBlock(bid);\n\t\t\treturn block?.type === 'code_block';\n\t\t},\n\n\t\tgetSupportedLanguages(): readonly string[] {\n\t\t\tif (config.highlighter) {\n\t\t\t\treturn config.highlighter.getSupportedLanguages();\n\t\t\t}\n\t\t\treturn [];\n\t\t},\n\t});\n}\n\n// --- Helper ---\n\nfunction setAttr(context: PluginContext, bid: BlockId, key: string, value: string): void {\n\tconst state = context.getState();\n\tconst block: BlockNode | undefined = state.getBlock(bid);\n\tif (!block || block.type !== 'code_block') return;\n\n\tconst path: string[] | undefined = findNodePath(state.doc, bid);\n\tif (!path) return;\n\n\tconst newAttrs: BlockAttrs = { ...block.attrs, [key]: value };\n\tconst tr: Transaction = state\n\t\t.transaction('command')\n\t\t.setNodeAttr(path as BlockId[], newAttrs)\n\t\t.build();\n\n\tcontext.dispatch(tr);\n}\n","/**\n * CodeBlockPlugin: orchestrates code block registration by delegating to\n * focused modules for keyboard handling, commands, and service API.\n *\n * Inline responsibilities: NodeSpec, NodeView, InputRule, Toolbar,\n * Middleware, Decorations, and lifecycle hooks (focus tracking).\n */\n\nimport type { DecorationSet } from '../../decorations/Decoration.js';\nimport { inline as inlineDecoration } from '../../decorations/Decoration.js';\nimport { DecorationSet as DecorationSetClass } from '../../decorations/Decoration.js';\nimport { CODE_BLOCK_CSS } from '../../editor/styles/code-block.js';\nimport { resolvePluginLocale } from '../../i18n/resolvePluginLocale.js';\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockText } from '../../model/Document.js';\nimport { escapeHTML } from '../../model/HTMLUtils.js';\nimport { type HTMLExportContext, createBlockElement } from '../../model/NodeSpec.js';\nimport {\n\tcreateCollapsedSelection,\n\tisCollapsed,\n\tisGapCursor,\n\tisNodeSelection,\n} from '../../model/Selection.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport { nodeType } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport type { Plugin, PluginContext } from '../Plugin.js';\nimport { formatShortcut } from '../toolbar/ToolbarItem.js';\nimport { registerCodeBlockCommands } from './CodeBlockCommands.js';\nimport { registerCodeBlockKeymaps } from './CodeBlockKeyboardHandlers.js';\nimport { CODE_BLOCK_LOCALES, type CodeBlockLocale } from './CodeBlockLocale.js';\nimport { createCodeBlockNodeViewFactory } from './CodeBlockNodeView.js';\nimport { registerCodeBlockService } from './CodeBlockService.js';\nimport type { CodeBlockConfig, CodeBlockKeymap, SyntaxToken } from './CodeBlockTypes.js';\nimport { CODE_BLOCK_ICON, DEFAULT_CONFIG, DEFAULT_KEYMAP } from './CodeBlockTypes.js';\n\nexport class CodeBlockPlugin implements Plugin {\n\treadonly id = 'code-block';\n\treadonly name = 'Code Block';\n\treadonly priority = 36;\n\n\tprivate readonly config: CodeBlockConfig;\n\tprivate readonly resolvedKeymap: Readonly<Record<keyof CodeBlockKeymap, string | null>>;\n\tprivate context: PluginContext | null = null;\n\tprivate locale!: CodeBlockLocale;\n\n\tconstructor(config?: Partial<CodeBlockConfig>) {\n\t\tthis.config = { ...DEFAULT_CONFIG, ...config };\n\t\tthis.resolvedKeymap = {\n\t\t\t...DEFAULT_KEYMAP,\n\t\t\t...config?.keymap,\n\t\t};\n\t}\n\n\tinit(context: PluginContext): void {\n\t\tthis.locale = resolvePluginLocale(CODE_BLOCK_LOCALES, context, this.config.locale);\n\t\tcontext.registerStyleSheet(CODE_BLOCK_CSS);\n\t\tthis.context = context;\n\n\t\tthis.registerNodeSpec(context);\n\t\tthis.registerNodeView(context);\n\t\tregisterCodeBlockCommands(context, this.config);\n\t\tregisterCodeBlockKeymaps(context, this.config, this.resolvedKeymap);\n\t\tthis.registerInputRule(context);\n\t\tthis.registerToolbarItem(context);\n\t\tthis.registerMiddleware(context);\n\t\tregisterCodeBlockService(context, this.config, () => this.context);\n\t\tthis.patchTableCellContent(context);\n\t}\n\n\tdestroy(): void {\n\t\tthis.context = null;\n\t}\n\n\tonStateChange(oldState: EditorState, newState: EditorState, _tr: Transaction): void {\n\t\tif (!this.context) return;\n\n\t\tconst oldBlockId: BlockId | null =\n\t\t\tisNodeSelection(oldState.selection) || isGapCursor(oldState.selection)\n\t\t\t\t? null\n\t\t\t\t: oldState.selection.anchor.blockId;\n\t\tconst newBlockId: BlockId | null =\n\t\t\tisNodeSelection(newState.selection) || isGapCursor(newState.selection)\n\t\t\t\t? null\n\t\t\t\t: newState.selection.anchor.blockId;\n\n\t\tconst oldBlock: BlockNode | undefined = oldBlockId ? oldState.getBlock(oldBlockId) : undefined;\n\t\tconst newBlock: BlockNode | undefined = newBlockId ? newState.getBlock(newBlockId) : undefined;\n\n\t\tconst wasInCode: boolean = oldBlock?.type === 'code_block';\n\t\tconst nowInCode: boolean = newBlock?.type === 'code_block';\n\n\t\tif (wasInCode && oldBlockId) {\n\t\t\tthis.setBlockFocused(oldBlockId, false);\n\t\t}\n\t\tif (nowInCode && newBlockId) {\n\t\t\tthis.setBlockFocused(newBlockId, true);\n\t\t}\n\n\t\tif (!wasInCode && nowInCode) {\n\t\t\tthis.context.announce(this.locale.enteredCodeBlock);\n\t\t} else if (wasInCode && !nowInCode) {\n\t\t\tthis.context.announce(this.locale.leftCodeBlock);\n\t\t}\n\t}\n\n\tdecorations(state: EditorState): DecorationSet {\n\t\tif (!this.config.highlighter) return DecorationSetClass.empty;\n\n\t\tconst decorations: ReturnType<typeof inlineDecoration>[] = [];\n\t\tconst highlighter = this.config.highlighter;\n\n\t\tfor (const bid of state.getBlockOrder()) {\n\t\t\tconst block: BlockNode | undefined = state.getBlock(bid);\n\t\t\tif (!block || block.type !== 'code_block') continue;\n\n\t\t\tconst lang: string = (block.attrs?.language as string) ?? '';\n\t\t\tif (!lang) continue;\n\n\t\t\tconst text: string = getBlockText(block);\n\t\t\tif (!text) continue;\n\n\t\t\tconst tokens: readonly SyntaxToken[] = highlighter.tokenize(text, lang);\n\t\t\tfor (const token of tokens) {\n\t\t\t\tdecorations.push(\n\t\t\t\t\tinlineDecoration(bid, token.from, token.to, {\n\t\t\t\t\t\tclass: `notectl-token--${token.type}`,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn DecorationSetClass.create(decorations);\n\t}\n\n\t// --- NodeSpec ---\n\n\tprivate registerNodeSpec(context: PluginContext): void {\n\t\tcontext.registerNodeSpec({\n\t\t\ttype: 'code_block',\n\t\t\tgroup: 'block',\n\t\t\tcontent: { allow: ['text'] },\n\t\t\tselectable: true,\n\t\t\tattrs: {\n\t\t\t\tlanguage: { default: '' },\n\t\t\t\tbackgroundColor: { default: '' },\n\t\t\t},\n\t\t\ttoDOM(node) {\n\t\t\t\tconst pre: HTMLElement = createBlockElement('pre', node.id);\n\t\t\t\tpre.className = 'notectl-code-block';\n\t\t\t\tconst code: HTMLElement = document.createElement('code');\n\t\t\t\tcode.className = 'notectl-code-block__content';\n\t\t\t\tpre.appendChild(code);\n\t\t\t\treturn pre;\n\t\t\t},\n\t\t\ttoHTML(node, content, ctx?: HTMLExportContext) {\n\t\t\t\tconst lang: string = escapeHTML((node.attrs?.language as string) ?? '');\n\t\t\t\tconst bg: string = escapeHTML((node.attrs?.backgroundColor as string) ?? '');\n\t\t\t\tconst langClass: string = lang ? ` class=\"language-${lang}\"` : '';\n\t\t\t\tconst bgAttr: string = bg\n\t\t\t\t\t? (ctx?.styleAttr(`background-color: ${bg}`) ?? ` style=\"background-color: ${bg}\"`)\n\t\t\t\t\t: '';\n\t\t\t\treturn `<pre${bgAttr}><code${langClass}>${content || ''}</code></pre>`;\n\t\t\t},\n\t\t\tparseHTML: [\n\t\t\t\t{\n\t\t\t\t\ttag: 'pre',\n\t\t\t\t\tgetAttrs(el: HTMLElement) {\n\t\t\t\t\t\tconst code: HTMLElement | null = el.querySelector('code');\n\t\t\t\t\t\tconst langClass: string = code?.className.match(/language-(\\S+)/)?.[1] ?? '';\n\t\t\t\t\t\tconst dataLang: string = code?.getAttribute('data-language') ?? '';\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tlanguage: dataLang || langClass,\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tsanitize: {\n\t\t\t\ttags: ['pre', 'code'],\n\t\t\t\tattrs: ['data-language', 'class', 'style'],\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- NodeView ---\n\n\tprivate registerNodeView(context: PluginContext): void {\n\t\tcontext.registerNodeView('code_block', createCodeBlockNodeViewFactory(this.config));\n\t}\n\n\t// --- Input Rule ---\n\n\tprivate registerInputRule(context: PluginContext): void {\n\t\tcontext.registerInputRule({\n\t\t\tpattern: /^```(\\w*) $/,\n\t\t\thandler: (state, match, start, _end) => {\n\t\t\t\tconst sel = state.selection;\n\t\t\t\tif (isNodeSelection(sel) || isGapCursor(sel)) return null;\n\t\t\t\tif (!isCollapsed(sel)) return null;\n\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(sel.anchor.blockId);\n\t\t\t\tif (!block || block.type !== 'paragraph') return null;\n\n\t\t\t\tconst language: string = match[1] ?? '';\n\t\t\t\tconst attrs: Record<string, string | number | boolean> = {\n\t\t\t\t\tlanguage,\n\t\t\t\t\tbackgroundColor: '',\n\t\t\t\t};\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 + match[0].length)\n\t\t\t\t\t.setBlockType(sel.anchor.blockId, nodeType('code_block'), attrs)\n\t\t\t\t\t.setSelection(createCollapsedSelection(sel.anchor.blockId, 0))\n\t\t\t\t\t.build();\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Toolbar ---\n\n\tprivate registerToolbarItem(context: PluginContext): void {\n\t\tcontext.registerToolbarItem({\n\t\t\tid: 'code_block',\n\t\t\tgroup: 'block',\n\t\t\ticon: CODE_BLOCK_ICON,\n\t\t\tlabel: this.locale.label,\n\t\t\ttooltip: this.locale.tooltip(\n\t\t\t\tthis.resolvedKeymap.toggle ? formatShortcut(this.resolvedKeymap.toggle) : undefined,\n\t\t\t),\n\t\t\tcommand: 'toggleCodeBlock',\n\t\t\tpriority: 56,\n\t\t\tseparatorAfter: this.config.separatorAfter,\n\t\t\tisActive: (state) => {\n\t\t\t\tif (isNodeSelection(state.selection) || isGapCursor(state.selection)) return false;\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(state.selection.anchor.blockId);\n\t\t\t\treturn block?.type === 'code_block';\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Middleware (Mark Prevention) ---\n\n\tprivate registerMiddleware(context: PluginContext): void {\n\t\tcontext.registerMiddleware(\n\t\t\t(tr, state, next) => {\n\t\t\t\tconst hasMarkInCodeBlock: boolean = tr.steps.some((step) => {\n\t\t\t\t\tif (step.type !== 'addMark') return false;\n\t\t\t\t\tconst block: BlockNode | undefined = state.getBlock(step.blockId);\n\t\t\t\t\treturn block?.type === 'code_block';\n\t\t\t\t});\n\n\t\t\t\tif (!hasMarkInCodeBlock) {\n\t\t\t\t\tnext(tr);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst filtered = tr.steps.filter((step) => {\n\t\t\t\t\tif (step.type !== 'addMark') return true;\n\t\t\t\t\tconst block: BlockNode | undefined = state.getBlock(step.blockId);\n\t\t\t\t\treturn block?.type !== 'code_block';\n\t\t\t\t});\n\n\t\t\t\tnext({ ...tr, steps: filtered });\n\t\t\t},\n\t\t\t{ name: 'code-block:mark-guard', priority: 50 },\n\t\t);\n\t}\n\n\t// --- Table Cell Patching ---\n\n\tprivate patchTableCellContent(context: PluginContext): void {\n\t\tconst registry = context.getSchemaRegistry();\n\t\tconst cellSpec = registry.getNodeSpec('table_cell');\n\t\tif (!cellSpec?.content) return;\n\n\t\tconst currentAllow: readonly string[] = cellSpec.content.allow ?? [];\n\t\tif (currentAllow.includes('code_block')) return;\n\n\t\tregistry.removeNodeSpec('table_cell');\n\t\tregistry.registerNodeSpec({\n\t\t\t...cellSpec,\n\t\t\tcontent: {\n\t\t\t\t...cellSpec.content,\n\t\t\t\tallow: [...currentAllow, 'code_block'],\n\t\t\t},\n\t\t});\n\t}\n\n\t// --- Helpers ---\n\n\tprivate setBlockFocused(bid: BlockId, focused: boolean): void {\n\t\tif (!this.context) return;\n\t\tconst container: HTMLElement = this.context.getContainer();\n\t\tconst el: Element | null = container.querySelector(`[data-block-id=\"${bid}\"]`);\n\t\tif (el) {\n\t\t\tel.classList.toggle('notectl-code-block--focused', focused);\n\t\t}\n\t}\n}\n","/** Code block styles — syntax highlighting container, header, copy button. */\nexport const CODE_BLOCK_CSS = `\n/* Code Block — uses theme custom properties */\n.notectl-code-block {\n\tposition: relative;\n\tmargin: 8px 0;\n\tborder-radius: 6px;\n\tbackground: var(--notectl-code-block-bg);\n\tcolor: var(--notectl-code-block-color);\n\tfont-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;\n\tfont-size: 14px;\n\tline-height: 1.5;\n\toverflow: hidden;\n}\n\n.notectl-code-block__header {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tpadding: 6px 12px;\n\tbackground: var(--notectl-code-block-header-bg);\n\tborder-bottom: 1px solid var(--notectl-code-block-header-border);\n\tfont-size: 12px;\n\tcolor: var(--notectl-code-block-header-color);\n\tuser-select: none;\n}\n\n.notectl-code-block__language {\n\tfont-weight: 500;\n\tletter-spacing: 0.02em;\n}\n\n.notectl-code-block__copy {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 24px;\n\theight: 24px;\n\tborder: none;\n\tborder-radius: 4px;\n\tbackground: transparent;\n\tcolor: var(--notectl-code-block-header-color);\n\tcursor: pointer;\n\tpadding: 0;\n\ttransition: background 0.15s, color 0.15s;\n}\n\n.notectl-code-block__copy:hover {\n\tbackground: rgba(128, 128, 128, 0.15);\n\tcolor: var(--notectl-code-block-color);\n}\n\n.notectl-code-block__copy svg {\n\tfill: currentColor;\n}\n\n.notectl-code-block__content {\n\tdisplay: block;\n\tpadding: 12px 16px;\n\twhite-space: pre-wrap;\n\tword-wrap: break-word;\n\ttab-size: 4;\n\t-moz-tab-size: 4;\n\toutline: none;\n\tmin-height: 1.5em;\n}\n\n.notectl-code-block--selected {\n\toutline: 2px solid var(--notectl-primary);\n\toutline-offset: 2px;\n}\n\n.notectl-code-block__esc-hint {\n\tdisplay: none;\n\tposition: absolute;\n\tbottom: 4px;\n\tright: 8px;\n\tfont-size: 11px;\n\tcolor: var(--notectl-code-block-header-color);\n\topacity: 0.5;\n\tpointer-events: none;\n\tuser-select: none;\n\tfont-family: system-ui, sans-serif;\n}\n\n.notectl-code-block--focused .notectl-code-block__esc-hint {\n\tdisplay: block;\n}\n`;\n","/**\n * NodeView factory for code blocks.\n * Renders <pre> with a non-editable header (language label + copy button)\n * and a <code> content area where the Reconciler renders text.\n */\n\nimport type { BlockNode } from '../../model/Document.js';\nimport { getBlockText } from '../../model/Document.js';\nimport type { BlockId } from '../../model/TypeBrands.js';\nimport type { EditorState } from '../../state/EditorState.js';\nimport type { Transaction } from '../../state/Transaction.js';\nimport { setStyleProperty } from '../../style/StyleRuntime.js';\nimport type { NodeView, NodeViewFactory } from '../../view/NodeView.js';\nimport type { CodeBlockConfig } from './CodeBlockTypes.js';\n\nconst COPY_ICON =\n\t'<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>';\n\n/** Creates a NodeViewFactory for code_block nodes. */\nexport function createCodeBlockNodeViewFactory(config: CodeBlockConfig): NodeViewFactory {\n\treturn (\n\t\tnode: BlockNode,\n\t\tgetState: () => EditorState,\n\t\t_dispatch: (tr: Transaction) => void,\n\t): NodeView => {\n\t\t// --- DOM Construction ---\n\t\tconst pre: HTMLElement = document.createElement('pre');\n\t\tpre.className = 'notectl-code-block';\n\t\tpre.setAttribute('data-block-id', node.id);\n\t\tpre.setAttribute('role', 'group');\n\t\tpre.setAttribute('aria-roledescription', 'code block');\n\n\t\t// Header (non-editable)\n\t\tconst header: HTMLDivElement = document.createElement('div');\n\t\theader.className = 'notectl-code-block__header';\n\t\theader.setAttribute('contenteditable', 'false');\n\n\t\tconst langLabel: HTMLSpanElement = document.createElement('span');\n\t\tlangLabel.className = 'notectl-code-block__language';\n\n\t\tconst showCopy: boolean = config.showCopyButton !== false;\n\t\tlet copyBtn: HTMLButtonElement | null = null;\n\n\t\tif (showCopy) {\n\t\t\tcopyBtn = document.createElement('button');\n\t\t\tcopyBtn.className = 'notectl-code-block__copy';\n\t\t\tcopyBtn.setAttribute('aria-label', 'Copy code');\n\t\t\tcopyBtn.setAttribute('data-notectl-no-print', '');\n\t\t\tcopyBtn.type = 'button';\n\t\t\tcopyBtn.innerHTML = COPY_ICON;\n\t\t}\n\n\t\t// Screen reader live region for copy feedback\n\t\tconst copyAnnouncer: HTMLSpanElement = document.createElement('span');\n\t\tcopyAnnouncer.className = 'notectl-sr-only';\n\t\tcopyAnnouncer.setAttribute('aria-live', 'assertive');\n\t\tcopyAnnouncer.setAttribute('aria-atomic', 'true');\n\n\t\theader.appendChild(langLabel);\n\t\tif (copyBtn) {\n\t\t\theader.appendChild(copyBtn);\n\t\t}\n\t\theader.appendChild(copyAnnouncer);\n\n\t\t// Content area (Reconciler target)\n\t\tconst code: HTMLElement = document.createElement('code');\n\t\tcode.className = 'notectl-code-block__content';\n\n\t\t// Escape hint (visible only when focused, CSS-driven)\n\t\tconst escHint: HTMLDivElement = document.createElement('div');\n\t\tescHint.className = 'notectl-code-block__esc-hint';\n\t\tescHint.setAttribute('contenteditable', 'false');\n\t\tescHint.setAttribute('aria-hidden', 'true');\n\t\tescHint.setAttribute('data-notectl-no-print', '');\n\t\tescHint.textContent = 'Esc to exit';\n\n\t\tpre.appendChild(header);\n\t\tpre.appendChild(code);\n\t\tpre.appendChild(escHint);\n\n\t\t// Apply config-level color overrides as CSS custom properties\n\t\tif (config.background) {\n\t\t\tsetStyleProperty(pre, '--notectl-code-block-bg', config.background);\n\t\t}\n\t\tif (config.headerBackground) {\n\t\t\tsetStyleProperty(pre, '--notectl-code-block-header-bg', config.headerBackground);\n\t\t}\n\t\tif (config.textColor) {\n\t\t\tsetStyleProperty(pre, '--notectl-code-block-color', config.textColor);\n\t\t}\n\t\tif (config.headerColor) {\n\t\t\tsetStyleProperty(pre, '--notectl-code-block-header-color', config.headerColor);\n\t\t}\n\n\t\tlet currentNodeId: BlockId = node.id;\n\n\t\t// --- Attribute Application ---\n\n\t\tfunction applyAttrs(n: BlockNode): void {\n\t\t\tconst lang: string = (n.attrs?.language as string) ?? '';\n\t\t\tconst langName: string = lang || 'plain';\n\t\t\tlangLabel.textContent = langName;\n\t\t\tpre.setAttribute('aria-label', `${langName} code block. Press Escape to exit.`);\n\n\t\t\tif (lang) {\n\t\t\t\tcode.setAttribute('data-language', lang);\n\t\t\t} else {\n\t\t\t\tcode.removeAttribute('data-language');\n\t\t\t}\n\n\t\t\tconst bg: string = (n.attrs?.backgroundColor as string) ?? '';\n\t\t\tsetStyleProperty(pre, 'backgroundColor', bg || '');\n\t\t}\n\n\t\tapplyAttrs(node);\n\n\t\t// --- Copy Button Handler ---\n\n\t\tif (copyBtn) {\n\t\t\tcopyBtn.addEventListener('click', (e: MouseEvent) => {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\n\t\t\t\tconst state: EditorState = getState();\n\t\t\t\tconst block: BlockNode | undefined = state.getBlock(currentNodeId);\n\t\t\t\tif (!block) return;\n\n\t\t\t\tconst text: string = getBlockText(block);\n\t\t\t\tnavigator.clipboard.writeText(text);\n\n\t\t\t\t// Announce to screen readers\n\t\t\t\tcopyAnnouncer.textContent = 'Copied to clipboard';\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tcopyAnnouncer.textContent = '';\n\t\t\t\t}, 1000);\n\t\t\t});\n\t\t}\n\n\t\t// --- NodeView Interface ---\n\n\t\treturn {\n\t\t\tdom: pre,\n\t\t\tcontentDOM: code,\n\n\t\t\tupdate(updatedNode: BlockNode): boolean {\n\t\t\t\tif (updatedNode.type !== 'code_block') return false;\n\t\t\t\tcurrentNodeId = updatedNode.id;\n\t\t\t\tpre.setAttribute('data-block-id', updatedNode.id);\n\t\t\t\tapplyAttrs(updatedNode);\n\t\t\t\treturn true;\n\t\t\t},\n\n\t\t\tselectNode(): void {\n\t\t\t\tpre.classList.add('notectl-code-block--selected');\n\t\t\t},\n\n\t\t\tdeselectNode(): void {\n\t\t\t\tpre.classList.remove('notectl-code-block--selected');\n\t\t\t},\n\n\t\t\tdestroy(): void {\n\t\t\t\t// No cleanup needed\n\t\t\t},\n\t\t};\n\t};\n}\n"],"names":["mapDecorationThroughStep","deco","step","type","blockId","len","text","length","newFrom","from","offset","newTo","to","delLen","clampAndShift","newBlockId","sourceBlockId","targetBlockId","targetLengthBefore","removeIfBlockDeleted","side","removedNode","id","pos","delFrom","delTo","inline","attrs","node","widget","toDOM","options","key","DecorationSet","byBlock","this","static","Map","decorations","empty","map","existing","get","push","set","decos","filter","d","isEmpty","create","bid","predicate","changed","filtered","size","other","otherDecos","decorationArraysEqual","tr","steps","mapped","values","next","result","Array","isArray","r","a","b","i","ai","bi","decorationsEqual","attrsEqual","bn","bw","aKeys","Object","keys","bKeys","withCodeBlockContext","context","handler","state","getState","isNodeSelection","selection","isGapCursor","sel","block","getBlock","anchor","handleEscape","blockOrder","getBlockOrder","idx","indexOf","nextId","transaction","setSelection","createCollapsedSelection","build","dispatch","insertParagraphAfter","blockLength","getBlockLength","newId","generateBlockId","splitBlock","setBlockType","nodeType","insertCodeBlock","config","language","defaultLanguage","backgroundColor","builder","inlineChildren","getInlineChildren","child","isTextNode","mark","marks","removeMark","CODE_BLOCK_LOCALE_EN","label","tooltip","shortcut","enteredCodeBlock","leftCodeBlock","CODE_BLOCK_LOCALES","en","de","es","fr","zh","ru","ar","hi","DEFAULT_KEYMAP","insertAfter","toggle","DEFAULT_CONFIG","useSpaces","spaceCount","showCopyButton","CODE_BLOCK_SERVICE_KEY","ServiceKey","setAttr","value","path","findNodePath","doc","newAttrs","setNodeAttr","CodeBlockPlugin","name","priority","resolvedKeymap","locale","keymap","resolvePluginLocale","registerStyleSheet","registerNodeSpec","registerNodeView","registerCommand","Enter","isCollapsed","getBlockText","endsWith","trimmedLen","deleteTextAt","insertText","Backspace","Tab","indent","repeat","lineStart","lastIndexOf","slice","Math","max","Escape","ArrowDown","ArrowUp","firstNewline","prevId","prevBlock","prevLen","ArrowRight","ArrowLeft","executeCommand","registerKeymap","registerInputRule","registerToolbarItem","registerMiddleware","getContext","registerService","ctx","color","getSupportedLanguages","highlighter","patchTableCellContent","destroy","oldState","newState","_tr","oldBlockId","oldBlock","newBlock","wasInCode","nowInCode","setBlockFocused","announce","DecorationSetClass","lang","tokens","tokenize","token","inlineDecoration","class","group","content","allow","selectable","default","pre","createBlockElement","className","code","document","createElement","appendChild","escapeHTML","bg","langClass","styleAttr","parseHTML","tag","el","querySelector","match","getAttribute","sanitize","tags","_dispatch","setAttribute","header","langLabel","copyBtn","innerHTML","copyAnnouncer","escHint","textContent","background","setStyleProperty","headerBackground","textColor","headerColor","currentNodeId","applyAttrs","n","langName","removeAttribute","addEventListener","e","preventDefault","stopPropagation","navigator","clipboard","writeText","setTimeout","dom","contentDOM","update","updatedNode","selectNode","classList","add","deselectNode","remove","pattern","start","_end","icon","formatShortcut","command","separatorAfter","isActive","some","registry","getSchemaRegistry","cellSpec","getNodeSpec","currentAllow","includes","removeNodeSpec","focused","getContainer"],"mappings":";;;;;;;;;AA0BO,SAASA,EACfC,IACAC,IAAAA;AAEA,UAAQD,GAAKE,MAAAA;AAAAA,IACZ,KAAK;AACJ,cAQH,SACCF,IACAC;AAEA,gBAAQA,GAAKC;UACZ,KAAK;AACJ,oBA4CH,SAAyBF,IAAwBC,IAAAA;AAChD,kBAAID,GAAKG,YAAYF,GAAKE,QAAS,QAAOH;AAE1C,oBAAMI,KAAcH,GAAKI,KAAKC,QAExBC,KAAkBP,GAAKQ,OAAOP,GAAKQ,SAAST,GAAKQ,OAAOJ,KAAMJ,GAAKQ,MAEnEE,KAAgBV,GAAKW,MAAMV,GAAKQ,SAAST,GAAKW,KAAKP,KAAMJ,GAAKW;AAEpE,qBAAIJ,OAAYP,GAAKQ,QAAQE,OAAUV,GAAKW,KAAWX,KAChD,EAAA,GAAKA,IAAMQ,MAAMD,IAASI,IAAID,GAAAA;AAAAA,YACtC,GAvD0BV,IAAMC;UAC9B,KAAK;AACJ,oBAuEH,SAAyBD,IAAwBC,IAAAA;AAChD,kBAAID,GAAKG,YAAYF,GAAKE,QAAS,QAAOH;AAE1C,oBAAMY,KAAiBX,GAAKU,KAAKV,GAAKO,MAChCD,KAAkBM,EAAcb,GAAKQ,MAAMP,GAAKO,MAAMP,GAAKU,IAAIC,EAAAA,GAC/DF,KAAgBG,EAAcb,GAAKW,IAAIV,GAAKO,MAAMP,GAAKU,IAAIC,EAAAA;AAEjE,qBAAIL,MAAWG,KAAc,OACzBH,OAAYP,GAAKQ,QAAQE,OAAUV,GAAKW,KAAWX,KAChD,KAAKA,IAAMQ,MAAMD,IAASI,IAAID,GAAAA;AAAAA,YACtC,GAjF0BV,IAAMC,EAAAA;AAAAA,UAC9B,KAAK;AACJ,oBAgGH,SACCD,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