@notectl/core 1.7.1 → 1.7.2
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.
- package/dist/chunks/{AttrRegistry-Ci0qAvtS.mjs → AttrRegistry-D9Jx_RVb.mjs} +2 -2
- package/dist/chunks/{AttrRegistry-Ci0qAvtS.mjs.map → AttrRegistry-D9Jx_RVb.mjs.map} +1 -1
- package/dist/chunks/AttributedMarkCommands-BtLea72z.mjs +80 -0
- package/dist/chunks/AttributedMarkCommands-BtLea72z.mjs.map +1 -0
- package/dist/chunks/{CaretNavigation-qLfeL0So.mjs → CaretNavigation-7JYpIKbs.mjs} +3 -3
- package/dist/chunks/{CaretNavigation-qLfeL0So.mjs.map → CaretNavigation-7JYpIKbs.mjs.map} +1 -1
- package/dist/chunks/{ColorGrid-BBkN0AOb.mjs → ColorGrid-Dneqb8if.mjs} +56 -55
- package/dist/chunks/ColorGrid-Dneqb8if.mjs.map +1 -0
- package/dist/chunks/{ColorPickerPopup-D3ysvOH-.mjs → ColorPickerPopup-CiCLBbe9.mjs} +11 -11
- package/dist/chunks/{ColorPickerPopup-D3ysvOH-.mjs.map → ColorPickerPopup-CiCLBbe9.mjs.map} +1 -1
- package/dist/chunks/{Document-DfZ1NOjs.mjs → Document-Brtw2jL1.mjs} +6 -6
- package/dist/chunks/{Document-DfZ1NOjs.mjs.map → Document-Brtw2jL1.mjs.map} +1 -1
- package/dist/chunks/{MarkCommands-uybmkw9l.mjs → MarkCommands-6RUJ4L3r.mjs} +3 -3
- package/dist/chunks/{MarkCommands-uybmkw9l.mjs.map → MarkCommands-6RUJ4L3r.mjs.map} +1 -1
- package/dist/chunks/{NodeResolver-CzLmmrph.mjs → NodeResolver-C2XYkeOi.mjs} +2 -2
- package/dist/chunks/{NodeResolver-CzLmmrph.mjs.map → NodeResolver-C2XYkeOi.mjs.map} +1 -1
- package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs +32 -0
- package/dist/chunks/PopupPositioning-BTT-_pQ3.mjs.map +1 -0
- package/dist/chunks/RangeIterator-Bh4Vl_6D.mjs +16 -0
- package/dist/chunks/{RangeIterator-Bye0UtbY.mjs.map → RangeIterator-Bh4Vl_6D.mjs.map} +1 -1
- package/dist/chunks/StyleRuntime-ChRjVQwL.mjs +239 -0
- package/dist/chunks/StyleRuntime-ChRjVQwL.mjs.map +1 -0
- package/dist/chunks/{ToolbarPlugin-B7oJRzpl.mjs → ToolbarPlugin-DpLVJ71w.mjs} +48 -47
- package/dist/chunks/ToolbarPlugin-DpLVJ71w.mjs.map +1 -0
- package/dist/chunks/{index-DoCvDkfj.mjs → index--n1RGpq-.mjs} +39 -38
- package/dist/chunks/index--n1RGpq-.mjs.map +1 -0
- package/dist/chunks/{index-DayTn6Re.mjs → index-4or5UzNO.mjs} +43 -41
- package/dist/chunks/index-4or5UzNO.mjs.map +1 -0
- package/dist/chunks/{index-CFJFD4lF.mjs → index-ABlTDvEX.mjs} +19 -18
- package/dist/chunks/index-ABlTDvEX.mjs.map +1 -0
- package/dist/chunks/{index-DmuuFS5D.mjs → index-BAke7kNL.mjs} +43 -43
- package/dist/chunks/{index-DmuuFS5D.mjs.map → index-BAke7kNL.mjs.map} +1 -1
- package/dist/chunks/{index-DGKQhSAl.mjs → index-BXtw5PNN.mjs} +2 -2
- package/dist/chunks/{index-DGKQhSAl.mjs.map → index-BXtw5PNN.mjs.map} +1 -1
- package/dist/chunks/{index-CH1r7DL-.mjs → index-BhDXjueu.mjs} +204 -203
- package/dist/chunks/index-BhDXjueu.mjs.map +1 -0
- package/dist/chunks/{index-CfyS_pgH.mjs → index-BqNUfq-y.mjs} +32 -31
- package/dist/chunks/index-BqNUfq-y.mjs.map +1 -0
- package/dist/chunks/{index-Ckzqtn5D.mjs → index-BvqkuEY1.mjs} +15 -14
- package/dist/chunks/index-BvqkuEY1.mjs.map +1 -0
- package/dist/chunks/{index-CrKz_IEn.mjs → index-C1opJocO.mjs} +2 -2
- package/dist/chunks/{index-CrKz_IEn.mjs.map → index-C1opJocO.mjs.map} +1 -1
- package/dist/chunks/{index-Deag_lVi.mjs → index-CWltg1wK.mjs} +24 -21
- package/dist/chunks/index-CWltg1wK.mjs.map +1 -0
- package/dist/chunks/{index-E7OgN7hM.mjs → index-Cd3uJLP3.mjs} +2 -2
- package/dist/chunks/{index-E7OgN7hM.mjs.map → index-Cd3uJLP3.mjs.map} +1 -1
- package/dist/chunks/{index-CFPP456m.mjs → index-CluzpB2b.mjs} +2 -2
- package/dist/chunks/{index-CFPP456m.mjs.map → index-CluzpB2b.mjs.map} +1 -1
- package/dist/chunks/{index-DIvHQtE2.mjs → index-D3NlpmT1.mjs} +15 -14
- package/dist/chunks/index-D3NlpmT1.mjs.map +1 -0
- package/dist/chunks/{index-Bt_d4IqB.mjs → index-D515iymW.mjs} +71 -70
- package/dist/chunks/{index-Bt_d4IqB.mjs.map → index-D515iymW.mjs.map} +1 -1
- package/dist/chunks/{index-Dum8yE_t.mjs → index-Dk49P9N4.mjs} +11 -11
- package/dist/chunks/{index-Dum8yE_t.mjs.map → index-Dk49P9N4.mjs.map} +1 -1
- package/dist/chunks/{index-yhz2qeeh.mjs → index-DyzigvbZ.mjs} +128 -124
- package/dist/chunks/index-DyzigvbZ.mjs.map +1 -0
- package/dist/chunks/{index-DuRNETFv.mjs → index-ErZ5_a1o.mjs} +3 -3
- package/dist/chunks/{index-DuRNETFv.mjs.map → index-ErZ5_a1o.mjs.map} +1 -1
- package/dist/chunks/{index-Dy6SllXW.mjs → index-fsVJLutn.mjs} +3 -3
- package/dist/chunks/{index-Dy6SllXW.mjs.map → index-fsVJLutn.mjs.map} +1 -1
- package/dist/commands/AttributedMarkCommands.d.ts.map +1 -1
- package/dist/editor/EditorThemeController.d.ts +3 -0
- package/dist/editor/EditorThemeController.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +13 -0
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/PaperLayoutController.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -1
- package/dist/notectl-core.mjs +452 -440
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +1325 -1068
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/blockquote.mjs +1 -1
- package/dist/plugins/caret-navigation.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockNodeView.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font/FontPlugin.d.ts.map +1 -1
- package/dist/plugins/font-size/FontSizePlugin.d.ts.map +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/gap-cursor.mjs +6 -6
- package/dist/plugins/hard-break.mjs +1 -1
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/highlight/HighlightPlugin.d.ts.map +1 -1
- package/dist/plugins/highlight.mjs +1 -1
- package/dist/plugins/horizontal-rule.mjs +1 -1
- package/dist/plugins/image/ImageNodeView.d.ts.map +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/link.mjs +1 -1
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/print/PrintContentPreparer.d.ts.map +1 -1
- package/dist/plugins/shared/ColorGrid.d.ts.map +1 -1
- package/dist/plugins/shared/PopupPositioning.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/table/TableContextMenu.d.ts.map +1 -1
- package/dist/plugins/table/TableControls.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsDOM.d.ts.map +1 -1
- package/dist/plugins/table/TableControlsLayout.d.ts.map +1 -1
- package/dist/plugins/table/TableNodeViews.d.ts.map +1 -1
- package/dist/plugins/table.mjs +1 -1
- package/dist/plugins/text-color/TextColorPlugin.d.ts.map +1 -1
- package/dist/plugins/text-color.mjs +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarPopupController.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarRenderers.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarTooltip.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/style/StyleRuntime.d.ts +38 -0
- package/dist/style/StyleRuntime.d.ts.map +1 -0
- package/dist/view/Reconciler.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs +0 -58
- package/dist/chunks/AttributedMarkCommands-BETuHXj8.mjs.map +0 -1
- package/dist/chunks/ColorGrid-BBkN0AOb.mjs.map +0 -1
- package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs +0 -30
- package/dist/chunks/PopupPositioning-Cn6L_mO2.mjs.map +0 -1
- package/dist/chunks/RangeIterator-Bye0UtbY.mjs +0 -16
- package/dist/chunks/ToolbarPlugin-B7oJRzpl.mjs.map +0 -1
- package/dist/chunks/index-CFJFD4lF.mjs.map +0 -1
- package/dist/chunks/index-CH1r7DL-.mjs.map +0 -1
- package/dist/chunks/index-CfyS_pgH.mjs.map +0 -1
- package/dist/chunks/index-Ckzqtn5D.mjs.map +0 -1
- package/dist/chunks/index-DIvHQtE2.mjs.map +0 -1
- package/dist/chunks/index-DayTn6Re.mjs.map +0 -1
- package/dist/chunks/index-Deag_lVi.mjs.map +0 -1
- package/dist/chunks/index-DoCvDkfj.mjs.map +0 -1
- package/dist/chunks/index-yhz2qeeh.mjs.map +0 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { S as t, r as e } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { c as o, m as n, u as c, a as r, i as l } from "./Document-Brtw2jL1.mjs";
|
|
3
3
|
import { e as s } from "./HTMLUtils-DTqQzcKR.mjs";
|
|
4
4
|
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 {
|
|
9
|
-
|
|
8
|
+
import { a as p } from "./StyleRuntime-ChRjVQwL.mjs";
|
|
9
|
+
import { f as b } from "./NodeResolver-C2XYkeOi.mjs";
|
|
10
|
+
function h(t2, e2) {
|
|
10
11
|
switch (t2.type) {
|
|
11
12
|
case "inline":
|
|
12
13
|
return (function(t3, e3) {
|
|
@@ -20,7 +21,7 @@ function b(t2, e2) {
|
|
|
20
21
|
case "deleteText":
|
|
21
22
|
return (function(t4, e4) {
|
|
22
23
|
if (t4.blockId !== e4.blockId) return t4;
|
|
23
|
-
const o2 = e4.to - e4.from, n2 =
|
|
24
|
+
const o2 = e4.to - e4.from, n2 = B(t4.from, e4.from, e4.to, o2), c2 = B(t4.to, e4.from, e4.to, o2);
|
|
24
25
|
return n2 >= c2 ? null : n2 === t4.from && c2 === t4.to ? t4 : { ...t4, from: n2, to: c2 };
|
|
25
26
|
})(t3, e3);
|
|
26
27
|
case "splitBlock":
|
|
@@ -35,7 +36,7 @@ function b(t2, e2) {
|
|
|
35
36
|
return t4.blockId !== e4.sourceBlockId ? t4 : { ...t4, blockId: e4.targetBlockId, from: t4.from + e4.targetLengthBefore, to: t4.to + e4.targetLengthBefore };
|
|
36
37
|
})(t3, e3);
|
|
37
38
|
case "removeNode":
|
|
38
|
-
return
|
|
39
|
+
return m(t3, e3);
|
|
39
40
|
default:
|
|
40
41
|
return t3;
|
|
41
42
|
}
|
|
@@ -65,7 +66,7 @@ function b(t2, e2) {
|
|
|
65
66
|
return t4.blockId !== e4.sourceBlockId ? t4 : { ...t4, blockId: e4.targetBlockId, offset: t4.offset + e4.targetLengthBefore };
|
|
66
67
|
})(t3, e3);
|
|
67
68
|
case "removeNode":
|
|
68
|
-
return
|
|
69
|
+
return m(t3, e3);
|
|
69
70
|
default:
|
|
70
71
|
return t3;
|
|
71
72
|
}
|
|
@@ -78,41 +79,41 @@ function b(t2, e2) {
|
|
|
78
79
|
return t4.blockId === e4.sourceBlockId ? null : t4;
|
|
79
80
|
})(t3, e3);
|
|
80
81
|
case "removeNode":
|
|
81
|
-
return
|
|
82
|
+
return m(t3, e3);
|
|
82
83
|
default:
|
|
83
84
|
return t3;
|
|
84
85
|
}
|
|
85
86
|
})(t2, e2);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
|
-
function
|
|
89
|
+
function m(t2, e2) {
|
|
89
90
|
return t2.blockId === e2.removedNode.id ? null : t2;
|
|
90
91
|
}
|
|
91
|
-
function
|
|
92
|
+
function B(t2, e2, o2, n2) {
|
|
92
93
|
return t2 <= e2 ? t2 : t2 >= o2 ? t2 - n2 : e2;
|
|
93
94
|
}
|
|
94
95
|
function y(t2, e2, o2, n2) {
|
|
95
96
|
return { type: "inline", blockId: t2, from: e2, to: o2, attrs: n2 };
|
|
96
97
|
}
|
|
97
|
-
function
|
|
98
|
+
function C(t2, e2) {
|
|
98
99
|
return { type: "node", blockId: t2, attrs: e2 };
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
+
function I(t2, e2, o2, n2) {
|
|
101
102
|
return { type: "widget", blockId: t2, offset: e2, toDOM: o2, side: n2?.side ?? -1, key: n2?.key };
|
|
102
103
|
}
|
|
103
|
-
class
|
|
104
|
+
class x {
|
|
104
105
|
constructor(t2) {
|
|
105
106
|
this.byBlock = t2;
|
|
106
107
|
}
|
|
107
|
-
static empty = new
|
|
108
|
+
static empty = new x(/* @__PURE__ */ new Map());
|
|
108
109
|
static create(t2) {
|
|
109
|
-
if (0 === t2.length) return
|
|
110
|
+
if (0 === t2.length) return x.empty;
|
|
110
111
|
const e2 = /* @__PURE__ */ new Map();
|
|
111
112
|
for (const o2 of t2) {
|
|
112
113
|
const t3 = e2.get(o2.blockId);
|
|
113
114
|
t3 ? t3.push(o2) : e2.set(o2.blockId, [o2]);
|
|
114
115
|
}
|
|
115
|
-
return new
|
|
116
|
+
return new x(e2);
|
|
116
117
|
}
|
|
117
118
|
find(t2) {
|
|
118
119
|
return this.byBlock.get(t2) ?? [];
|
|
@@ -131,14 +132,14 @@ class I {
|
|
|
131
132
|
}
|
|
132
133
|
add(t2) {
|
|
133
134
|
if (0 === t2.length) return this;
|
|
134
|
-
if (this.isEmpty) return
|
|
135
|
+
if (this.isEmpty) return x.create(t2);
|
|
135
136
|
const e2 = /* @__PURE__ */ new Map();
|
|
136
137
|
for (const [t3, o2] of this.byBlock) e2.set(t3, [...o2]);
|
|
137
138
|
for (const o2 of t2) {
|
|
138
139
|
const t3 = e2.get(o2.blockId);
|
|
139
140
|
t3 ? t3.push(o2) : e2.set(o2.blockId, [o2]);
|
|
140
141
|
}
|
|
141
|
-
return new
|
|
142
|
+
return new x(e2);
|
|
142
143
|
}
|
|
143
144
|
remove(t2) {
|
|
144
145
|
const e2 = /* @__PURE__ */ new Map();
|
|
@@ -147,7 +148,7 @@ class I {
|
|
|
147
148
|
const r2 = c2.filter((e3) => !t2(e3));
|
|
148
149
|
r2.length !== c2.length && (o2 = true), r2.length > 0 && e2.set(n2, r2);
|
|
149
150
|
}
|
|
150
|
-
return o2 ? 0 === e2.size ?
|
|
151
|
+
return o2 ? 0 === e2.size ? x.empty : new x(e2) : this;
|
|
151
152
|
}
|
|
152
153
|
merge(t2) {
|
|
153
154
|
if (t2.isEmpty) return this;
|
|
@@ -158,7 +159,7 @@ class I {
|
|
|
158
159
|
const t3 = e2.get(o2);
|
|
159
160
|
t3 ? t3.push(...n2) : e2.set(o2, [...n2]);
|
|
160
161
|
}
|
|
161
|
-
return new
|
|
162
|
+
return new x(e2);
|
|
162
163
|
}
|
|
163
164
|
equals(t2) {
|
|
164
165
|
if (this === t2) return true;
|
|
@@ -166,7 +167,7 @@ class I {
|
|
|
166
167
|
for (const [e2, o2] of this.byBlock) {
|
|
167
168
|
const n2 = t2.byBlock.get(e2);
|
|
168
169
|
if (!n2) return false;
|
|
169
|
-
if (!
|
|
170
|
+
if (!w(o2, n2)) return false;
|
|
170
171
|
}
|
|
171
172
|
return true;
|
|
172
173
|
}
|
|
@@ -180,35 +181,35 @@ class I {
|
|
|
180
181
|
for (const o2 of t2.steps) {
|
|
181
182
|
const t3 = [];
|
|
182
183
|
for (const n2 of e2) {
|
|
183
|
-
const e3 =
|
|
184
|
+
const e3 = h(n2, o2);
|
|
184
185
|
if (null !== e3) if (Array.isArray(e3)) for (const o3 of e3) t3.push(o3);
|
|
185
186
|
else t3.push(e3);
|
|
186
187
|
}
|
|
187
188
|
e2 = t3;
|
|
188
189
|
}
|
|
189
|
-
return 0 === e2.length ?
|
|
190
|
+
return 0 === e2.length ? x.empty : x.create(e2);
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
|
-
function
|
|
193
|
+
function w(t2, e2) {
|
|
193
194
|
if (t2 === e2) return true;
|
|
194
195
|
if (t2.length !== e2.length) return false;
|
|
195
196
|
for (let o2 = 0; o2 < t2.length; o2++) {
|
|
196
197
|
const n2 = t2[o2], c2 = e2[o2];
|
|
197
|
-
if (!n2 || !c2 || !
|
|
198
|
+
if (!n2 || !c2 || !v(n2, c2)) return false;
|
|
198
199
|
}
|
|
199
200
|
return true;
|
|
200
201
|
}
|
|
201
|
-
function
|
|
202
|
+
function v(t2, e2) {
|
|
202
203
|
if (t2.type !== e2.type) return false;
|
|
203
204
|
if (t2.blockId !== e2.blockId) return false;
|
|
204
205
|
switch (t2.type) {
|
|
205
206
|
case "inline": {
|
|
206
207
|
const o2 = e2;
|
|
207
|
-
return t2.from === o2.from && t2.to === o2.to &&
|
|
208
|
+
return t2.from === o2.from && t2.to === o2.to && _(t2.attrs, o2.attrs);
|
|
208
209
|
}
|
|
209
210
|
case "node": {
|
|
210
211
|
const o2 = e2;
|
|
211
|
-
return
|
|
212
|
+
return _(t2.attrs, o2.attrs);
|
|
212
213
|
}
|
|
213
214
|
case "widget": {
|
|
214
215
|
const o2 = e2;
|
|
@@ -216,36 +217,36 @@ function w(t2, e2) {
|
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
|
-
function
|
|
220
|
+
function _(t2, e2) {
|
|
220
221
|
if (t2 === e2) return true;
|
|
221
222
|
const o2 = Object.keys(t2), n2 = Object.keys(e2);
|
|
222
223
|
if (o2.length !== n2.length) return false;
|
|
223
224
|
for (const n3 of o2) if (t2[n3] !== e2[n3]) return false;
|
|
224
225
|
return true;
|
|
225
226
|
}
|
|
226
|
-
function
|
|
227
|
+
function S(t2, e2) {
|
|
227
228
|
const o2 = t2.getState();
|
|
228
229
|
if (a(o2.selection) || d(o2.selection)) return false;
|
|
229
230
|
const n2 = o2.selection, c2 = o2.getBlock(n2.anchor.blockId);
|
|
230
231
|
return !(!c2 || "code_block" !== c2.type) && e2({ state: o2, block: c2, blockId: n2.anchor.blockId, offset: n2.anchor.offset });
|
|
231
232
|
}
|
|
232
|
-
function
|
|
233
|
-
return
|
|
233
|
+
function A(t2) {
|
|
234
|
+
return S(t2, ({ state: e2, blockId: o2 }) => {
|
|
234
235
|
const n2 = e2.getBlockOrder(), c2 = n2.indexOf(o2);
|
|
235
236
|
if (c2 < n2.length - 1) {
|
|
236
237
|
const o3 = n2[c2 + 1], r2 = e2.transaction("command").setSelection(f(o3, 0)).build();
|
|
237
238
|
t2.dispatch(r2);
|
|
238
|
-
} else
|
|
239
|
+
} else T(t2, o2);
|
|
239
240
|
return true;
|
|
240
241
|
});
|
|
241
242
|
}
|
|
242
|
-
function
|
|
243
|
+
function T(t2, e2) {
|
|
243
244
|
const n2 = t2.getState(), r2 = n2.getBlock(e2);
|
|
244
245
|
if (!r2) return;
|
|
245
246
|
const l2 = o(r2), s2 = c(), i2 = n2.transaction("command").splitBlock(e2, l2, s2).setBlockType(s2, k("paragraph")).setSelection(f(s2, 0)).build();
|
|
246
247
|
t2.dispatch(i2);
|
|
247
248
|
}
|
|
248
|
-
function
|
|
249
|
+
function M(t2, e2) {
|
|
249
250
|
const n2 = t2.getState(), c2 = n2.selection;
|
|
250
251
|
if (a(c2) || d(c2)) return false;
|
|
251
252
|
const s2 = n2.getBlock(c2.anchor.blockId);
|
|
@@ -261,16 +262,16 @@ function T(t2, e2) {
|
|
|
261
262
|
} else c3 += 1;
|
|
262
263
|
})(u2, s2), u2.setBlockType(c2.anchor.blockId, k("code_block"), i2).setSelection(f(c2.anchor.blockId, 0)), t2.dispatch(u2.build()), true;
|
|
263
264
|
}
|
|
264
|
-
const
|
|
265
|
-
function
|
|
265
|
+
const N = { label: "Code Block", tooltip: (t2) => t2 ? `Code Block (${t2})` : "Code Block", enteredCodeBlock: "Entered code block. Press Escape to exit.", leftCodeBlock: "Left code block." }, E = { en: N, de: { label: "Codeblock", tooltip: (t2) => t2 ? `Codeblock (${t2})` : "Codeblock", enteredCodeBlock: "Codeblock betreten. Escape zum Verlassen drücken.", leftCodeBlock: "Codeblock verlassen." }, es: { label: "Bloque de código", tooltip: (t2) => t2 ? `Bloque de código (${t2})` : "Bloque de código", enteredCodeBlock: "Bloque de código activado. Pulse Escape para salir.", leftCodeBlock: "Bloque de código desactivado." }, fr: { label: "Bloc de code", tooltip: (t2) => t2 ? `Bloc de code (${t2})` : "Bloc de code", enteredCodeBlock: "Bloc de code activé. Appuyez sur Échap pour quitter.", leftCodeBlock: "Bloc de code quitté." }, zh: { label: "代码块", tooltip: (t2) => t2 ? `代码块 (${t2})` : "代码块", enteredCodeBlock: "已进入代码块。按 Escape 退出。", leftCodeBlock: "已离开代码块。" }, ru: { label: "Блок кода", tooltip: (t2) => t2 ? `Блок кода (${t2})` : "Блок кода", enteredCodeBlock: "Вход в блок кода. Нажмите Escape для выхода.", leftCodeBlock: "Выход из блока кода." }, ar: { label: "كتلة كود", tooltip: (t2) => t2 ? `كتلة كود (${t2})` : "كتلة كود", enteredCodeBlock: "تم الدخول إلى كتلة الكود. اضغط Escape للخروج.", leftCodeBlock: "تم الخروج من كتلة الكود." }, hi: { label: "कोड ब्लॉक", tooltip: (t2) => t2 ? `कोड ब्लॉक (${t2})` : "कोड ब्लॉक", enteredCodeBlock: "कोड ब्लॉक में प्रवेश किया। बाहर निकलने के लिए Escape दबाएँ।", leftCodeBlock: "कोड ब्लॉक से बाहर।" } }, L = { insertAfter: "Mod-Enter", toggle: "Mod-Shift-M" }, O = { defaultLanguage: "", useSpaces: false, spaceCount: 2, showCopyButton: true }, z = new t("codeBlock");
|
|
266
|
+
function $(t2, e2, o2, n2) {
|
|
266
267
|
const c2 = t2.getState(), r2 = c2.getBlock(e2);
|
|
267
268
|
if (!r2 || "code_block" !== r2.type) return;
|
|
268
|
-
const l2 =
|
|
269
|
+
const l2 = b(c2.doc, e2);
|
|
269
270
|
if (!l2) return;
|
|
270
271
|
const s2 = { ...r2.attrs, [o2]: n2 }, i2 = c2.transaction("command").setNodeAttr(l2, s2).build();
|
|
271
272
|
t2.dispatch(i2);
|
|
272
273
|
}
|
|
273
|
-
class
|
|
274
|
+
class j {
|
|
274
275
|
id = "code-block";
|
|
275
276
|
name = "Code Block";
|
|
276
277
|
priority = 36;
|
|
@@ -279,10 +280,10 @@ class $ {
|
|
|
279
280
|
context = null;
|
|
280
281
|
locale;
|
|
281
282
|
constructor(t2) {
|
|
282
|
-
this.config = { ...
|
|
283
|
+
this.config = { ...O, ...t2 }, this.resolvedKeymap = { ...L, ...t2?.keymap };
|
|
283
284
|
}
|
|
284
285
|
init(t2) {
|
|
285
|
-
this.locale = e(
|
|
286
|
+
this.locale = e(E, t2, this.config.locale), t2.registerStyleSheet("\n/* Code Block — uses theme custom properties */\n.notectl-code-block {\n position: relative;\n margin: 8px 0;\n border-radius: 6px;\n background: var(--notectl-code-block-bg);\n color: var(--notectl-code-block-color);\n font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;\n font-size: 14px;\n line-height: 1.5;\n overflow: hidden;\n}\n\n.notectl-code-block__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n background: var(--notectl-code-block-header-bg);\n border-bottom: 1px solid var(--notectl-code-block-header-border);\n font-size: 12px;\n color: var(--notectl-code-block-header-color);\n user-select: none;\n}\n\n.notectl-code-block__language {\n font-weight: 500;\n letter-spacing: 0.02em;\n}\n\n.notectl-code-block__copy {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--notectl-code-block-header-color);\n cursor: pointer;\n padding: 0;\n transition: background 0.15s, color 0.15s;\n}\n\n.notectl-code-block__copy:hover {\n background: rgba(128, 128, 128, 0.15);\n color: var(--notectl-code-block-color);\n}\n\n.notectl-code-block__copy svg {\n fill: currentColor;\n}\n\n.notectl-code-block__content {\n display: block;\n padding: 12px 16px;\n white-space: pre-wrap;\n word-wrap: break-word;\n tab-size: 4;\n -moz-tab-size: 4;\n outline: none;\n min-height: 1.5em;\n}\n\n.notectl-code-block--selected {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n}\n\n.notectl-code-block__esc-hint {\n display: none;\n position: absolute;\n bottom: 4px;\n right: 8px;\n font-size: 11px;\n color: var(--notectl-code-block-header-color);\n opacity: 0.5;\n pointer-events: none;\n user-select: none;\n font-family: system-ui, sans-serif;\n}\n\n.notectl-code-block--focused .notectl-code-block__esc-hint {\n display: block;\n}\n"), this.context = t2, this.registerNodeSpec(t2), this.registerNodeView(t2), (function(t3, e2) {
|
|
286
287
|
t3.registerCommand("toggleCodeBlock", () => (function(t4, e3) {
|
|
287
288
|
const o2 = t4.getState();
|
|
288
289
|
if (a(o2.selection) || d(o2.selection)) return false;
|
|
@@ -292,11 +293,11 @@ class $ {
|
|
|
292
293
|
const e4 = o2.transaction("command").setBlockType(o2.selection.anchor.blockId, k("paragraph")).setSelection(o2.selection).build();
|
|
293
294
|
return t4.dispatch(e4), true;
|
|
294
295
|
}
|
|
295
|
-
return
|
|
296
|
-
})(t3, e2)), t3.registerCommand("insertCodeBlock", () =>
|
|
296
|
+
return M(t4, e3);
|
|
297
|
+
})(t3, e2)), t3.registerCommand("insertCodeBlock", () => M(t3, e2)), t3.registerCommand("setCodeBlockLanguage", () => false), t3.registerCommand("setCodeBlockBackground", () => false), t3.registerCommand("exitCodeBlock", () => A(t3));
|
|
297
298
|
})(t2, this.config), (function(t3, e2, r2) {
|
|
298
299
|
const l2 = { Enter: () => (function(t4) {
|
|
299
|
-
return
|
|
300
|
+
return S(t4, ({ state: e3, block: o2, blockId: r3, offset: l3 }) => {
|
|
300
301
|
if (!u(e3.selection)) return false;
|
|
301
302
|
const s3 = n(o2);
|
|
302
303
|
if (s3.endsWith("\n") && l3 === s3.length) return (function(t5, e4, o3) {
|
|
@@ -307,19 +308,19 @@ class $ {
|
|
|
307
308
|
return t4.dispatch(i3), true;
|
|
308
309
|
});
|
|
309
310
|
})(t3), Backspace: () => (function(t4) {
|
|
310
|
-
return
|
|
311
|
+
return S(t4, ({ state: e3, blockId: o2, offset: n2 }) => {
|
|
311
312
|
if (!u(e3.selection)) return false;
|
|
312
313
|
if (0 !== n2) return false;
|
|
313
314
|
const c2 = e3.transaction("input").setBlockType(o2, k("paragraph")).setSelection(e3.selection).build();
|
|
314
315
|
return t4.dispatch(c2), true;
|
|
315
316
|
});
|
|
316
317
|
})(t3), Tab: () => (function(t4, e3) {
|
|
317
|
-
return
|
|
318
|
+
return S(t4, ({ state: o2, blockId: n2, offset: c2 }) => {
|
|
318
319
|
const r3 = e3.useSpaces ? " ".repeat(e3.spaceCount ?? 2) : " ", l3 = o2.transaction("input").insertText(n2, c2, r3, []).setSelection(f(n2, c2 + r3.length)).build();
|
|
319
320
|
return t4.dispatch(l3), true;
|
|
320
321
|
});
|
|
321
322
|
})(t3, e2), "Shift-Tab": () => (function(t4, e3) {
|
|
322
|
-
return
|
|
323
|
+
return S(t4, ({ state: o2, block: c2, blockId: r3, offset: l3 }) => {
|
|
323
324
|
const s3 = n(c2), i3 = s3.lastIndexOf("\n", l3 - 1) + 1;
|
|
324
325
|
if (e3.useSpaces) {
|
|
325
326
|
const n2 = e3.spaceCount ?? 2;
|
|
@@ -333,19 +334,19 @@ class $ {
|
|
|
333
334
|
}
|
|
334
335
|
return true;
|
|
335
336
|
});
|
|
336
|
-
})(t3, e2), Escape: () =>
|
|
337
|
-
return
|
|
337
|
+
})(t3, e2), Escape: () => A(t3), ArrowDown: () => (function(t4) {
|
|
338
|
+
return S(t4, ({ state: e3, block: o2, blockId: c2, offset: r3 }) => {
|
|
338
339
|
if (!u(e3.selection)) return false;
|
|
339
340
|
if (-1 !== n(o2).indexOf("\n", r3)) return false;
|
|
340
341
|
const l3 = e3.getBlockOrder(), s3 = l3.indexOf(c2);
|
|
341
342
|
if (s3 < l3.length - 1) {
|
|
342
343
|
const o3 = l3[s3 + 1], n2 = e3.transaction("command").setSelection(f(o3, 0)).build();
|
|
343
344
|
t4.dispatch(n2);
|
|
344
|
-
} else
|
|
345
|
+
} else T(t4, c2);
|
|
345
346
|
return true;
|
|
346
347
|
});
|
|
347
348
|
})(t3), ArrowUp: () => (function(t4) {
|
|
348
|
-
return
|
|
349
|
+
return S(t4, ({ state: e3, block: c2, blockId: r3, offset: l3 }) => {
|
|
349
350
|
if (!u(e3.selection)) return false;
|
|
350
351
|
const s3 = n(c2).indexOf("\n");
|
|
351
352
|
if (-1 !== s3 && l3 > s3) return false;
|
|
@@ -357,18 +358,18 @@ class $ {
|
|
|
357
358
|
return false;
|
|
358
359
|
});
|
|
359
360
|
})(t3), ArrowRight: () => (function(t4) {
|
|
360
|
-
return
|
|
361
|
+
return S(t4, ({ state: e3, block: o2, blockId: c2, offset: r3 }) => {
|
|
361
362
|
if (!u(e3.selection)) return false;
|
|
362
363
|
if (r3 !== n(o2).length) return false;
|
|
363
364
|
const l3 = e3.getBlockOrder(), s3 = l3.indexOf(c2);
|
|
364
365
|
if (s3 < l3.length - 1) {
|
|
365
366
|
const o3 = l3[s3 + 1], n2 = e3.transaction("command").setSelection(f(o3, 0)).build();
|
|
366
367
|
t4.dispatch(n2);
|
|
367
|
-
} else
|
|
368
|
+
} else T(t4, c2);
|
|
368
369
|
return true;
|
|
369
370
|
});
|
|
370
371
|
})(t3), ArrowLeft: () => (function(t4) {
|
|
371
|
-
return
|
|
372
|
+
return S(t4, ({ state: e3, blockId: n2, offset: c2 }) => {
|
|
372
373
|
if (!u(e3.selection)) return false;
|
|
373
374
|
if (0 !== c2) return false;
|
|
374
375
|
const r3 = e3.getBlockOrder(), l3 = r3.indexOf(n2);
|
|
@@ -380,18 +381,18 @@ class $ {
|
|
|
380
381
|
});
|
|
381
382
|
})(t3) }, { insertAfter: s2, toggle: i2 } = r2;
|
|
382
383
|
s2 && (l2[s2] = () => (function(t4) {
|
|
383
|
-
return
|
|
384
|
+
return S(t4, ({ blockId: e3 }) => (T(t4, e3), true));
|
|
384
385
|
})(t3)), i2 && (l2[i2] = () => t3.executeCommand("toggleCodeBlock")), t3.registerKeymap(l2, { priority: "context" });
|
|
385
386
|
})(t2, this.config, this.resolvedKeymap), this.registerInputRule(t2), this.registerToolbarItem(t2), this.registerMiddleware(t2), (function(t3, e2, o2) {
|
|
386
|
-
t3.registerService(
|
|
387
|
-
|
|
387
|
+
t3.registerService(z, { setLanguage(e3, o3) {
|
|
388
|
+
$(t3, e3, "language", o3);
|
|
388
389
|
}, getLanguage(t4) {
|
|
389
390
|
const e3 = o2();
|
|
390
391
|
if (!e3) return "";
|
|
391
392
|
const n2 = e3.getState().getBlock(t4);
|
|
392
393
|
return n2 && "code_block" === n2.type ? n2.attrs?.language ?? "" : "";
|
|
393
394
|
}, setBackground(e3, o3) {
|
|
394
|
-
|
|
395
|
+
$(t3, e3, "backgroundColor", o3);
|
|
395
396
|
}, getBackground(t4) {
|
|
396
397
|
const e3 = o2();
|
|
397
398
|
if (!e3) return "";
|
|
@@ -414,7 +415,7 @@ class $ {
|
|
|
414
415
|
s2 && n2 && this.setBlockFocused(n2, false), i2 && c2 && this.setBlockFocused(c2, true), !s2 && i2 ? this.context.announce(this.locale.enteredCodeBlock) : s2 && !i2 && this.context.announce(this.locale.leftCodeBlock);
|
|
415
416
|
}
|
|
416
417
|
decorations(t2) {
|
|
417
|
-
if (!this.config.highlighter) return
|
|
418
|
+
if (!this.config.highlighter) return x.empty;
|
|
418
419
|
const e2 = [], o2 = this.config.highlighter;
|
|
419
420
|
for (const c2 of t2.getBlockOrder()) {
|
|
420
421
|
const r2 = t2.getBlock(c2);
|
|
@@ -426,7 +427,7 @@ class $ {
|
|
|
426
427
|
const i2 = o2.tokenize(s2, l2);
|
|
427
428
|
for (const t3 of i2) e2.push(y(c2, t3.from, t3.to, { class: `notectl-token--${t3.type}` }));
|
|
428
429
|
}
|
|
429
|
-
return
|
|
430
|
+
return x.create(e2);
|
|
430
431
|
}
|
|
431
432
|
registerNodeSpec(t2) {
|
|
432
433
|
t2.registerNodeSpec({ type: "code_block", group: "block", content: { allow: ["text"] }, selectable: true, attrs: { language: { default: "" }, backgroundColor: { default: "" } }, toDOM(t3) {
|
|
@@ -458,13 +459,13 @@ class $ {
|
|
|
458
459
|
const d2 = document.createElement("code");
|
|
459
460
|
d2.className = "notectl-code-block__content";
|
|
460
461
|
const u2 = document.createElement("div");
|
|
461
|
-
u2.className = "notectl-code-block__esc-hint", u2.setAttribute("contenteditable", "false"), u2.setAttribute("aria-hidden", "true"), u2.setAttribute("data-notectl-no-print", ""), u2.textContent = "Esc to exit", r2.appendChild(l2), r2.appendChild(d2), r2.appendChild(u2), e2.background && r2
|
|
462
|
+
u2.className = "notectl-code-block__esc-hint", u2.setAttribute("contenteditable", "false"), u2.setAttribute("aria-hidden", "true"), u2.setAttribute("data-notectl-no-print", ""), u2.textContent = "Esc to exit", r2.appendChild(l2), r2.appendChild(d2), r2.appendChild(u2), e2.background && p(r2, "--notectl-code-block-bg", e2.background), e2.headerBackground && p(r2, "--notectl-code-block-header-bg", e2.headerBackground), e2.textColor && p(r2, "--notectl-code-block-color", e2.textColor), e2.headerColor && p(r2, "--notectl-code-block-header-color", e2.headerColor);
|
|
462
463
|
let f2 = t3.id;
|
|
463
464
|
function k2(t4) {
|
|
464
465
|
const e3 = t4.attrs?.language ?? "", o3 = e3 || "plain";
|
|
465
466
|
s2.textContent = o3, r2.setAttribute("aria-label", `${o3} code block. Press Escape to exit.`), e3 ? d2.setAttribute("data-language", e3) : d2.removeAttribute("data-language");
|
|
466
467
|
const n2 = t4.attrs?.backgroundColor ?? "";
|
|
467
|
-
r2
|
|
468
|
+
p(r2, "backgroundColor", n2 || "");
|
|
468
469
|
}
|
|
469
470
|
return k2(t3), i2 && i2.addEventListener("click", (t4) => {
|
|
470
471
|
t4.preventDefault(), t4.stopPropagation();
|
|
@@ -528,14 +529,14 @@ class $ {
|
|
|
528
529
|
}
|
|
529
530
|
}
|
|
530
531
|
export {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
532
|
+
j as C,
|
|
533
|
+
x as D,
|
|
534
|
+
E as a,
|
|
535
|
+
N as b,
|
|
536
|
+
z as c,
|
|
537
|
+
w as d,
|
|
537
538
|
y as i,
|
|
538
|
-
|
|
539
|
-
|
|
539
|
+
C as n,
|
|
540
|
+
I as w
|
|
540
541
|
};
|
|
541
|
-
//# sourceMappingURL=index-
|
|
542
|
+
//# sourceMappingURL=index-D515iymW.mjs.map
|