@notectl/core 1.0.8 → 1.0.9
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/ToolbarPlugin-DFkl1uYO.mjs +818 -0
- package/dist/chunks/ToolbarPlugin-DFkl1uYO.mjs.map +1 -0
- package/dist/chunks/{index-CxiWyUho.mjs → index-BCvuDpVr.mjs} +2 -2
- package/dist/chunks/{index-CxiWyUho.mjs.map → index-BCvuDpVr.mjs.map} +1 -1
- package/dist/chunks/{index-C2GQoHot.mjs → index-BFsYGsBR.mjs} +2 -2
- package/dist/chunks/{index-C2GQoHot.mjs.map → index-BFsYGsBR.mjs.map} +1 -1
- package/dist/chunks/{index-B_3qDrUN.mjs → index-BIL37LSL.mjs} +23 -14
- package/dist/chunks/index-BIL37LSL.mjs.map +1 -0
- package/dist/chunks/{index-Ct0ivLhO.mjs → index-BL56fbXt.mjs} +214 -219
- package/dist/chunks/{index-Ct0ivLhO.mjs.map → index-BL56fbXt.mjs.map} +1 -1
- package/dist/chunks/{index-BYgspns5.mjs → index-BQ8iIYLn.mjs} +2 -2
- package/dist/chunks/{index-BYgspns5.mjs.map → index-BQ8iIYLn.mjs.map} +1 -1
- package/dist/chunks/index-BTJfyJlJ.mjs +187 -0
- package/dist/chunks/index-BTJfyJlJ.mjs.map +1 -0
- package/dist/chunks/{index-D3CQWJiw.mjs → index-DA8TG2S8.mjs} +39 -19
- package/dist/chunks/index-DA8TG2S8.mjs.map +1 -0
- package/dist/chunks/{index-C-YWHOcC.mjs → index-DAFCISBN.mjs} +21 -21
- package/dist/chunks/{index-C-YWHOcC.mjs.map → index-DAFCISBN.mjs.map} +1 -1
- package/dist/chunks/{index-BAk1EG1x.mjs → index-DGrRWMlW.mjs} +2 -2
- package/dist/chunks/{index-BAk1EG1x.mjs.map → index-DGrRWMlW.mjs.map} +1 -1
- package/dist/chunks/{index-CT3HGdQt.mjs → index-DfO_fKw6.mjs} +6 -6
- package/dist/chunks/{index-CT3HGdQt.mjs.map → index-DfO_fKw6.mjs.map} +1 -1
- package/dist/chunks/resolvePluginLocale-B4w1OkPy.mjs.map +1 -1
- package/dist/editor/DocumentSerializer.d.ts.map +1 -1
- package/dist/editor/NotectlEditor.d.ts +27 -5
- package/dist/editor/NotectlEditor.d.ts.map +1 -1
- package/dist/editor/styles/list.d.ts +2 -0
- package/dist/editor/styles/list.d.ts.map +1 -1
- package/dist/editor/styles/toolbar.d.ts +1 -1
- package/dist/editor/styles/toolbar.d.ts.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/input/ClipboardHandler.d.ts +2 -0
- package/dist/input/ClipboardHandler.d.ts.map +1 -1
- package/dist/input/InputHandler.d.ts +2 -0
- package/dist/input/InputHandler.d.ts.map +1 -1
- package/dist/input/KeyboardHandler.d.ts +2 -0
- package/dist/input/KeyboardHandler.d.ts.map +1 -1
- package/dist/input/LegacyHTMLNormalizer.d.ts +18 -0
- package/dist/input/LegacyHTMLNormalizer.d.ts.map +1 -0
- package/dist/input/PasteHandler.d.ts +4 -0
- package/dist/input/PasteHandler.d.ts.map +1 -1
- package/dist/model/HTMLParser.d.ts +13 -0
- package/dist/model/HTMLParser.d.ts.map +1 -1
- package/dist/model/SchemaRegistry.d.ts +2 -2
- package/dist/model/SchemaRegistry.d.ts.map +1 -1
- package/dist/notectl-core.mjs +546 -394
- package/dist/notectl-core.mjs.map +1 -1
- package/dist/notectl-core.umd.js +1772 -1161
- package/dist/notectl-core.umd.js.map +1 -1
- package/dist/plugins/Plugin.d.ts +17 -2
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/PluginManager.d.ts +17 -1
- package/dist/plugins/PluginManager.d.ts.map +1 -1
- package/dist/plugins/alignment/AlignmentPlugin.d.ts.map +1 -1
- package/dist/plugins/alignment.mjs +1 -1
- package/dist/plugins/code-block/CodeBlockPlugin.d.ts.map +1 -1
- package/dist/plugins/code-block.mjs +1 -1
- package/dist/plugins/font-size.mjs +1 -1
- package/dist/plugins/font.mjs +1 -1
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts +14 -0
- package/dist/plugins/heading/HeadingBlockTypePicker.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingCommands.d.ts +5 -0
- package/dist/plugins/heading/HeadingCommands.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts +5 -0
- package/dist/plugins/heading/HeadingInputRules.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts +5 -0
- package/dist/plugins/heading/HeadingKeyboardHandlers.d.ts.map +1 -0
- package/dist/plugins/heading/HeadingPlugin.d.ts +1 -41
- package/dist/plugins/heading/HeadingPlugin.d.ts.map +1 -1
- package/dist/plugins/heading.mjs +1 -1
- package/dist/plugins/image/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/image.mjs +1 -1
- package/dist/plugins/list/ListPlugin.d.ts +9 -0
- package/dist/plugins/list/ListPlugin.d.ts.map +1 -1
- package/dist/plugins/list.mjs +1 -1
- package/dist/plugins/strikethrough/StrikethroughPlugin.d.ts.map +1 -1
- package/dist/plugins/strikethrough.mjs +1 -1
- package/dist/plugins/super-sub/SuperSubPlugin.d.ts.map +1 -1
- package/dist/plugins/super-sub.mjs +1 -1
- package/dist/plugins/text-formatting/TextFormattingPlugin.d.ts.map +1 -1
- package/dist/plugins/text-formatting.mjs +1 -1
- package/dist/plugins/toolbar/ToolbarLocale.d.ts +1 -0
- package/dist/plugins/toolbar/ToolbarLocale.d.ts.map +1 -1
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts +23 -0
- package/dist/plugins/toolbar/ToolbarOverflowBehavior.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts +56 -0
- package/dist/plugins/toolbar/ToolbarOverflowController.d.ts.map +1 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts +17 -0
- package/dist/plugins/toolbar/ToolbarPlugin.d.ts.map +1 -1
- package/dist/plugins/toolbar.mjs +1 -1
- package/dist/state/ReadonlyGuard.d.ts +6 -0
- package/dist/state/ReadonlyGuard.d.ts.map +1 -0
- package/dist/state/Transaction.d.ts +4 -0
- package/dist/state/Transaction.d.ts.map +1 -1
- package/dist/view/EditorView.d.ts +2 -0
- package/dist/view/EditorView.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs +0 -368
- package/dist/chunks/ToolbarPlugin-DY2xaJiu.mjs.map +0 -1
- package/dist/chunks/index-B_3qDrUN.mjs.map +0 -1
- package/dist/chunks/index-D3CQWJiw.mjs.map +0 -1
- package/dist/chunks/index-Dh76rR13.mjs +0 -196
- package/dist/chunks/index-Dh76rR13.mjs.map +0 -1
- package/dist/input/SourceNormalizer.d.ts +0 -7
- package/dist/input/SourceNormalizer.d.ts.map +0 -1
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import { S as
|
|
1
|
+
import { S as e, r as t } from "./resolvePluginLocale-B4w1OkPy.mjs";
|
|
2
2
|
import { e as n } from "./HTMLUtils-0wvCRvJc.mjs";
|
|
3
3
|
import { c as i } from "./NodeSpec-NZVvcCuH.mjs";
|
|
4
4
|
import { i as r, c as o, b as a } from "./Selection-D5ZjXoB7.mjs";
|
|
5
5
|
import { f as s } from "./ToolbarItem-ugDymuXi.mjs";
|
|
6
6
|
import { a as l, c, u as d } from "./Document-CI3iCwEP.mjs";
|
|
7
7
|
import { n as g } from "./TypeBrands-C09nE2qO.mjs";
|
|
8
|
-
function u(
|
|
9
|
-
const n2 =
|
|
10
|
-
const n3 =
|
|
11
|
-
if ("table_cell" === n3?.type) return
|
|
12
|
-
const i3 =
|
|
13
|
-
if (i3) for (const
|
|
14
|
-
const n4 =
|
|
15
|
-
if ("table_cell" === n4?.type) return
|
|
8
|
+
function u(e2, t2) {
|
|
9
|
+
const n2 = e2.getState(), i2 = n2.selection, o2 = { src: t2.src, alt: t2.alt ?? "", align: t2.align ?? "center", ...void 0 !== t2.width ? { width: t2.width } : {}, ...void 0 !== t2.height ? { height: t2.height } : {} }, s2 = r(i2) ? i2.nodeId : i2.anchor.blockId, u2 = (function(e3, t3) {
|
|
10
|
+
const n3 = e3.getBlock(t3);
|
|
11
|
+
if ("table_cell" === n3?.type) return t3;
|
|
12
|
+
const i3 = e3.getNodePath(t3);
|
|
13
|
+
if (i3) for (const t4 of i3) {
|
|
14
|
+
const n4 = e3.getBlock(t4);
|
|
15
|
+
if ("table_cell" === n4?.type) return t4;
|
|
16
16
|
}
|
|
17
17
|
})(n2, s2);
|
|
18
|
-
return u2 ? (function(
|
|
19
|
-
const r2 =
|
|
18
|
+
return u2 ? (function(e3, t3, n3, i3) {
|
|
19
|
+
const r2 = e3.getNodePath(n3);
|
|
20
20
|
if (!r2) return false;
|
|
21
|
-
const o3 = c(g("image"), [], void 0, i3), s3 =
|
|
21
|
+
const o3 = c(g("image"), [], void 0, i3), s3 = e3.getBlock(n3);
|
|
22
22
|
if (!s3) return false;
|
|
23
|
-
const u3 =
|
|
24
|
-
for (let
|
|
25
|
-
const
|
|
26
|
-
-1 !==
|
|
23
|
+
const u3 = e3.transaction("command"), m2 = d(s3);
|
|
24
|
+
for (let e4 = m2.length - 1; e4 >= 0; e4--) {
|
|
25
|
+
const t4 = s3.children.findIndex((t5) => l(t5) && t5.id === m2[e4]?.id);
|
|
26
|
+
-1 !== t4 && u3.removeNode(r2, t4);
|
|
27
27
|
}
|
|
28
|
-
return u3.insertNode(r2, 0, o3), u3.setSelection(a(o3.id, [...r2, o3.id])),
|
|
29
|
-
})(n2,
|
|
30
|
-
const r2 =
|
|
28
|
+
return u3.insertNode(r2, 0, o3), u3.setSelection(a(o3.id, [...r2, o3.id])), t3.dispatch(u3.build()), true;
|
|
29
|
+
})(n2, e2, u2, o2) : (function(e3, t3, n3, i3) {
|
|
30
|
+
const r2 = e3.doc.children.findIndex((e4) => e4.id === n3);
|
|
31
31
|
if (-1 === r2) return false;
|
|
32
|
-
const o3 = c(g("image"), [], void 0, i3), s3 = c(g("paragraph")), l2 =
|
|
33
|
-
return
|
|
34
|
-
})(n2,
|
|
32
|
+
const o3 = c(g("image"), [], void 0, i3), s3 = c(g("paragraph")), l2 = e3.transaction("command").insertNode([], r2 + 1, o3).insertNode([], r2 + 2, s3).setSelection(a(o3.id, [])).build();
|
|
33
|
+
return t3.dispatch(l2), true;
|
|
34
|
+
})(n2, e2, s2, o2);
|
|
35
35
|
}
|
|
36
|
-
function m(
|
|
37
|
-
const i2 =
|
|
36
|
+
function m(e2, t2, n2) {
|
|
37
|
+
const i2 = e2.getState(), o2 = i2.selection;
|
|
38
38
|
if (!r(o2)) return false;
|
|
39
39
|
const a2 = i2.getBlock(o2.nodeId);
|
|
40
40
|
if (!a2 || "image" !== a2.type) return false;
|
|
41
41
|
const s2 = a2.attrs?.width, l2 = a2.attrs?.height;
|
|
42
42
|
if (void 0 === s2 || void 0 === l2) return false;
|
|
43
|
-
const c2 = l2 > 0 ? s2 / l2 : 1, d2 = Math.max(50, Math.min(n2, s2 +
|
|
44
|
-
return (d2 !== s2 || g2 !== l2) && (function(
|
|
45
|
-
const n3 =
|
|
43
|
+
const c2 = l2 > 0 ? s2 / l2 : 1, d2 = Math.max(50, Math.min(n2, s2 + t2)), g2 = Math.round(d2 / c2);
|
|
44
|
+
return (d2 !== s2 || g2 !== l2) && (function(e3, t3) {
|
|
45
|
+
const n3 = e3.getState(), i3 = n3.selection;
|
|
46
46
|
if (!r(i3)) return false;
|
|
47
47
|
const o3 = n3.getBlock(i3.nodeId);
|
|
48
48
|
if (!o3 || "image" !== o3.type) return false;
|
|
49
49
|
const a3 = n3.getNodePath(i3.nodeId);
|
|
50
50
|
if (!a3) return false;
|
|
51
|
-
const s3 = { ...o3.attrs ?? {}, ...
|
|
52
|
-
return
|
|
53
|
-
})(
|
|
51
|
+
const s3 = { ...o3.attrs ?? {}, ...t3 }, l3 = n3.transaction("command").setNodeAttr(a3, s3).build();
|
|
52
|
+
return e3.dispatch(l3), true;
|
|
53
|
+
})(e2, { width: d2, height: g2 });
|
|
54
54
|
}
|
|
55
|
-
const p = { insertImage: "Insert Image", insertImageTooltip: "Insert Image", uploadFromComputer: "Upload from computer", uploadAria: "Upload image from computer", separator: "or", urlPlaceholder: "https://...", urlAria: "Image URL", insertButton: "Insert", insertAria: "Insert image", imageAria: (
|
|
56
|
-
const i2 = [
|
|
57
|
-
return void 0 !==
|
|
58
|
-
}, resetToNaturalSize: "Image reset to natural size.", uploadFailed: "Image upload failed." }, h = { en: p, de: { insertImage: "Bild einfügen", insertImageTooltip: "Bild einfügen", uploadFromComputer: "Vom Computer hochladen", uploadAria: "Bild vom Computer hochladen", separator: "oder", urlPlaceholder: "https://...", urlAria: "Bild-URL", insertButton: "Einfügen", insertAria: "Bild einfügen", imageAria: (
|
|
59
|
-
const i2 = [
|
|
60
|
-
return void 0 !==
|
|
61
|
-
}, resetToNaturalSize: "Bild auf Originalgröße zurückgesetzt.", uploadFailed: "Bild-Upload fehlgeschlagen." }, es: { insertImage: "Insertar imagen", insertImageTooltip: "Insertar imagen", uploadFromComputer: "Subir desde el ordenador", uploadAria: "Subir imagen desde el ordenador", separator: "o", urlPlaceholder: "https://...", urlAria: "URL de la imagen", insertButton: "Insertar", insertAria: "Insertar imagen", imageAria: (
|
|
62
|
-
const i2 = [
|
|
63
|
-
return void 0 !==
|
|
64
|
-
}, resetToNaturalSize: "Imagen restablecida a tamaño natural.", uploadFailed: "Error al subir la imagen." }, fr: { insertImage: "Insérer une image", insertImageTooltip: "Insérer une image", uploadFromComputer: "Télécharger depuis l’ordinateur", uploadAria: "Télécharger une image depuis l’ordinateur", separator: "ou", urlPlaceholder: "https://...", urlAria: "URL de l’image", insertButton: "Insérer", insertAria: "Insérer une image", imageAria: (
|
|
65
|
-
const i2 = [
|
|
66
|
-
return void 0 !==
|
|
67
|
-
}, resetToNaturalSize: "Image rétablie à sa taille d’origine.", uploadFailed: "Échec du téléchargement de l’image." }, zh: { insertImage: "插入图片", insertImageTooltip: "插入图片", uploadFromComputer: "从电脑上传", uploadAria: "从电脑上传图片", separator: "或", urlPlaceholder: "https://...", urlAria: "图片链接", insertButton: "插入", insertAria: "插入图片", imageAria: (
|
|
68
|
-
const i2 = [
|
|
69
|
-
return void 0 !==
|
|
70
|
-
}, resetToNaturalSize: "图片已恢复原始大小。", uploadFailed: "图片上传失败。" }, ru: { insertImage: "Вставить изображение", insertImageTooltip: "Вставить изображение", uploadFromComputer: "Загрузить с компьютера", uploadAria: "Загрузить изображение с компьютера", separator: "или", urlPlaceholder: "https://...", urlAria: "URL изображения", insertButton: "Вставить", insertAria: "Вставить изображение", imageAria: (
|
|
71
|
-
const i2 = [
|
|
72
|
-
return void 0 !==
|
|
73
|
-
}, resetToNaturalSize: "Изображение сброшено до исходного размера.", uploadFailed: "Ошибка загрузки изображения." }, ar: { insertImage: "إدراج صورة", insertImageTooltip: "إدراج صورة", uploadFromComputer: "رفع من الحاسوب", uploadAria: "رفع صورة من الحاسوب", separator: "أو", urlPlaceholder: "https://...", urlAria: "رابط الصورة", insertButton: "إدراج", insertAria: "إدراج صورة", imageAria: (
|
|
74
|
-
const i2 = [
|
|
75
|
-
return void 0 !==
|
|
76
|
-
}, resetToNaturalSize: "تمت إعادة الصورة إلى حجمها الطبيعي.", uploadFailed: "فشل رفع الصورة." }, hi: { insertImage: "चित्र डालें", insertImageTooltip: "चित्र डालें", uploadFromComputer: "कंप्यूटर से अपलोड करें", uploadAria: "कंप्यूटर से चित्र अपलोड करें", separator: "या", urlPlaceholder: "https://...", urlAria: "चित्र URL", insertButton: "डालें", insertAria: "चित्र डालें", imageAria: (
|
|
77
|
-
const i2 = [
|
|
78
|
-
return void 0 !==
|
|
55
|
+
const p = { insertImage: "Insert Image", insertImageTooltip: "Insert Image", uploadFromComputer: "Upload from computer", uploadAria: "Upload image from computer", separator: "or", urlPlaceholder: "https://...", urlAria: "Image URL", insertButton: "Insert", insertAria: "Insert image", imageAria: (e2, t2, n2) => {
|
|
56
|
+
const i2 = [e2 || "Image"];
|
|
57
|
+
return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} by ${n2} pixels`), i2.join(", ");
|
|
58
|
+
}, resetToNaturalSize: "Image reset to natural size.", uploadFailed: "Image upload failed." }, h = { en: p, de: { insertImage: "Bild einfügen", insertImageTooltip: "Bild einfügen", uploadFromComputer: "Vom Computer hochladen", uploadAria: "Bild vom Computer hochladen", separator: "oder", urlPlaceholder: "https://...", urlAria: "Bild-URL", insertButton: "Einfügen", insertAria: "Bild einfügen", imageAria: (e2, t2, n2) => {
|
|
59
|
+
const i2 = [e2 || "Bild"];
|
|
60
|
+
return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} mal ${n2} Pixel`), i2.join(", ");
|
|
61
|
+
}, resetToNaturalSize: "Bild auf Originalgröße zurückgesetzt.", uploadFailed: "Bild-Upload fehlgeschlagen." }, es: { insertImage: "Insertar imagen", insertImageTooltip: "Insertar imagen", uploadFromComputer: "Subir desde el ordenador", uploadAria: "Subir imagen desde el ordenador", separator: "o", urlPlaceholder: "https://...", urlAria: "URL de la imagen", insertButton: "Insertar", insertAria: "Insertar imagen", imageAria: (e2, t2, n2) => {
|
|
62
|
+
const i2 = [e2 || "Imagen"];
|
|
63
|
+
return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} por ${n2} píxeles`), i2.join(", ");
|
|
64
|
+
}, resetToNaturalSize: "Imagen restablecida a tamaño natural.", uploadFailed: "Error al subir la imagen." }, fr: { insertImage: "Insérer une image", insertImageTooltip: "Insérer une image", uploadFromComputer: "Télécharger depuis l’ordinateur", uploadAria: "Télécharger une image depuis l’ordinateur", separator: "ou", urlPlaceholder: "https://...", urlAria: "URL de l’image", insertButton: "Insérer", insertAria: "Insérer une image", imageAria: (e2, t2, n2) => {
|
|
65
|
+
const i2 = [e2 || "Image"];
|
|
66
|
+
return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} par ${n2} pixels`), i2.join(", ");
|
|
67
|
+
}, resetToNaturalSize: "Image rétablie à sa taille d’origine.", uploadFailed: "Échec du téléchargement de l’image." }, zh: { insertImage: "插入图片", insertImageTooltip: "插入图片", uploadFromComputer: "从电脑上传", uploadAria: "从电脑上传图片", separator: "或", urlPlaceholder: "https://...", urlAria: "图片链接", insertButton: "插入", insertAria: "插入图片", imageAria: (e2, t2, n2) => {
|
|
68
|
+
const i2 = [e2 || "图片"];
|
|
69
|
+
return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} x ${n2} 像素`), i2.join(",");
|
|
70
|
+
}, resetToNaturalSize: "图片已恢复原始大小。", uploadFailed: "图片上传失败。" }, ru: { insertImage: "Вставить изображение", insertImageTooltip: "Вставить изображение", uploadFromComputer: "Загрузить с компьютера", uploadAria: "Загрузить изображение с компьютера", separator: "или", urlPlaceholder: "https://...", urlAria: "URL изображения", insertButton: "Вставить", insertAria: "Вставить изображение", imageAria: (e2, t2, n2) => {
|
|
71
|
+
const i2 = [e2 || "Изображение"];
|
|
72
|
+
return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} на ${n2} пикселей`), i2.join(", ");
|
|
73
|
+
}, resetToNaturalSize: "Изображение сброшено до исходного размера.", uploadFailed: "Ошибка загрузки изображения." }, ar: { insertImage: "إدراج صورة", insertImageTooltip: "إدراج صورة", uploadFromComputer: "رفع من الحاسوب", uploadAria: "رفع صورة من الحاسوب", separator: "أو", urlPlaceholder: "https://...", urlAria: "رابط الصورة", insertButton: "إدراج", insertAria: "إدراج صورة", imageAria: (e2, t2, n2) => {
|
|
74
|
+
const i2 = [e2 || "صورة"];
|
|
75
|
+
return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} × ${n2} بكسل`), i2.join("، ");
|
|
76
|
+
}, resetToNaturalSize: "تمت إعادة الصورة إلى حجمها الطبيعي.", uploadFailed: "فشل رفع الصورة." }, hi: { insertImage: "चित्र डालें", insertImageTooltip: "चित्र डालें", uploadFromComputer: "कंप्यूटर से अपलोड करें", uploadAria: "कंप्यूटर से चित्र अपलोड करें", separator: "या", urlPlaceholder: "https://...", urlAria: "चित्र URL", insertButton: "डालें", insertAria: "चित्र डालें", imageAria: (e2, t2, n2) => {
|
|
77
|
+
const i2 = [e2 || "चित्र"];
|
|
78
|
+
return void 0 !== t2 && void 0 !== n2 && i2.push(`${t2} x ${n2} पिक्सेल`), i2.join(", ");
|
|
79
79
|
}, resetToNaturalSize: "चित्र मूल आकार में पुनर्स्थापित।", uploadFailed: "चित्र अपलोड विफल।" } }, f = { left: "notectl-image--left", center: "notectl-image--center", right: "notectl-image--right" }, b = { nw: "nwse-resize", ne: "nesw-resize", sw: "nesw-resize", se: "nwse-resize" }, v = { nw: -1, ne: 1, sw: -1, se: 1 }, x = { nw: "Resize top-left", ne: "Resize top-right", sw: "Resize bottom-left", se: "Resize bottom-right" };
|
|
80
80
|
let y = null;
|
|
81
81
|
function I() {
|
|
82
82
|
y && (y.remove(), y = null);
|
|
83
83
|
}
|
|
84
|
-
function z(
|
|
84
|
+
function z(e2, t2, n2) {
|
|
85
85
|
return (i2, r2, o2) => {
|
|
86
86
|
const a2 = document.createElement("figure");
|
|
87
87
|
a2.className = "notectl-image", a2.setAttribute("data-block-id", i2.id), a2.setAttribute("data-void", "true"), a2.setAttribute("data-selectable", "true");
|
|
@@ -92,46 +92,46 @@ function z(t2, e2, n2) {
|
|
|
92
92
|
const d2 = document.createElement("div");
|
|
93
93
|
d2.className = "notectl-image__overlay", l2.appendChild(c2), l2.appendChild(d2), a2.appendChild(l2);
|
|
94
94
|
let g2 = i2.id, u2 = null;
|
|
95
|
-
function m2(
|
|
96
|
-
const n3 =
|
|
95
|
+
function m2(e3) {
|
|
96
|
+
const n3 = e3.attrs?.src ?? "", i3 = e3.attrs?.alt ?? "", r3 = e3.attrs?.width, o3 = e3.attrs?.height, s2 = e3.attrs?.align ?? "center";
|
|
97
97
|
c2.src !== n3 && (c2.src = n3), c2.alt = i3, c2.style.width = void 0 !== r3 ? `${r3}px` : "", c2.style.height = void 0 !== o3 ? `${o3}px` : "";
|
|
98
|
-
for (const
|
|
98
|
+
for (const e4 of Object.values(f)) a2.classList.remove(e4);
|
|
99
99
|
const l3 = f[s2];
|
|
100
100
|
l3 && a2.classList.add(l3);
|
|
101
|
-
const g3 =
|
|
102
|
-
d2.classList.toggle("notectl-image__overlay--uploading", u3), d2.classList.toggle("notectl-image__overlay--error", "error" === g3), d2.textContent = u3 ? "Uploading..." : "error" === g3 ? "Upload failed" : "", u3 ? a2.setAttribute("aria-busy", "true") : a2.removeAttribute("aria-busy"), (function(
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
})(
|
|
101
|
+
const g3 = t2.get(e3.id) ?? "idle", u3 = "uploading" === g3;
|
|
102
|
+
d2.classList.toggle("notectl-image__overlay--uploading", u3), d2.classList.toggle("notectl-image__overlay--error", "error" === g3), d2.textContent = u3 ? "Uploading..." : "error" === g3 ? "Upload failed" : "", u3 ? a2.setAttribute("aria-busy", "true") : a2.removeAttribute("aria-busy"), (function(e4) {
|
|
103
|
+
const t3 = e4.attrs?.alt ?? "", n4 = e4.attrs?.width, i4 = e4.attrs?.height, r4 = [];
|
|
104
|
+
t3 ? r4.push(t3) : r4.push("Image"), void 0 !== n4 && void 0 !== i4 && r4.push(`${n4} by ${i4} pixels`), a2.setAttribute("aria-label", r4.join(", "));
|
|
105
|
+
})(e3);
|
|
106
106
|
}
|
|
107
107
|
m2(i2);
|
|
108
108
|
let p2 = false;
|
|
109
|
-
function h2(
|
|
109
|
+
function h2(t3, n3, i3, s2) {
|
|
110
110
|
let l3 = 0, d3 = 0, g3 = 1;
|
|
111
|
-
const u3 = (
|
|
112
|
-
const i4 =
|
|
111
|
+
const u3 = (t4) => {
|
|
112
|
+
const i4 = t4.clientX - l3, r3 = (o3 = d3 + i4 * v[n3], Math.max(50, Math.min(e2.maxWidth, o3)));
|
|
113
113
|
var o3;
|
|
114
114
|
const a3 = Math.round(r3 / g3);
|
|
115
115
|
c2.style.width = `${r3}px`, c2.style.height = `${a3}px`, s2.textContent = `${Math.round(r3)} × ${a3}`;
|
|
116
|
-
}, m3 = (
|
|
116
|
+
}, m3 = (e3) => {
|
|
117
117
|
document.removeEventListener("pointermove", u3), document.removeEventListener("pointerup", m3), a2.classList.remove("notectl-image--resizing"), s2.classList.remove("notectl-image__size-indicator--visible"), I();
|
|
118
|
-
const
|
|
119
|
-
!(function(
|
|
120
|
-
const i4 = r2(), a3 = i4.getBlock(
|
|
118
|
+
const t4 = Math.round(c2.getBoundingClientRect().width), n4 = Math.round(t4 / g3);
|
|
119
|
+
!(function(e4, t5, n5) {
|
|
120
|
+
const i4 = r2(), a3 = i4.getBlock(e4);
|
|
121
121
|
if (!a3) return;
|
|
122
122
|
const s3 = a3.attrs?.width, l4 = a3.attrs?.height;
|
|
123
|
-
if (s3 ===
|
|
124
|
-
const c3 = i4.getNodePath(
|
|
123
|
+
if (s3 === t5 && l4 === n5) return;
|
|
124
|
+
const c3 = i4.getNodePath(e4);
|
|
125
125
|
if (!c3) return;
|
|
126
|
-
const d4 = { ...a3.attrs ?? {}, width:
|
|
126
|
+
const d4 = { ...a3.attrs ?? {}, width: t5, height: n5 }, g4 = i4.transaction("command").setNodeAttr(c3, d4).build();
|
|
127
127
|
o2(g4);
|
|
128
|
-
})(i3,
|
|
128
|
+
})(i3, t4, n4), e3.target?.releasePointerCapture?.(e3.pointerId);
|
|
129
129
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
130
|
+
t3.addEventListener("pointerdown", (e3) => {
|
|
131
|
+
e3.preventDefault(), e3.stopPropagation(), l3 = e3.clientX, d3 = c2.getBoundingClientRect().width;
|
|
132
|
+
const t4 = c2.getBoundingClientRect().height;
|
|
133
133
|
var i4;
|
|
134
|
-
g3 =
|
|
134
|
+
g3 = t4 > 0 ? d3 / t4 : 1, a2.classList.add("notectl-image--resizing"), s2.textContent = `${Math.round(d3)} × ${Math.round(t4)}`, s2.classList.add("notectl-image__size-indicator--visible"), i4 = b[n3], I(), y = document.createElement("style"), y.textContent = `*{cursor:${i4}!important;user-select:none!important}`, document.head.appendChild(y), e3.target.setPointerCapture(e3.pointerId), document.addEventListener("pointermove", u3), document.addEventListener("pointerup", m3);
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
function z2() {
|
|
@@ -139,35 +139,35 @@ function z(t2, e2, n2) {
|
|
|
139
139
|
}
|
|
140
140
|
return c2.addEventListener("load", () => {
|
|
141
141
|
if (p2) return;
|
|
142
|
-
const
|
|
142
|
+
const t3 = r2(), n3 = t3.getBlock(g2);
|
|
143
143
|
if (!n3 || "image" !== n3.type) return;
|
|
144
144
|
const i3 = void 0 !== n3.attrs?.width, a3 = void 0 !== n3.attrs?.height;
|
|
145
145
|
if (i3 && a3) return void (p2 = true);
|
|
146
146
|
const s2 = c2.naturalWidth, l3 = c2.naturalHeight;
|
|
147
147
|
if (0 === s2 || 0 === l3) return;
|
|
148
|
-
const d3 = Math.min(s2,
|
|
148
|
+
const d3 = Math.min(s2, e2.maxWidth), u3 = s2 > 0 ? l3 / s2 : 1, m3 = Math.round(d3 * u3), h3 = t3.getNodePath(g2);
|
|
149
149
|
if (!h3) return;
|
|
150
|
-
const f2 = { ...n3.attrs ?? {}, width: d3, height: m3 }, b2 =
|
|
150
|
+
const f2 = { ...n3.attrs ?? {}, width: d3, height: m3 }, b2 = t3.transaction("command").setNodeAttr(h3, f2).build();
|
|
151
151
|
o2(b2), p2 = true;
|
|
152
|
-
}), { dom: a2, contentDOM: null, update: (
|
|
153
|
-
a2.classList.add("notectl-image--selected"), (function(
|
|
154
|
-
if (!
|
|
152
|
+
}), { dom: a2, contentDOM: null, update: (e3) => "image" === e3.type && (g2 = e3.id, a2.setAttribute("data-block-id", e3.id), m2(e3), true), selectNode() {
|
|
153
|
+
a2.classList.add("notectl-image--selected"), (function(t3) {
|
|
154
|
+
if (!e2.resizable || u2) return;
|
|
155
155
|
u2 = document.createElement("div"), u2.className = "notectl-image__resize-overlay", u2.setAttribute("data-notectl-no-print", "");
|
|
156
156
|
const i3 = document.createElement("div");
|
|
157
157
|
i3.className = "notectl-image__size-indicator", u2.appendChild(i3);
|
|
158
158
|
const r3 = ["nw", "ne", "sw", "se"];
|
|
159
|
-
for (const
|
|
159
|
+
for (const e3 of r3) {
|
|
160
160
|
const n3 = document.createElement("div");
|
|
161
|
-
n3.className = `notectl-image__resize-handle notectl-image__resize-handle--${
|
|
161
|
+
n3.className = `notectl-image__resize-handle notectl-image__resize-handle--${e3}`, n3.setAttribute("role", "separator"), n3.setAttribute("aria-label", x[e3]), h2(n3, e3, t3, i3), u2.appendChild(n3);
|
|
162
162
|
}
|
|
163
163
|
if (n2) {
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
return
|
|
164
|
+
const e3 = (function(e4) {
|
|
165
|
+
const t4 = e4.shrinkWidth ?? null, n3 = e4.growWidth ?? null;
|
|
166
|
+
return t4 && n3 ? `${s(t4)} / ${s(n3)} to resize` : "";
|
|
167
167
|
})(n2);
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
|
|
168
|
+
if (e3) {
|
|
169
|
+
const t4 = document.createElement("div");
|
|
170
|
+
t4.className = "notectl-image__keyboard-hint", t4.setAttribute("aria-hidden", "true"), t4.textContent = e3, u2.appendChild(t4);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
l2.appendChild(u2);
|
|
@@ -179,7 +179,7 @@ function z(t2, e2, n2) {
|
|
|
179
179
|
} };
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
const w = new
|
|
182
|
+
const w = new e("image:upload"), A = { growWidth: "Mod-Shift-ArrowRight", shrinkWidth: "Mod-Shift-ArrowLeft", growWidthLarge: "Mod-Shift-Alt-ArrowRight", shrinkWidthLarge: "Mod-Shift-Alt-ArrowLeft", resetSize: "Mod-Shift-0" }, _ = { maxWidth: 800, maxFileSize: 10485760, acceptedTypes: ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"], resizable: true, resizeStep: 10, resizeStepLarge: 50 };
|
|
183
183
|
class S {
|
|
184
184
|
id = "image";
|
|
185
185
|
name = "Image";
|
|
@@ -190,162 +190,157 @@ class S {
|
|
|
190
190
|
blobUrls = /* @__PURE__ */ new Set();
|
|
191
191
|
context = null;
|
|
192
192
|
locale;
|
|
193
|
-
constructor(
|
|
194
|
-
this.config = { ..._, ...
|
|
193
|
+
constructor(e2) {
|
|
194
|
+
this.config = { ..._, ...e2 }, this.resolvedKeymap = { ...A, ...e2?.keymap };
|
|
195
195
|
}
|
|
196
|
-
init(
|
|
197
|
-
this.locale =
|
|
198
|
-
|
|
199
|
-
const
|
|
196
|
+
init(e2) {
|
|
197
|
+
this.locale = t(h, e2, this.config.locale), e2.registerStyleSheet("\n/* Image */\n.notectl-image {\n margin: 8px 0;\n user-select: none;\n line-height: 0;\n}\n\n.notectl-image--center {\n text-align: center;\n}\n\n.notectl-image--left {\n text-align: left;\n}\n\n.notectl-image--right {\n text-align: right;\n}\n\n.notectl-image__container {\n display: inline-block;\n position: relative;\n line-height: 0;\n}\n\n.notectl-image__img {\n display: block;\n max-width: 100%;\n border-radius: 4px;\n}\n\n.notectl-image--selected .notectl-image__container {\n outline: 2px solid var(--notectl-primary);\n outline-offset: 2px;\n border-radius: 6px;\n}\n\n/* Alignment toolbar (appears on image selection) */\n.notectl-image__align-toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n top: -36px;\n left: 50%;\n transform: translateX(-50%);\n background: var(--notectl-surface-overlay);\n border: 1px solid var(--notectl-border);\n border-radius: 6px;\n padding: 2px;\n box-shadow: 0 2px 8px var(--notectl-shadow);\n z-index: 10;\n}\n\n.notectl-image__align-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: none;\n background: transparent;\n border-radius: 4px;\n cursor: pointer;\n color: var(--notectl-fg);\n}\n\n.notectl-image__align-btn:hover {\n background: var(--notectl-hover-bg);\n}\n\n.notectl-image__align-btn--active {\n background: var(--notectl-active-bg);\n color: var(--notectl-primary-fg);\n}\n\n.notectl-image__align-btn svg {\n width: 16px;\n height: 16px;\n fill: currentColor;\n}\n\n/* Upload overlay */\n.notectl-image__overlay {\n position: absolute;\n inset: 0;\n display: none;\n align-items: center;\n justify-content: center;\n background: rgba(255, 255, 255, 0.8);\n border-radius: 4px;\n font-size: 13px;\n color: var(--notectl-fg-muted);\n}\n\n.notectl-image__overlay--uploading {\n display: flex;\n}\n\n.notectl-image__overlay--error {\n display: flex;\n background: var(--notectl-danger-muted);\n color: var(--notectl-danger);\n}\n\n/* Resize overlay + handles */\n.notectl-image__resize-overlay {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n.notectl-image__resize-handle {\n position: absolute;\n width: 10px;\n height: 10px;\n background: var(--notectl-bg);\n border: 2px solid var(--notectl-primary);\n border-radius: 50%;\n pointer-events: all;\n z-index: 2;\n transition: transform 0.1s, background 0.1s;\n}\n\n.notectl-image__resize-handle:hover {\n background: var(--notectl-primary);\n transform: scale(1.3);\n}\n\n.notectl-image--resizing .notectl-image__resize-handle {\n background: var(--notectl-primary);\n}\n\n.notectl-image__resize-handle--nw {\n top: -5px;\n left: -5px;\n cursor: nwse-resize;\n}\n\n.notectl-image__resize-handle--ne {\n top: -5px;\n right: -5px;\n cursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--sw {\n bottom: -5px;\n left: -5px;\n cursor: nesw-resize;\n}\n\n.notectl-image__resize-handle--se {\n bottom: -5px;\n right: -5px;\n cursor: nwse-resize;\n}\n\n/* Size indicator tooltip */\n.notectl-image__size-indicator {\n position: absolute;\n bottom: -28px;\n left: 50%;\n transform: translateX(-50%);\n padding: 2px 8px;\n background: var(--notectl-tooltip-bg);\n color: var(--notectl-tooltip-fg);\n font-size: 11px;\n font-weight: 500;\n border-radius: 4px;\n white-space: nowrap;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s;\n z-index: 3;\n}\n\n.notectl-image__size-indicator--visible {\n opacity: 1;\n}\n\n/* Keyboard resize hint (shown on selection, hidden during drag) */\n.notectl-image__keyboard-hint {\n display: none;\n position: absolute;\n bottom: -28px;\n left: 50%;\n transform: translateX(-50%);\n padding: 2px 8px;\n font-size: 11px;\n color: var(--notectl-fg-muted);\n white-space: nowrap;\n pointer-events: none;\n z-index: 3;\n}\n\n.notectl-image--selected .notectl-image__keyboard-hint {\n display: block;\n}\n\n.notectl-image--resizing .notectl-image__keyboard-hint {\n display: none;\n}\n\n/* Resizing feedback */\n.notectl-image--resizing .notectl-image__img {\n opacity: 0.85;\n}\n"), this.context = e2, this.registerNodeSpec(e2), this.registerNodeView(e2), (function(e3) {
|
|
198
|
+
e3.registerCommand("insertImage", () => u(e3, { src: "" })), e3.registerCommand("removeImage", () => (function(e4) {
|
|
199
|
+
const t2 = e4.getState(), n2 = t2.selection;
|
|
200
200
|
if (!r(n2)) return false;
|
|
201
|
-
const i2 =
|
|
201
|
+
const i2 = t2.getBlock(n2.nodeId);
|
|
202
202
|
if (!i2 || "image" !== i2.type) return false;
|
|
203
|
-
const a2 =
|
|
203
|
+
const a2 = t2.getNodePath(n2.nodeId);
|
|
204
204
|
if (!a2 || 0 === a2.length) return false;
|
|
205
205
|
const s2 = a2.slice(0, -1);
|
|
206
206
|
let c2;
|
|
207
|
-
if (0 === s2.length) c2 =
|
|
207
|
+
if (0 === s2.length) c2 = t2.doc;
|
|
208
208
|
else {
|
|
209
|
-
const
|
|
210
|
-
c2 =
|
|
209
|
+
const e5 = s2[s2.length - 1];
|
|
210
|
+
c2 = e5 ? t2.getBlock(e5) : void 0;
|
|
211
211
|
}
|
|
212
212
|
if (!c2) return false;
|
|
213
|
-
const d2 = c2.children.findIndex((
|
|
213
|
+
const d2 = c2.children.findIndex((e5) => l(e5) && e5.id === n2.nodeId);
|
|
214
214
|
if (-1 === d2) return false;
|
|
215
|
-
const g2 = (function(
|
|
216
|
-
if (0 ===
|
|
217
|
-
const
|
|
215
|
+
const g2 = (function(e5, t3, n3) {
|
|
216
|
+
if (0 === t3.length) {
|
|
217
|
+
const t4 = e5.doc.children, i3 = t4.findIndex((e6) => e6.id === n3), r2 = t4[i3 + 1] ?? t4[i3 - 1];
|
|
218
218
|
return r2?.id;
|
|
219
219
|
}
|
|
220
|
-
return
|
|
221
|
-
})(
|
|
220
|
+
return t3[t3.length - 1];
|
|
221
|
+
})(t2, s2, n2.nodeId);
|
|
222
222
|
if (!g2) return false;
|
|
223
|
-
const u2 =
|
|
224
|
-
return
|
|
225
|
-
})(
|
|
226
|
-
})(
|
|
223
|
+
const u2 = t2.transaction("command").removeNode(s2, d2).setSelection(o(g2, 0)).build();
|
|
224
|
+
return e4.dispatch(u2), true;
|
|
225
|
+
})(e3));
|
|
226
|
+
})(e2), this.registerResizeCommands(e2), this.registerResizeKeymaps(e2), this.registerFileHandler(e2), this.registerToolbarItem(e2);
|
|
227
227
|
}
|
|
228
228
|
destroy() {
|
|
229
|
-
for (const
|
|
229
|
+
for (const e2 of this.blobUrls) URL.revokeObjectURL(e2);
|
|
230
230
|
this.blobUrls.clear(), this.uploadStates.clear(), this.context = null;
|
|
231
231
|
}
|
|
232
|
-
onStateChange(
|
|
232
|
+
onStateChange(e2, t2, n2) {
|
|
233
233
|
if (!this.context) return;
|
|
234
|
-
for (const
|
|
235
|
-
const i2 = this.isImageSelected(
|
|
236
|
-
!i2 && r2 && this.announceImageSelection(
|
|
234
|
+
for (const e3 of this.uploadStates.keys()) t2.getBlock(e3) || this.uploadStates.delete(e3);
|
|
235
|
+
const i2 = this.isImageSelected(e2), r2 = this.isImageSelected(t2);
|
|
236
|
+
!i2 && r2 && this.announceImageSelection(t2);
|
|
237
237
|
}
|
|
238
|
-
registerNodeSpec(
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
const n2 = i("figure",
|
|
238
|
+
registerNodeSpec(e2) {
|
|
239
|
+
const t2 = this.locale;
|
|
240
|
+
e2.registerNodeSpec({ type: "image", group: "block", isVoid: true, selectable: true, attrs: { src: { default: "" }, alt: { default: "" }, align: { default: "center" } }, toDOM(e3) {
|
|
241
|
+
const n2 = i("figure", e3.id);
|
|
242
242
|
n2.className = "notectl-image", n2.setAttribute("data-void", "true"), n2.setAttribute("data-selectable", "true");
|
|
243
243
|
const r2 = document.createElement("div");
|
|
244
244
|
r2.className = "notectl-image__container";
|
|
245
|
-
const o2 =
|
|
246
|
-
l2.className = "notectl-image__img", l2.src =
|
|
247
|
-
const c2 = { left: "notectl-image--left", center: "notectl-image--center", right: "notectl-image--right" }[
|
|
248
|
-
return c2 && n2.classList.add(c2), n2.setAttribute("aria-label",
|
|
249
|
-
}, toHTML(
|
|
250
|
-
const
|
|
251
|
-
return `<figure class="notectl-image notectl-image--${n(a2)}"><img src="${
|
|
252
|
-
}, parseHTML: [{ tag: "figure", getAttrs(
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
const n2 = { src:
|
|
256
|
-
return i2 && (n2.width = Number.parseInt(i2, 10)), r2 && (n2.height = Number.parseInt(r2, 10)),
|
|
257
|
-
} }, { tag: "img", getAttrs(
|
|
258
|
-
const
|
|
259
|
-
return n2 && (
|
|
245
|
+
const o2 = e3.attrs?.alt ?? "", a2 = e3.attrs?.width, s2 = e3.attrs?.height, l2 = document.createElement("img");
|
|
246
|
+
l2.className = "notectl-image__img", l2.src = e3.attrs?.src ?? "", l2.alt = o2, l2.draggable = false, void 0 !== a2 && (l2.style.width = `${a2}px`), void 0 !== s2 && (l2.style.height = `${s2}px`);
|
|
247
|
+
const c2 = { left: "notectl-image--left", center: "notectl-image--center", right: "notectl-image--right" }[e3.attrs?.align ?? "center"];
|
|
248
|
+
return c2 && n2.classList.add(c2), n2.setAttribute("aria-label", t2.imageAria(o2, a2, s2)), r2.appendChild(l2), n2.appendChild(r2), n2;
|
|
249
|
+
}, toHTML(e3) {
|
|
250
|
+
const t3 = n(e3.attrs?.src ?? ""), i2 = n(e3.attrs?.alt ?? ""), r2 = e3.attrs?.width, o2 = e3.attrs?.height, a2 = e3.attrs?.align ?? "center", s2 = (void 0 !== r2 ? ` width="${r2}"` : "") + (void 0 !== o2 ? ` height="${o2}"` : "");
|
|
251
|
+
return `<figure class="notectl-image notectl-image--${n(a2)}"><img src="${t3}" alt="${i2}"${s2}></figure>`;
|
|
252
|
+
}, parseHTML: [{ tag: "figure", getAttrs(e3) {
|
|
253
|
+
const t3 = e3.querySelector("img");
|
|
254
|
+
if (!t3) return false;
|
|
255
|
+
const n2 = { src: t3.getAttribute("src") ?? "", alt: t3.getAttribute("alt") ?? "", align: "center" }, i2 = t3.getAttribute("width"), r2 = t3.getAttribute("height");
|
|
256
|
+
return i2 && (n2.width = Number.parseInt(i2, 10)), r2 && (n2.height = Number.parseInt(r2, 10)), e3.classList.contains("notectl-image--left") && (n2.align = "left"), e3.classList.contains("notectl-image--right") && (n2.align = "right"), n2;
|
|
257
|
+
} }, { tag: "img", getAttrs(e3) {
|
|
258
|
+
const t3 = { src: e3.getAttribute("src") ?? "", alt: e3.getAttribute("alt") ?? "", align: "center" }, n2 = e3.getAttribute("width"), i2 = e3.getAttribute("height");
|
|
259
|
+
return n2 && (t3.width = Number.parseInt(n2, 10)), i2 && (t3.height = Number.parseInt(i2, 10)), t3;
|
|
260
260
|
} }], sanitize: { tags: ["figure", "img"], attrs: ["src", "alt", "width", "height", "class"] } });
|
|
261
261
|
}
|
|
262
|
-
registerNodeView(
|
|
263
|
-
|
|
262
|
+
registerNodeView(e2) {
|
|
263
|
+
e2.registerNodeView("image", z(this.config, this.uploadStates, this.resolvedKeymap));
|
|
264
264
|
}
|
|
265
|
-
registerResizeCommands(
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
const n3 = m(
|
|
269
|
-
return n3 && this.announceCurrentSize(
|
|
270
|
-
}),
|
|
271
|
-
const n3 = m(
|
|
272
|
-
return n3 && this.announceCurrentSize(
|
|
273
|
-
}),
|
|
274
|
-
const
|
|
275
|
-
return
|
|
276
|
-
}),
|
|
277
|
-
const
|
|
278
|
-
return
|
|
279
|
-
}),
|
|
280
|
-
const
|
|
281
|
-
const
|
|
265
|
+
registerResizeCommands(e2) {
|
|
266
|
+
const t2 = this.config.resizeStep ?? 10, n2 = this.config.resizeStepLarge ?? 50, i2 = this.config.maxWidth;
|
|
267
|
+
e2.registerCommand("resizeImageGrow", () => {
|
|
268
|
+
const n3 = m(e2, t2, i2);
|
|
269
|
+
return n3 && this.announceCurrentSize(e2), n3;
|
|
270
|
+
}), e2.registerCommand("resizeImageShrink", () => {
|
|
271
|
+
const n3 = m(e2, -t2, i2);
|
|
272
|
+
return n3 && this.announceCurrentSize(e2), n3;
|
|
273
|
+
}), e2.registerCommand("resizeImageGrowLarge", () => {
|
|
274
|
+
const t3 = m(e2, n2, i2);
|
|
275
|
+
return t3 && this.announceCurrentSize(e2), t3;
|
|
276
|
+
}), e2.registerCommand("resizeImageShrinkLarge", () => {
|
|
277
|
+
const t3 = m(e2, -n2, i2);
|
|
278
|
+
return t3 && this.announceCurrentSize(e2), t3;
|
|
279
|
+
}), e2.registerCommand("resetImageSize", () => {
|
|
280
|
+
const t3 = (function(e3) {
|
|
281
|
+
const t4 = e3.getState(), n3 = t4.selection;
|
|
282
282
|
if (!r(n3)) return false;
|
|
283
|
-
const i3 =
|
|
283
|
+
const i3 = t4.getBlock(n3.nodeId);
|
|
284
284
|
if (!i3 || "image" !== i3.type) return false;
|
|
285
|
-
const o2 =
|
|
285
|
+
const o2 = t4.getNodePath(n3.nodeId);
|
|
286
286
|
if (!o2) return false;
|
|
287
|
-
const a2 = { ...i3.attrs ?? {} }, s2 = Object.fromEntries(Object.entries(a2).filter(([
|
|
288
|
-
return
|
|
289
|
-
})(
|
|
290
|
-
return
|
|
287
|
+
const a2 = { ...i3.attrs ?? {} }, s2 = Object.fromEntries(Object.entries(a2).filter(([e4]) => "width" !== e4 && "height" !== e4)), l2 = t4.transaction("command").setNodeAttr(o2, s2).build();
|
|
288
|
+
return e3.dispatch(l2), true;
|
|
289
|
+
})(e2);
|
|
290
|
+
return t3 && e2.announce(this.locale.resetToNaturalSize), t3;
|
|
291
291
|
});
|
|
292
292
|
}
|
|
293
|
-
registerResizeKeymaps(
|
|
294
|
-
const
|
|
293
|
+
registerResizeKeymaps(e2) {
|
|
294
|
+
const t2 = {}, n2 = { growWidth: "resizeImageGrow", shrinkWidth: "resizeImageShrink", growWidthLarge: "resizeImageGrowLarge", shrinkWidthLarge: "resizeImageShrinkLarge", resetSize: "resetImageSize" };
|
|
295
295
|
for (const [i2, r2] of Object.entries(n2)) {
|
|
296
296
|
const n3 = this.resolvedKeymap[i2] ?? null;
|
|
297
|
-
n3 && (
|
|
297
|
+
n3 && (t2[n3] = () => e2.executeCommand(r2));
|
|
298
298
|
}
|
|
299
|
-
Object.keys(
|
|
299
|
+
Object.keys(t2).length > 0 && e2.registerKeymap(t2);
|
|
300
300
|
}
|
|
301
|
-
registerFileHandler(
|
|
302
|
-
|
|
303
|
-
const i2 = e2.filter((t3) => this.isAcceptedType(t3.type));
|
|
304
|
-
if (0 === i2.length) return false;
|
|
305
|
-
for (const e3 of i2) this.handleFileInsert(t2, e3);
|
|
306
|
-
return true;
|
|
307
|
-
});
|
|
301
|
+
registerFileHandler(e2) {
|
|
302
|
+
e2.registerFileHandler("image/*", async (t2, n2) => !!this.isAcceptedType(t2.type) && (this.handleFileInsert(e2, t2), true));
|
|
308
303
|
}
|
|
309
|
-
handleFileInsert(
|
|
310
|
-
if (
|
|
311
|
-
const n2 = URL.createObjectURL(
|
|
312
|
-
if (this.blobUrls.add(n2), !u(
|
|
313
|
-
const i2 =
|
|
304
|
+
handleFileInsert(e2, t2) {
|
|
305
|
+
if (t2.size > this.config.maxFileSize) return;
|
|
306
|
+
const n2 = URL.createObjectURL(t2);
|
|
307
|
+
if (this.blobUrls.add(n2), !u(e2, { src: n2 })) return URL.revokeObjectURL(n2), void this.blobUrls.delete(n2);
|
|
308
|
+
const i2 = e2.getState().selection;
|
|
314
309
|
if (!r(i2)) return;
|
|
315
310
|
const o2 = i2.nodeId;
|
|
316
|
-
this.uploadStates.set(o2, "uploading"),
|
|
311
|
+
this.uploadStates.set(o2, "uploading"), e2.getService(w) ? this.uploadFile(e2, t2, o2, n2) : this.uploadStates.set(o2, "complete");
|
|
317
312
|
}
|
|
318
|
-
async uploadFile(
|
|
319
|
-
const r2 =
|
|
313
|
+
async uploadFile(e2, t2, n2, i2) {
|
|
314
|
+
const r2 = e2.getService(w);
|
|
320
315
|
if (r2) try {
|
|
321
|
-
const o2 = await r2.upload(
|
|
316
|
+
const o2 = await r2.upload(t2);
|
|
322
317
|
this.uploadStates.set(n2, "complete");
|
|
323
|
-
const a2 =
|
|
318
|
+
const a2 = e2.getState(), s2 = a2.getBlock(n2);
|
|
324
319
|
if (!s2) return;
|
|
325
320
|
const l2 = a2.getNodePath(n2);
|
|
326
321
|
if (!l2) return;
|
|
327
322
|
const c2 = { ...s2.attrs ?? {}, src: o2.url, ...void 0 !== o2.width ? { width: o2.width } : {}, ...void 0 !== o2.height ? { height: o2.height } : {} }, d2 = a2.transaction("command").setNodeAttr(l2, c2).build();
|
|
328
|
-
|
|
323
|
+
e2.dispatch(d2), URL.revokeObjectURL(i2), this.blobUrls.delete(i2);
|
|
329
324
|
} catch {
|
|
330
|
-
this.uploadStates.set(n2, "error"),
|
|
325
|
+
this.uploadStates.set(n2, "error"), e2.announce(this.locale.uploadFailed);
|
|
331
326
|
}
|
|
332
327
|
}
|
|
333
|
-
registerToolbarItem(
|
|
334
|
-
|
|
335
|
-
this.renderImagePopup(
|
|
328
|
+
registerToolbarItem(e2) {
|
|
329
|
+
e2.registerToolbarItem({ id: "image", group: "insert", icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>', label: this.locale.insertImage, tooltip: this.locale.insertImageTooltip, command: "insertImage", priority: 50, popupType: "custom", separatorAfter: this.config.separatorAfter, renderPopup: (e3, t2, n2) => {
|
|
330
|
+
this.renderImagePopup(e3, t2, n2);
|
|
336
331
|
} });
|
|
337
332
|
}
|
|
338
|
-
renderImagePopup(
|
|
339
|
-
|
|
333
|
+
renderImagePopup(e2, t2, n2) {
|
|
334
|
+
e2.style.padding = "8px", e2.style.minWidth = "240px";
|
|
340
335
|
const i2 = document.createElement("input");
|
|
341
336
|
i2.type = "file", i2.accept = this.config.acceptedTypes.join(","), i2.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;opacity:0;";
|
|
342
337
|
const r2 = document.createElement("button");
|
|
343
|
-
r2.type = "button", r2.textContent = this.locale.uploadFromComputer, r2.setAttribute("aria-label", this.locale.uploadAria), r2.style.cssText = "display:block;width:100%;padding:8px 12px;cursor:pointer;text-align:center;box-sizing:border-box;border:1px solid var(--notectl-border);border-radius:4px;background:var(--notectl-surface-raised);color:var(--notectl-fg);", r2.addEventListener("mousedown", (
|
|
344
|
-
|
|
338
|
+
r2.type = "button", r2.textContent = this.locale.uploadFromComputer, r2.setAttribute("aria-label", this.locale.uploadAria), r2.style.cssText = "display:block;width:100%;padding:8px 12px;cursor:pointer;text-align:center;box-sizing:border-box;border:1px solid var(--notectl-border);border-radius:4px;background:var(--notectl-surface-raised);color:var(--notectl-fg);", r2.addEventListener("mousedown", (e3) => {
|
|
339
|
+
e3.preventDefault(), e3.stopPropagation(), i2.click();
|
|
345
340
|
}), i2.addEventListener("change", () => {
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
}),
|
|
341
|
+
const e3 = i2.files?.[0];
|
|
342
|
+
e3 && (this.handleFileInsert(t2, e3), n2(), t2.getContainer().focus());
|
|
343
|
+
}), e2.appendChild(i2), e2.appendChild(r2);
|
|
349
344
|
const o2 = document.createElement("div");
|
|
350
345
|
o2.style.cssText = "display:flex;align-items:center;margin:8px 0;color:var(--notectl-fg-muted);font-size:12px;";
|
|
351
346
|
const a2 = document.createElement("span");
|
|
@@ -353,48 +348,48 @@ class S {
|
|
|
353
348
|
const s2 = document.createElement("span");
|
|
354
349
|
s2.textContent = this.locale.separator, s2.style.cssText = "padding:0 8px;";
|
|
355
350
|
const l2 = document.createElement("span");
|
|
356
|
-
l2.style.cssText = "flex:1;height:1px;background:var(--notectl-border);", o2.appendChild(a2), o2.appendChild(s2), o2.appendChild(l2),
|
|
351
|
+
l2.style.cssText = "flex:1;height:1px;background:var(--notectl-border);", o2.appendChild(a2), o2.appendChild(s2), o2.appendChild(l2), e2.appendChild(o2);
|
|
357
352
|
const c2 = document.createElement("input");
|
|
358
353
|
c2.type = "url", c2.placeholder = this.locale.urlPlaceholder, c2.setAttribute("aria-label", this.locale.urlAria), c2.style.cssText = "width:100%;padding:6px 8px;box-sizing:border-box;border:1px solid var(--notectl-border);border-radius:4px;background:var(--notectl-bg);color:var(--notectl-fg);";
|
|
359
354
|
const d2 = document.createElement("button");
|
|
360
355
|
d2.type = "button", d2.textContent = this.locale.insertButton, d2.setAttribute("aria-label", this.locale.insertAria), d2.style.cssText = "width:100%;padding:8px 12px;margin-top:4px;cursor:pointer;border:1px solid var(--notectl-border);border-radius:4px;background:var(--notectl-surface-raised);color:var(--notectl-fg);";
|
|
361
356
|
const g2 = () => {
|
|
362
|
-
const
|
|
363
|
-
|
|
357
|
+
const e3 = c2.value.trim();
|
|
358
|
+
e3 && (u(t2, { src: e3 }), n2(), t2.getContainer().focus());
|
|
364
359
|
};
|
|
365
|
-
d2.addEventListener("mousedown", (
|
|
366
|
-
|
|
367
|
-
}), c2.addEventListener("keydown", (
|
|
368
|
-
"Enter" ===
|
|
369
|
-
}),
|
|
360
|
+
d2.addEventListener("mousedown", (e3) => {
|
|
361
|
+
e3.preventDefault(), e3.stopPropagation(), g2();
|
|
362
|
+
}), c2.addEventListener("keydown", (e3) => {
|
|
363
|
+
"Enter" === e3.key && (e3.preventDefault(), g2());
|
|
364
|
+
}), e2.appendChild(c2), e2.appendChild(d2), requestAnimationFrame(() => c2.focus());
|
|
370
365
|
}
|
|
371
|
-
isAcceptedType(
|
|
372
|
-
return this.config.acceptedTypes.some((
|
|
366
|
+
isAcceptedType(e2) {
|
|
367
|
+
return this.config.acceptedTypes.some((t2) => t2 === e2 || t2.endsWith("/*") && e2.startsWith(t2.slice(0, -1)));
|
|
373
368
|
}
|
|
374
|
-
isImageSelected(
|
|
375
|
-
const
|
|
376
|
-
if (!r(
|
|
377
|
-
const n2 =
|
|
369
|
+
isImageSelected(e2) {
|
|
370
|
+
const t2 = e2.selection;
|
|
371
|
+
if (!r(t2)) return false;
|
|
372
|
+
const n2 = e2.getBlock(t2.nodeId);
|
|
378
373
|
return "image" === n2?.type;
|
|
379
374
|
}
|
|
380
|
-
announceImageSelection(
|
|
375
|
+
announceImageSelection(e2) {
|
|
381
376
|
if (!this.context) return;
|
|
382
|
-
const
|
|
383
|
-
if (!r(
|
|
384
|
-
const n2 =
|
|
377
|
+
const t2 = e2.selection;
|
|
378
|
+
if (!r(t2)) return;
|
|
379
|
+
const n2 = e2.getBlock(t2.nodeId);
|
|
385
380
|
if (!n2 || "image" !== n2.type) return;
|
|
386
381
|
const i2 = n2.attrs?.alt ?? "", o2 = n2.attrs?.width, a2 = n2.attrs?.height, l2 = ["Image selected."];
|
|
387
382
|
i2 && l2.push(`Alt text: ${i2}.`), void 0 !== o2 && void 0 !== a2 && l2.push(`Size: ${o2} by ${a2} pixels.`);
|
|
388
383
|
const c2 = this.resolvedKeymap.shrinkWidth ?? null, d2 = this.resolvedKeymap.growWidth ?? null;
|
|
389
384
|
c2 && d2 && l2.push(`${s(c2)} / ${s(d2)} to resize.`), this.context.announce(l2.join(" "));
|
|
390
385
|
}
|
|
391
|
-
announceCurrentSize(
|
|
392
|
-
const
|
|
386
|
+
announceCurrentSize(e2) {
|
|
387
|
+
const t2 = e2.getState(), n2 = t2.selection;
|
|
393
388
|
if (!r(n2)) return;
|
|
394
|
-
const i2 =
|
|
389
|
+
const i2 = t2.getBlock(n2.nodeId);
|
|
395
390
|
if (!i2 || "image" !== i2.type) return;
|
|
396
391
|
const o2 = i2.attrs?.width, a2 = i2.attrs?.height;
|
|
397
|
-
void 0 !== o2 && void 0 !== a2 &&
|
|
392
|
+
void 0 !== o2 && void 0 !== a2 && e2.announce(`Image resized to ${o2} by ${a2} pixels.`);
|
|
398
393
|
}
|
|
399
394
|
}
|
|
400
395
|
export {
|
|
@@ -404,4 +399,4 @@ export {
|
|
|
404
399
|
w as b,
|
|
405
400
|
S as c
|
|
406
401
|
};
|
|
407
|
-
//# sourceMappingURL=index-
|
|
402
|
+
//# sourceMappingURL=index-BL56fbXt.mjs.map
|