@novaprose/core 0.3.0 → 0.4.0
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/{advlist-DEJUHLI6.js → advlist-FH3K3AAQ.js} +2 -2
- package/dist/{autolink-ZVHNOOS7.js → autolink-IDJWAL2V.js} +2 -2
- package/dist/{autoresize-WT4ONZKK.js → autoresize-4ZEPQCHP.js} +2 -2
- package/dist/{autosave-2KI5WGV5.js → autosave-WODRZ7L6.js} +2 -2
- package/dist/{charmap-3LM5LZCC.js → charmap-LWA7TL3K.js} +2 -2
- package/dist/{chunk-BGG3UVGZ.js → chunk-2A3IYKPE.js} +5 -2
- package/dist/chunk-2A3IYKPE.js.map +1 -0
- package/dist/{chunk-F6TSOU5U.js → chunk-6GWG2BLC.js} +1 -1
- package/dist/chunk-6GWG2BLC.js.map +1 -0
- package/dist/{directionality-MTLAIFIQ.js → directionality-N62ZB7CF.js} +2 -2
- package/dist/{emoticons-YVGVA76P.js → emoticons-WQ3K4J6G.js} +2 -2
- package/dist/index.cjs +591 -145
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +129 -2
- package/dist/index.d.ts +129 -2
- package/dist/index.js +461 -20
- package/dist/index.js.map +1 -1
- package/dist/{insertdatetime-QYWZUYO4.js → insertdatetime-2RZ3UUQE.js} +2 -2
- package/dist/{nonbreaking-SIACL5V6.js → nonbreaking-L6GNDHVO.js} +2 -2
- package/dist/{quickbars-TYJG6WTF.js → quickbars-TIRY3RH4.js} +2 -2
- package/dist/{revisionhistory-ZCRBPP33.js → revisionhistory-GDTOULKS.js} +3 -3
- package/dist/{visualblocks-WB6NAEGB.js → visualblocks-V4CQ4XMF.js} +2 -2
- package/package.json +1 -1
- package/src/style.css +37 -0
- package/dist/chunk-BGG3UVGZ.js.map +0 -1
- package/dist/chunk-F6TSOU5U.js.map +0 -1
- /package/dist/{advlist-DEJUHLI6.js.map → advlist-FH3K3AAQ.js.map} +0 -0
- /package/dist/{autolink-ZVHNOOS7.js.map → autolink-IDJWAL2V.js.map} +0 -0
- /package/dist/{autoresize-WT4ONZKK.js.map → autoresize-4ZEPQCHP.js.map} +0 -0
- /package/dist/{autosave-2KI5WGV5.js.map → autosave-WODRZ7L6.js.map} +0 -0
- /package/dist/{charmap-3LM5LZCC.js.map → charmap-LWA7TL3K.js.map} +0 -0
- /package/dist/{directionality-MTLAIFIQ.js.map → directionality-N62ZB7CF.js.map} +0 -0
- /package/dist/{emoticons-YVGVA76P.js.map → emoticons-WQ3K4J6G.js.map} +0 -0
- /package/dist/{insertdatetime-QYWZUYO4.js.map → insertdatetime-2RZ3UUQE.js.map} +0 -0
- /package/dist/{nonbreaking-SIACL5V6.js.map → nonbreaking-L6GNDHVO.js.map} +0 -0
- /package/dist/{quickbars-TYJG6WTF.js.map → quickbars-TIRY3RH4.js.map} +0 -0
- /package/dist/{revisionhistory-ZCRBPP33.js.map → revisionhistory-GDTOULKS.js.map} +0 -0
- /package/dist/{visualblocks-WB6NAEGB.js.map → visualblocks-V4CQ4XMF.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1305,16 +1305,16 @@ function createSchema(extensions = {}) {
|
|
|
1305
1305
|
for (const [name] of extraMarks) {
|
|
1306
1306
|
if (name in marks) throw new Error(`[nova] mark "${name}" already exists in the base schema`);
|
|
1307
1307
|
}
|
|
1308
|
-
return new
|
|
1308
|
+
return new import_prosemirror_model2.Schema({
|
|
1309
1309
|
nodes: { ...nodes, ...Object.fromEntries(extraNodes) },
|
|
1310
1310
|
marks: { ...marks, ...Object.fromEntries(extraMarks) }
|
|
1311
1311
|
});
|
|
1312
1312
|
}
|
|
1313
|
-
var
|
|
1313
|
+
var import_prosemirror_model2, import_prosemirror_tables, ALIGNMENTS, COLOR_RE, LENGTH_RE, LINE_HEIGHT_RE, FONT_FAMILY_RE, cssValue, blockStyleSpec, BULLET_STYLES, ORDERED_STYLES, OL_TYPE, IMAGE_ALIGN_STYLES, CELL_VALIGN, MAX_SPAN, nodes, marks, schema;
|
|
1314
1314
|
var init_schema = __esm({
|
|
1315
1315
|
"src/schema.ts"() {
|
|
1316
1316
|
"use strict";
|
|
1317
|
-
|
|
1317
|
+
import_prosemirror_model2 = require("prosemirror-model");
|
|
1318
1318
|
import_prosemirror_tables = require("prosemirror-tables");
|
|
1319
1319
|
init_url();
|
|
1320
1320
|
ALIGNMENTS = ["left", "center", "right", "justify"];
|
|
@@ -1627,7 +1627,7 @@ var init_schema = __esm({
|
|
|
1627
1627
|
toDOM: (mark) => styleSpan("font-size", cssValue.length(mark.attrs.value))
|
|
1628
1628
|
}
|
|
1629
1629
|
};
|
|
1630
|
-
schema = new
|
|
1630
|
+
schema = new import_prosemirror_model2.Schema({ nodes, marks });
|
|
1631
1631
|
}
|
|
1632
1632
|
});
|
|
1633
1633
|
|
|
@@ -1641,13 +1641,13 @@ function insertText2(editor, text) {
|
|
|
1641
1641
|
dispatch(state.tr.insertText(text).scrollIntoView());
|
|
1642
1642
|
editor.focus();
|
|
1643
1643
|
}
|
|
1644
|
-
var ICON4,
|
|
1644
|
+
var ICON4, LABELS7, FORMATS, insertdatetime_default;
|
|
1645
1645
|
var init_insertdatetime = __esm({
|
|
1646
1646
|
"src/plugins/insertdatetime.ts"() {
|
|
1647
1647
|
"use strict";
|
|
1648
1648
|
init_plugins();
|
|
1649
1649
|
ICON4 = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 10h18M8 3v4M16 3v4"/><path d="M12 13v3l2 1"/></svg>';
|
|
1650
|
-
|
|
1650
|
+
LABELS7 = {
|
|
1651
1651
|
en: {
|
|
1652
1652
|
title: "Insert date/time",
|
|
1653
1653
|
date: "Date",
|
|
@@ -1674,7 +1674,7 @@ var init_insertdatetime = __esm({
|
|
|
1674
1674
|
toolbar: "insertdatetime",
|
|
1675
1675
|
setup(editor) {
|
|
1676
1676
|
const lang = editor.options.language ?? "en";
|
|
1677
|
-
const labels =
|
|
1677
|
+
const labels = LABELS7[lang.split("-")[0]] ?? LABELS7.en;
|
|
1678
1678
|
const now = () => editor.options.pluginOptions?.insertdatetime?.now?.() ?? /* @__PURE__ */ new Date();
|
|
1679
1679
|
const format = (kind) => new Intl.DateTimeFormat(lang, FORMATS[kind]).format(now());
|
|
1680
1680
|
editor.ui.registry.addMenuItem("insertdatetime", {
|
|
@@ -1861,7 +1861,7 @@ function markRange(state, type, pos) {
|
|
|
1861
1861
|
});
|
|
1862
1862
|
return segments.find((s) => s.from <= pos && pos <= s.to) ?? null;
|
|
1863
1863
|
}
|
|
1864
|
-
var import_prosemirror_commands, import_prosemirror_history, import_prosemirror_schema_list, nodesOf, marksOf, withNode,
|
|
1864
|
+
var import_prosemirror_commands, import_prosemirror_history, import_prosemirror_schema_list, nodesOf, marksOf, withNode, withMark2, insertHorizontalRule, unlink, clearFormatting, commands;
|
|
1865
1865
|
var init_commands = __esm({
|
|
1866
1866
|
"src/commands.ts"() {
|
|
1867
1867
|
"use strict";
|
|
@@ -1872,7 +1872,7 @@ var init_commands = __esm({
|
|
|
1872
1872
|
nodesOf = (state) => state.schema.nodes;
|
|
1873
1873
|
marksOf = (state) => state.schema.marks;
|
|
1874
1874
|
withNode = (name, make) => (state, dispatch, view) => make(nodesOf(state)[name])(state, dispatch, view);
|
|
1875
|
-
|
|
1875
|
+
withMark2 = (name, make) => (state, dispatch, view) => make(marksOf(state)[name])(state, dispatch, view);
|
|
1876
1876
|
insertHorizontalRule = (state, dispatch) => {
|
|
1877
1877
|
dispatch?.(
|
|
1878
1878
|
state.tr.replaceSelectionWith(nodesOf(state).horizontal_rule.create()).scrollIntoView()
|
|
@@ -1906,13 +1906,13 @@ var init_commands = __esm({
|
|
|
1906
1906
|
return true;
|
|
1907
1907
|
};
|
|
1908
1908
|
commands = {
|
|
1909
|
-
bold:
|
|
1910
|
-
italic:
|
|
1911
|
-
underline:
|
|
1912
|
-
strike:
|
|
1913
|
-
code:
|
|
1914
|
-
subscript:
|
|
1915
|
-
superscript:
|
|
1909
|
+
bold: withMark2("bold", import_prosemirror_commands.toggleMark),
|
|
1910
|
+
italic: withMark2("italic", import_prosemirror_commands.toggleMark),
|
|
1911
|
+
underline: withMark2("underline", import_prosemirror_commands.toggleMark),
|
|
1912
|
+
strike: withMark2("strike", import_prosemirror_commands.toggleMark),
|
|
1913
|
+
code: withMark2("code", import_prosemirror_commands.toggleMark),
|
|
1914
|
+
subscript: withMark2("subscript", import_prosemirror_commands.toggleMark),
|
|
1915
|
+
superscript: withMark2("superscript", import_prosemirror_commands.toggleMark),
|
|
1916
1916
|
paragraph: withNode("paragraph", (type) => setBlockKeepAlign(type)),
|
|
1917
1917
|
h1: heading(1),
|
|
1918
1918
|
h2: heading(2),
|
|
@@ -2046,8 +2046,8 @@ function dataImageSrcs(doc, type) {
|
|
|
2046
2046
|
return srcs;
|
|
2047
2047
|
}
|
|
2048
2048
|
function embeddedImageUploadPlugin(editor) {
|
|
2049
|
-
return new
|
|
2050
|
-
key: new
|
|
2049
|
+
return new import_prosemirror_state5.Plugin({
|
|
2050
|
+
key: new import_prosemirror_state5.PluginKey("nova-embedded-image-upload"),
|
|
2051
2051
|
appendTransaction(transactions, oldState, newState) {
|
|
2052
2052
|
if (!editor.options.uploadImage) return null;
|
|
2053
2053
|
const fromUser = transactions.some(
|
|
@@ -2064,8 +2064,8 @@ function embeddedImageUploadPlugin(editor) {
|
|
|
2064
2064
|
});
|
|
2065
2065
|
}
|
|
2066
2066
|
function imageDropPastePlugin(editor) {
|
|
2067
|
-
return new
|
|
2068
|
-
key: new
|
|
2067
|
+
return new import_prosemirror_state5.Plugin({
|
|
2068
|
+
key: new import_prosemirror_state5.PluginKey("nova-image-drop-paste"),
|
|
2069
2069
|
props: {
|
|
2070
2070
|
handlePaste(_view, event) {
|
|
2071
2071
|
if (!editor.isAllowed("image")) return false;
|
|
@@ -2151,7 +2151,7 @@ function openImageDialog(editor) {
|
|
|
2151
2151
|
}
|
|
2152
2152
|
function getSelectedImage(state) {
|
|
2153
2153
|
const { selection } = state;
|
|
2154
|
-
if (selection instanceof
|
|
2154
|
+
if (selection instanceof import_prosemirror_state5.NodeSelection && selection.node.type === nodesOf(state).image) {
|
|
2155
2155
|
return { node: selection.node, pos: selection.from };
|
|
2156
2156
|
}
|
|
2157
2157
|
return null;
|
|
@@ -2162,7 +2162,7 @@ function setImageAttrs(attrs) {
|
|
|
2162
2162
|
if (!image) return false;
|
|
2163
2163
|
if (dispatch) {
|
|
2164
2164
|
const tr = state.tr.setNodeMarkup(image.pos, void 0, { ...image.node.attrs, ...attrs });
|
|
2165
|
-
tr.setSelection(
|
|
2165
|
+
tr.setSelection(import_prosemirror_state5.NodeSelection.create(tr.doc, image.pos));
|
|
2166
2166
|
dispatch(tr);
|
|
2167
2167
|
}
|
|
2168
2168
|
return true;
|
|
@@ -2206,11 +2206,11 @@ function openImageAltDialog(editor) {
|
|
|
2206
2206
|
}
|
|
2207
2207
|
});
|
|
2208
2208
|
}
|
|
2209
|
-
var
|
|
2209
|
+
var import_prosemirror_state5, IMAGE_TYPES, DATA_IMAGE;
|
|
2210
2210
|
var init_image = __esm({
|
|
2211
2211
|
"src/image.ts"() {
|
|
2212
2212
|
"use strict";
|
|
2213
|
-
|
|
2213
|
+
import_prosemirror_state5 = require("prosemirror-state");
|
|
2214
2214
|
init_commands();
|
|
2215
2215
|
init_commands();
|
|
2216
2216
|
init_dialog();
|
|
@@ -2353,7 +2353,7 @@ function insertTable(rows, cols, withHeader = true) {
|
|
|
2353
2353
|
if (n === node) tablePos = pos;
|
|
2354
2354
|
return tablePos < 0;
|
|
2355
2355
|
});
|
|
2356
|
-
if (tablePos >= 0) tr.setSelection(
|
|
2356
|
+
if (tablePos >= 0) tr.setSelection(import_prosemirror_state6.TextSelection.near(tr.doc.resolve(tablePos + 3)));
|
|
2357
2357
|
dispatch(tr.scrollIntoView());
|
|
2358
2358
|
}
|
|
2359
2359
|
return true;
|
|
@@ -2363,7 +2363,7 @@ function tablePlugins() {
|
|
|
2363
2363
|
return [
|
|
2364
2364
|
(0, import_prosemirror_tables2.columnResizing)({ cellMinWidth: 48, View: NovaTableView }),
|
|
2365
2365
|
(0, import_prosemirror_tables2.tableEditing)(),
|
|
2366
|
-
(0,
|
|
2366
|
+
(0, import_prosemirror_keymap3.keymap)({
|
|
2367
2367
|
Tab: nextCellOrNewRow,
|
|
2368
2368
|
"Shift-Tab": (0, import_prosemirror_tables2.goToNextCell)(-1)
|
|
2369
2369
|
})
|
|
@@ -2504,7 +2504,7 @@ function sortTable(direction, locale) {
|
|
|
2504
2504
|
const cmp = numeric ? numbers[a.i] - numbers[b.i] : collator.compare(ta, tb);
|
|
2505
2505
|
return (direction === "asc" ? cmp : -cmp) || a.i - b.i;
|
|
2506
2506
|
}).map(({ row }) => row);
|
|
2507
|
-
const sorted = table.copy(
|
|
2507
|
+
const sorted = table.copy(import_prosemirror_model3.Fragment.from([...head, ...order]));
|
|
2508
2508
|
dispatch(state.tr.replaceWith(pos, pos + table.nodeSize, sorted).scrollIntoView());
|
|
2509
2509
|
}
|
|
2510
2510
|
return true;
|
|
@@ -2595,13 +2595,13 @@ function setCellProps(props) {
|
|
|
2595
2595
|
return true;
|
|
2596
2596
|
};
|
|
2597
2597
|
}
|
|
2598
|
-
var
|
|
2598
|
+
var import_prosemirror_keymap3, import_prosemirror_model3, import_prosemirror_state6, import_prosemirror_tables2, MAX_GRID, nextCellOrNewRow, tableCommands, NovaTableView;
|
|
2599
2599
|
var init_table = __esm({
|
|
2600
2600
|
"src/table.ts"() {
|
|
2601
2601
|
"use strict";
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2602
|
+
import_prosemirror_keymap3 = require("prosemirror-keymap");
|
|
2603
|
+
import_prosemirror_model3 = require("prosemirror-model");
|
|
2604
|
+
import_prosemirror_state6 = require("prosemirror-state");
|
|
2605
2605
|
import_prosemirror_tables2 = require("prosemirror-tables");
|
|
2606
2606
|
init_schema();
|
|
2607
2607
|
init_dom();
|
|
@@ -2666,7 +2666,7 @@ __export(quickbars_exports, {
|
|
|
2666
2666
|
});
|
|
2667
2667
|
function hasTextSelection(editor) {
|
|
2668
2668
|
const { selection } = editor.view.state;
|
|
2669
|
-
if (!(selection instanceof
|
|
2669
|
+
if (!(selection instanceof import_prosemirror_state7.TextSelection) || selection.empty) return false;
|
|
2670
2670
|
if (selection.$from.parent.type.spec.code) return false;
|
|
2671
2671
|
return editor.view.state.doc.textBetween(selection.from, selection.to).trim().length > 0;
|
|
2672
2672
|
}
|
|
@@ -2686,11 +2686,11 @@ function pickImage(editor) {
|
|
|
2686
2686
|
});
|
|
2687
2687
|
input.click();
|
|
2688
2688
|
}
|
|
2689
|
-
var
|
|
2689
|
+
var import_prosemirror_state7, DEFAULT_SELECTION, DEFAULT_INSERT, quickbars_default;
|
|
2690
2690
|
var init_quickbars = __esm({
|
|
2691
2691
|
"src/plugins/quickbars.ts"() {
|
|
2692
2692
|
"use strict";
|
|
2693
|
-
|
|
2693
|
+
import_prosemirror_state7 = require("prosemirror-state");
|
|
2694
2694
|
init_image();
|
|
2695
2695
|
init_link();
|
|
2696
2696
|
init_plugins();
|
|
@@ -2751,14 +2751,14 @@ var charmap_exports = {};
|
|
|
2751
2751
|
__export(charmap_exports, {
|
|
2752
2752
|
default: () => charmap_default
|
|
2753
2753
|
});
|
|
2754
|
-
var ICON5,
|
|
2754
|
+
var ICON5, LABELS8, SYMBOLS, charmap_default;
|
|
2755
2755
|
var init_charmap = __esm({
|
|
2756
2756
|
"src/plugins/charmap.ts"() {
|
|
2757
2757
|
"use strict";
|
|
2758
2758
|
init_plugins();
|
|
2759
2759
|
init_shared();
|
|
2760
2760
|
ICON5 = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 20h4v-3a7 7 0 1 1 6 0v3h4"/></svg>';
|
|
2761
|
-
|
|
2761
|
+
LABELS8 = {
|
|
2762
2762
|
en: {
|
|
2763
2763
|
title: "Special character",
|
|
2764
2764
|
search: "Search characters",
|
|
@@ -2913,7 +2913,7 @@ var init_charmap = __esm({
|
|
|
2913
2913
|
name: "charmap",
|
|
2914
2914
|
toolbar: "charmap",
|
|
2915
2915
|
setup(editor) {
|
|
2916
|
-
const labels = pickLabels(editor,
|
|
2916
|
+
const labels = pickLabels(editor, LABELS8);
|
|
2917
2917
|
const groups = SYMBOLS.map((items, i) => ({ title: labels.groups[i], items }));
|
|
2918
2918
|
const panel = (close) => symbolPanel({
|
|
2919
2919
|
groups,
|
|
@@ -2946,14 +2946,14 @@ var emoticons_exports = {};
|
|
|
2946
2946
|
__export(emoticons_exports, {
|
|
2947
2947
|
default: () => emoticons_default
|
|
2948
2948
|
});
|
|
2949
|
-
var ICON6,
|
|
2949
|
+
var ICON6, LABELS9, EMOJI, emoticons_default;
|
|
2950
2950
|
var init_emoticons = __esm({
|
|
2951
2951
|
"src/plugins/emoticons.ts"() {
|
|
2952
2952
|
"use strict";
|
|
2953
2953
|
init_plugins();
|
|
2954
2954
|
init_shared();
|
|
2955
2955
|
ICON6 = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><path d="M9 9h.01M15 9h.01"/></svg>';
|
|
2956
|
-
|
|
2956
|
+
LABELS9 = {
|
|
2957
2957
|
en: {
|
|
2958
2958
|
title: "Emoji",
|
|
2959
2959
|
search: "Search emoji",
|
|
@@ -3111,7 +3111,7 @@ var init_emoticons = __esm({
|
|
|
3111
3111
|
name: "emoticons",
|
|
3112
3112
|
toolbar: "emoticons",
|
|
3113
3113
|
setup(editor) {
|
|
3114
|
-
const labels = pickLabels(editor,
|
|
3114
|
+
const labels = pickLabels(editor, LABELS9);
|
|
3115
3115
|
const groups = EMOJI.map((items, i) => ({ title: labels.groups[i], items }));
|
|
3116
3116
|
const all = EMOJI.flat();
|
|
3117
3117
|
const panel = (close) => symbolPanel({
|
|
@@ -3160,21 +3160,21 @@ var nonbreaking_exports = {};
|
|
|
3160
3160
|
__export(nonbreaking_exports, {
|
|
3161
3161
|
default: () => nonbreaking_default
|
|
3162
3162
|
});
|
|
3163
|
-
var
|
|
3163
|
+
var import_prosemirror_keymap4, NBSP, ICON7, LABELS10, nonbreaking_default;
|
|
3164
3164
|
var init_nonbreaking = __esm({
|
|
3165
3165
|
"src/plugins/nonbreaking.ts"() {
|
|
3166
3166
|
"use strict";
|
|
3167
|
-
|
|
3167
|
+
import_prosemirror_keymap4 = require("prosemirror-keymap");
|
|
3168
3168
|
init_plugins();
|
|
3169
3169
|
init_shared();
|
|
3170
3170
|
NBSP = String.fromCharCode(160);
|
|
3171
3171
|
ICON7 = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 9v5h16V9"/></svg>';
|
|
3172
|
-
|
|
3172
|
+
LABELS10 = { en: { title: "Nonbreaking space" }, ru: { title: "\u041D\u0435\u0440\u0430\u0437\u0440\u044B\u0432\u043D\u044B\u0439 \u043F\u0440\u043E\u0431\u0435\u043B" } };
|
|
3173
3173
|
nonbreaking_default = definePlugin({
|
|
3174
3174
|
name: "nonbreaking",
|
|
3175
3175
|
toolbar: "nonbreaking",
|
|
3176
3176
|
prosemirrorPlugins: () => [
|
|
3177
|
-
(0,
|
|
3177
|
+
(0, import_prosemirror_keymap4.keymap)({
|
|
3178
3178
|
"Mod-Shift-Space": (state, dispatch) => {
|
|
3179
3179
|
dispatch?.(state.tr.insertText(NBSP).scrollIntoView());
|
|
3180
3180
|
return true;
|
|
@@ -3182,7 +3182,7 @@ var init_nonbreaking = __esm({
|
|
|
3182
3182
|
})
|
|
3183
3183
|
],
|
|
3184
3184
|
setup(editor) {
|
|
3185
|
-
const { title } = pickLabels(editor,
|
|
3185
|
+
const { title } = pickLabels(editor, LABELS10);
|
|
3186
3186
|
const spec = {
|
|
3187
3187
|
icon: ICON7,
|
|
3188
3188
|
tooltip: title,
|
|
@@ -3227,12 +3227,12 @@ function linkifyBefore(state, tr, end) {
|
|
|
3227
3227
|
tr.addMark(from, to, link.create({ href }));
|
|
3228
3228
|
return true;
|
|
3229
3229
|
}
|
|
3230
|
-
var import_prosemirror_inputrules,
|
|
3230
|
+
var import_prosemirror_inputrules, import_prosemirror_state8, URL_AT_END, SINGLE_URL, autolink_default;
|
|
3231
3231
|
var init_autolink = __esm({
|
|
3232
3232
|
"src/plugins/autolink.ts"() {
|
|
3233
3233
|
"use strict";
|
|
3234
3234
|
import_prosemirror_inputrules = require("prosemirror-inputrules");
|
|
3235
|
-
|
|
3235
|
+
import_prosemirror_state8 = require("prosemirror-state");
|
|
3236
3236
|
init_commands();
|
|
3237
3237
|
init_plugins();
|
|
3238
3238
|
init_url();
|
|
@@ -3253,7 +3253,7 @@ var init_autolink = __esm({
|
|
|
3253
3253
|
})
|
|
3254
3254
|
]
|
|
3255
3255
|
}),
|
|
3256
|
-
new
|
|
3256
|
+
new import_prosemirror_state8.Plugin({
|
|
3257
3257
|
/**
|
|
3258
3258
|
* Enter после адреса. Раскладка клавиш ядра обрабатывает Enter раньше плагинов, поэтому смотрим
|
|
3259
3259
|
* на результат: курсор в начале нового блока, а предыдущий блок заканчивается адресом.
|
|
@@ -3262,14 +3262,14 @@ var init_autolink = __esm({
|
|
|
3262
3262
|
if (!editor.isAllowed("link") || !transactions.some((tr2) => tr2.docChanged)) return null;
|
|
3263
3263
|
const { $from, empty } = state.selection;
|
|
3264
3264
|
if (!empty || $from.parentOffset !== 0 || $from.depth < 1) return null;
|
|
3265
|
-
const prev =
|
|
3265
|
+
const prev = import_prosemirror_state8.Selection.findFrom(state.doc.resolve($from.before()), -1, true);
|
|
3266
3266
|
if (!prev || !prev.empty || prev.$from.parentOffset !== prev.$from.parent.content.size)
|
|
3267
3267
|
return null;
|
|
3268
3268
|
const tr = state.tr;
|
|
3269
3269
|
return linkifyBefore(state, tr, prev.from) ? tr : null;
|
|
3270
3270
|
}
|
|
3271
3271
|
}),
|
|
3272
|
-
new
|
|
3272
|
+
new import_prosemirror_state8.Plugin({
|
|
3273
3273
|
props: {
|
|
3274
3274
|
handlePaste(view, event) {
|
|
3275
3275
|
const { state } = view;
|
|
@@ -3304,14 +3304,14 @@ function storage() {
|
|
|
3304
3304
|
return null;
|
|
3305
3305
|
}
|
|
3306
3306
|
}
|
|
3307
|
-
var ICON8,
|
|
3307
|
+
var ICON8, LABELS11, autosave_default;
|
|
3308
3308
|
var init_autosave = __esm({
|
|
3309
3309
|
"src/plugins/autosave.ts"() {
|
|
3310
3310
|
"use strict";
|
|
3311
3311
|
init_plugins();
|
|
3312
3312
|
init_shared();
|
|
3313
3313
|
ICON8 = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l3 2"/></svg>';
|
|
3314
|
-
|
|
3314
|
+
LABELS11 = {
|
|
3315
3315
|
en: {
|
|
3316
3316
|
restore: "Restore last draft",
|
|
3317
3317
|
found: "An unsaved draft was found. Use \u201CRestore last draft\u201D to bring it back.",
|
|
@@ -3328,7 +3328,7 @@ var init_autosave = __esm({
|
|
|
3328
3328
|
toolbar: "restoredraft",
|
|
3329
3329
|
setup(editor) {
|
|
3330
3330
|
const options = editor.options.pluginOptions?.autosave ?? {};
|
|
3331
|
-
const labels = pickLabels(editor,
|
|
3331
|
+
const labels = pickLabels(editor, LABELS11);
|
|
3332
3332
|
const store = storage();
|
|
3333
3333
|
const key3 = options.key ?? `novaprose-draft:${typeof location === "undefined" ? "" : location.pathname}:${editor.options.element.id || "editor"}`;
|
|
3334
3334
|
const delay = options.delay ?? 1e3;
|
|
@@ -3427,19 +3427,19 @@ var visualblocks_exports = {};
|
|
|
3427
3427
|
__export(visualblocks_exports, {
|
|
3428
3428
|
default: () => visualblocks_default
|
|
3429
3429
|
});
|
|
3430
|
-
var ICON9,
|
|
3430
|
+
var ICON9, LABELS12, visualblocks_default;
|
|
3431
3431
|
var init_visualblocks = __esm({
|
|
3432
3432
|
"src/plugins/visualblocks.ts"() {
|
|
3433
3433
|
"use strict";
|
|
3434
3434
|
init_plugins();
|
|
3435
3435
|
init_shared();
|
|
3436
3436
|
ICON9 = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="3 3" aria-hidden="true"><rect x="3" y="4" width="18" height="6" rx="1"/><rect x="3" y="14" width="18" height="6" rx="1"/></svg>';
|
|
3437
|
-
|
|
3437
|
+
LABELS12 = { en: { title: "Show blocks" }, ru: { title: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0431\u043B\u043E\u043A\u0438" } };
|
|
3438
3438
|
visualblocks_default = definePlugin({
|
|
3439
3439
|
name: "visualblocks",
|
|
3440
3440
|
toolbar: "visualblocks",
|
|
3441
3441
|
setup(editor) {
|
|
3442
|
-
const { title } = pickLabels(editor,
|
|
3442
|
+
const { title } = pickLabels(editor, LABELS12);
|
|
3443
3443
|
const options = editor.options.pluginOptions?.visualblocks ?? {};
|
|
3444
3444
|
const isOn = () => editor.root.classList.contains("nova-visualblocks");
|
|
3445
3445
|
const toggle = () => {
|
|
@@ -3490,7 +3490,7 @@ function setDir(dir) {
|
|
|
3490
3490
|
return true;
|
|
3491
3491
|
};
|
|
3492
3492
|
}
|
|
3493
|
-
var ICONS,
|
|
3493
|
+
var ICONS, LABELS13, directionality_default;
|
|
3494
3494
|
var init_directionality = __esm({
|
|
3495
3495
|
"src/plugins/directionality.ts"() {
|
|
3496
3496
|
"use strict";
|
|
@@ -3501,7 +3501,7 @@ var init_directionality = __esm({
|
|
|
3501
3501
|
ltr: '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 4v10M13 4v10M7 4h9M5 19h14l-3-3M19 19l-3 3"/></svg>',
|
|
3502
3502
|
rtl: '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M11 4v10M15 4v10M9 4h9M19 19H5l3-3M5 19l3 3"/></svg>'
|
|
3503
3503
|
};
|
|
3504
|
-
|
|
3504
|
+
LABELS13 = {
|
|
3505
3505
|
en: { ltr: "Left to right", rtl: "Right to left" },
|
|
3506
3506
|
ru: { ltr: "\u0421\u043B\u0435\u0432\u0430 \u043D\u0430\u043F\u0440\u0430\u0432\u043E", rtl: "\u0421\u043F\u0440\u0430\u0432\u0430 \u043D\u0430\u043B\u0435\u0432\u043E" }
|
|
3507
3507
|
};
|
|
@@ -3509,7 +3509,7 @@ var init_directionality = __esm({
|
|
|
3509
3509
|
name: "directionality",
|
|
3510
3510
|
toolbar: "ltr rtl",
|
|
3511
3511
|
setup(editor) {
|
|
3512
|
-
const labels = pickLabels(editor,
|
|
3512
|
+
const labels = pickLabels(editor, LABELS13);
|
|
3513
3513
|
for (const dir of ["ltr", "rtl"]) {
|
|
3514
3514
|
const isActive = () => currentDir(editor) === dir;
|
|
3515
3515
|
const onAction = () => {
|
|
@@ -3563,7 +3563,7 @@ function applyStyle(editor, kind, style, fallback) {
|
|
|
3563
3563
|
);
|
|
3564
3564
|
editor.focus();
|
|
3565
3565
|
}
|
|
3566
|
-
var
|
|
3566
|
+
var LABELS14, advlist_default;
|
|
3567
3567
|
var init_advlist = __esm({
|
|
3568
3568
|
"src/plugins/advlist.ts"() {
|
|
3569
3569
|
"use strict";
|
|
@@ -3571,7 +3571,7 @@ var init_advlist = __esm({
|
|
|
3571
3571
|
init_plugins();
|
|
3572
3572
|
init_schema();
|
|
3573
3573
|
init_shared();
|
|
3574
|
-
|
|
3574
|
+
LABELS14 = {
|
|
3575
3575
|
en: {
|
|
3576
3576
|
disc: "Default",
|
|
3577
3577
|
circle: "Circle",
|
|
@@ -3598,7 +3598,7 @@ var init_advlist = __esm({
|
|
|
3598
3598
|
advlist_default = definePlugin({
|
|
3599
3599
|
name: "advlist",
|
|
3600
3600
|
setup(editor) {
|
|
3601
|
-
const labels = pickLabels(editor,
|
|
3601
|
+
const labels = pickLabels(editor, LABELS14);
|
|
3602
3602
|
const options = editor.options.pluginOptions?.advlist ?? {};
|
|
3603
3603
|
const lists = [
|
|
3604
3604
|
{
|
|
@@ -4078,14 +4078,14 @@ function buildKeymap(resolve = (name) => commands[name]) {
|
|
|
4078
4078
|
"Shift-Tab": commands.outdent
|
|
4079
4079
|
};
|
|
4080
4080
|
if (!mac) keys["Mod-y"] = byName(resolve, "redo");
|
|
4081
|
-
return [(0,
|
|
4081
|
+
return [(0, import_prosemirror_keymap5.keymap)(keys), (0, import_prosemirror_keymap5.keymap)(import_prosemirror_commands2.baseKeymap)];
|
|
4082
4082
|
}
|
|
4083
|
-
var import_prosemirror_commands2,
|
|
4083
|
+
var import_prosemirror_commands2, import_prosemirror_keymap5, import_prosemirror_schema_list2, mac, insertHardBreak, byName;
|
|
4084
4084
|
var init_keymap = __esm({
|
|
4085
4085
|
"src/keymap.ts"() {
|
|
4086
4086
|
"use strict";
|
|
4087
4087
|
import_prosemirror_commands2 = require("prosemirror-commands");
|
|
4088
|
-
|
|
4088
|
+
import_prosemirror_keymap5 = require("prosemirror-keymap");
|
|
4089
4089
|
import_prosemirror_schema_list2 = require("prosemirror-schema-list");
|
|
4090
4090
|
init_commands();
|
|
4091
4091
|
mac = typeof navigator !== "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
@@ -4653,7 +4653,7 @@ function htmlToPlainText(html) {
|
|
|
4653
4653
|
}
|
|
4654
4654
|
function pastePlugin(editor) {
|
|
4655
4655
|
let reentrant = false;
|
|
4656
|
-
return new
|
|
4656
|
+
return new import_prosemirror_state9.Plugin({
|
|
4657
4657
|
key,
|
|
4658
4658
|
props: {
|
|
4659
4659
|
/**
|
|
@@ -4665,7 +4665,7 @@ function pastePlugin(editor) {
|
|
|
4665
4665
|
const { selection } = view.state;
|
|
4666
4666
|
const parent = selection.$from.parent;
|
|
4667
4667
|
if (slice.openStart > 0 && selection.empty && parent.isTextblock && parent.content.size === 0 && slice.content.firstChild?.isBlock) {
|
|
4668
|
-
return new
|
|
4668
|
+
return new import_prosemirror_model4.Slice(slice.content, 0, slice.openEnd);
|
|
4669
4669
|
}
|
|
4670
4670
|
return slice;
|
|
4671
4671
|
},
|
|
@@ -4712,15 +4712,15 @@ function pastePlugin(editor) {
|
|
|
4712
4712
|
}
|
|
4713
4713
|
});
|
|
4714
4714
|
}
|
|
4715
|
-
var
|
|
4715
|
+
var import_prosemirror_model4, import_prosemirror_state9, key;
|
|
4716
4716
|
var init_paste = __esm({
|
|
4717
4717
|
"src/paste.ts"() {
|
|
4718
4718
|
"use strict";
|
|
4719
|
-
|
|
4720
|
-
|
|
4719
|
+
import_prosemirror_model4 = require("prosemirror-model");
|
|
4720
|
+
import_prosemirror_state9 = require("prosemirror-state");
|
|
4721
4721
|
init_paste_office();
|
|
4722
4722
|
init_paste_rtf();
|
|
4723
|
-
key = new
|
|
4723
|
+
key = new import_prosemirror_state9.PluginKey("nova-paste");
|
|
4724
4724
|
}
|
|
4725
4725
|
});
|
|
4726
4726
|
|
|
@@ -4737,19 +4737,19 @@ function preprocessDOM(root) {
|
|
|
4737
4737
|
function parserFor(target) {
|
|
4738
4738
|
let parser = parsers.get(target);
|
|
4739
4739
|
if (!parser) {
|
|
4740
|
-
parser = new NovaDOMParser(target,
|
|
4740
|
+
parser = new NovaDOMParser(target, import_prosemirror_model5.DOMParser.fromSchema(target).rules);
|
|
4741
4741
|
parsers.set(target, parser);
|
|
4742
4742
|
}
|
|
4743
4743
|
return parser;
|
|
4744
4744
|
}
|
|
4745
|
-
var
|
|
4745
|
+
var import_prosemirror_model5, CELL_BG_ATTR, NovaDOMParser, parsers, novaParser;
|
|
4746
4746
|
var init_parser = __esm({
|
|
4747
4747
|
"src/parser.ts"() {
|
|
4748
4748
|
"use strict";
|
|
4749
|
-
|
|
4749
|
+
import_prosemirror_model5 = require("prosemirror-model");
|
|
4750
4750
|
init_schema();
|
|
4751
4751
|
CELL_BG_ATTR = "data-nova-cell-bg";
|
|
4752
|
-
NovaDOMParser = class extends
|
|
4752
|
+
NovaDOMParser = class extends import_prosemirror_model5.DOMParser {
|
|
4753
4753
|
parse(dom, options) {
|
|
4754
4754
|
preprocessDOM(dom);
|
|
4755
4755
|
return super.parse(dom, options);
|
|
@@ -5023,7 +5023,7 @@ function printContent(editor) {
|
|
|
5023
5023
|
style.textContent = PRINT_CSS;
|
|
5024
5024
|
doc.head.append(style);
|
|
5025
5025
|
doc.body.append(
|
|
5026
|
-
|
|
5026
|
+
import_prosemirror_model6.DOMSerializer.fromSchema(editor.schema).serializeFragment(editor.view.state.doc.content, {
|
|
5027
5027
|
document: doc
|
|
5028
5028
|
})
|
|
5029
5029
|
);
|
|
@@ -5073,7 +5073,7 @@ function registerMenuItems(editor) {
|
|
|
5073
5073
|
text: t("selectAll"),
|
|
5074
5074
|
shortcut: "Mod-a",
|
|
5075
5075
|
onAction: (e) => {
|
|
5076
|
-
e.view.dispatch(e.view.state.tr.setSelection(new
|
|
5076
|
+
e.view.dispatch(e.view.state.tr.setSelection(new import_prosemirror_state10.AllSelection(e.view.state.doc)));
|
|
5077
5077
|
e.focus();
|
|
5078
5078
|
}
|
|
5079
5079
|
});
|
|
@@ -5090,12 +5090,12 @@ function registerMenuItems(editor) {
|
|
|
5090
5090
|
onAction: (e) => openInsertTableDialog(e)
|
|
5091
5091
|
});
|
|
5092
5092
|
}
|
|
5093
|
-
var
|
|
5093
|
+
var import_prosemirror_model6, import_prosemirror_state10, PRINT_CSS;
|
|
5094
5094
|
var init_menu_items = __esm({
|
|
5095
5095
|
"src/ui/menu-items.ts"() {
|
|
5096
5096
|
"use strict";
|
|
5097
|
-
|
|
5098
|
-
|
|
5097
|
+
import_prosemirror_model6 = require("prosemirror-model");
|
|
5098
|
+
import_prosemirror_state10 = require("prosemirror-state");
|
|
5099
5099
|
init_table();
|
|
5100
5100
|
init_dialog();
|
|
5101
5101
|
init_dom();
|
|
@@ -5154,7 +5154,7 @@ function flattenItems(fragment) {
|
|
|
5154
5154
|
fragment.forEach((item) => {
|
|
5155
5155
|
if (item.type === item.type.schema.nodes.list_item)
|
|
5156
5156
|
item.content.forEach((block) => out.push(block));
|
|
5157
|
-
else out.push(...asBlocks(
|
|
5157
|
+
else out.push(...asBlocks(import_prosemirror_model7.Fragment.from(item)));
|
|
5158
5158
|
});
|
|
5159
5159
|
return out;
|
|
5160
5160
|
}
|
|
@@ -5164,7 +5164,7 @@ function flattenTable(fragment) {
|
|
|
5164
5164
|
return out;
|
|
5165
5165
|
}
|
|
5166
5166
|
function contentRulesPlugin(rules) {
|
|
5167
|
-
return new
|
|
5167
|
+
return new import_prosemirror_state11.Plugin({
|
|
5168
5168
|
key: key2,
|
|
5169
5169
|
appendTransaction(transactions, oldState, newState) {
|
|
5170
5170
|
if (!transactions.some((tr2) => tr2.docChanged)) return null;
|
|
@@ -5195,12 +5195,12 @@ function contentRulesPlugin(rules) {
|
|
|
5195
5195
|
}
|
|
5196
5196
|
});
|
|
5197
5197
|
}
|
|
5198
|
-
var
|
|
5198
|
+
var import_prosemirror_model7, import_prosemirror_state11, ALIASES, KNOWN_TAGS, KNOWN_STYLES, REQUIREMENTS, ContentRules, key2;
|
|
5199
5199
|
var init_content_rules = __esm({
|
|
5200
5200
|
"src/content-rules.ts"() {
|
|
5201
5201
|
"use strict";
|
|
5202
|
-
|
|
5203
|
-
|
|
5202
|
+
import_prosemirror_model7 = require("prosemirror-model");
|
|
5203
|
+
import_prosemirror_state11 = require("prosemirror-state");
|
|
5204
5204
|
ALIASES = {
|
|
5205
5205
|
b: "strong",
|
|
5206
5206
|
i: "em",
|
|
@@ -5451,7 +5451,7 @@ var init_content_rules = __esm({
|
|
|
5451
5451
|
normalizeChildren(fragment) {
|
|
5452
5452
|
const out = [];
|
|
5453
5453
|
fragment.forEach((child) => out.push(...this.normalize(child)));
|
|
5454
|
-
return
|
|
5454
|
+
return import_prosemirror_model7.Fragment.from(out);
|
|
5455
5455
|
}
|
|
5456
5456
|
/** Нормализовать документ целиком (начальное содержимое). */
|
|
5457
5457
|
normalizeDoc(doc) {
|
|
@@ -5460,7 +5460,7 @@ var init_content_rules = __esm({
|
|
|
5460
5460
|
return doc.type.createAndFill(null, content.size ? content : schema2.nodes.paragraph.create());
|
|
5461
5461
|
}
|
|
5462
5462
|
};
|
|
5463
|
-
key2 = new
|
|
5463
|
+
key2 = new import_prosemirror_state11.PluginKey("nova-content-rules");
|
|
5464
5464
|
}
|
|
5465
5465
|
});
|
|
5466
5466
|
|
|
@@ -5498,7 +5498,7 @@ function indexFrom(matches, pos) {
|
|
|
5498
5498
|
return i < 0 ? 0 : i;
|
|
5499
5499
|
}
|
|
5500
5500
|
function searchPlugin() {
|
|
5501
|
-
return new
|
|
5501
|
+
return new import_prosemirror_state12.Plugin({
|
|
5502
5502
|
key: searchKey,
|
|
5503
5503
|
state: {
|
|
5504
5504
|
init: () => EMPTY,
|
|
@@ -5523,10 +5523,10 @@ function searchPlugin() {
|
|
|
5523
5523
|
decorations(state) {
|
|
5524
5524
|
const search = searchKey.getState(state);
|
|
5525
5525
|
if (!search?.matches.length) return null;
|
|
5526
|
-
return
|
|
5526
|
+
return import_prosemirror_view3.DecorationSet.create(
|
|
5527
5527
|
state.doc,
|
|
5528
5528
|
search.matches.map(
|
|
5529
|
-
(m, i) =>
|
|
5529
|
+
(m, i) => import_prosemirror_view3.Decoration.inline(m.from, m.to, {
|
|
5530
5530
|
class: i === search.current ? "nova-search-match nova-search-current" : "nova-search-match"
|
|
5531
5531
|
})
|
|
5532
5532
|
)
|
|
@@ -5545,7 +5545,7 @@ function setSearch(options) {
|
|
|
5545
5545
|
};
|
|
5546
5546
|
}
|
|
5547
5547
|
function gotoMatch(tr, match, index) {
|
|
5548
|
-
return tr.setMeta(searchKey, { type: "goto", index }).setSelection(
|
|
5548
|
+
return tr.setMeta(searchKey, { type: "goto", index }).setSelection(import_prosemirror_state12.TextSelection.create(tr.doc, match.from, match.to)).scrollIntoView();
|
|
5549
5549
|
}
|
|
5550
5550
|
function findNext(dir = 1) {
|
|
5551
5551
|
return (state, dispatch) => {
|
|
@@ -5568,7 +5568,7 @@ function replaceCurrent(replacement) {
|
|
|
5568
5568
|
if (replacement) tr.replaceWith(match.from, match.to, state.schema.text(replacement, marks2));
|
|
5569
5569
|
else tr.delete(match.from, match.to);
|
|
5570
5570
|
const after = tr.mapping.map(match.to);
|
|
5571
|
-
dispatch(tr.setSelection(
|
|
5571
|
+
dispatch(tr.setSelection(import_prosemirror_state12.TextSelection.create(tr.doc, after)).scrollIntoView());
|
|
5572
5572
|
}
|
|
5573
5573
|
return true;
|
|
5574
5574
|
};
|
|
@@ -5590,15 +5590,15 @@ function replaceAll(replacement) {
|
|
|
5590
5590
|
return true;
|
|
5591
5591
|
};
|
|
5592
5592
|
}
|
|
5593
|
-
var
|
|
5593
|
+
var import_prosemirror_state12, import_prosemirror_view3, MAX_MATCHES, LEAF, searchKey, EMPTY, clearSearch;
|
|
5594
5594
|
var init_search = __esm({
|
|
5595
5595
|
"src/search.ts"() {
|
|
5596
5596
|
"use strict";
|
|
5597
|
-
|
|
5598
|
-
|
|
5597
|
+
import_prosemirror_state12 = require("prosemirror-state");
|
|
5598
|
+
import_prosemirror_view3 = require("prosemirror-view");
|
|
5599
5599
|
MAX_MATCHES = 1e4;
|
|
5600
5600
|
LEAF = "\uFFFC";
|
|
5601
|
-
searchKey = new
|
|
5601
|
+
searchKey = new import_prosemirror_state12.PluginKey("nova-search");
|
|
5602
5602
|
EMPTY = {
|
|
5603
5603
|
query: "",
|
|
5604
5604
|
caseSensitive: false,
|
|
@@ -5827,7 +5827,7 @@ function openPreview(editor) {
|
|
|
5827
5827
|
const { t } = editor.ui;
|
|
5828
5828
|
const content = h("div", { className: "nova-prosemirror nova-preview" });
|
|
5829
5829
|
content.append(
|
|
5830
|
-
|
|
5830
|
+
import_prosemirror_model8.DOMSerializer.fromSchema(editor.schema).serializeFragment(editor.view.state.doc.content)
|
|
5831
5831
|
);
|
|
5832
5832
|
content.querySelectorAll("a[href]").forEach((a) => {
|
|
5833
5833
|
a.setAttribute("target", "_blank");
|
|
@@ -5896,11 +5896,11 @@ function openHelp(editor) {
|
|
|
5896
5896
|
}
|
|
5897
5897
|
editor.ui.openDialog({ title: t("help"), body, size: "large", cancelLabel: t("dialog.close") });
|
|
5898
5898
|
}
|
|
5899
|
-
var
|
|
5899
|
+
var import_prosemirror_model8, SHORTCUTS;
|
|
5900
5900
|
var init_views = __esm({
|
|
5901
5901
|
"src/ui/views.ts"() {
|
|
5902
5902
|
"use strict";
|
|
5903
|
-
|
|
5903
|
+
import_prosemirror_model8 = require("prosemirror-model");
|
|
5904
5904
|
init_dom();
|
|
5905
5905
|
SHORTCUTS = [
|
|
5906
5906
|
{
|
|
@@ -7027,8 +7027,8 @@ var init_popover = __esm({
|
|
|
7027
7027
|
|
|
7028
7028
|
// src/ui/link-bubble.ts
|
|
7029
7029
|
function linkBubblePlugin(editor) {
|
|
7030
|
-
return new
|
|
7031
|
-
key: new
|
|
7030
|
+
return new import_prosemirror_state13.Plugin({
|
|
7031
|
+
key: new import_prosemirror_state13.PluginKey("nova-link-bubble"),
|
|
7032
7032
|
view(view) {
|
|
7033
7033
|
const { t } = editor.ui;
|
|
7034
7034
|
const anchor = h("a", {
|
|
@@ -7109,11 +7109,11 @@ function linkBubblePlugin(editor) {
|
|
|
7109
7109
|
}
|
|
7110
7110
|
});
|
|
7111
7111
|
}
|
|
7112
|
-
var
|
|
7112
|
+
var import_prosemirror_state13;
|
|
7113
7113
|
var init_link_bubble = __esm({
|
|
7114
7114
|
"src/ui/link-bubble.ts"() {
|
|
7115
7115
|
"use strict";
|
|
7116
|
-
|
|
7116
|
+
import_prosemirror_state13 = require("prosemirror-state");
|
|
7117
7117
|
init_commands();
|
|
7118
7118
|
init_link();
|
|
7119
7119
|
init_commands();
|
|
@@ -7438,8 +7438,8 @@ var init_toolbar = __esm({
|
|
|
7438
7438
|
|
|
7439
7439
|
// src/ui/context-toolbar.ts
|
|
7440
7440
|
function contextToolbarPlugin(editor) {
|
|
7441
|
-
return new
|
|
7442
|
-
key: new
|
|
7441
|
+
return new import_prosemirror_state14.Plugin({
|
|
7442
|
+
key: new import_prosemirror_state14.PluginKey("nova-context-toolbar"),
|
|
7443
7443
|
view(view) {
|
|
7444
7444
|
const container = h("div", {
|
|
7445
7445
|
className: "nova-bubble nova-context-toolbar",
|
|
@@ -7475,7 +7475,7 @@ function contextToolbarPlugin(editor) {
|
|
|
7475
7475
|
};
|
|
7476
7476
|
const anchorRect = (spec) => {
|
|
7477
7477
|
const { selection } = view.state;
|
|
7478
|
-
if ((spec.position ?? "node") === "node" && selection instanceof
|
|
7478
|
+
if ((spec.position ?? "node") === "node" && selection instanceof import_prosemirror_state14.NodeSelection) {
|
|
7479
7479
|
const dom = view.nodeDOM(selection.from);
|
|
7480
7480
|
return dom?.getBoundingClientRect() ?? null;
|
|
7481
7481
|
}
|
|
@@ -7571,11 +7571,11 @@ function focusContextToolbar(editor) {
|
|
|
7571
7571
|
button?.focus();
|
|
7572
7572
|
return !!button;
|
|
7573
7573
|
}
|
|
7574
|
-
var
|
|
7574
|
+
var import_prosemirror_state14;
|
|
7575
7575
|
var init_context_toolbar = __esm({
|
|
7576
7576
|
"src/ui/context-toolbar.ts"() {
|
|
7577
7577
|
"use strict";
|
|
7578
|
-
|
|
7578
|
+
import_prosemirror_state14 = require("prosemirror-state");
|
|
7579
7579
|
init_dom();
|
|
7580
7580
|
init_popover();
|
|
7581
7581
|
init_toolbar();
|
|
@@ -7583,11 +7583,11 @@ var init_context_toolbar = __esm({
|
|
|
7583
7583
|
});
|
|
7584
7584
|
|
|
7585
7585
|
// src/ui/image-view.ts
|
|
7586
|
-
var
|
|
7586
|
+
var import_prosemirror_state15, MIN_WIDTH, ImageView;
|
|
7587
7587
|
var init_image_view = __esm({
|
|
7588
7588
|
"src/ui/image-view.ts"() {
|
|
7589
7589
|
"use strict";
|
|
7590
|
-
|
|
7590
|
+
import_prosemirror_state15 = require("prosemirror-state");
|
|
7591
7591
|
init_schema();
|
|
7592
7592
|
init_url();
|
|
7593
7593
|
MIN_WIDTH = 24;
|
|
@@ -7689,7 +7689,7 @@ var init_image_view = __esm({
|
|
|
7689
7689
|
width,
|
|
7690
7690
|
height: Math.round(width * ratio)
|
|
7691
7691
|
});
|
|
7692
|
-
tr.setSelection(
|
|
7692
|
+
tr.setSelection(import_prosemirror_state15.NodeSelection.create(tr.doc, pos));
|
|
7693
7693
|
this.view.dispatch(tr);
|
|
7694
7694
|
};
|
|
7695
7695
|
handle.addEventListener("pointermove", onMove);
|
|
@@ -7821,8 +7821,8 @@ function autocompleterPlugin(editor) {
|
|
|
7821
7821
|
renderItems(view);
|
|
7822
7822
|
});
|
|
7823
7823
|
};
|
|
7824
|
-
return new
|
|
7825
|
-
key: new
|
|
7824
|
+
return new import_prosemirror_state16.Plugin({
|
|
7825
|
+
key: new import_prosemirror_state16.PluginKey("nova-autocompleter"),
|
|
7826
7826
|
view(view) {
|
|
7827
7827
|
list = h("div", {
|
|
7828
7828
|
className: "nova-popover nova-ac",
|
|
@@ -7869,11 +7869,11 @@ function autocompleterPlugin(editor) {
|
|
|
7869
7869
|
}
|
|
7870
7870
|
});
|
|
7871
7871
|
}
|
|
7872
|
-
var
|
|
7872
|
+
var import_prosemirror_state16, MAX_QUERY;
|
|
7873
7873
|
var init_autocompleter = __esm({
|
|
7874
7874
|
"src/ui/autocompleter.ts"() {
|
|
7875
7875
|
"use strict";
|
|
7876
|
-
|
|
7876
|
+
import_prosemirror_state16 = require("prosemirror-state");
|
|
7877
7877
|
init_dom();
|
|
7878
7878
|
init_popover();
|
|
7879
7879
|
MAX_QUERY = 30;
|
|
@@ -8399,7 +8399,7 @@ function reportPluginError(message, error) {
|
|
|
8399
8399
|
console.error(`[nova] ${message}`, ...error === void 0 ? [] : [error]);
|
|
8400
8400
|
}
|
|
8401
8401
|
function parseContent(schema2, content) {
|
|
8402
|
-
if (typeof content !== "string") return
|
|
8402
|
+
if (typeof content !== "string") return import_prosemirror_model9.Node.fromJSON(schema2, content);
|
|
8403
8403
|
const container = document.createElement("div");
|
|
8404
8404
|
const template = document.createElement("template");
|
|
8405
8405
|
template.innerHTML = content;
|
|
@@ -8409,17 +8409,17 @@ function parseContent(schema2, content) {
|
|
|
8409
8409
|
function createEditor(options) {
|
|
8410
8410
|
return new Editor(options);
|
|
8411
8411
|
}
|
|
8412
|
-
var import_prosemirror_dropcursor, import_prosemirror_gapcursor, import_prosemirror_history2,
|
|
8412
|
+
var import_prosemirror_dropcursor, import_prosemirror_gapcursor, import_prosemirror_history2, import_prosemirror_keymap6, import_prosemirror_model9, import_prosemirror_state17, import_prosemirror_view4, htmlSerializer, Editor;
|
|
8413
8413
|
var init_editor = __esm({
|
|
8414
8414
|
"src/editor.ts"() {
|
|
8415
8415
|
"use strict";
|
|
8416
8416
|
import_prosemirror_dropcursor = require("prosemirror-dropcursor");
|
|
8417
8417
|
import_prosemirror_gapcursor = require("prosemirror-gapcursor");
|
|
8418
8418
|
import_prosemirror_history2 = require("prosemirror-history");
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8419
|
+
import_prosemirror_keymap6 = require("prosemirror-keymap");
|
|
8420
|
+
import_prosemirror_model9 = require("prosemirror-model");
|
|
8421
|
+
import_prosemirror_state17 = require("prosemirror-state");
|
|
8422
|
+
import_prosemirror_view4 = require("prosemirror-view");
|
|
8423
8423
|
init_commands();
|
|
8424
8424
|
init_i18n();
|
|
8425
8425
|
init_image();
|
|
@@ -8462,6 +8462,7 @@ var init_editor = __esm({
|
|
|
8462
8462
|
mode;
|
|
8463
8463
|
pluginsByName = /* @__PURE__ */ new Map();
|
|
8464
8464
|
commandOverrides = /* @__PURE__ */ new Map();
|
|
8465
|
+
transactionTransforms = [];
|
|
8465
8466
|
cleanups = [];
|
|
8466
8467
|
/** Ограничения контента (validElements/invalidElements/validStyles) или null — без ограничений. */
|
|
8467
8468
|
contentRules;
|
|
@@ -8503,7 +8504,7 @@ var init_editor = __esm({
|
|
|
8503
8504
|
createTranslator(options.language, options.translations),
|
|
8504
8505
|
() => this.focus()
|
|
8505
8506
|
);
|
|
8506
|
-
const editorKeys = (0,
|
|
8507
|
+
const editorKeys = (0, import_prosemirror_keymap6.keymap)({
|
|
8507
8508
|
"Mod-k": () => (openLinkDialog(this), true),
|
|
8508
8509
|
// Стандартное сочетание доступности: перейти из текста на панель инструментов.
|
|
8509
8510
|
"Alt-F9": () => {
|
|
@@ -8540,7 +8541,7 @@ var init_editor = __esm({
|
|
|
8540
8541
|
this.schema = this.buildSchema(syncPlugins);
|
|
8541
8542
|
syncPlugins.forEach((plugin) => this.registerCommands(plugin));
|
|
8542
8543
|
const initialDoc = parseContent(this.schema, options.content ?? "");
|
|
8543
|
-
const state =
|
|
8544
|
+
const state = import_prosemirror_state17.EditorState.create({
|
|
8544
8545
|
doc: this.contentRules ? this.contentRules.normalizeDoc(initialDoc) : initialDoc,
|
|
8545
8546
|
plugins: [
|
|
8546
8547
|
// Первым: при открытом списке Enter/Tab/стрелки принадлежат автокомплитеру, а не раскладке клавиш.
|
|
@@ -8567,7 +8568,7 @@ var init_editor = __esm({
|
|
|
8567
8568
|
this.editable = options.editable ?? true;
|
|
8568
8569
|
this.pasteAsText = options.pasteAsText ?? false;
|
|
8569
8570
|
const handleTransaction = this.handleTransaction.bind(this);
|
|
8570
|
-
this.view = new
|
|
8571
|
+
this.view = new import_prosemirror_view4.EditorView(contentHost, {
|
|
8571
8572
|
state,
|
|
8572
8573
|
editable: () => this.editable,
|
|
8573
8574
|
attributes: {
|
|
@@ -8730,6 +8731,7 @@ var init_editor = __esm({
|
|
|
8730
8731
|
}
|
|
8731
8732
|
handleTransaction(tr, view = this.view) {
|
|
8732
8733
|
if (view.isDestroyed) return;
|
|
8734
|
+
for (const transform of this.transactionTransforms) tr = transform(tr, view.state, this);
|
|
8733
8735
|
view.updateState(view.state.apply(tr));
|
|
8734
8736
|
if (!this.view) return;
|
|
8735
8737
|
this.toolbar?.update();
|
|
@@ -8775,6 +8777,7 @@ var init_editor = __esm({
|
|
|
8775
8777
|
for (const [name, command] of Object.entries(plugin.commands ?? {})) {
|
|
8776
8778
|
if (command) this.commandOverrides.set(name, command);
|
|
8777
8779
|
}
|
|
8780
|
+
if (plugin.transformTransaction) this.transactionTransforms.push(plugin.transformTransaction);
|
|
8778
8781
|
}
|
|
8779
8782
|
exec(command) {
|
|
8780
8783
|
const cmd = typeof command === "string" ? this.resolveCommand(command) : command;
|
|
@@ -9009,11 +9012,11 @@ __export(revisionhistory_exports, {
|
|
|
9009
9012
|
default: () => revisionhistory_default
|
|
9010
9013
|
});
|
|
9011
9014
|
function toDoc(editor, content) {
|
|
9012
|
-
const html = typeof content === "string" ? content : serializer.serializeFragment(
|
|
9015
|
+
const html = typeof content === "string" ? content : serializer.serializeFragment(import_prosemirror_model10.Node.fromJSON(editor.schema, content).content);
|
|
9013
9016
|
return parseContent(editor.schema, html);
|
|
9014
9017
|
}
|
|
9015
9018
|
function openHistory(editor, options) {
|
|
9016
|
-
const labels = pickLabels(editor,
|
|
9019
|
+
const labels = pickLabels(editor, LABELS15);
|
|
9017
9020
|
const lang = editor.options.language ?? "en";
|
|
9018
9021
|
const dateFormat = new Intl.DateTimeFormat(lang, { dateStyle: "medium", timeStyle: "short" });
|
|
9019
9022
|
const titleId = uniqueId("nova-history-title");
|
|
@@ -9062,29 +9065,29 @@ function openHistory(editor, options) {
|
|
|
9062
9065
|
)
|
|
9063
9066
|
);
|
|
9064
9067
|
const decorationsFor = (doc) => {
|
|
9065
|
-
if (!highlight || !selected) return
|
|
9068
|
+
if (!highlight || !selected) return import_prosemirror_view5.DecorationSet.empty;
|
|
9066
9069
|
const { added, removed } = diffDocs(doc, editor.view.state.doc);
|
|
9067
9070
|
const decorations = [
|
|
9068
|
-
...added.map((r) =>
|
|
9071
|
+
...added.map((r) => import_prosemirror_view5.Decoration.inline(r.from, r.to, { class: "nova-diff-added" })),
|
|
9069
9072
|
...removed.map(
|
|
9070
|
-
(r) =>
|
|
9073
|
+
(r) => import_prosemirror_view5.Decoration.widget(
|
|
9071
9074
|
r.pos,
|
|
9072
9075
|
() => h(r.block ? "div" : "span", { className: "nova-diff-removed" }, r.text),
|
|
9073
9076
|
{ side: -1, ignoreSelection: true }
|
|
9074
9077
|
)
|
|
9075
9078
|
)
|
|
9076
9079
|
];
|
|
9077
|
-
return
|
|
9080
|
+
return import_prosemirror_view5.DecorationSet.create(doc, decorations);
|
|
9078
9081
|
};
|
|
9079
9082
|
const showDoc = (doc) => {
|
|
9080
9083
|
selectedDoc = doc;
|
|
9081
|
-
const state =
|
|
9084
|
+
const state = import_prosemirror_state18.EditorState.create({ doc });
|
|
9082
9085
|
const decorations = decorationsFor(doc);
|
|
9083
9086
|
if (preview) {
|
|
9084
9087
|
preview.setProps({ state, decorations: () => decorations });
|
|
9085
9088
|
return;
|
|
9086
9089
|
}
|
|
9087
|
-
preview = new
|
|
9090
|
+
preview = new import_prosemirror_view5.EditorView(previewHost, {
|
|
9088
9091
|
state,
|
|
9089
9092
|
editable: () => false,
|
|
9090
9093
|
decorations: () => decorations,
|
|
@@ -9230,21 +9233,21 @@ function openHistory(editor, options) {
|
|
|
9230
9233
|
});
|
|
9231
9234
|
return { close, element: view };
|
|
9232
9235
|
}
|
|
9233
|
-
var
|
|
9236
|
+
var import_prosemirror_model10, import_prosemirror_history3, import_prosemirror_state18, import_prosemirror_view5, LABELS15, ICON10, serializer, revisionhistory_default;
|
|
9234
9237
|
var init_revisionhistory = __esm({
|
|
9235
9238
|
"src/plugins/revisionhistory.ts"() {
|
|
9236
9239
|
"use strict";
|
|
9237
|
-
|
|
9240
|
+
import_prosemirror_model10 = require("prosemirror-model");
|
|
9238
9241
|
import_prosemirror_history3 = require("prosemirror-history");
|
|
9239
|
-
|
|
9240
|
-
|
|
9242
|
+
import_prosemirror_state18 = require("prosemirror-state");
|
|
9243
|
+
import_prosemirror_view5 = require("prosemirror-view");
|
|
9241
9244
|
init_editor();
|
|
9242
9245
|
init_plugins();
|
|
9243
9246
|
init_serializer();
|
|
9244
9247
|
init_dom();
|
|
9245
9248
|
init_history_diff();
|
|
9246
9249
|
init_shared();
|
|
9247
|
-
|
|
9250
|
+
LABELS15 = {
|
|
9248
9251
|
en: {
|
|
9249
9252
|
button: "Version history",
|
|
9250
9253
|
title: "Version history",
|
|
@@ -9293,7 +9296,7 @@ var init_revisionhistory = __esm({
|
|
|
9293
9296
|
console.warn("[nova] revisionhistory: set pluginOptions.revisionhistory.list and .load");
|
|
9294
9297
|
return;
|
|
9295
9298
|
}
|
|
9296
|
-
const labels = pickLabels(editor,
|
|
9299
|
+
const labels = pickLabels(editor, LABELS15);
|
|
9297
9300
|
let current = null;
|
|
9298
9301
|
const open = () => {
|
|
9299
9302
|
if (current?.element.isConnected) return;
|
|
@@ -9322,6 +9325,7 @@ __export(index_exports, {
|
|
|
9322
9325
|
DEFAULT_MENUBAR: () => DEFAULT_MENUBAR,
|
|
9323
9326
|
DEFAULT_MENUS: () => DEFAULT_MENUS,
|
|
9324
9327
|
Editor: () => Editor,
|
|
9328
|
+
HTMLSerializer: () => HTMLSerializer,
|
|
9325
9329
|
KNOWN_STYLES: () => KNOWN_STYLES,
|
|
9326
9330
|
KNOWN_TAGS: () => KNOWN_TAGS,
|
|
9327
9331
|
MENTION_ID_RE: () => MENTION_ID_RE,
|
|
@@ -9357,6 +9361,7 @@ __export(index_exports, {
|
|
|
9357
9361
|
hasHeaderColumn: () => hasHeaderColumn,
|
|
9358
9362
|
hasHeaderRow: () => hasHeaderRow,
|
|
9359
9363
|
htmlToPlainText: () => htmlToPlainText,
|
|
9364
|
+
icons: () => icons,
|
|
9360
9365
|
imageSize: () => imageSize,
|
|
9361
9366
|
insertImage: () => insertImage,
|
|
9362
9367
|
insertTable: () => insertTable,
|
|
@@ -9368,6 +9373,8 @@ __export(index_exports, {
|
|
|
9368
9373
|
isPluginRegistered: () => isPluginRegistered,
|
|
9369
9374
|
isSafeImageUrl: () => isSafeImageUrl,
|
|
9370
9375
|
isSafeLinkUrl: () => isSafeLinkUrl,
|
|
9376
|
+
isSuggesting: () => isSuggesting,
|
|
9377
|
+
listSuggestions: () => listSuggestions,
|
|
9371
9378
|
marksOf: () => marksOf,
|
|
9372
9379
|
newCommentId: () => newCommentId,
|
|
9373
9380
|
nodesOf: () => nodesOf,
|
|
@@ -9387,6 +9394,7 @@ __export(index_exports, {
|
|
|
9387
9394
|
removeLink: () => removeLink,
|
|
9388
9395
|
replaceAll: () => replaceAll,
|
|
9389
9396
|
replaceCurrent: () => replaceCurrent,
|
|
9397
|
+
resolveSuggestions: () => resolveSuggestions,
|
|
9390
9398
|
ru: () => ru,
|
|
9391
9399
|
sanitizeThread: () => sanitizeThread,
|
|
9392
9400
|
schema: () => schema,
|
|
@@ -9397,6 +9405,8 @@ __export(index_exports, {
|
|
|
9397
9405
|
setLink: () => setLink,
|
|
9398
9406
|
setSearch: () => setSearch,
|
|
9399
9407
|
setStyle: () => setStyle,
|
|
9408
|
+
setSuggesting: () => setSuggesting,
|
|
9409
|
+
suggestionsResult: () => suggestionsResult,
|
|
9400
9410
|
tableCommands: () => tableCommands,
|
|
9401
9411
|
toggleFullscreen: () => toggleFullscreen,
|
|
9402
9412
|
uploadImages: () => uploadImages
|
|
@@ -9981,8 +9991,434 @@ var comments_default = definePlugin({
|
|
|
9981
9991
|
}
|
|
9982
9992
|
});
|
|
9983
9993
|
|
|
9984
|
-
// src/plugins/
|
|
9994
|
+
// src/plugins/suggestions.ts
|
|
9995
|
+
var import_prosemirror_model = require("prosemirror-model");
|
|
9985
9996
|
var import_prosemirror_state3 = require("prosemirror-state");
|
|
9997
|
+
var import_prosemirror_transform = require("prosemirror-transform");
|
|
9998
|
+
var import_prosemirror_view2 = require("prosemirror-view");
|
|
9999
|
+
var import_prosemirror_keymap2 = require("prosemirror-keymap");
|
|
10000
|
+
init_plugins();
|
|
10001
|
+
init_shared();
|
|
10002
|
+
var ID_RE2 = /^[A-Za-z0-9_-]{1,64}$/;
|
|
10003
|
+
var USER_ID_RE = /^[\w.@:+-]{1,128}$/;
|
|
10004
|
+
var LABELS4 = {
|
|
10005
|
+
en: {
|
|
10006
|
+
toggle: "Suggest edits",
|
|
10007
|
+
review: "Review suggestions",
|
|
10008
|
+
accept: "Accept",
|
|
10009
|
+
reject: "Reject",
|
|
10010
|
+
acceptAll: "Accept all suggestions",
|
|
10011
|
+
rejectAll: "Reject all suggestions",
|
|
10012
|
+
next: "Next suggestion",
|
|
10013
|
+
previous: "Previous suggestion",
|
|
10014
|
+
inserted: "Inserted by {name}",
|
|
10015
|
+
deleted: "Deleted by {name}",
|
|
10016
|
+
toolbar: "Suggestion",
|
|
10017
|
+
guest: "Guest",
|
|
10018
|
+
none: "No suggestions"
|
|
10019
|
+
},
|
|
10020
|
+
ru: {
|
|
10021
|
+
toggle: "\u041F\u0440\u0435\u0434\u043B\u0430\u0433\u0430\u0442\u044C \u043F\u0440\u0430\u0432\u043A\u0438",
|
|
10022
|
+
review: "\u041F\u0440\u0430\u0432\u043A\u0438",
|
|
10023
|
+
accept: "\u041F\u0440\u0438\u043D\u044F\u0442\u044C",
|
|
10024
|
+
reject: "\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C",
|
|
10025
|
+
acceptAll: "\u041F\u0440\u0438\u043D\u044F\u0442\u044C \u0432\u0441\u0435 \u043F\u0440\u0430\u0432\u043A\u0438",
|
|
10026
|
+
rejectAll: "\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C \u0432\u0441\u0435 \u043F\u0440\u0430\u0432\u043A\u0438",
|
|
10027
|
+
next: "\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F \u043F\u0440\u0430\u0432\u043A\u0430",
|
|
10028
|
+
previous: "\u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F \u043F\u0440\u0430\u0432\u043A\u0430",
|
|
10029
|
+
inserted: "\u0412\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u043E: {name}",
|
|
10030
|
+
deleted: "\u0423\u0434\u0430\u043B\u0435\u043D\u043E: {name}",
|
|
10031
|
+
toolbar: "\u041F\u0440\u0430\u0432\u043A\u0430",
|
|
10032
|
+
guest: "\u0413\u043E\u0441\u0442\u044C",
|
|
10033
|
+
none: "\u041F\u0440\u0430\u0432\u043E\u043A \u043D\u0435\u0442"
|
|
10034
|
+
}
|
|
10035
|
+
};
|
|
10036
|
+
var ICON_TOGGLE = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z"/></svg>';
|
|
10037
|
+
var ICON_REVIEW = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 11l3 3 8-8"/><path d="M20 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/></svg>';
|
|
10038
|
+
var ICON_ACCEPT = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12l5 5 9-10"/></svg>';
|
|
10039
|
+
var ICON_REJECT = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>';
|
|
10040
|
+
var suggestionsKey = new import_prosemirror_state3.PluginKey("nova-suggestions");
|
|
10041
|
+
var OWN = "nova-suggestions-own";
|
|
10042
|
+
var PALETTE2 = ["#1a7f37", "#8250df", "#bf3989", "#0969da", "#bc4c00", "#1b7c83"];
|
|
10043
|
+
function colorFor2(key3) {
|
|
10044
|
+
let hash = 0;
|
|
10045
|
+
for (const ch of key3) hash = hash * 31 + ch.charCodeAt(0) | 0;
|
|
10046
|
+
return PALETTE2[Math.abs(hash) % PALETTE2.length];
|
|
10047
|
+
}
|
|
10048
|
+
function newId() {
|
|
10049
|
+
const bytes = new Uint8Array(9);
|
|
10050
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
10051
|
+
return "s" + Array.from(bytes, (b) => (b % 36).toString(36)).join("");
|
|
10052
|
+
}
|
|
10053
|
+
function markSpec(kind) {
|
|
10054
|
+
const tag = kind === "insert" ? "ins" : "del";
|
|
10055
|
+
return {
|
|
10056
|
+
attrs: { id: {}, author: { default: "" }, name: { default: "" }, time: { default: 0 } },
|
|
10057
|
+
inclusive: false,
|
|
10058
|
+
excludes: "",
|
|
10059
|
+
parseDOM: [
|
|
10060
|
+
{
|
|
10061
|
+
tag: `${tag}[data-suggestion]`,
|
|
10062
|
+
// Раньше правила зачёркивания (<del> без data-suggestion — обычное зачёркивание).
|
|
10063
|
+
priority: 60,
|
|
10064
|
+
getAttrs: (dom) => {
|
|
10065
|
+
const el = dom;
|
|
10066
|
+
const id = el.getAttribute("data-suggestion") ?? "";
|
|
10067
|
+
if (!ID_RE2.test(id)) return false;
|
|
10068
|
+
const author = el.getAttribute("data-author") ?? "";
|
|
10069
|
+
return {
|
|
10070
|
+
id,
|
|
10071
|
+
author: USER_ID_RE.test(author) ? author : "",
|
|
10072
|
+
name: (el.getAttribute("data-name") ?? "").slice(0, 80),
|
|
10073
|
+
time: Number(el.getAttribute("data-time")) || 0
|
|
10074
|
+
};
|
|
10075
|
+
}
|
|
10076
|
+
}
|
|
10077
|
+
],
|
|
10078
|
+
toDOM: (mark) => [
|
|
10079
|
+
tag,
|
|
10080
|
+
{
|
|
10081
|
+
"data-suggestion": ID_RE2.test(mark.attrs.id) ? mark.attrs.id : null,
|
|
10082
|
+
"data-author": USER_ID_RE.test(mark.attrs.author) ? mark.attrs.author : null,
|
|
10083
|
+
"data-name": String(mark.attrs.name ?? "").slice(0, 80) || null,
|
|
10084
|
+
"data-time": Number(mark.attrs.time) || null
|
|
10085
|
+
},
|
|
10086
|
+
0
|
|
10087
|
+
]
|
|
10088
|
+
};
|
|
10089
|
+
}
|
|
10090
|
+
var typesOf = (schema2) => ({
|
|
10091
|
+
insert: schema2.marks.suggestion_insert,
|
|
10092
|
+
delete: schema2.marks.suggestion_delete
|
|
10093
|
+
});
|
|
10094
|
+
function isTracked(tr) {
|
|
10095
|
+
if (!tr.docChanged || tr.getMeta(OWN)) return false;
|
|
10096
|
+
if (tr.getMeta("addToHistory") === false) return false;
|
|
10097
|
+
if (tr.getMeta("history$")) return false;
|
|
10098
|
+
const ySync = tr.getMeta("y-sync$");
|
|
10099
|
+
if (ySync?.isChangeOrigin) return false;
|
|
10100
|
+
return tr.steps.every((step) => step instanceof import_prosemirror_transform.ReplaceStep);
|
|
10101
|
+
}
|
|
10102
|
+
function neighbourMark(doc, pos, type, authorId) {
|
|
10103
|
+
const $pos = doc.resolve(pos);
|
|
10104
|
+
for (const node of [$pos.nodeBefore, $pos.nodeAfter]) {
|
|
10105
|
+
const mark = node?.marks.find((m) => m.type === type && m.attrs.author === authorId);
|
|
10106
|
+
if (mark) return mark;
|
|
10107
|
+
}
|
|
10108
|
+
return null;
|
|
10109
|
+
}
|
|
10110
|
+
function withMark(fragment, mark, parent) {
|
|
10111
|
+
const nodes2 = [];
|
|
10112
|
+
fragment.forEach((node) => {
|
|
10113
|
+
if (node.isInline) {
|
|
10114
|
+
nodes2.push(
|
|
10115
|
+
parent && !parent.allowsMarkType(mark.type) ? node : node.mark(mark.addToSet(node.marks))
|
|
10116
|
+
);
|
|
10117
|
+
} else {
|
|
10118
|
+
nodes2.push(node.copy(withMark(node.content, mark, node.type)));
|
|
10119
|
+
}
|
|
10120
|
+
});
|
|
10121
|
+
return import_prosemirror_model.Fragment.from(nodes2);
|
|
10122
|
+
}
|
|
10123
|
+
function suggestTransaction(tr, state, author) {
|
|
10124
|
+
if (!isTracked(tr)) return tr;
|
|
10125
|
+
const types = typesOf(state.schema);
|
|
10126
|
+
const out = state.tr;
|
|
10127
|
+
const time = Date.now();
|
|
10128
|
+
let toOut = (pos) => pos;
|
|
10129
|
+
let forwardDeleteEnd = null;
|
|
10130
|
+
let insertEnd = null;
|
|
10131
|
+
tr.steps.forEach((rawStep) => {
|
|
10132
|
+
const step = rawStep;
|
|
10133
|
+
const outStart = out.steps.length;
|
|
10134
|
+
const prev = toOut;
|
|
10135
|
+
let from = prev(step.from);
|
|
10136
|
+
let to = Math.max(from, prev(step.to));
|
|
10137
|
+
if (to > from) {
|
|
10138
|
+
const own = [];
|
|
10139
|
+
const plain = [];
|
|
10140
|
+
out.doc.nodesBetween(from, to, (node, pos) => {
|
|
10141
|
+
if (!node.isInline) return true;
|
|
10142
|
+
const start = Math.max(pos, from);
|
|
10143
|
+
const end = Math.min(pos + node.nodeSize, to);
|
|
10144
|
+
if (start >= end) return false;
|
|
10145
|
+
const mine = node.marks.some(
|
|
10146
|
+
(m) => m.type === types.insert && m.attrs.author === author.id
|
|
10147
|
+
);
|
|
10148
|
+
if (mine) own.push({ from: start, to: end });
|
|
10149
|
+
else if (!types.delete.isInSet(node.marks)) plain.push({ from: start, to: end });
|
|
10150
|
+
return false;
|
|
10151
|
+
});
|
|
10152
|
+
if (plain.length) {
|
|
10153
|
+
const first = plain[0];
|
|
10154
|
+
const mark = neighbourMark(out.doc, first.from, types.delete, author.id) ?? neighbourMark(out.doc, plain[plain.length - 1].to, types.delete, author.id) ?? types.delete.create({ id: newId(), author: author.id, name: author.name, time });
|
|
10155
|
+
for (const range of plain) out.addMark(range.from, range.to, mark);
|
|
10156
|
+
}
|
|
10157
|
+
for (const range of own.reverse()) out.delete(range.from, range.to);
|
|
10158
|
+
const map = out.mapping.slice(outStart);
|
|
10159
|
+
from = map.map(from, 1);
|
|
10160
|
+
to = map.map(to, -1);
|
|
10161
|
+
const sel = state.selection;
|
|
10162
|
+
if (tr.steps.length === 1 && step.slice.size === 0 && sel.empty && sel.from === step.from && tr.selection.head === step.from) {
|
|
10163
|
+
forwardDeleteEnd = to;
|
|
10164
|
+
}
|
|
10165
|
+
}
|
|
10166
|
+
if (step.slice.size > 0) {
|
|
10167
|
+
let at = to;
|
|
10168
|
+
if (!step.slice.openStart) {
|
|
10169
|
+
for (let next = out.doc.resolve(at).nodeAfter; next && types.delete.isInSet(next.marks); ) {
|
|
10170
|
+
at += next.nodeSize;
|
|
10171
|
+
next = out.doc.resolve(at).nodeAfter;
|
|
10172
|
+
}
|
|
10173
|
+
}
|
|
10174
|
+
const mark = neighbourMark(out.doc, at, types.insert, author.id) ?? types.insert.create({ id: newId(), author: author.id, name: author.name, time });
|
|
10175
|
+
const $at = out.doc.resolve(at);
|
|
10176
|
+
const content = withMark(
|
|
10177
|
+
step.slice.content,
|
|
10178
|
+
mark,
|
|
10179
|
+
step.slice.openStart ? null : $at.parent.type
|
|
10180
|
+
);
|
|
10181
|
+
out.replace(at, at, new import_prosemirror_model.Slice(content, step.slice.openStart, step.slice.openEnd));
|
|
10182
|
+
if (tr.steps.length === 1) insertEnd = at + step.slice.size;
|
|
10183
|
+
}
|
|
10184
|
+
const inverse = step.getMap().invert();
|
|
10185
|
+
const outMap = out.mapping.slice(outStart);
|
|
10186
|
+
toOut = (pos) => outMap.map(prev(inverse.map(pos, -1)), 1);
|
|
10187
|
+
});
|
|
10188
|
+
if (forwardDeleteEnd !== null) {
|
|
10189
|
+
out.setSelection(import_prosemirror_state3.TextSelection.create(out.doc, forwardDeleteEnd));
|
|
10190
|
+
} else if (insertEnd !== null && tr.selection.empty) {
|
|
10191
|
+
out.setSelection(import_prosemirror_state3.TextSelection.create(out.doc, insertEnd));
|
|
10192
|
+
} else {
|
|
10193
|
+
const anchor = toOut(tr.selection.anchor);
|
|
10194
|
+
const head = toOut(tr.selection.head);
|
|
10195
|
+
try {
|
|
10196
|
+
out.setSelection(import_prosemirror_state3.TextSelection.create(out.doc, anchor, head));
|
|
10197
|
+
} catch {
|
|
10198
|
+
}
|
|
10199
|
+
}
|
|
10200
|
+
for (const key3 of ["addToHistory", "uiEvent", "paste", "scrollIntoView"]) {
|
|
10201
|
+
const value = tr.getMeta(key3);
|
|
10202
|
+
if (value !== void 0) out.setMeta(key3, value);
|
|
10203
|
+
}
|
|
10204
|
+
if (tr.scrolledIntoView) out.scrollIntoView();
|
|
10205
|
+
return out;
|
|
10206
|
+
}
|
|
10207
|
+
function listSuggestions(doc) {
|
|
10208
|
+
const types = typesOf(doc.type.schema);
|
|
10209
|
+
const result = [];
|
|
10210
|
+
doc.descendants((node, pos) => {
|
|
10211
|
+
if (!node.isInline) return true;
|
|
10212
|
+
for (const mark of node.marks) {
|
|
10213
|
+
const kind = mark.type === types.insert ? "insert" : mark.type === types.delete ? "delete" : null;
|
|
10214
|
+
if (!kind) continue;
|
|
10215
|
+
const last = result[result.length - 1];
|
|
10216
|
+
const text = node.isText ? node.text : "";
|
|
10217
|
+
if (last && last.id === mark.attrs.id && last.kind === kind && last.to === pos) {
|
|
10218
|
+
last.to = pos + node.nodeSize;
|
|
10219
|
+
last.text += text;
|
|
10220
|
+
} else {
|
|
10221
|
+
result.push({
|
|
10222
|
+
id: mark.attrs.id,
|
|
10223
|
+
kind,
|
|
10224
|
+
author: { id: mark.attrs.author, name: mark.attrs.name },
|
|
10225
|
+
time: Number(mark.attrs.time) || 0,
|
|
10226
|
+
from: pos,
|
|
10227
|
+
to: pos + node.nodeSize,
|
|
10228
|
+
text
|
|
10229
|
+
});
|
|
10230
|
+
}
|
|
10231
|
+
}
|
|
10232
|
+
return false;
|
|
10233
|
+
});
|
|
10234
|
+
return result;
|
|
10235
|
+
}
|
|
10236
|
+
function resolveSuggestions(state, action, ids) {
|
|
10237
|
+
const types = typesOf(state.schema);
|
|
10238
|
+
const tr = state.tr.setMeta(OWN, true);
|
|
10239
|
+
const chosen = listSuggestions(state.doc).filter((s) => !ids || ids.includes(s.id));
|
|
10240
|
+
for (const s of [...chosen].sort((a, b) => b.from - a.from)) {
|
|
10241
|
+
const remove = s.kind === "insert" === (action === "reject");
|
|
10242
|
+
if (remove) tr.delete(s.from, s.to);
|
|
10243
|
+
else tr.removeMark(s.from, s.to, s.kind === "insert" ? types.insert : types.delete);
|
|
10244
|
+
}
|
|
10245
|
+
return tr;
|
|
10246
|
+
}
|
|
10247
|
+
function suggestionsResult(editor, action) {
|
|
10248
|
+
return resolveSuggestions(editor.view.state, action).doc;
|
|
10249
|
+
}
|
|
10250
|
+
function suggestionAt(state) {
|
|
10251
|
+
const { from } = state.selection;
|
|
10252
|
+
return listSuggestions(state.doc).find(
|
|
10253
|
+
(s) => from >= s.from && from <= s.to && (s.to > from || s.from < from)
|
|
10254
|
+
) ?? null;
|
|
10255
|
+
}
|
|
10256
|
+
function isSuggesting(state) {
|
|
10257
|
+
return suggestionsKey.getState(state)?.enabled ?? false;
|
|
10258
|
+
}
|
|
10259
|
+
function setSuggesting(editor, enabled) {
|
|
10260
|
+
const { state, dispatch } = editor.view;
|
|
10261
|
+
dispatch(state.tr.setMeta(suggestionsKey, { enabled }).setMeta(OWN, true));
|
|
10262
|
+
editor.updateUI();
|
|
10263
|
+
}
|
|
10264
|
+
var suggestions_default = definePlugin({
|
|
10265
|
+
name: "suggestions",
|
|
10266
|
+
toolbar: "suggestions reviewsuggestions",
|
|
10267
|
+
marks: {
|
|
10268
|
+
suggestion_insert: markSpec("insert"),
|
|
10269
|
+
suggestion_delete: markSpec("delete")
|
|
10270
|
+
},
|
|
10271
|
+
prosemirrorPlugins: (editor) => {
|
|
10272
|
+
const options = editor.options.pluginOptions?.suggestions ?? {};
|
|
10273
|
+
let cache = null;
|
|
10274
|
+
return [
|
|
10275
|
+
new import_prosemirror_state3.Plugin({
|
|
10276
|
+
key: suggestionsKey,
|
|
10277
|
+
state: {
|
|
10278
|
+
init: () => ({ enabled: !!(options.enabled || options.force) }),
|
|
10279
|
+
apply(tr, value) {
|
|
10280
|
+
const meta = tr.getMeta(suggestionsKey);
|
|
10281
|
+
if (!meta) return value;
|
|
10282
|
+
return { enabled: options.force ? true : meta.enabled };
|
|
10283
|
+
}
|
|
10284
|
+
},
|
|
10285
|
+
props: {
|
|
10286
|
+
attributes: (state) => suggestionsKey.getState(state)?.enabled ? { class: "nova-suggesting" } : {},
|
|
10287
|
+
decorations(state) {
|
|
10288
|
+
if (cache?.doc === state.doc) return cache.set;
|
|
10289
|
+
const labels = pickLabels(editor, LABELS4);
|
|
10290
|
+
const time = new Intl.DateTimeFormat(editor.options.language ?? "en", {
|
|
10291
|
+
dateStyle: "medium",
|
|
10292
|
+
timeStyle: "short"
|
|
10293
|
+
});
|
|
10294
|
+
const set = import_prosemirror_view2.DecorationSet.create(
|
|
10295
|
+
state.doc,
|
|
10296
|
+
listSuggestions(state.doc).map(
|
|
10297
|
+
(s) => import_prosemirror_view2.Decoration.inline(s.from, s.to, {
|
|
10298
|
+
title: (s.kind === "insert" ? labels.inserted : labels.deleted).replace(
|
|
10299
|
+
"{name}",
|
|
10300
|
+
s.author.name || labels.guest
|
|
10301
|
+
) + (s.time ? ` \xB7 ${time.format(s.time)}` : ""),
|
|
10302
|
+
class: s.kind === "insert" ? "nova-sugg-insert" : "nova-sugg-delete",
|
|
10303
|
+
style: `--nova-suggestion: ${colorFor2(s.author.id || s.author.name)}`
|
|
10304
|
+
})
|
|
10305
|
+
)
|
|
10306
|
+
);
|
|
10307
|
+
cache = { doc: state.doc, set };
|
|
10308
|
+
return set;
|
|
10309
|
+
}
|
|
10310
|
+
}
|
|
10311
|
+
}),
|
|
10312
|
+
(0, import_prosemirror_keymap2.keymap)({
|
|
10313
|
+
// Ctrl/Cmd+Alt+Shift+E — переключить режим правок.
|
|
10314
|
+
"Mod-Alt-Shift-e": () => {
|
|
10315
|
+
if (options.force) return false;
|
|
10316
|
+
setSuggesting(editor, !isSuggesting(editor.view.state));
|
|
10317
|
+
return true;
|
|
10318
|
+
}
|
|
10319
|
+
})
|
|
10320
|
+
];
|
|
10321
|
+
},
|
|
10322
|
+
transformTransaction(tr, state, editor) {
|
|
10323
|
+
if (!isSuggesting(state)) return tr;
|
|
10324
|
+
const options = editor.options.pluginOptions?.suggestions ?? {};
|
|
10325
|
+
const labels = pickLabels(editor, LABELS4);
|
|
10326
|
+
const author = {
|
|
10327
|
+
id: USER_ID_RE.test(options.author?.id ?? "") ? options.author.id : "guest",
|
|
10328
|
+
name: String(options.author?.name || labels.guest).slice(0, 80)
|
|
10329
|
+
};
|
|
10330
|
+
return suggestTransaction(tr, state, author);
|
|
10331
|
+
},
|
|
10332
|
+
setup(editor) {
|
|
10333
|
+
const options = editor.options.pluginOptions?.suggestions ?? {};
|
|
10334
|
+
const labels = pickLabels(editor, LABELS4);
|
|
10335
|
+
const canReview = options.canReview !== false;
|
|
10336
|
+
const dispatch = (tr) => editor.view.dispatch(tr);
|
|
10337
|
+
const current = () => suggestionAt(editor.view.state);
|
|
10338
|
+
const resolveCurrent = (action) => {
|
|
10339
|
+
const s = current();
|
|
10340
|
+
if (s) dispatch(resolveSuggestions(editor.view.state, action, [s.id]));
|
|
10341
|
+
editor.focus();
|
|
10342
|
+
};
|
|
10343
|
+
const go = (direction) => {
|
|
10344
|
+
const { state } = editor.view;
|
|
10345
|
+
const list = listSuggestions(state.doc);
|
|
10346
|
+
const pos = state.selection.from;
|
|
10347
|
+
const target = direction === 1 ? list.find((s) => s.from > pos) ?? list[0] : [...list].reverse().find((s) => s.to < pos) ?? list[list.length - 1];
|
|
10348
|
+
if (!target) {
|
|
10349
|
+
editor.ui.notify(labels.none);
|
|
10350
|
+
return;
|
|
10351
|
+
}
|
|
10352
|
+
dispatch(
|
|
10353
|
+
state.tr.setSelection(import_prosemirror_state3.TextSelection.create(state.doc, target.from)).scrollIntoView()
|
|
10354
|
+
);
|
|
10355
|
+
editor.focus();
|
|
10356
|
+
};
|
|
10357
|
+
const hasAny = () => listSuggestions(editor.view.state.doc).length > 0;
|
|
10358
|
+
editor.ui.registry.addToggleButton("suggestions", {
|
|
10359
|
+
icon: ICON_TOGGLE,
|
|
10360
|
+
tooltip: labels.toggle,
|
|
10361
|
+
shortcut: "Mod-Alt-Shift-e",
|
|
10362
|
+
isActive: (e) => isSuggesting(e.view.state),
|
|
10363
|
+
isEnabled: () => !options.force,
|
|
10364
|
+
onAction: (e) => setSuggesting(e, !isSuggesting(e.view.state))
|
|
10365
|
+
});
|
|
10366
|
+
editor.ui.registry.addMenuButton("reviewsuggestions", {
|
|
10367
|
+
icon: ICON_REVIEW,
|
|
10368
|
+
tooltip: labels.review,
|
|
10369
|
+
isEnabled: hasAny,
|
|
10370
|
+
items: () => [
|
|
10371
|
+
{ id: "next", label: labels.next, onSelect: () => go(1) },
|
|
10372
|
+
{ id: "previous", label: labels.previous, onSelect: () => go(-1) },
|
|
10373
|
+
...canReview ? [
|
|
10374
|
+
{ type: "separator" },
|
|
10375
|
+
{
|
|
10376
|
+
id: "accept-all",
|
|
10377
|
+
label: labels.acceptAll,
|
|
10378
|
+
onSelect: () => dispatch(resolveSuggestions(editor.view.state, "accept"))
|
|
10379
|
+
},
|
|
10380
|
+
{
|
|
10381
|
+
id: "reject-all",
|
|
10382
|
+
label: labels.rejectAll,
|
|
10383
|
+
onSelect: () => dispatch(resolveSuggestions(editor.view.state, "reject"))
|
|
10384
|
+
}
|
|
10385
|
+
] : []
|
|
10386
|
+
]
|
|
10387
|
+
});
|
|
10388
|
+
if (canReview) {
|
|
10389
|
+
editor.ui.registry.addButton("acceptsuggestion", {
|
|
10390
|
+
icon: ICON_ACCEPT,
|
|
10391
|
+
text: labels.accept,
|
|
10392
|
+
tooltip: labels.accept,
|
|
10393
|
+
onAction: () => resolveCurrent("accept")
|
|
10394
|
+
});
|
|
10395
|
+
editor.ui.registry.addButton("rejectsuggestion", {
|
|
10396
|
+
icon: ICON_REJECT,
|
|
10397
|
+
text: labels.reject,
|
|
10398
|
+
tooltip: labels.reject,
|
|
10399
|
+
onAction: () => resolveCurrent("reject")
|
|
10400
|
+
});
|
|
10401
|
+
editor.ui.registry.addContextToolbar("suggestion", {
|
|
10402
|
+
label: labels.toolbar,
|
|
10403
|
+
predicate: (e) => suggestionAt(e.view.state) !== null,
|
|
10404
|
+
items: "acceptsuggestion rejectsuggestion",
|
|
10405
|
+
position: "selection",
|
|
10406
|
+
placement: "bottom-start",
|
|
10407
|
+
priority: 20
|
|
10408
|
+
});
|
|
10409
|
+
}
|
|
10410
|
+
editor.ui.registry.addMenuItem("suggestions", {
|
|
10411
|
+
text: labels.toggle,
|
|
10412
|
+
icon: ICON_TOGGLE,
|
|
10413
|
+
isActive: (e) => isSuggesting(e.view.state),
|
|
10414
|
+
isEnabled: () => !options.force,
|
|
10415
|
+
onAction: (e) => setSuggesting(e, !isSuggesting(e.view.state))
|
|
10416
|
+
});
|
|
10417
|
+
}
|
|
10418
|
+
});
|
|
10419
|
+
|
|
10420
|
+
// src/plugins/media.ts
|
|
10421
|
+
var import_prosemirror_state4 = require("prosemirror-state");
|
|
9986
10422
|
init_plugins();
|
|
9987
10423
|
init_schema();
|
|
9988
10424
|
init_dialog();
|
|
@@ -10002,7 +10438,7 @@ function parseMediaUrl(url) {
|
|
|
10002
10438
|
return null;
|
|
10003
10439
|
}
|
|
10004
10440
|
var ICON2 = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="5" width="20" height="14" rx="2"/><path d="m10 9 5 3-5 3z"/></svg>';
|
|
10005
|
-
var
|
|
10441
|
+
var LABELS5 = {
|
|
10006
10442
|
en: {
|
|
10007
10443
|
title: "Video",
|
|
10008
10444
|
url: "Video URL",
|
|
@@ -10103,7 +10539,7 @@ var media_default = definePlugin({
|
|
|
10103
10539
|
}
|
|
10104
10540
|
},
|
|
10105
10541
|
prosemirrorPlugins: () => [
|
|
10106
|
-
new
|
|
10542
|
+
new import_prosemirror_state4.Plugin({
|
|
10107
10543
|
props: {
|
|
10108
10544
|
nodeViews: {
|
|
10109
10545
|
// В редакторе плеер закрыт прозрачным слоем: клик выделяет блок, а не запускает видео.
|
|
@@ -10122,10 +10558,10 @@ var media_default = definePlugin({
|
|
|
10122
10558
|
})
|
|
10123
10559
|
],
|
|
10124
10560
|
setup(editor) {
|
|
10125
|
-
const labels = pickLabels(editor,
|
|
10561
|
+
const labels = pickLabels(editor, LABELS5);
|
|
10126
10562
|
const selected = () => {
|
|
10127
10563
|
const { selection } = editor.view.state;
|
|
10128
|
-
return selection instanceof
|
|
10564
|
+
return selection instanceof import_prosemirror_state4.NodeSelection && selection.node.type.name === "media" ? selection : null;
|
|
10129
10565
|
};
|
|
10130
10566
|
const open = () => {
|
|
10131
10567
|
const current = selected();
|
|
@@ -10175,7 +10611,7 @@ var media_default = definePlugin({
|
|
|
10175
10611
|
init_plugins();
|
|
10176
10612
|
init_shared();
|
|
10177
10613
|
var ICON3 = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 3v5h12V3M6 21v-5h12v5"/><path d="M3 12h2M9 12h2M15 12h2M21 12h-0"/></svg>';
|
|
10178
|
-
var
|
|
10614
|
+
var LABELS6 = { en: { title: "Page break" }, ru: { title: "\u0420\u0430\u0437\u0440\u044B\u0432 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B" } };
|
|
10179
10615
|
var pagebreak_default = definePlugin({
|
|
10180
10616
|
name: "pagebreak",
|
|
10181
10617
|
toolbar: "pagebreak",
|
|
@@ -10200,7 +10636,7 @@ var pagebreak_default = definePlugin({
|
|
|
10200
10636
|
}
|
|
10201
10637
|
},
|
|
10202
10638
|
setup(editor) {
|
|
10203
|
-
const { title } = pickLabels(editor,
|
|
10639
|
+
const { title } = pickLabels(editor, LABELS6);
|
|
10204
10640
|
const insert = () => {
|
|
10205
10641
|
const { state, dispatch } = editor.view;
|
|
10206
10642
|
const type = editor.schema.nodes.pagebreak;
|
|
@@ -10232,6 +10668,7 @@ registerPlugin("pagebreak", pagebreak_default);
|
|
|
10232
10668
|
registerPlugin("media", media_default);
|
|
10233
10669
|
registerPlugin("comments", comments_default);
|
|
10234
10670
|
registerPlugin("mentions", mentions_default);
|
|
10671
|
+
registerPlugin("suggestions", suggestions_default);
|
|
10235
10672
|
registerPlugin("directionality", () => Promise.resolve().then(() => (init_directionality(), directionality_exports)));
|
|
10236
10673
|
registerPlugin("advlist", () => Promise.resolve().then(() => (init_advlist(), advlist_exports)));
|
|
10237
10674
|
registerPlugin("revisionhistory", () => Promise.resolve().then(() => (init_revisionhistory(), revisionhistory_exports)));
|
|
@@ -10261,12 +10698,15 @@ init_search();
|
|
|
10261
10698
|
init_views();
|
|
10262
10699
|
init_table();
|
|
10263
10700
|
init_comments();
|
|
10701
|
+
init_icons();
|
|
10702
|
+
init_serializer();
|
|
10264
10703
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10265
10704
|
0 && (module.exports = {
|
|
10266
10705
|
ContentRules,
|
|
10267
10706
|
DEFAULT_MENUBAR,
|
|
10268
10707
|
DEFAULT_MENUS,
|
|
10269
10708
|
Editor,
|
|
10709
|
+
HTMLSerializer,
|
|
10270
10710
|
KNOWN_STYLES,
|
|
10271
10711
|
KNOWN_TAGS,
|
|
10272
10712
|
MENTION_ID_RE,
|
|
@@ -10302,6 +10742,7 @@ init_comments();
|
|
|
10302
10742
|
hasHeaderColumn,
|
|
10303
10743
|
hasHeaderRow,
|
|
10304
10744
|
htmlToPlainText,
|
|
10745
|
+
icons,
|
|
10305
10746
|
imageSize,
|
|
10306
10747
|
insertImage,
|
|
10307
10748
|
insertTable,
|
|
@@ -10313,6 +10754,8 @@ init_comments();
|
|
|
10313
10754
|
isPluginRegistered,
|
|
10314
10755
|
isSafeImageUrl,
|
|
10315
10756
|
isSafeLinkUrl,
|
|
10757
|
+
isSuggesting,
|
|
10758
|
+
listSuggestions,
|
|
10316
10759
|
marksOf,
|
|
10317
10760
|
newCommentId,
|
|
10318
10761
|
nodesOf,
|
|
@@ -10332,6 +10775,7 @@ init_comments();
|
|
|
10332
10775
|
removeLink,
|
|
10333
10776
|
replaceAll,
|
|
10334
10777
|
replaceCurrent,
|
|
10778
|
+
resolveSuggestions,
|
|
10335
10779
|
ru,
|
|
10336
10780
|
sanitizeThread,
|
|
10337
10781
|
schema,
|
|
@@ -10342,6 +10786,8 @@ init_comments();
|
|
|
10342
10786
|
setLink,
|
|
10343
10787
|
setSearch,
|
|
10344
10788
|
setStyle,
|
|
10789
|
+
setSuggesting,
|
|
10790
|
+
suggestionsResult,
|
|
10345
10791
|
tableCommands,
|
|
10346
10792
|
toggleFullscreen,
|
|
10347
10793
|
uploadImages
|