@vitral/editor 0.2.9 → 0.2.11
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/README.md +8 -0
- package/dist/buttons.js +3 -1
- package/dist/buttons.js.map +1 -1
- package/dist/editor.js +42 -4
- package/dist/editor.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/math.d.ts +61 -0
- package/dist/math.js +404 -0
- package/dist/math.js.map +1 -0
- package/dist/render/toolbar.d.ts +2 -0
- package/dist/render/toolbar.js +17 -6
- package/dist/render/toolbar.js.map +1 -1
- package/dist/slash.js +2 -1
- package/dist/slash.js.map +1 -1
- package/dist/types.d.ts +43 -4
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -24,6 +24,14 @@ around them: the toolbar and its buttons, the block type, the colour swatches,
|
|
|
24
24
|
the link, image and table panels, the floating toolbar over a selection, the
|
|
25
25
|
menu a `/` opens in an empty block, and the handle beside a block.
|
|
26
26
|
|
|
27
|
+
Formulas are written in LaTeX and drawn: the toolbar's formula button and the
|
|
28
|
+
slash menu open a panel with the source, the formula drawn as it is typed and
|
|
29
|
+
the usual ones ready-made; a number or a letter of a formula pressed in the
|
|
30
|
+
text is edited where it stands. The drawing is outlines laid out here, not
|
|
31
|
+
text set by the browser, so it is the same everywhere and prints as it looks.
|
|
32
|
+
`math: false` switches the editing off, `math: { templates, inlineEdit }`
|
|
33
|
+
shapes it, and `createMathTools` attaches the same to an editor of your own.
|
|
34
|
+
|
|
27
35
|
A slash menu entry is `{ id, label, description, icon, command }` or carries a
|
|
28
36
|
`run` of its own, so an application can offer whatever it likes; the same goes
|
|
29
37
|
for the block handle's actions. What a framework component draws better — a
|
package/dist/buttons.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { arrowDown, arrowUp, bold, clearFormatting, code, codeBlock, copy, grip, heading1, heading2, heading3, highlighter, horizontalRule, image, indent, italic, link, list, listChecks, listOrdered, outdent, pilcrow, quote, redo, strikethrough, table, textColor, trash, underline, undo } from "@vitral/icons";
|
|
1
|
+
import { arrowDown, arrowUp, bold, clearFormatting, code, codeBlock, copy, grip, heading1, heading2, heading3, highlighter, horizontalRule, image, indent, italic, link, list, listChecks, listOrdered, outdent, pilcrow, quote, redo, sigma, strikethrough, table, textColor, trash, underline, undo } from "@vitral/icons";
|
|
2
2
|
//#region src/buttons.ts
|
|
3
3
|
/** What each plain toolbar button is: icon, name, command and pressed state. */
|
|
4
4
|
var editorButtons = {
|
|
@@ -150,6 +150,7 @@ var defaultToolbar = [
|
|
|
150
150
|
"link",
|
|
151
151
|
"image",
|
|
152
152
|
"table",
|
|
153
|
+
"math",
|
|
153
154
|
"horizontalRule"
|
|
154
155
|
],
|
|
155
156
|
[
|
|
@@ -183,6 +184,7 @@ var editorIcons = [
|
|
|
183
184
|
grip,
|
|
184
185
|
highlighter,
|
|
185
186
|
image,
|
|
187
|
+
sigma,
|
|
186
188
|
table,
|
|
187
189
|
textColor,
|
|
188
190
|
trash
|
package/dist/buttons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buttons.js","names":[],"sources":["../src/buttons.ts"],"sourcesContent":["import type { Locale } from '@vitral/core';\nimport {\n arrowDown,\n arrowUp,\n bold,\n clearFormatting,\n code,\n codeBlock,\n copy,\n grip,\n heading1,\n heading2,\n heading3,\n highlighter,\n horizontalRule,\n image,\n indent,\n italic,\n link,\n list,\n listChecks,\n listOrdered,\n outdent,\n pilcrow,\n quote,\n redo,\n strikethrough,\n table,\n textColor,\n trash,\n underline,\n undo,\n type IconDef\n} from '@vitral/icons';\nimport type { EditorButtonCommand, EditorToolbarItem } from './types';\n\n/**\n * What every toolbar button is — icon, name, command, pressed state — as plain\n * data, so the Vue toolbar, the framework-free one and anything else draw the\n * same buttons from the same list.\n */\n\nexport interface EditorButtonSpec {\n icon: IconDef;\n label: (text: Locale['editor']) => string;\n /** The command the button runs, with its arguments; `link` opens the link editor. */\n command: readonly [string, ...unknown[]];\n /** What the button's pressed state reflects. */\n active?: readonly [string, Record<string, unknown>?];\n}\n\n/** What each plain toolbar button is: icon, name, command and pressed state. */\nexport const editorButtons: Record<EditorButtonCommand, EditorButtonSpec> = {\n paragraph: { icon: pilcrow, label: (t) => t.paragraph, command: ['setParagraph'], active: ['paragraph'] },\n heading1: { icon: heading1, label: (t) => t.heading1, command: ['toggleHeading', 1], active: ['heading', { level: 1 }] },\n heading2: { icon: heading2, label: (t) => t.heading2, command: ['toggleHeading', 2], active: ['heading', { level: 2 }] },\n heading3: { icon: heading3, label: (t) => t.heading3, command: ['toggleHeading', 3], active: ['heading', { level: 3 }] },\n bold: { icon: bold, label: (t) => t.bold, command: ['toggleBold'], active: ['bold'] },\n italic: { icon: italic, label: (t) => t.italic, command: ['toggleItalic'], active: ['italic'] },\n underline: { icon: underline, label: (t) => t.underline, command: ['toggleUnderline'], active: ['underline'] },\n strike: { icon: strikethrough, label: (t) => t.strike, command: ['toggleStrike'], active: ['strike'] },\n code: { icon: code, label: (t) => t.code, command: ['toggleCode'], active: ['code'] },\n bulletList: { icon: list, label: (t) => t.bulletList, command: ['toggleBulletList'], active: ['bulletList'] },\n orderedList: { icon: listOrdered, label: (t) => t.orderedList, command: ['toggleOrderedList'], active: ['orderedList'] },\n taskList: { icon: listChecks, label: (t) => t.taskList, command: ['toggleTaskList'], active: ['taskList'] },\n indent: { icon: indent, label: (t) => t.indent, command: ['sinkListItem'] },\n outdent: { icon: outdent, label: (t) => t.outdent, command: ['liftListItem'] },\n blockquote: { icon: quote, label: (t) => t.blockquote, command: ['toggleBlockquote'], active: ['blockquote'] },\n codeBlock: { icon: codeBlock, label: (t) => t.codeBlock, command: ['toggleCodeBlock'], active: ['codeBlock'] },\n horizontalRule: { icon: horizontalRule, label: (t) => t.horizontalRule, command: ['insertHorizontalRule'] },\n link: { icon: link, label: (t) => t.link, command: ['link'], active: ['link'] },\n undo: { icon: undo, label: (t) => t.undo, command: ['undo'] },\n redo: { icon: redo, label: (t) => t.redo, command: ['redo'] },\n clear: { icon: clearFormatting, label: (t) => t.clearFormatting, command: ['clearFormatting'] }\n};\n\n/** Where a button's shortcut is looked up, when it is not its own command's. */\nexport const shortcutCommands: Partial<Record<EditorButtonCommand, readonly [string, ...unknown[]]>> = {\n indent: ['indent'],\n outdent: ['outdent']\n};\n\n/** The toolbar `<Editor>` shows unless told otherwise. */\nexport const defaultToolbar: EditorToolbarItem[][] = [\n ['blockType'],\n ['bold', 'italic', 'underline', 'strike', 'code'],\n ['color', 'highlight'],\n ['bulletList', 'orderedList', 'taskList'],\n ['blockquote', 'codeBlock', 'link', 'image', 'table', 'horizontalRule'],\n ['undo', 'redo', 'clear']\n];\n\n/** The floating toolbar's buttons. */\nexport const defaultBubbleMenu: EditorToolbarItem[] = ['bold', 'italic', 'underline', 'strike', 'code', 'link', 'color'];\n\n/**\n * The icons the editor ships with, by name. The toolbar holds its own\n * definitions, but the slash menu, the block handle and anything an\n * application names in a command of its own are looked up by name — so the\n * editor puts its own set in the registry rather than going blank in an\n * application that never registered them.\n */\nexport const editorIcons: IconDef[] = [\n ...Object.values(editorButtons).map((spec) => spec.icon),\n arrowDown,\n arrowUp,\n copy,\n grip,\n highlighter,\n image,\n table,\n textColor,\n trash\n];\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"buttons.js","names":[],"sources":["../src/buttons.ts"],"sourcesContent":["import type { Locale } from '@vitral/core';\nimport {\n arrowDown,\n arrowUp,\n bold,\n clearFormatting,\n code,\n codeBlock,\n copy,\n grip,\n heading1,\n heading2,\n heading3,\n highlighter,\n horizontalRule,\n image,\n indent,\n italic,\n link,\n list,\n listChecks,\n listOrdered,\n outdent,\n pilcrow,\n quote,\n redo,\n sigma,\n strikethrough,\n table,\n textColor,\n trash,\n underline,\n undo,\n type IconDef\n} from '@vitral/icons';\nimport type { EditorButtonCommand, EditorToolbarItem } from './types';\n\n/**\n * What every toolbar button is — icon, name, command, pressed state — as plain\n * data, so the Vue toolbar, the framework-free one and anything else draw the\n * same buttons from the same list.\n */\n\nexport interface EditorButtonSpec {\n icon: IconDef;\n label: (text: Locale['editor']) => string;\n /** The command the button runs, with its arguments; `link` opens the link editor. */\n command: readonly [string, ...unknown[]];\n /** What the button's pressed state reflects. */\n active?: readonly [string, Record<string, unknown>?];\n}\n\n/** What each plain toolbar button is: icon, name, command and pressed state. */\nexport const editorButtons: Record<EditorButtonCommand, EditorButtonSpec> = {\n paragraph: { icon: pilcrow, label: (t) => t.paragraph, command: ['setParagraph'], active: ['paragraph'] },\n heading1: { icon: heading1, label: (t) => t.heading1, command: ['toggleHeading', 1], active: ['heading', { level: 1 }] },\n heading2: { icon: heading2, label: (t) => t.heading2, command: ['toggleHeading', 2], active: ['heading', { level: 2 }] },\n heading3: { icon: heading3, label: (t) => t.heading3, command: ['toggleHeading', 3], active: ['heading', { level: 3 }] },\n bold: { icon: bold, label: (t) => t.bold, command: ['toggleBold'], active: ['bold'] },\n italic: { icon: italic, label: (t) => t.italic, command: ['toggleItalic'], active: ['italic'] },\n underline: { icon: underline, label: (t) => t.underline, command: ['toggleUnderline'], active: ['underline'] },\n strike: { icon: strikethrough, label: (t) => t.strike, command: ['toggleStrike'], active: ['strike'] },\n code: { icon: code, label: (t) => t.code, command: ['toggleCode'], active: ['code'] },\n bulletList: { icon: list, label: (t) => t.bulletList, command: ['toggleBulletList'], active: ['bulletList'] },\n orderedList: { icon: listOrdered, label: (t) => t.orderedList, command: ['toggleOrderedList'], active: ['orderedList'] },\n taskList: { icon: listChecks, label: (t) => t.taskList, command: ['toggleTaskList'], active: ['taskList'] },\n indent: { icon: indent, label: (t) => t.indent, command: ['sinkListItem'] },\n outdent: { icon: outdent, label: (t) => t.outdent, command: ['liftListItem'] },\n blockquote: { icon: quote, label: (t) => t.blockquote, command: ['toggleBlockquote'], active: ['blockquote'] },\n codeBlock: { icon: codeBlock, label: (t) => t.codeBlock, command: ['toggleCodeBlock'], active: ['codeBlock'] },\n horizontalRule: { icon: horizontalRule, label: (t) => t.horizontalRule, command: ['insertHorizontalRule'] },\n link: { icon: link, label: (t) => t.link, command: ['link'], active: ['link'] },\n undo: { icon: undo, label: (t) => t.undo, command: ['undo'] },\n redo: { icon: redo, label: (t) => t.redo, command: ['redo'] },\n clear: { icon: clearFormatting, label: (t) => t.clearFormatting, command: ['clearFormatting'] }\n};\n\n/** Where a button's shortcut is looked up, when it is not its own command's. */\nexport const shortcutCommands: Partial<Record<EditorButtonCommand, readonly [string, ...unknown[]]>> = {\n indent: ['indent'],\n outdent: ['outdent']\n};\n\n/** The toolbar `<Editor>` shows unless told otherwise. */\nexport const defaultToolbar: EditorToolbarItem[][] = [\n ['blockType'],\n ['bold', 'italic', 'underline', 'strike', 'code'],\n ['color', 'highlight'],\n ['bulletList', 'orderedList', 'taskList'],\n ['blockquote', 'codeBlock', 'link', 'image', 'table', 'math', 'horizontalRule'],\n ['undo', 'redo', 'clear']\n];\n\n/** The floating toolbar's buttons. */\nexport const defaultBubbleMenu: EditorToolbarItem[] = ['bold', 'italic', 'underline', 'strike', 'code', 'link', 'color'];\n\n/**\n * The icons the editor ships with, by name. The toolbar holds its own\n * definitions, but the slash menu, the block handle and anything an\n * application names in a command of its own are looked up by name — so the\n * editor puts its own set in the registry rather than going blank in an\n * application that never registered them.\n */\nexport const editorIcons: IconDef[] = [\n ...Object.values(editorButtons).map((spec) => spec.icon),\n arrowDown,\n arrowUp,\n copy,\n grip,\n highlighter,\n image,\n sigma,\n table,\n textColor,\n trash\n];\n"],"mappings":";;;AAqDA,IAAa,gBAA+D;CACxE,WAAW;EAAE,MAAM;EAAS,QAAQ,MAAM,EAAE;EAAW,SAAS,CAAC,cAAc;EAAG,QAAQ,CAAC,WAAW;CAAE;CACxG,UAAU;EAAE,MAAM;EAAU,QAAQ,MAAM,EAAE;EAAU,SAAS,CAAC,iBAAiB,CAAC;EAAG,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,CAAC;CAAE;CACvH,UAAU;EAAE,MAAM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CACA;AACJ"}
|
package/dist/editor.js
CHANGED
|
@@ -3,6 +3,7 @@ import { bubbleView, toolbarView } from "./render/toolbar.js";
|
|
|
3
3
|
import { colorPanelView, imagePanelView, linkPanelView, tablePanelView } from "./render/menus.js";
|
|
4
4
|
import { createBlockHandle, defaultBlockActions } from "./block.js";
|
|
5
5
|
import { createChipMenu } from "./chips.js";
|
|
6
|
+
import { createMathTools, defaultMathTemplates } from "./math.js";
|
|
6
7
|
import { createFindBar } from "./find.js";
|
|
7
8
|
import { createSlashMenu, defaultSlashCommands } from "./slash.js";
|
|
8
9
|
import { activeEditorBlockType, activeEditorMark, ariaEditorShortcut, createEditor, createEditorView, editorKeyName, editorLinkAt, editorLinkHint, editorPalette, editorSelectionRange, editorShortcutFor, en, followEditorLink, formatEditorShortcut, formatMessage, isEmptyEditorDoc, isMacPlatform, loadStyle, matchEditorPaletteColor, visuallyHidden } from "@vitral/core";
|
|
@@ -71,7 +72,8 @@ function createTextEditor(element, config = {}) {
|
|
|
71
72
|
const editor = createEditor({
|
|
72
73
|
content: current.content ?? "",
|
|
73
74
|
maxLength: current.maxLength ?? null,
|
|
74
|
-
historyDelay: current.historyDelay
|
|
75
|
+
historyDelay: current.historyDelay,
|
|
76
|
+
mathOutput: typeof current.math === "object" ? current.math.output : void 0
|
|
75
77
|
});
|
|
76
78
|
const editable = () => !current.readonly && !current.disabled;
|
|
77
79
|
const collapsed = () => editorSelectionRange(editor.state.selection).empty;
|
|
@@ -228,11 +230,29 @@ function createTextEditor(element, config = {}) {
|
|
|
228
230
|
overlayTarget: current.overlayTarget,
|
|
229
231
|
zIndex: current.zIndex
|
|
230
232
|
});
|
|
233
|
+
const mathOn = () => current.math !== false;
|
|
234
|
+
const mathOptions = () => typeof current.math === "object" ? current.math : {};
|
|
235
|
+
const mathTools = createMathTools({
|
|
236
|
+
editor,
|
|
237
|
+
view: () => view,
|
|
238
|
+
content: () => contentEl,
|
|
239
|
+
anchor: () => caretEl,
|
|
240
|
+
place: placeCaret,
|
|
241
|
+
templates: () => mathOptions().templates ?? defaultMathTemplates(locale()),
|
|
242
|
+
inlineEdit: () => mathOptions().inlineEdit !== false,
|
|
243
|
+
part,
|
|
244
|
+
locale,
|
|
245
|
+
enabled: () => mathOn() && editable(),
|
|
246
|
+
focus: () => view?.focus(),
|
|
247
|
+
id: `${id}-math`,
|
|
248
|
+
overlayTarget: current.overlayTarget,
|
|
249
|
+
zIndex: current.zIndex
|
|
250
|
+
});
|
|
231
251
|
const slashMenu = createSlashMenu({
|
|
232
252
|
editor,
|
|
233
253
|
content: () => contentEl,
|
|
234
254
|
anchor: () => caretEl,
|
|
235
|
-
commands: () => Array.isArray(current.slashMenu) ? current.slashMenu : defaultSlashCommands(locale()),
|
|
255
|
+
commands: () => Array.isArray(current.slashMenu) ? current.slashMenu : defaultSlashCommands(locale()).filter((command) => command.id !== "math" || mathOn()),
|
|
236
256
|
part,
|
|
237
257
|
locale,
|
|
238
258
|
enabled: () => current.slashMenu !== false && editable(),
|
|
@@ -242,6 +262,7 @@ function createTextEditor(element, config = {}) {
|
|
|
242
262
|
zIndex: current.zIndex,
|
|
243
263
|
onRun: (command) => {
|
|
244
264
|
if (command.run) command.run(handle);
|
|
265
|
+
else if (command.command?.[0] === "math") return mathTools.open();
|
|
245
266
|
else if (command.command) run(command.command[0], ...command.command.slice(1));
|
|
246
267
|
focus();
|
|
247
268
|
}
|
|
@@ -335,6 +356,10 @@ function createTextEditor(element, config = {}) {
|
|
|
335
356
|
openFind: () => findBar.isOpen ? findBar.close() : findBar.open(),
|
|
336
357
|
openImage: (event) => openPanel(imagePanel, "image", event),
|
|
337
358
|
openTable: (event) => openPanel(tablePanel, "table", event),
|
|
359
|
+
openMath: (event) => {
|
|
360
|
+
closePanels();
|
|
361
|
+
mathTools.open(editor.isActive("math") ? null : event.currentTarget);
|
|
362
|
+
},
|
|
338
363
|
openColor: (kind, event) => {
|
|
339
364
|
colorKind = kind;
|
|
340
365
|
openPanel(colorPanel, kind, event);
|
|
@@ -396,7 +421,11 @@ function createTextEditor(element, config = {}) {
|
|
|
396
421
|
}
|
|
397
422
|
});
|
|
398
423
|
}
|
|
399
|
-
|
|
424
|
+
/** The groups of the toolbar, without the formula button where formulas are off. */
|
|
425
|
+
const toolbarGroups = () => {
|
|
426
|
+
const groups = Array.isArray(current.toolbar) ? current.toolbar : defaultToolbar;
|
|
427
|
+
return mathOn() ? groups : groups.map((group) => group.filter((item) => item !== "math")).filter((group) => group.length);
|
|
428
|
+
};
|
|
400
429
|
function countText() {
|
|
401
430
|
const words = locale().editor;
|
|
402
431
|
const count = editor.characterCount();
|
|
@@ -426,6 +455,7 @@ function createTextEditor(element, config = {}) {
|
|
|
426
455
|
"aria-invalid": current.invalid ? "true" : void 0,
|
|
427
456
|
"aria-placeholder": current.placeholder || void 0,
|
|
428
457
|
"data-placeholder": current.placeholder || void 0,
|
|
458
|
+
"data-math-edit": mathOn() && editable() ? mathOptions().inlineEdit === false ? "panel" : "inline" : void 0,
|
|
429
459
|
contenteditable: editable() ? "true" : "false",
|
|
430
460
|
tabindex: current.disabled ? "-1" : "0",
|
|
431
461
|
spellcheck: "true",
|
|
@@ -466,6 +496,7 @@ function createTextEditor(element, config = {}) {
|
|
|
466
496
|
syncBubble();
|
|
467
497
|
renderPanels();
|
|
468
498
|
blockHandle.sync();
|
|
499
|
+
mathTools.sync();
|
|
469
500
|
}
|
|
470
501
|
function attachView() {
|
|
471
502
|
view?.destroy();
|
|
@@ -477,6 +508,11 @@ function createTextEditor(element, config = {}) {
|
|
|
477
508
|
selectedClass: "vt-editor-node-selected",
|
|
478
509
|
emptyClass: "vt-editor-content-empty",
|
|
479
510
|
chipClass: (kind) => current.unstyled ? void 0 : ["vt-editor-chip", kind ? `vt-editor-chip-${kind}` : ""].filter(Boolean).join(" "),
|
|
511
|
+
mathClass: ({ display, pending }) => current.unstyled ? void 0 : [
|
|
512
|
+
"vt-editor-math",
|
|
513
|
+
display ? "vt-editor-math-display" : "",
|
|
514
|
+
pending ? "vt-editor-math-pending" : ""
|
|
515
|
+
].filter(Boolean).join(" "),
|
|
480
516
|
handleKey: (_name, binding) => {
|
|
481
517
|
if (binding?.[0] !== "link" || !editable()) return false;
|
|
482
518
|
openLinkPanel();
|
|
@@ -501,9 +537,10 @@ function createTextEditor(element, config = {}) {
|
|
|
501
537
|
};
|
|
502
538
|
if (content) editor.setContent(current.content ?? "", { emit: false });
|
|
503
539
|
if ("maxLength" in next) editor.maxLength = current.maxLength ?? null;
|
|
540
|
+
if ("math" in next) editor.mathOutput = mathOptions().output ?? "drawing";
|
|
504
541
|
render();
|
|
505
542
|
},
|
|
506
|
-
getHTML: () => editor.getHTML(),
|
|
543
|
+
getHTML: (options) => editor.getHTML(options),
|
|
507
544
|
getJSON: () => editor.getJSON(),
|
|
508
545
|
getText: () => editor.getText(),
|
|
509
546
|
getMarkdown: () => editor.getMarkdown(),
|
|
@@ -533,6 +570,7 @@ function createTextEditor(element, config = {}) {
|
|
|
533
570
|
findBar.destroy();
|
|
534
571
|
slashMenu.destroy();
|
|
535
572
|
chipMenu.destroy();
|
|
573
|
+
mathTools.destroy();
|
|
536
574
|
blockHandle.destroy();
|
|
537
575
|
[...panels(), bubble].forEach((overlay) => overlay.destroy());
|
|
538
576
|
blockSelect?.destroy();
|
package/dist/editor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.js","names":[],"sources":["../src/editor.ts"],"sourcesContent":["import {\n activeEditorBlockType,\n activeEditorMark,\n ariaEditorShortcut,\n createEditor as createEditorInstance,\n createEditorView,\n editorLinkAt,\n editorKeyName,\n editorLinkHint,\n editorPalette,\n editorShortcutFor,\n editorSelectionRange,\n editorTextblocks,\n en,\n formatEditorShortcut,\n followEditorLink,\n formatMessage,\n isEmptyEditorDoc,\n isMacPlatform,\n loadStyle,\n matchEditorPaletteColor,\n visuallyHidden,\n type EditorColor,\n type EditorInstance,\n type EditorNode,\n type EditorView,\n type Locale\n} from '@vitral/core';\nimport { createOverlay, createSelect, createTooltips, type Overlay, type SelectHandle } from '@vitral/controls';\nimport { createRoot, h, mergeAttrs, partResolver, type Child, type Props } from '@vitral/dom';\nimport { registerIcons } from '@vitral/icons';\nimport { baseStyle, buttonStyle, editorStyle } from '@vitral/styles';\nimport { defaultBubbleMenu, defaultToolbar, editorIcons } from './buttons';\nimport { createBlockHandle, defaultBlockActions } from './block';\nimport { colorPanelView, imagePanelView, linkPanelView, tablePanelView, type LinkPanelState, type PanelContext } from './render/menus';\nimport { createChipMenu } from './chips';\nimport { createFindBar } from './find';\nimport { createSlashMenu, defaultSlashCommands } from './slash';\nimport { bubbleView, toolbarView, type ToolbarContext } from './render/toolbar';\nimport type { TextEditorConfig, TextEditorHandle, EditorToolbarItem } from './types';\n\n/**\n * A rich text editor with no framework in it: the document, the commands and\n * the history are `@vitral/core`'s, the text itself is its view over a\n * `contenteditable` element, and everything around them — the toolbar, the\n * panels, the floating toolbar over a selection, the menu a `/` opens and the\n * handle beside a block — is drawn here.\n */\n\nlet counter = 0;\n\nexport function createTextEditor(element: HTMLElement, config: TextEditorConfig = {}): TextEditorHandle {\n let current: TextEditorConfig = { ...config };\n let view: EditorView | null = null;\n let contentEl: HTMLElement | null = null;\n let caretEl: HTMLElement | null = null;\n let blockSelect: SelectHandle | null = null;\n let blockSelectHost: HTMLElement | null = null;\n let link: LinkPanelState = { href: '', text: '', newTab: false, existing: false };\n const anchors = new Map<string, HTMLElement>();\n\n const id = config.id ?? `vt-texteditor-${++counter}`;\n const ids = { content: `${id}-content`, help: `${id}-help`, slash: `${id}-slash`, block: `${id}-block` };\n const root = createRoot(element);\n const locale = (): Locale => current.locale ?? en;\n const palette = (): readonly EditorColor[] => current.palette ?? editorPalette;\n const part = partResolver({\n style: editorStyle,\n unstyled: () => !!current.unstyled,\n classes: () => current.classes,\n pt: () => current.pt,\n props: () => current as Record<string, unknown>\n });\n\n if (!config.unstyled) {\n const options = { nonce: config.nonce, cssLayer: config.cssLayer };\n loadStyle(baseStyle.name, baseStyle.css, options);\n loadStyle(buttonStyle.name, buttonStyle.css, options);\n loadStyle(editorStyle.name, editorStyle.css, options);\n }\n // The toolbar holds its own definitions, but the slash menu, the block\n // handle and any command an application names its own icon for are looked\n // up by name: the editor puts its set in the registry rather than drawing\n // a bar of empty buttons in an application that never registered them.\n // What each button is, shown the way every other Vitral control shows it.\n const tooltips = createTooltips(() => ({\n placement: 'bottom',\n unstyled: current.unstyled,\n nonce: current.nonce,\n cssLayer: current.cssLayer,\n zIndex: current.zIndex,\n pt: current.pt\n }));\n\n registerIcons(editorIcons);\n\n const editor: EditorInstance = createEditorInstance({\n content: current.content ?? '',\n maxLength: current.maxLength ?? null,\n historyDelay: current.historyDelay\n });\n\n const editable = () => !current.readonly && !current.disabled;\n const collapsed = () => editorSelectionRange(editor.state.selection).empty;\n const run = (name: string, ...args: unknown[]) => (editor.run as (n: string, ...a: unknown[]) => boolean)(name, ...args);\n const can = (name: string, ...args: unknown[]) => (editor.can as (n: string, ...a: unknown[]) => boolean)(name, ...args);\n\n // ---- what the outside hears ---------------------------------------------------------\n\n const stop = editor.subscribe((update) => {\n if (update.docChanged) {\n current.on?.change?.({ html: editor.getHTML(), json: editor.getJSON(), text: editor.getText() });\n }\n if (update.docChanged) findBar.sync();\n if (update.selectionChanged) {\n current.on?.['selection-change']?.({ empty: collapsed(), source: update.origin === 'user' ? 'user' : update.origin === 'history' ? 'history' : 'api' });\n }\n render();\n });\n\n // ---- the panels ------------------------------------------------------------------------\n\n const panelContext = (): PanelContext => ({ locale: locale(), part, ids });\n\n const anchorFor = (name: string) => () => anchors.get(name) ?? caretEl;\n\n function panel(name: string, render: () => ReturnType<typeof linkPanelView> | null, placement: 'bottom-start' | 'bottom-end' = 'bottom-start'): Overlay {\n return createOverlay({\n anchor: anchorFor(name),\n render,\n placement,\n target: () => current.overlayTarget,\n zIndex: current.zIndex,\n onClose: () => renderPanels()\n });\n }\n\n const linkPanel = panel('link', () => linkPanelView(panelContext(), link, linkActions));\n const imagePanel = panel('image', () => imagePanelView(panelContext(), imageActions));\n const tablePanel = panel('table', () => tablePanelView(panelContext(), { insert: insertTable }));\n const colorPanel = panel('color', () => colorPanelView(panelContext(), { kind: colorKind, palette: palette(), chosen: colorOf(colorKind), onChoose: chooseColor }));\n let colorKind: 'color' | 'highlight' = 'color';\n\n const linkActions = {\n change: (patch: Partial<LinkPanelState>) => {\n link = { ...link, ...patch, error: undefined };\n linkPanel.update();\n },\n apply: () => {\n const href = link.href.trim();\n if (!href) {\n link = { ...link, error: locale().editor.invalidUrl };\n linkPanel.update();\n return;\n }\n run('setLink', href, { target: link.newTab ? '_blank' : null, text: link.text.trim() || undefined });\n linkPanel.close();\n focus();\n },\n remove: () => {\n run('unsetLink');\n linkPanel.close();\n focus();\n },\n open: () => {\n followEditorLink(link.href.trim());\n linkPanel.close();\n },\n cancel: () => {\n linkPanel.close();\n focus();\n }\n };\n\n /** The link editor, filled in with the link under the caret when there is one. */\n function openLinkPanel(event?: MouseEvent) {\n if (!editable()) return;\n const at = editorLinkAt(editor.state);\n link = { href: at?.href ?? '', text: at?.text ?? '', newTab: at?.target === '_blank', existing: !!at };\n if (!event) placeCaret();\n openPanel(linkPanel, 'link', event);\n }\n\n const imageActions = {\n insert: (src: string, alt: string) => {\n if (src.trim()) run('insertImage', { src: src.trim(), alt: alt.trim() });\n imagePanel.close();\n focus();\n },\n cancel: () => {\n imagePanel.close();\n focus();\n }\n };\n\n function insertTable(rows: number, columns: number) {\n run('insertTable', rows, columns, true);\n tablePanel.close();\n focus();\n }\n\n const colorOf = (kind: 'color' | 'highlight'): EditorColor | undefined => {\n const mark = activeEditorMark(editor.state, kind);\n const value = mark?.attrs?.color;\n if (typeof value !== 'string') return undefined;\n const name = matchEditorPaletteColor(value, kind, palette());\n return palette().find((color) => color.name === name);\n };\n\n function chooseColor(color: EditorColor | null) {\n run(colorKind === 'color' ? 'setColor' : 'setHighlight', color?.name ?? null);\n colorPanel.close();\n focus();\n }\n\n // ---- the floating toolbar over a selection -----------------------------------------------\n\n const bubble = createOverlay({\n anchor: () => caretEl,\n render: () => bubbleView(toolbarContext(), bubbleItems()) as never,\n placement: 'top',\n target: () => current.overlayTarget,\n zIndex: current.zIndex,\n restoreFocus: false\n });\n\n const bubbleItems = (): EditorToolbarItem[] => (Array.isArray(current.bubbleMenu) ? current.bubbleMenu : defaultBubbleMenu);\n\n function syncBubble() {\n const wanted = current.bubbleMenu !== false && editable() && !collapsed() && !editor.isEmpty();\n if (wanted) {\n placeCaret();\n bubble.open();\n bubble.update();\n } else bubble.close();\n }\n\n // ---- the menu a slash opens, and the handle beside a block ---------------------------------\n\n const chipMenu = createChipMenu({\n editor,\n content: () => contentEl,\n anchor: () => caretEl,\n triggers: () => (current.chips ? (Array.isArray(current.chips) ? current.chips : [current.chips]) : []),\n part,\n locale,\n enabled: () => !!current.chips && editable(),\n place: placeCaret,\n id: `${ids.slash}-chips`,\n overlayTarget: current.overlayTarget,\n zIndex: current.zIndex\n });\n\n const slashMenu = createSlashMenu({\n editor,\n content: () => contentEl,\n anchor: () => caretEl,\n commands: () => (Array.isArray(current.slashMenu) ? current.slashMenu : defaultSlashCommands(locale())),\n part,\n locale,\n enabled: () => current.slashMenu !== false && editable(),\n place: placeCaret,\n ids,\n overlayTarget: current.overlayTarget,\n zIndex: current.zIndex,\n onRun: (command) => {\n if (command.run) command.run(handle);\n else if (command.command) run(command.command[0], ...command.command.slice(1));\n focus();\n }\n });\n\n const blockHandle = createBlockHandle({\n editor,\n host: () => element,\n caretRect: () => view?.selectionRect() ?? null,\n content: () => contentEl,\n actions: () => (Array.isArray(current.blockMenu) ? current.blockMenu : defaultBlockActions(locale())),\n part,\n locale,\n enabled: () => current.blockMenu !== false && editable(),\n ids,\n overlayTarget: current.overlayTarget,\n zIndex: current.zIndex\n });\n\n // ---- find and replace ---------------------------------------------------------------------\n\n const findBar = createFindBar({\n editor,\n view: () => view,\n part,\n locale,\n editable,\n render: () => render(),\n id: `${id}-find`\n });\n\n // Ctrl/⌘+F finds and Ctrl+H (⌘+⌥+F on a Mac, where ⌘+H hides the app)\n // replaces, anywhere in the editor — the text, the toolbar or the bar.\n const onFindKey = (event: KeyboardEvent) => {\n if (current.find === false) return;\n const name = editorKeyName(event);\n const replace = name === (isMacPlatform() ? 'Mod-Alt-f' : 'Mod-h');\n if (name !== 'Mod-f' && !replace) return;\n event.preventDefault();\n findBar.open({ replace });\n };\n element.addEventListener('keydown', onFindKey);\n\n // ---- where a popup hangs from ---------------------------------------------------------------\n\n /** The caret's own rectangle, as an element popups can be anchored to. */\n function placeCaret() {\n if (!caretEl || !contentEl) return;\n const rect = view?.selectionRect();\n if (!rect) return;\n const host = element.getBoundingClientRect();\n caretEl.style.top = `${rect.top - host.top}px`;\n caretEl.style.left = `${rect.left - host.left}px`;\n caretEl.style.width = `${Math.max(1, rect.width)}px`;\n caretEl.style.height = `${rect.height}px`;\n }\n\n function openPanel(overlay: Overlay, name: string, event?: MouseEvent) {\n if (event) anchors.set(name, event.currentTarget as HTMLElement);\n else anchors.delete(name);\n closePanels(overlay);\n overlay.open();\n overlay.update();\n }\n\n const panels = () => [linkPanel, imagePanel, tablePanel, colorPanel];\n const closePanels = (except?: Overlay) => panels().forEach((overlay) => overlay !== except && overlay.close());\n const renderPanels = () => panels().forEach((overlay) => overlay.update());\n\n // ---- the toolbar -----------------------------------------------------------------------------\n\n function toolbarContext(): ToolbarContext {\n return {\n locale: locale(),\n part,\n editable: editable(),\n can,\n isActive: (name, attrs) => editor.isActive(name, attrs as never),\n shortcut: (name, args) => {\n const binding = editorShortcutFor(name, args);\n return binding ? { label: formatEditorShortcut(binding), aria: ariaEditorShortcut(binding) } : undefined;\n },\n colors: { text: colorOf('color'), highlight: colorOf('highlight') },\n ref: (name) => (el) => {\n if (el) anchors.set(name, el as HTMLElement);\n else anchors.delete(name);\n },\n on: {\n tip: (element, text) => tooltips.attach(element, text),\n command: (name, args, event) => {\n run(name, ...args);\n if (event.detail > 0) focus();\n },\n openLink: (event) => openLinkPanel(event),\n openFind: () => (findBar.isOpen ? findBar.close() : findBar.open()),\n openImage: (event) => openPanel(imagePanel, 'image', event),\n openTable: (event) => openPanel(tablePanel, 'table', event),\n openColor: (kind, event) => {\n colorKind = kind;\n openPanel(colorPanel, kind, event);\n },\n blockSelect: (el) => {\n blockSelectHost = (el as HTMLElement | null) ?? null;\n syncBlockSelect();\n }\n }\n };\n }\n\n /** The block type, drawn by the control kit's select. */\n function syncBlockSelect() {\n if (!blockSelectHost) return;\n const words = locale().editor;\n const options = [\n { label: words.paragraph, value: 'paragraph' },\n { label: words.heading1, value: 'heading1' },\n { label: words.heading2, value: 'heading2' },\n { label: words.heading3, value: 'heading3' },\n { label: words.codeBlock, value: 'codeBlock' }\n ];\n const active = activeEditorBlockType(editor.state);\n const settings = {\n options,\n optionValue: 'value',\n value: active,\n size: 'small' as const,\n ariaLabel: words.blockType,\n disabled: !editable(),\n locale: locale(),\n unstyled: current.unstyled,\n overlayTarget: current.overlayTarget,\n zIndex: current.zIndex,\n nonce: current.nonce,\n cssLayer: current.cssLayer\n };\n if (blockSelect) blockSelect.update(settings);\n else\n blockSelect = createSelect(blockSelectHost, {\n ...settings,\n onChange: (value) => {\n if (value === 'paragraph') run('setParagraph');\n else if (value === 'codeBlock') run('toggleCodeBlock');\n else run('toggleHeading', Number(String(value).slice(-1)));\n focus();\n }\n });\n }\n\n // ---- drawing --------------------------------------------------------------------------------\n\n const toolbarGroups = (): EditorToolbarItem[][] => (Array.isArray(current.toolbar) ? current.toolbar : defaultToolbar);\n\n function countText(): string {\n const words = locale().editor;\n const count = editor.characterCount();\n const characters = current.maxLength\n ? formatMessage(words.charactersLimit, { count, limit: current.maxLength })\n : formatMessage(count === 1 ? words.character : words.characters, { count });\n const mode = current.showCount === true ? 'characters' : current.showCount;\n if (mode === 'characters' || !mode) return characters;\n const wordCount = editor.wordCount();\n const wordText = formatMessage(wordCount === 1 ? words.word : words.words, { count: wordCount });\n return mode === 'words' ? wordText : `${wordText} · ${characters}`;\n }\n\n function contentView(): Child {\n return h(\n 'div',\n mergeAttrs({ key: 'content', id: ids.content }, part('content'), {\n class: isEmptyEditorDoc(editor.state.doc) ? 'vt-editor-content-empty' : undefined,\n role: 'textbox',\n 'aria-multiline': 'true',\n 'aria-label': current.ariaLabelledby ? undefined : current.ariaLabel,\n 'aria-labelledby': current.ariaLabelledby,\n 'aria-describedby': ids.help,\n 'aria-readonly': current.readonly ? 'true' : undefined,\n 'aria-disabled': current.disabled ? 'true' : undefined,\n 'aria-invalid': current.invalid ? 'true' : undefined,\n 'aria-placeholder': current.placeholder || undefined,\n 'data-placeholder': current.placeholder || undefined,\n contenteditable: editable() ? 'true' : 'false',\n tabindex: current.disabled ? '-1' : '0',\n spellcheck: 'true',\n translate: 'no',\n ref: (el: Element | null) => {\n const next = el as HTMLElement | null;\n if (next === contentEl) return;\n contentEl = next;\n attachView();\n },\n onFocus: (event: FocusEvent) => current.on?.focus?.(event),\n onBlur: (event: FocusEvent) => current.on?.blur?.(event)\n })\n );\n }\n\n function render() {\n const drawn = toolbarContext();\n root.attrs(part('root', { readonly: current.readonly, disabled: current.disabled, invalid: current.invalid }));\n root.render([\n current.hooks?.toolbar ? (current.hooks.toolbar() as Child) : current.toolbar === false ? null : toolbarView(drawn, toolbarGroups()),\n findBar.view(),\n contentView(),\n h('span', mergeAttrs({ key: 'caret', 'aria-hidden': 'true' }, part('caret'), { ref: (el: Element | null) => (caretEl = el as HTMLElement | null) })),\n h('span', { key: 'help', id: ids.help, style: visuallyHidden }, locale().editor.keyboardHelp),\n current.hooks?.footer\n ? (current.hooks.footer() as Child)\n : current.showCount\n ? h('div', mergeAttrs({ key: 'footer' }, part('footer')), h('span', part('count', { limit: !!current.maxLength }), countText()))\n : null\n ]);\n syncBlockSelect();\n syncBubble();\n renderPanels();\n blockHandle.sync();\n }\n\n function attachView() {\n view?.destroy();\n view = null;\n if (!contentEl) return;\n view = createEditorView(contentEl, editor, {\n editable,\n taskLabel: locale().editor.taskDone,\n selectedClass: 'vt-editor-node-selected',\n emptyClass: 'vt-editor-content-empty',\n chipClass: (kind) => (current.unstyled ? undefined : ['vt-editor-chip', kind ? `vt-editor-chip-${kind}` : ''].filter(Boolean).join(' ')),\n // Ctrl/⌘+K opens the link editor, over the caret.\n handleKey: (_name, binding) => {\n if (binding?.[0] !== 'link' || !editable()) return false;\n openLinkPanel();\n return true;\n },\n linkHint: (href) => ({ ...tooltips.options(editorLinkHint(href, locale().editor.followLink)), placement: 'top' })\n });\n if (current.autofocus) view.focus();\n }\n\n const focus = () => view?.focus();\n\n render();\n\n const handle: TextEditorHandle = {\n element,\n update(next) {\n const content = 'content' in next;\n current = { ...current, ...next };\n if (content) editor.setContent(current.content ?? '', { emit: false });\n if ('maxLength' in next) editor.maxLength = current.maxLength ?? null;\n render();\n },\n getHTML: () => editor.getHTML(),\n getJSON: () => editor.getJSON(),\n getText: () => editor.getText(),\n getMarkdown: () => editor.getMarkdown(),\n typeText: (text) => {\n const typed = editor.typeText(text);\n render();\n return typed;\n },\n setContent: (value) => {\n editor.setContent(value);\n render();\n },\n run: (name, ...args) => {\n const applied = run(name, ...args);\n render();\n return applied;\n },\n can,\n isActive: (name, attrs) => editor.isActive(name, attrs as never),\n focus,\n openFind: (options) => findBar.open(options),\n closeFind: () => findBar.close({ focusEditor: false }),\n refresh: render,\n destroy() {\n stop();\n element.removeEventListener('keydown', onFindKey);\n findBar.destroy();\n slashMenu.destroy();\n chipMenu.destroy();\n blockHandle.destroy();\n [...panels(), bubble].forEach((overlay) => overlay.destroy());\n blockSelect?.destroy();\n tooltips.destroy();\n view?.destroy();\n root.clear();\n }\n };\n\n return handle;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiDA,IAAI,UAAU;AAEd,SAAgB,iBAAiB,SAAsB,SAA2B,CAAC,GAAqB;CACpG,IAAI,UAA4B,EAAE,GAAG,OAAO;CAC5C,IAAI,OAA0B;CAC9B,IAAI,YAAgC;CACpC,IAAI,UAA8B;CAClC,IAAI,c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;GAAK;GAChC,IAAI,SAAS,OAAO,WAAW,QAAQ,WAAW,IAAI,EAAE,MAAM,MAAM,CAAC;GACrE,IAAI,eAAe,MAAM,OAAO,YAAY,QAAQ,aAAa;GACjE,OAAO;EACX;EACA,eAAe,OAAO,QAAQ;EAC9B,eAAe,OAAO,QAAQ;EAC9B,eAAe,OAAO,QAAQ;EAC9B,mBAAmB,OAAO,YAAY;EACtC,WAAW,SAAS;GAChB,MAAM,QAAQ,OAAO,SAAS,IAAI;GAClC,OAAO;GACP,OAAO;EACX;EACA,aAAa,UAAU;GACnB,OAAO,WAAW,KAAK;GACvB,OAAO;EACX;EACA,MAAM,MAAM,GAAG,SAAS;GACpB,MAAM,UAAU,IAAI,MAAM,GAAG,IAAI;GACjC,OAAO;GACP,OAAO;EACX;EACA;EACA,WAAW,MAAM,UAAU,OAAO,SAAS,MAAM,KAAc;EAC/D;EACA,WAAW,YAAY,QAAQ,KAAK,OAAO;EAC3C,iBAAiB,QAAQ,MAAM,EAAE,aAAa,MAAM,CAAC;EACrD,SAAS;EACT,UAAU;GACN,KAAK;GACL,QAAQ,oBAAoB,WAAW,SAAS;GAChD,QAAQ,QAAQ;GAChB,UAAU,QAAQ;GAClB,SAAS,QAAQ;GACjB,YAAY,QAAQ;GACpB,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC,SAAS,YAAY,QAAQ,QAAQ,CAAC;GAC5D,aAAa,QAAQ;GACrB,SAAS,QAAQ;GACjB,MAAM,QAAQ;GACd,KAAK,MAAM;EACf;CACJ;CAEA,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"editor.js","names":[],"sources":["../src/editor.ts"],"sourcesContent":["import {\n activeEditorBlockType,\n activeEditorMark,\n ariaEditorShortcut,\n createEditor as createEditorInstance,\n createEditorView,\n editorLinkAt,\n editorKeyName,\n editorLinkHint,\n editorPalette,\n editorShortcutFor,\n editorSelectionRange,\n editorTextblocks,\n en,\n formatEditorShortcut,\n followEditorLink,\n formatMessage,\n isEmptyEditorDoc,\n isMacPlatform,\n loadStyle,\n matchEditorPaletteColor,\n visuallyHidden,\n type EditorColor,\n type EditorInstance,\n type EditorNode,\n type EditorView,\n type Locale\n} from '@vitral/core';\nimport { createOverlay, createSelect, createTooltips, type Overlay, type SelectHandle } from '@vitral/controls';\nimport { createRoot, h, mergeAttrs, partResolver, type Child, type Props } from '@vitral/dom';\nimport { registerIcons } from '@vitral/icons';\nimport { baseStyle, buttonStyle, editorStyle } from '@vitral/styles';\nimport { defaultBubbleMenu, defaultToolbar, editorIcons } from './buttons';\nimport { createBlockHandle, defaultBlockActions } from './block';\nimport { colorPanelView, imagePanelView, linkPanelView, tablePanelView, type LinkPanelState, type PanelContext } from './render/menus';\nimport { createChipMenu } from './chips';\nimport { createMathTools, defaultMathTemplates } from './math';\nimport { createFindBar } from './find';\nimport { createSlashMenu, defaultSlashCommands } from './slash';\nimport { bubbleView, toolbarView, type ToolbarContext } from './render/toolbar';\nimport type { TextEditorConfig, TextEditorHandle, EditorToolbarItem } from './types';\n\n/**\n * A rich text editor with no framework in it: the document, the commands and\n * the history are `@vitral/core`'s, the text itself is its view over a\n * `contenteditable` element, and everything around them — the toolbar, the\n * panels, the floating toolbar over a selection, the menu a `/` opens and the\n * handle beside a block — is drawn here.\n */\n\nlet counter = 0;\n\nexport function createTextEditor(element: HTMLElement, config: TextEditorConfig = {}): TextEditorHandle {\n let current: TextEditorConfig = { ...config };\n let view: EditorView | null = null;\n let contentEl: HTMLElement | null = null;\n let caretEl: HTMLElement | null = null;\n let blockSelect: SelectHandle | null = null;\n let blockSelectHost: HTMLElement | null = null;\n let link: LinkPanelState = { href: '', text: '', newTab: false, existing: false };\n const anchors = new Map<string, HTMLElement>();\n\n const id = config.id ?? `vt-texteditor-${++counter}`;\n const ids = { content: `${id}-content`, help: `${id}-help`, slash: `${id}-slash`, block: `${id}-block` };\n const root = createRoot(element);\n const locale = (): Locale => current.locale ?? en;\n const palette = (): readonly EditorColor[] => current.palette ?? editorPalette;\n const part = partResolver({\n style: editorStyle,\n unstyled: () => !!current.unstyled,\n classes: () => current.classes,\n pt: () => current.pt,\n props: () => current as Record<string, unknown>\n });\n\n if (!config.unstyled) {\n const options = { nonce: config.nonce, cssLayer: config.cssLayer };\n loadStyle(baseStyle.name, baseStyle.css, options);\n loadStyle(buttonStyle.name, buttonStyle.css, options);\n loadStyle(editorStyle.name, editorStyle.css, options);\n }\n // The toolbar holds its own definitions, but the slash menu, the block\n // handle and any command an application names its own icon for are looked\n // up by name: the editor puts its set in the registry rather than drawing\n // a bar of empty buttons in an application that never registered them.\n // What each button is, shown the way every other Vitral control shows it.\n const tooltips = createTooltips(() => ({\n placement: 'bottom',\n unstyled: current.unstyled,\n nonce: current.nonce,\n cssLayer: current.cssLayer,\n zIndex: current.zIndex,\n pt: current.pt\n }));\n\n registerIcons(editorIcons);\n\n const editor: EditorInstance = createEditorInstance({\n content: current.content ?? '',\n maxLength: current.maxLength ?? null,\n historyDelay: current.historyDelay,\n mathOutput: typeof current.math === 'object' ? current.math.output : undefined\n });\n\n const editable = () => !current.readonly && !current.disabled;\n const collapsed = () => editorSelectionRange(editor.state.selection).empty;\n const run = (name: string, ...args: unknown[]) => (editor.run as (n: string, ...a: unknown[]) => boolean)(name, ...args);\n const can = (name: string, ...args: unknown[]) => (editor.can as (n: string, ...a: unknown[]) => boolean)(name, ...args);\n\n // ---- what the outside hears ---------------------------------------------------------\n\n const stop = editor.subscribe((update) => {\n if (update.docChanged) {\n current.on?.change?.({ html: editor.getHTML(), json: editor.getJSON(), text: editor.getText() });\n }\n if (update.docChanged) findBar.sync();\n if (update.selectionChanged) {\n current.on?.['selection-change']?.({ empty: collapsed(), source: update.origin === 'user' ? 'user' : update.origin === 'history' ? 'history' : 'api' });\n }\n render();\n });\n\n // ---- the panels ------------------------------------------------------------------------\n\n const panelContext = (): PanelContext => ({ locale: locale(), part, ids });\n\n const anchorFor = (name: string) => () => anchors.get(name) ?? caretEl;\n\n function panel(name: string, render: () => ReturnType<typeof linkPanelView> | null, placement: 'bottom-start' | 'bottom-end' = 'bottom-start'): Overlay {\n return createOverlay({\n anchor: anchorFor(name),\n render,\n placement,\n target: () => current.overlayTarget,\n zIndex: current.zIndex,\n onClose: () => renderPanels()\n });\n }\n\n const linkPanel = panel('link', () => linkPanelView(panelContext(), link, linkActions));\n const imagePanel = panel('image', () => imagePanelView(panelContext(), imageActions));\n const tablePanel = panel('table', () => tablePanelView(panelContext(), { insert: insertTable }));\n const colorPanel = panel('color', () => colorPanelView(panelContext(), { kind: colorKind, palette: palette(), chosen: colorOf(colorKind), onChoose: chooseColor }));\n let colorKind: 'color' | 'highlight' = 'color';\n\n const linkActions = {\n change: (patch: Partial<LinkPanelState>) => {\n link = { ...link, ...patch, error: undefined };\n linkPanel.update();\n },\n apply: () => {\n const href = link.href.trim();\n if (!href) {\n link = { ...link, error: locale().editor.invalidUrl };\n linkPanel.update();\n return;\n }\n run('setLink', href, { target: link.newTab ? '_blank' : null, text: link.text.trim() || undefined });\n linkPanel.close();\n focus();\n },\n remove: () => {\n run('unsetLink');\n linkPanel.close();\n focus();\n },\n open: () => {\n followEditorLink(link.href.trim());\n linkPanel.close();\n },\n cancel: () => {\n linkPanel.close();\n focus();\n }\n };\n\n /** The link editor, filled in with the link under the caret when there is one. */\n function openLinkPanel(event?: MouseEvent) {\n if (!editable()) return;\n const at = editorLinkAt(editor.state);\n link = { href: at?.href ?? '', text: at?.text ?? '', newTab: at?.target === '_blank', existing: !!at };\n if (!event) placeCaret();\n openPanel(linkPanel, 'link', event);\n }\n\n const imageActions = {\n insert: (src: string, alt: string) => {\n if (src.trim()) run('insertImage', { src: src.trim(), alt: alt.trim() });\n imagePanel.close();\n focus();\n },\n cancel: () => {\n imagePanel.close();\n focus();\n }\n };\n\n function insertTable(rows: number, columns: number) {\n run('insertTable', rows, columns, true);\n tablePanel.close();\n focus();\n }\n\n const colorOf = (kind: 'color' | 'highlight'): EditorColor | undefined => {\n const mark = activeEditorMark(editor.state, kind);\n const value = mark?.attrs?.color;\n if (typeof value !== 'string') return undefined;\n const name = matchEditorPaletteColor(value, kind, palette());\n return palette().find((color) => color.name === name);\n };\n\n function chooseColor(color: EditorColor | null) {\n run(colorKind === 'color' ? 'setColor' : 'setHighlight', color?.name ?? null);\n colorPanel.close();\n focus();\n }\n\n // ---- the floating toolbar over a selection -----------------------------------------------\n\n const bubble = createOverlay({\n anchor: () => caretEl,\n render: () => bubbleView(toolbarContext(), bubbleItems()) as never,\n placement: 'top',\n target: () => current.overlayTarget,\n zIndex: current.zIndex,\n restoreFocus: false\n });\n\n const bubbleItems = (): EditorToolbarItem[] => (Array.isArray(current.bubbleMenu) ? current.bubbleMenu : defaultBubbleMenu);\n\n function syncBubble() {\n const wanted = current.bubbleMenu !== false && editable() && !collapsed() && !editor.isEmpty();\n if (wanted) {\n placeCaret();\n bubble.open();\n bubble.update();\n } else bubble.close();\n }\n\n // ---- the menu a slash opens, and the handle beside a block ---------------------------------\n\n const chipMenu = createChipMenu({\n editor,\n content: () => contentEl,\n anchor: () => caretEl,\n triggers: () => (current.chips ? (Array.isArray(current.chips) ? current.chips : [current.chips]) : []),\n part,\n locale,\n enabled: () => !!current.chips && editable(),\n place: placeCaret,\n id: `${ids.slash}-chips`,\n overlayTarget: current.overlayTarget,\n zIndex: current.zIndex\n });\n\n // ---- formulas ---------------------------------------------------------------------------------\n\n const mathOn = () => current.math !== false;\n const mathOptions = () => (typeof current.math === 'object' ? current.math : {});\n const mathTools = createMathTools({\n editor,\n view: () => view,\n content: () => contentEl,\n anchor: () => caretEl,\n place: placeCaret,\n templates: () => mathOptions().templates ?? defaultMathTemplates(locale()),\n inlineEdit: () => mathOptions().inlineEdit !== false,\n part,\n locale,\n enabled: () => mathOn() && editable(),\n focus: () => view?.focus(),\n id: `${id}-math`,\n overlayTarget: current.overlayTarget,\n zIndex: current.zIndex\n });\n\n const slashMenu = createSlashMenu({\n editor,\n content: () => contentEl,\n anchor: () => caretEl,\n commands: () => (Array.isArray(current.slashMenu) ? current.slashMenu : defaultSlashCommands(locale()).filter((command) => command.id !== 'math' || mathOn())),\n part,\n locale,\n enabled: () => current.slashMenu !== false && editable(),\n place: placeCaret,\n ids,\n overlayTarget: current.overlayTarget,\n zIndex: current.zIndex,\n onRun: (command) => {\n if (command.run) command.run(handle);\n // The formula panel takes the keyboard itself: it opens where the caret was left.\n else if (command.command?.[0] === 'math') return mathTools.open();\n else if (command.command) run(command.command[0], ...command.command.slice(1));\n focus();\n }\n });\n\n const blockHandle = createBlockHandle({\n editor,\n host: () => element,\n caretRect: () => view?.selectionRect() ?? null,\n content: () => contentEl,\n actions: () => (Array.isArray(current.blockMenu) ? current.blockMenu : defaultBlockActions(locale())),\n part,\n locale,\n enabled: () => current.blockMenu !== false && editable(),\n ids,\n overlayTarget: current.overlayTarget,\n zIndex: current.zIndex\n });\n\n // ---- find and replace ---------------------------------------------------------------------\n\n const findBar = createFindBar({\n editor,\n view: () => view,\n part,\n locale,\n editable,\n render: () => render(),\n id: `${id}-find`\n });\n\n // Ctrl/⌘+F finds and Ctrl+H (⌘+⌥+F on a Mac, where ⌘+H hides the app)\n // replaces, anywhere in the editor — the text, the toolbar or the bar.\n const onFindKey = (event: KeyboardEvent) => {\n if (current.find === false) return;\n const name = editorKeyName(event);\n const replace = name === (isMacPlatform() ? 'Mod-Alt-f' : 'Mod-h');\n if (name !== 'Mod-f' && !replace) return;\n event.preventDefault();\n findBar.open({ replace });\n };\n element.addEventListener('keydown', onFindKey);\n\n // ---- where a popup hangs from ---------------------------------------------------------------\n\n /** The caret's own rectangle, as an element popups can be anchored to. */\n function placeCaret() {\n if (!caretEl || !contentEl) return;\n const rect = view?.selectionRect();\n if (!rect) return;\n const host = element.getBoundingClientRect();\n caretEl.style.top = `${rect.top - host.top}px`;\n caretEl.style.left = `${rect.left - host.left}px`;\n caretEl.style.width = `${Math.max(1, rect.width)}px`;\n caretEl.style.height = `${rect.height}px`;\n }\n\n function openPanel(overlay: Overlay, name: string, event?: MouseEvent) {\n if (event) anchors.set(name, event.currentTarget as HTMLElement);\n else anchors.delete(name);\n closePanels(overlay);\n overlay.open();\n overlay.update();\n }\n\n const panels = () => [linkPanel, imagePanel, tablePanel, colorPanel];\n const closePanels = (except?: Overlay) => panels().forEach((overlay) => overlay !== except && overlay.close());\n const renderPanels = () => panels().forEach((overlay) => overlay.update());\n\n // ---- the toolbar -----------------------------------------------------------------------------\n\n function toolbarContext(): ToolbarContext {\n return {\n locale: locale(),\n part,\n editable: editable(),\n can,\n isActive: (name, attrs) => editor.isActive(name, attrs as never),\n shortcut: (name, args) => {\n const binding = editorShortcutFor(name, args);\n return binding ? { label: formatEditorShortcut(binding), aria: ariaEditorShortcut(binding) } : undefined;\n },\n colors: { text: colorOf('color'), highlight: colorOf('highlight') },\n ref: (name) => (el) => {\n if (el) anchors.set(name, el as HTMLElement);\n else anchors.delete(name);\n },\n on: {\n tip: (element, text) => tooltips.attach(element, text),\n command: (name, args, event) => {\n run(name, ...args);\n if (event.detail > 0) focus();\n },\n openLink: (event) => openLinkPanel(event),\n openFind: () => (findBar.isOpen ? findBar.close() : findBar.open()),\n openImage: (event) => openPanel(imagePanel, 'image', event),\n openTable: (event) => openPanel(tablePanel, 'table', event),\n openMath: (event) => {\n closePanels();\n // On a formula it hangs from the formula; for a new one, from the button.\n mathTools.open(editor.isActive('math') ? null : (event.currentTarget as HTMLElement));\n },\n openColor: (kind, event) => {\n colorKind = kind;\n openPanel(colorPanel, kind, event);\n },\n blockSelect: (el) => {\n blockSelectHost = (el as HTMLElement | null) ?? null;\n syncBlockSelect();\n }\n }\n };\n }\n\n /** The block type, drawn by the control kit's select. */\n function syncBlockSelect() {\n if (!blockSelectHost) return;\n const words = locale().editor;\n const options = [\n { label: words.paragraph, value: 'paragraph' },\n { label: words.heading1, value: 'heading1' },\n { label: words.heading2, value: 'heading2' },\n { label: words.heading3, value: 'heading3' },\n { label: words.codeBlock, value: 'codeBlock' }\n ];\n const active = activeEditorBlockType(editor.state);\n const settings = {\n options,\n optionValue: 'value',\n value: active,\n size: 'small' as const,\n ariaLabel: words.blockType,\n disabled: !editable(),\n locale: locale(),\n unstyled: current.unstyled,\n overlayTarget: current.overlayTarget,\n zIndex: current.zIndex,\n nonce: current.nonce,\n cssLayer: current.cssLayer\n };\n if (blockSelect) blockSelect.update(settings);\n else\n blockSelect = createSelect(blockSelectHost, {\n ...settings,\n onChange: (value) => {\n if (value === 'paragraph') run('setParagraph');\n else if (value === 'codeBlock') run('toggleCodeBlock');\n else run('toggleHeading', Number(String(value).slice(-1)));\n focus();\n }\n });\n }\n\n // ---- drawing --------------------------------------------------------------------------------\n\n /** The groups of the toolbar, without the formula button where formulas are off. */\n const toolbarGroups = (): EditorToolbarItem[][] => {\n const groups = Array.isArray(current.toolbar) ? current.toolbar : defaultToolbar;\n return mathOn() ? groups : groups.map((group) => group.filter((item) => item !== 'math')).filter((group) => group.length);\n };\n\n function countText(): string {\n const words = locale().editor;\n const count = editor.characterCount();\n const characters = current.maxLength\n ? formatMessage(words.charactersLimit, { count, limit: current.maxLength })\n : formatMessage(count === 1 ? words.character : words.characters, { count });\n const mode = current.showCount === true ? 'characters' : current.showCount;\n if (mode === 'characters' || !mode) return characters;\n const wordCount = editor.wordCount();\n const wordText = formatMessage(wordCount === 1 ? words.word : words.words, { count: wordCount });\n return mode === 'words' ? wordText : `${wordText} · ${characters}`;\n }\n\n function contentView(): Child {\n return h(\n 'div',\n mergeAttrs({ key: 'content', id: ids.content }, part('content'), {\n class: isEmptyEditorDoc(editor.state.doc) ? 'vt-editor-content-empty' : undefined,\n role: 'textbox',\n 'aria-multiline': 'true',\n 'aria-label': current.ariaLabelledby ? undefined : current.ariaLabel,\n 'aria-labelledby': current.ariaLabelledby,\n 'aria-describedby': ids.help,\n 'aria-readonly': current.readonly ? 'true' : undefined,\n 'aria-disabled': current.disabled ? 'true' : undefined,\n 'aria-invalid': current.invalid ? 'true' : undefined,\n 'aria-placeholder': current.placeholder || undefined,\n 'data-placeholder': current.placeholder || undefined,\n // How a formula answers a press, which is what its look under the pointer follows.\n 'data-math-edit': mathOn() && editable() ? (mathOptions().inlineEdit === false ? 'panel' : 'inline') : undefined,\n contenteditable: editable() ? 'true' : 'false',\n tabindex: current.disabled ? '-1' : '0',\n spellcheck: 'true',\n translate: 'no',\n ref: (el: Element | null) => {\n const next = el as HTMLElement | null;\n if (next === contentEl) return;\n contentEl = next;\n attachView();\n },\n onFocus: (event: FocusEvent) => current.on?.focus?.(event),\n onBlur: (event: FocusEvent) => current.on?.blur?.(event)\n })\n );\n }\n\n function render() {\n const drawn = toolbarContext();\n root.attrs(part('root', { readonly: current.readonly, disabled: current.disabled, invalid: current.invalid }));\n root.render([\n current.hooks?.toolbar ? (current.hooks.toolbar() as Child) : current.toolbar === false ? null : toolbarView(drawn, toolbarGroups()),\n findBar.view(),\n contentView(),\n h('span', mergeAttrs({ key: 'caret', 'aria-hidden': 'true' }, part('caret'), { ref: (el: Element | null) => (caretEl = el as HTMLElement | null) })),\n h('span', { key: 'help', id: ids.help, style: visuallyHidden }, locale().editor.keyboardHelp),\n current.hooks?.footer\n ? (current.hooks.footer() as Child)\n : current.showCount\n ? h('div', mergeAttrs({ key: 'footer' }, part('footer')), h('span', part('count', { limit: !!current.maxLength }), countText()))\n : null\n ]);\n syncBlockSelect();\n syncBubble();\n renderPanels();\n blockHandle.sync();\n mathTools.sync();\n }\n\n function attachView() {\n view?.destroy();\n view = null;\n if (!contentEl) return;\n view = createEditorView(contentEl, editor, {\n editable,\n taskLabel: locale().editor.taskDone,\n selectedClass: 'vt-editor-node-selected',\n emptyClass: 'vt-editor-content-empty',\n chipClass: (kind) => (current.unstyled ? undefined : ['vt-editor-chip', kind ? `vt-editor-chip-${kind}` : ''].filter(Boolean).join(' ')),\n mathClass: ({ display, pending }) => (current.unstyled ? undefined : ['vt-editor-math', display ? 'vt-editor-math-display' : '', pending ? 'vt-editor-math-pending' : ''].filter(Boolean).join(' ')),\n // Ctrl/⌘+K opens the link editor, over the caret.\n handleKey: (_name, binding) => {\n if (binding?.[0] !== 'link' || !editable()) return false;\n openLinkPanel();\n return true;\n },\n linkHint: (href) => ({ ...tooltips.options(editorLinkHint(href, locale().editor.followLink)), placement: 'top' })\n });\n if (current.autofocus) view.focus();\n }\n\n const focus = () => view?.focus();\n\n render();\n\n const handle: TextEditorHandle = {\n element,\n update(next) {\n const content = 'content' in next;\n current = { ...current, ...next };\n if (content) editor.setContent(current.content ?? '', { emit: false });\n if ('maxLength' in next) editor.maxLength = current.maxLength ?? null;\n if ('math' in next) editor.mathOutput = mathOptions().output ?? 'drawing';\n render();\n },\n getHTML: (options) => editor.getHTML(options),\n getJSON: () => editor.getJSON(),\n getText: () => editor.getText(),\n getMarkdown: () => editor.getMarkdown(),\n typeText: (text) => {\n const typed = editor.typeText(text);\n render();\n return typed;\n },\n setContent: (value) => {\n editor.setContent(value);\n render();\n },\n run: (name, ...args) => {\n const applied = run(name, ...args);\n render();\n return applied;\n },\n can,\n isActive: (name, attrs) => editor.isActive(name, attrs as never),\n focus,\n openFind: (options) => findBar.open(options),\n closeFind: () => findBar.close({ focusEditor: false }),\n refresh: render,\n destroy() {\n stop();\n element.removeEventListener('keydown', onFindKey);\n findBar.destroy();\n slashMenu.destroy();\n chipMenu.destroy();\n mathTools.destroy();\n blockHandle.destroy();\n [...panels(), bubble].forEach((overlay) => overlay.destroy());\n blockSelect?.destroy();\n tooltips.destroy();\n view?.destroy();\n root.clear();\n }\n };\n\n return handle;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkDA,IAAI,UAAU;AAEd,SAAgB,iBAAiB,SAAsB,SAA2B,CAAC,GAAqB;CACpG,IAAI,UAA4B,EAAE,GAAG,OAAO;CAC5C,IAAI,OAA0B;CAC9B,IAAI,YAAgC;CACpC,IAAI,UAA8B;CAClC,IAAI,cAAmC;CACvC,IAAI,kBAAsC;CAC1C,IAAI,OAAuB;EAAE,MAAM;EAAI,MAAM;EAAI,QAAQ;EAAO,UAAU;CAAM;CAChF,MAAM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C,eAAe,OAAO,QAAQ;EAC9B,eAAe,OAAO,QAAQ;EAC9B,mBAAmB,OAAO,YAAY;EACtC,WAAW,SAAS;GAChB,MAAM,QAAQ,OAAO,SAAS,IAAI;GAClC,OAAO;GACP,OAAO;EACX;EACA,aAAa,UAAU;GACnB,OAAO,WAAW,KAAK;GACvB,OAAO;EACX;EACA,MAAM,MAAM,GAAG,SAAS;GACpB,MAAM,UAAU,IAAI,MAAM,GAAG,IAAI;GACjC,OAAO;GACP,OAAO;EACX;EACA;EACA,WAAW,MAAM,UAAU,OAAO,SAAS,MAAM,KAAc;EAC/D;EACA,WAAW,YAAY,QAAQ,KAAK,OAAO;EAC3C,iBAAiB,QAAQ,MAAM,EAAE,aAAa,MAAM,CAAC;EACrD,SAAS;EACT,UAAU;GACN,KAAK;GACL,QAAQ,oBAAoB,WAAW,SAAS;GAChD,QAAQ,QAAQ;GAChB,UAAU,QAAQ;GAClB,SAAS,QAAQ;GACjB,UAAU,QAAQ;GAClB,YAAY,QAAQ;GACpB,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC,SAAS,YAAY,QAAQ,QAAQ,CAAC;GAC5D,aAAa,QAAQ;GACrB,SAAS,QAAQ;GACjB,MAAM,QAAQ;GACd,KAAK,MAAM;EACf;CACJ;CAEA,OAAO;AACX"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
export { createTextEditor } from './editor';
|
|
8
8
|
export { createSlashMenu, defaultSlashCommands, type SlashMenu, type SlashMenuOptions } from './slash';
|
|
9
9
|
export { createChipMenu, type ChipMenu, type ChipMenuOptions } from './chips';
|
|
10
|
+
export { createMathTools, defaultMathTemplates, type MathTools, type MathToolsOptions } from './math';
|
|
10
11
|
export { createFindBar, type FindBar, type FindBarOptions } from './find';
|
|
11
12
|
export { createBlockHandle, defaultBlockActions, type BlockHandle, type BlockHandleOptions } from './block';
|
|
12
13
|
export { editorButtons, editorIcons, shortcutCommands, defaultToolbar, defaultBubbleMenu, type EditorButtonSpec } from './buttons';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ import { bubbleView, buttonView, iconView, toolbarView } from "./render/toolbar.
|
|
|
3
3
|
import { blockHandleView, blockMenuView, colorPanelView, imagePanelView, linkPanelView, slashMenuView, tablePanelView } from "./render/menus.js";
|
|
4
4
|
import { createBlockHandle, defaultBlockActions } from "./block.js";
|
|
5
5
|
import { createChipMenu } from "./chips.js";
|
|
6
|
+
import { createMathTools, defaultMathTemplates } from "./math.js";
|
|
6
7
|
import { createFindBar } from "./find.js";
|
|
7
8
|
import { createSlashMenu, defaultSlashCommands } from "./slash.js";
|
|
8
9
|
import { createTextEditor } from "./editor.js";
|
|
9
|
-
export { blockHandleView, blockMenuView, bubbleView, buttonView, colorPanelView, createBlockHandle, createChipMenu, createFindBar, createSlashMenu, createTextEditor, defaultBlockActions, defaultBubbleMenu, defaultSlashCommands, defaultToolbar, editorButtons, editorIcons, iconView, imagePanelView, linkPanelView, shortcutCommands, slashMenuView, tablePanelView, toolbarView };
|
|
10
|
+
export { blockHandleView, blockMenuView, bubbleView, buttonView, colorPanelView, createBlockHandle, createChipMenu, createFindBar, createMathTools, createSlashMenu, createTextEditor, defaultBlockActions, defaultBubbleMenu, defaultMathTemplates, defaultSlashCommands, defaultToolbar, editorButtons, editorIcons, iconView, imagePanelView, linkPanelView, shortcutCommands, slashMenuView, tablePanelView, toolbarView };
|
package/dist/math.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type EditorInstance, type EditorView, type Locale } from '@vitral/core';
|
|
2
|
+
import { type OverlayTarget } from '@vitral/controls';
|
|
3
|
+
import { type Props } from '@vitral/dom';
|
|
4
|
+
import type { MathTemplate } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Formulas, as a piece that attaches to any editor, the way the slash menu
|
|
7
|
+
* does. A formula is held as LaTeX and drawn from it, and there are two ways
|
|
8
|
+
* to change one:
|
|
9
|
+
*
|
|
10
|
+
* - the panel, which the toolbar's button and the slash menu open: the source
|
|
11
|
+
* in a box, the formula drawn above it as it is typed, and the usual
|
|
12
|
+
* formulas ready-made on buttons;
|
|
13
|
+
* - pressing it in the text. A number, a letter or a sign is edited where it
|
|
14
|
+
* stands, in a box over it, and the formula is drawn again around it with
|
|
15
|
+
* every key; Tab goes on to the next value. A press anywhere else on the
|
|
16
|
+
* formula opens the panel with that piece of the source selected.
|
|
17
|
+
*
|
|
18
|
+
* Either way the document only ever holds the source, and the drawing is made
|
|
19
|
+
* from it again, so there is no drawing to get out of step. What is typed is
|
|
20
|
+
* never trusted to be a formula: a piece that cannot be read is drawn as
|
|
21
|
+
* written, where it stands, and the rest of the formula around it.
|
|
22
|
+
*/
|
|
23
|
+
export interface MathToolsOptions {
|
|
24
|
+
editor: EditorInstance;
|
|
25
|
+
view: () => EditorView | null;
|
|
26
|
+
/** The `contenteditable` element, where a press on a formula is heard. */
|
|
27
|
+
content: () => HTMLElement | null;
|
|
28
|
+
/** What the panel hangs from when it is opened by no button and on no formula: an element over the caret. */
|
|
29
|
+
anchor: () => HTMLElement | null;
|
|
30
|
+
/** Puts that element where the caret is, before the panel opens. */
|
|
31
|
+
place?: () => void;
|
|
32
|
+
/** The ready-made formulas on offer; read every time the panel opens. */
|
|
33
|
+
templates: () => MathTemplate[];
|
|
34
|
+
/** Whether a value is edited where it stands. */
|
|
35
|
+
inlineEdit?: () => boolean;
|
|
36
|
+
part: (name: string, state?: unknown) => Props;
|
|
37
|
+
locale?: () => Locale;
|
|
38
|
+
/** Off while the editor is read-only, or has formulas turned off. */
|
|
39
|
+
enabled?: () => boolean;
|
|
40
|
+
/** Puts the keyboard back in the text. */
|
|
41
|
+
focus?: () => void;
|
|
42
|
+
id?: string;
|
|
43
|
+
overlayTarget?: OverlayTarget;
|
|
44
|
+
zIndex?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface MathTools {
|
|
47
|
+
readonly isOpen: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Opens the panel: on the formula the selection is on, to change it, or
|
|
50
|
+
* for a new one where the caret is. `anchor` is what it hangs from, a
|
|
51
|
+
* toolbar button say; the formula itself, or the caret, otherwise.
|
|
52
|
+
*/
|
|
53
|
+
open(anchor?: HTMLElement | null): void;
|
|
54
|
+
/** Looks again for the element the text is in: called when the host has drawn. */
|
|
55
|
+
sync(): void;
|
|
56
|
+
close(): void;
|
|
57
|
+
destroy(): void;
|
|
58
|
+
}
|
|
59
|
+
/** The formulas the panel offers when an application names none. */
|
|
60
|
+
export declare function defaultMathTemplates(locale: Locale): MathTemplate[];
|
|
61
|
+
export declare function createMathTools(options: MathToolsOptions): MathTools;
|