stilo-editor 0.1.0 → 0.2.1
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 +76 -129
- package/dist/content.css +238 -1
- package/dist/core/editor.d.ts +15 -3
- package/dist/core/extension-manager.d.ts +3 -3
- package/dist/core/extension.d.ts +6 -1
- package/dist/core/helpers/block-style.d.ts +25 -0
- package/dist/core/helpers/input-rules.d.ts +8 -1
- package/dist/core/helpers/lists.d.ts +10 -2
- package/dist/core/helpers/marks.d.ts +14 -0
- package/dist/core/helpers/nodes.d.ts +12 -0
- package/dist/core/helpers/word-count.d.ts +14 -0
- package/dist/core/html/css.d.ts +16 -1
- package/dist/core/html/paste/base-styles.d.ts +7 -0
- package/dist/core/html/paste/google-docs.d.ts +7 -0
- package/dist/core/html/paste/index.d.ts +9 -0
- package/dist/core/html/paste/table-widths.d.ts +7 -0
- package/dist/core/html/paste/word.d.ts +8 -0
- package/dist/core/html/serialize.d.ts +2 -2
- package/dist/extensions/code-block/index.d.ts +24 -0
- package/dist/extensions/default-extensions/index.d.ts +11 -0
- package/dist/extensions/heading/index.d.ts +2 -1
- package/dist/extensions/image/image-view.d.ts +27 -0
- package/dist/extensions/image/index.d.ts +29 -0
- package/dist/extensions/index.d.ts +10 -1
- package/dist/extensions/line-height/index.d.ts +18 -0
- package/dist/extensions/list-item/index.d.ts +1 -1
- package/dist/extensions/paragraph/index.d.ts +4 -4
- package/dist/extensions/search/index.d.ts +55 -0
- package/dist/extensions/table/index.d.ts +70 -0
- package/dist/extensions/task-item/index.d.ts +24 -0
- package/dist/extensions/task-item/task-item-view.d.ts +24 -0
- package/dist/extensions/task-list/index.d.ts +11 -0
- package/dist/extensions/text-align/index.d.ts +18 -0
- package/dist/extensions/text-case/index.d.ts +14 -0
- package/dist/extensions/text-style/font-size.d.ts +21 -0
- package/dist/extensions/text-style/index.d.ts +18 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/src-CV6pgfTS.js +2662 -0
- package/dist/style.css +599 -1
- package/dist/ui/components/dropdown.d.ts +9 -0
- package/dist/ui/components/find-bar.d.ts +24 -0
- package/dist/ui/components/font-size-input.d.ts +21 -0
- package/dist/ui/components/icon-menu.d.ts +20 -0
- package/dist/ui/components/status-bar.d.ts +19 -0
- package/dist/ui/components/table-actions.d.ts +25 -0
- package/dist/ui/components/table-handles.d.ts +16 -0
- package/dist/ui/components/table-menu.d.ts +21 -0
- package/dist/ui/i18n/types.d.ts +1 -1
- package/dist/ui/index.d.ts +6 -2
- package/dist/ui/toolbar/fonts.d.ts +8 -0
- package/dist/ui/toolbar/items.d.ts +23 -2
- package/dist/ui/toolbar/types.d.ts +67 -4
- package/dist/ui.css +361 -0
- package/dist/ui.js +1361 -303
- package/package.json +19 -9
- package/dist/src-3tAxKI0c.js +0 -1316
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Editor } from '../../index';
|
|
2
|
+
import type { Messages } from '../i18n/types';
|
|
3
|
+
import type { ToolbarFontSizeInput } from '../toolbar/types';
|
|
4
|
+
/** Options of {@link createFontSizeInput}. */
|
|
5
|
+
export interface CreateFontSizeInputOptions {
|
|
6
|
+
/** The element the list scrolls with: the toolbar. */
|
|
7
|
+
container: HTMLElement;
|
|
8
|
+
messages: Messages;
|
|
9
|
+
}
|
|
10
|
+
/** The font size control and its list (T-038). */
|
|
11
|
+
export interface FontSizeInput {
|
|
12
|
+
/** The wrapper of the three parts. */
|
|
13
|
+
readonly element: HTMLElement;
|
|
14
|
+
/** The toolbar items, in order: decrease, field, increase. */
|
|
15
|
+
readonly parts: readonly HTMLElement[];
|
|
16
|
+
/** Shows the size at the selection and refreshes the enabled state. */
|
|
17
|
+
update(): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
20
|
+
/** Creates the font size control of `item` (list closed); the list is mounted in `container`. */
|
|
21
|
+
export declare function createFontSizeInput(editor: Editor, item: ToolbarFontSizeInput, options: CreateFontSizeInputOptions): FontSizeInput;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Editor } from '../../index';
|
|
2
|
+
import type { Messages } from '../i18n/types';
|
|
3
|
+
import type { ToolbarIconMenu } from '../toolbar/types';
|
|
4
|
+
/** Options of {@link createIconMenu}. */
|
|
5
|
+
export interface IconMenuOptions {
|
|
6
|
+
/** The element the menu scrolls with: the toolbar. */
|
|
7
|
+
container: HTMLElement;
|
|
8
|
+
messages: Messages;
|
|
9
|
+
/** Whether shortcuts are shown with Mac symbols. */
|
|
10
|
+
mac: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** A button that shows the icon of the active option and opens the options in a row (T-039). */
|
|
13
|
+
export interface IconMenu {
|
|
14
|
+
readonly trigger: HTMLButtonElement;
|
|
15
|
+
/** Shows the active option and refreshes the enabled states. */
|
|
16
|
+
update(): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
19
|
+
/** Creates the trigger of `item` and its menu (closed), mounted in `container`. */
|
|
20
|
+
export declare function createIconMenu(editor: Editor, item: ToolbarIconMenu, options: IconMenuOptions): IconMenu;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Editor } from '../../index';
|
|
2
|
+
import type { Messages } from '../i18n/types';
|
|
3
|
+
/** Options of {@link createStatusBar}. */
|
|
4
|
+
export interface StatusBarOptions {
|
|
5
|
+
/** The status bar element is appended inside it. */
|
|
6
|
+
container: HTMLElement;
|
|
7
|
+
/** UI strings. Default: `en`. */
|
|
8
|
+
messages?: Messages;
|
|
9
|
+
}
|
|
10
|
+
/** A status bar created by {@link createStatusBar}. */
|
|
11
|
+
export interface StatusBar {
|
|
12
|
+
readonly element: HTMLElement;
|
|
13
|
+
/** Counts again now (it also counts 500 ms after the last change). */
|
|
14
|
+
update(): void;
|
|
15
|
+
/** Removes the status bar and every listener. Calling it twice is a no-op. */
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
18
|
+
/** Creates a status bar with the word and character count of the document (F-901). */
|
|
19
|
+
export declare function createStatusBar(editor: Editor, options: StatusBarOptions): StatusBar;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Editor } from '../../index';
|
|
2
|
+
import type { Messages } from '../i18n/types';
|
|
3
|
+
/** A table operation: the command of the same name, `toggleHeader*` for the header toggles. */
|
|
4
|
+
export type TableAction = 'addRowBefore' | 'addRowAfter' | 'deleteRow' | 'addColumnBefore' | 'addColumnAfter' | 'deleteColumn' | 'mergeCells' | 'splitCell' | 'toggleHeaderRow' | 'toggleHeaderColumn' | 'deleteTable';
|
|
5
|
+
/** Options of {@link createTableActions}. */
|
|
6
|
+
export interface TableActionsOptions {
|
|
7
|
+
/** The operations, in groups divided by a separator. */
|
|
8
|
+
groups: ReadonlyArray<ReadonlyArray<TableAction>>;
|
|
9
|
+
/** The accessible name of the menu. */
|
|
10
|
+
label: string;
|
|
11
|
+
messages: Messages;
|
|
12
|
+
/** Closes the popover holding the menu (`Tab`, and before an operation runs). */
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
15
|
+
/** A `role="menu"` of table operations, for a popover. */
|
|
16
|
+
export interface TableActions {
|
|
17
|
+
readonly element: HTMLElement;
|
|
18
|
+
/** Enables the items whose command can run and checks the header toggles. */
|
|
19
|
+
refresh(): void;
|
|
20
|
+
/** Focuses the first enabled item. */
|
|
21
|
+
focusFirst(): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
}
|
|
24
|
+
/** Creates a menu of table operations; an item runs its command on the selection. */
|
|
25
|
+
export declare function createTableActions(editor: Editor, options: TableActionsOptions): TableActions;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Editor } from '../../index';
|
|
2
|
+
import type { Messages } from '../i18n/types';
|
|
3
|
+
/** Options of {@link createTableHandles}. */
|
|
4
|
+
export interface TableHandlesOptions {
|
|
5
|
+
/** The element the handles scroll with: the parent of the editable element. */
|
|
6
|
+
container: HTMLElement;
|
|
7
|
+
messages: Messages;
|
|
8
|
+
}
|
|
9
|
+
/** The handles of the row, the column and the table of the cell under the mouse or the cursor. */
|
|
10
|
+
export interface TableHandles {
|
|
11
|
+
/** Shows, moves or hides the handles after the selection, the focus or the mouse changed. */
|
|
12
|
+
update(): void;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
/** Creates the table handles, which follow the editor on their own. */
|
|
16
|
+
export declare function createTableHandles(editor: Editor, options: TableHandlesOptions): TableHandles;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Editor } from '../../index';
|
|
2
|
+
import type { Messages } from '../i18n/types';
|
|
3
|
+
/** Options of {@link createTableMenu}. */
|
|
4
|
+
export interface TableMenuOptions {
|
|
5
|
+
/** The toolbar button that opens the menu. */
|
|
6
|
+
anchor: HTMLElement;
|
|
7
|
+
/** The element the menu scrolls with: the toolbar. */
|
|
8
|
+
container: HTMLElement;
|
|
9
|
+
messages: Messages;
|
|
10
|
+
}
|
|
11
|
+
/** The table menu: the insert grid outside a table, the table operations inside one. */
|
|
12
|
+
export interface TableMenu {
|
|
13
|
+
readonly isOpen: boolean;
|
|
14
|
+
open(): void;
|
|
15
|
+
/** Closes the menu and gives the focus back to the editor. */
|
|
16
|
+
close(): void;
|
|
17
|
+
toggle(): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
20
|
+
/** Creates the table menu (closed), anchored to the toolbar button. */
|
|
21
|
+
export declare function createTableMenu(editor: Editor, options: TableMenuOptions): TableMenu;
|
package/dist/ui/i18n/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Keys of the built-in UI strings (dot.case). */
|
|
2
|
-
export type MessageKey = 'toolbar.label' | 'toolbar.undo' | 'toolbar.redo' | 'toolbar.bold' | 'toolbar.italic' | 'toolbar.underline' | 'toolbar.strike' | 'toolbar.subscript' | 'toolbar.superscript' | 'toolbar.code' | 'toolbar.clearFormatting' | 'toolbar.bulletList' | 'toolbar.orderedList' | 'toolbar.blockquote' | 'toolbar.horizontalRule' | 'toolbar.link' | 'toolbar.heading' | 'heading.paragraph' | 'heading.h1' | 'heading.h2' | 'heading.h3' | 'heading.h4' | 'heading.h5' | 'heading.h6' | 'link.url' | 'link.newTab' | 'link.apply' | 'link.remove' | 'link.edit' | 'link.open' | 'toolbar.characters' | 'characters.search' | 'characters.noResults' | 'characters.symbols' | 'characters.emoji' | 'characters.punctuation' | 'characters.currency' | 'characters.math' | 'characters.arrows' | 'characters.greek' | 'characters.latin' | 'characters.signs' | 'characters.smileys' | 'characters.people' | 'characters.nature' | 'characters.food' | 'characters.travel' | 'characters.activities' | 'characters.objects' | 'characters.emojiSymbols' | 'toolbar.textColor' | 'toolbar.highlight' | 'color.more' | 'color.default' | 'color.none' | 'color.pick' | 'color.custom' | 'color.apply' | 'color.black' | 'color.darkGray2' | 'color.darkGray1' | 'color.gray' | 'color.lightGray1' | 'color.lightGray2' | 'color.lightGray3' | 'color.white' | 'color.red' | 'color.orange' | 'color.yellow' | 'color.green' | 'color.cyan' | 'color.blue' | 'color.purple' | 'color.pink' | 'color.lightRed' | 'color.lightOrange' | 'color.lightYellow' | 'color.lightGreen' | 'color.lightCyan' | 'color.lightBlue' | 'color.lightPurple' | 'color.lightPink' | 'color.darkRed' | 'color.darkOrange' | 'color.darkYellow' | 'color.darkGreen' | 'color.darkCyan' | 'color.darkBlue' | 'color.darkPurple' | 'color.darkPink';
|
|
2
|
+
export type MessageKey = 'toolbar.label' | 'toolbar.undo' | 'toolbar.redo' | 'toolbar.bold' | 'toolbar.italic' | 'toolbar.underline' | 'toolbar.strike' | 'toolbar.subscript' | 'toolbar.superscript' | 'toolbar.code' | 'toolbar.clearFormatting' | 'toolbar.textCase' | 'toolbar.bulletList' | 'toolbar.orderedList' | 'toolbar.taskList' | 'toolbar.blockquote' | 'toolbar.codeBlock' | 'toolbar.horizontalRule' | 'toolbar.link' | 'toolbar.heading' | 'toolbar.fontFamily' | 'toolbar.fontSize' | 'fontSize.decrease' | 'fontSize.increase' | 'toolbar.textAlign' | 'align.left' | 'align.center' | 'align.right' | 'align.justify' | 'toolbar.lineHeight' | 'lineHeight.default' | 'textCase.upper' | 'textCase.lower' | 'textCase.title' | 'textCase.sentence' | 'textCase.toggle' | 'font.default' | 'font.sansSerif' | 'font.serif' | 'font.monospace' | 'heading.paragraph' | 'heading.h1' | 'heading.h2' | 'heading.h3' | 'heading.h4' | 'heading.h5' | 'heading.h6' | 'link.url' | 'link.newTab' | 'link.apply' | 'link.remove' | 'link.edit' | 'link.open' | 'toolbar.characters' | 'characters.search' | 'characters.noResults' | 'characters.symbols' | 'characters.emoji' | 'characters.punctuation' | 'characters.currency' | 'characters.math' | 'characters.arrows' | 'characters.greek' | 'characters.latin' | 'characters.signs' | 'characters.smileys' | 'characters.people' | 'characters.nature' | 'characters.food' | 'characters.travel' | 'characters.activities' | 'characters.objects' | 'characters.emojiSymbols' | 'toolbar.textColor' | 'toolbar.highlight' | 'color.more' | 'color.default' | 'color.none' | 'color.pick' | 'color.custom' | 'color.apply' | 'color.black' | 'color.darkGray2' | 'color.darkGray1' | 'color.gray' | 'color.lightGray1' | 'color.lightGray2' | 'color.lightGray3' | 'color.white' | 'color.red' | 'color.orange' | 'color.yellow' | 'color.green' | 'color.cyan' | 'color.blue' | 'color.purple' | 'color.pink' | 'color.lightRed' | 'color.lightOrange' | 'color.lightYellow' | 'color.lightGreen' | 'color.lightCyan' | 'color.lightBlue' | 'color.lightPurple' | 'color.lightPink' | 'color.darkRed' | 'color.darkOrange' | 'color.darkYellow' | 'color.darkGreen' | 'color.darkCyan' | 'color.darkBlue' | 'color.darkPurple' | 'color.darkPink' | 'toolbar.table' | 'table.insert' | 'table.size' | 'table.row' | 'table.column' | 'table.headerRow' | 'table.headerColumn' | 'table.addRowBefore' | 'table.addRowAfter' | 'table.deleteRow' | 'table.addColumnBefore' | 'table.addColumnAfter' | 'table.deleteColumn' | 'table.mergeCells' | 'table.splitCell' | 'table.deleteTable' | 'toolbar.find' | 'find.find' | 'find.replace' | 'find.previous' | 'find.next' | 'find.matchCase' | 'find.wholeWord' | 'find.replaceOne' | 'find.replaceAll' | 'find.close' | 'find.position' | 'find.results' | 'find.noResults' | 'status.words' | 'status.characters';
|
|
3
3
|
/** UI strings: every {@link MessageKey}, plus the label keys of custom toolbar items. */
|
|
4
4
|
export type Messages = Readonly<Record<MessageKey, string>> & Readonly<Record<string, string>>;
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -3,17 +3,21 @@
|
|
|
3
3
|
export type { Dropdown, DropdownOptions, DropdownOptionView, DropdownState, } from './components/dropdown';
|
|
4
4
|
/** Shortcut formatting utilities. */
|
|
5
5
|
export { formatShortcut } from './components/shortcut';
|
|
6
|
+
/** Status bar with the word and character count. */
|
|
7
|
+
export { createStatusBar, type StatusBar, type StatusBarOptions, } from './components/status-bar';
|
|
6
8
|
/** English UI strings. */
|
|
7
9
|
export { en } from './i18n/en';
|
|
8
10
|
/** Italian UI strings. */
|
|
9
11
|
export { it } from './i18n/it';
|
|
10
12
|
/** i18n types. */
|
|
11
13
|
export type { MessageKey, Messages } from './i18n/types';
|
|
14
|
+
/** Default lists of the font dropdowns. */
|
|
15
|
+
export { DEFAULT_FONT_SIZES, DEFAULT_FONTS } from './toolbar/fonts';
|
|
12
16
|
/** Default toolbar items and layout. */
|
|
13
|
-
export { DEFAULT_ITEMS, DEFAULT_TOOLBAR, headingDropdown, highlightButton, textColorButton, } from './toolbar/items';
|
|
17
|
+
export { DEFAULT_ITEMS, DEFAULT_TOOLBAR, type FontSizeInputOptions, fontFamilyDropdown, fontSizeInput, headingDropdown, highlightButton, lineHeightDropdown, textAlignMenu, textColorButton, } from './toolbar/items';
|
|
14
18
|
/** Default palette of the color buttons. */
|
|
15
19
|
export { DEFAULT_PALETTE } from './toolbar/palette';
|
|
16
20
|
/** Toolbar element and creation function. */
|
|
17
21
|
export { createToolbar, type Toolbar, type ToolbarOptions } from './toolbar/toolbar';
|
|
18
22
|
/** Toolbar item types. */
|
|
19
|
-
export type { ToolbarButton, ToolbarColor, ToolbarColorButton, ToolbarContext, ToolbarDropdown, ToolbarDropdownOption, ToolbarItem, } from './toolbar/types';
|
|
23
|
+
export type { ToolbarButton, ToolbarColor, ToolbarColorButton, ToolbarContext, ToolbarDropdown, ToolbarDropdownOption, ToolbarFont, ToolbarFontSizeInput, ToolbarIconMenu, ToolbarIconMenuOption, ToolbarItem, } from './toolbar/types';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToolbarFont } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The default fonts of the font family dropdown: the three generic families, which every system
|
|
4
|
+
* resolves, then common fonts with fallbacks for the systems that lack them.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_FONTS: readonly ToolbarFont[];
|
|
7
|
+
/** The default sizes of the font size list, by unit (`rem` uses the px list). */
|
|
8
|
+
export declare const DEFAULT_FONT_SIZES: Readonly<Record<'pt' | 'px', readonly number[]>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HeadingLevel } from '../../index';
|
|
2
|
-
import type { ToolbarColor, ToolbarColorButton, ToolbarDropdown, ToolbarItem } from './types';
|
|
1
|
+
import type { FontSizeUnit, HeadingLevel } from '../../index';
|
|
2
|
+
import type { ToolbarColor, ToolbarColorButton, ToolbarDropdown, ToolbarFont, ToolbarFontSizeInput, ToolbarIconMenu, ToolbarItem } from './types';
|
|
3
3
|
/** Default toolbar item IDs for the `items` configuration. */
|
|
4
4
|
export declare const DEFAULT_TOOLBAR: ReadonlyArray<ReadonlyArray<string>>;
|
|
5
5
|
/** The default toolbar items, by ID. */
|
|
@@ -8,5 +8,26 @@ export declare const DEFAULT_ITEMS: Readonly<Record<string, ToolbarItem>>;
|
|
|
8
8
|
export declare function textColorButton(palette?: readonly ToolbarColor[]): ToolbarColorButton;
|
|
9
9
|
/** The highlight split button (`Highlight` extension), default a plain `<mark>`. */
|
|
10
10
|
export declare function highlightButton(palette?: readonly ToolbarColor[]): ToolbarColorButton;
|
|
11
|
+
/**
|
|
12
|
+
* The font family dropdown (`TextStyle` extension): "Default" removes the font family, then one
|
|
13
|
+
* option per font, drawn in that font. A font that is not in the list is shown by its first name.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fontFamilyDropdown(fonts?: readonly ToolbarFont[]): ToolbarDropdown;
|
|
16
|
+
/** Options of {@link fontSizeInput}. */
|
|
17
|
+
export interface FontSizeInputOptions {
|
|
18
|
+
/** The unit the field shows and writes. Default: `pt`. */
|
|
19
|
+
unit?: FontSizeUnit;
|
|
20
|
+
/** The sizes of the list, in `unit` (px for `rem`). Default: `DEFAULT_FONT_SIZES` of the unit. */
|
|
21
|
+
sizes?: readonly number[];
|
|
22
|
+
}
|
|
23
|
+
/** The font size control (`TextStyle` extension): −, a field with a list of sizes, +. */
|
|
24
|
+
export declare function fontSizeInput(options?: FontSizeInputOptions): ToolbarFontSizeInput;
|
|
25
|
+
/** The text alignment menu (`TextAlign` extension): left, center, right, justify. */
|
|
26
|
+
export declare function textAlignMenu(): ToolbarIconMenu;
|
|
27
|
+
/**
|
|
28
|
+
* The line spacing dropdown (`LineHeight` extension): "Default" (no line height of its own) and
|
|
29
|
+
* the `values`, shown as numbers.
|
|
30
|
+
*/
|
|
31
|
+
export declare function lineHeightDropdown(values?: readonly number[]): ToolbarDropdown;
|
|
11
32
|
/** A heading dropdown toolbar item. */
|
|
12
33
|
export declare function headingDropdown(levels?: HeadingLevel[]): ToolbarDropdown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IconNode } from 'lucide';
|
|
2
|
-
import type { Editor } from '../../index';
|
|
2
|
+
import type { Editor, FontSizeUnit } from '../../index';
|
|
3
3
|
/** A toolbar button. */
|
|
4
4
|
export interface ToolbarButton {
|
|
5
5
|
/** Unique within the toolbar; written as `data-item`. */
|
|
@@ -25,14 +25,25 @@ export interface ToolbarContext {
|
|
|
25
25
|
openLinkPopover(): void;
|
|
26
26
|
/** Opens or closes the character picker (no-op without the `characters` item). */
|
|
27
27
|
toggleCharacterPicker(): void;
|
|
28
|
+
/** Opens or closes the find bar (no-op without the `Search` extension). */
|
|
29
|
+
toggleFindBar(): void;
|
|
30
|
+
/** Opens or closes the table menu (no-op without the `table` item). T-045. */
|
|
31
|
+
toggleTableMenu(): void;
|
|
28
32
|
}
|
|
29
|
-
/** A dropdown of mutually exclusive options (T-014). */
|
|
33
|
+
/** A dropdown of mutually exclusive options, or of actions (T-048) (T-014). */
|
|
30
34
|
export interface ToolbarDropdown {
|
|
31
35
|
id: string;
|
|
32
36
|
kind: 'dropdown';
|
|
33
37
|
/** Key of the accessible name of the trigger and of the menu. */
|
|
34
38
|
labelKey: string;
|
|
39
|
+
/** Shown by the trigger instead of the active option (T-040); default: the option label. */
|
|
40
|
+
icon?: IconNode;
|
|
35
41
|
options: ToolbarDropdownOption[];
|
|
42
|
+
/**
|
|
43
|
+
* The text of the trigger when no option is active, e.g. a font size that is not in the list;
|
|
44
|
+
* `null` (or no function) shows the dropdown label.
|
|
45
|
+
*/
|
|
46
|
+
getValueLabel?(editor: Editor): string | null;
|
|
36
47
|
isAvailable?(editor: Editor): boolean;
|
|
37
48
|
}
|
|
38
49
|
/** An option of a {@link ToolbarDropdown}. */
|
|
@@ -41,8 +52,11 @@ export interface ToolbarDropdownOption {
|
|
|
41
52
|
id: string;
|
|
42
53
|
labelKey: string;
|
|
43
54
|
shortcut?: string;
|
|
55
|
+
/** Shows the option label in this font family (a CSS `font-family` list). */
|
|
56
|
+
fontFamily?: string;
|
|
44
57
|
run(editor: Editor): void;
|
|
45
|
-
|
|
58
|
+
/** Without it the option is an action (`role="menuitem"`), never checked. T-048. */
|
|
59
|
+
isActive?(editor: Editor): boolean;
|
|
46
60
|
/** Default: always enabled. */
|
|
47
61
|
isEnabled?(editor: Editor): boolean;
|
|
48
62
|
}
|
|
@@ -83,5 +97,54 @@ export interface ToolbarColorButton {
|
|
|
83
97
|
isEnabled?(editor: Editor): boolean;
|
|
84
98
|
isAvailable?(editor: Editor): boolean;
|
|
85
99
|
}
|
|
100
|
+
/** A font of the `fontFamilyDropdown` list. */
|
|
101
|
+
export interface ToolbarFont {
|
|
102
|
+
/** A CSS `font-family` list, written as the editor stores it (`'Times New Roman', serif`). */
|
|
103
|
+
fontFamily: string;
|
|
104
|
+
/** Key of the font name in `messages`; a missing key is shown as is. */
|
|
105
|
+
labelKey: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The font size control (T-038): a decrease button, a field that shows the size at the selection,
|
|
109
|
+
* takes a typed size and opens a list of sizes, and an increase button.
|
|
110
|
+
*/
|
|
111
|
+
export interface ToolbarFontSizeInput {
|
|
112
|
+
/** Unique within the toolbar; written as `data-item` on the three parts. */
|
|
113
|
+
id: string;
|
|
114
|
+
kind: 'fontSize';
|
|
115
|
+
/** Key of the accessible name of the field and of the list. */
|
|
116
|
+
labelKey: string;
|
|
117
|
+
/** The unit the field shows and writes; `rem` shows px and writes rem. */
|
|
118
|
+
unit: FontSizeUnit;
|
|
119
|
+
/** The sizes of the list, in `unit` (px for `rem`). */
|
|
120
|
+
sizes: readonly number[];
|
|
121
|
+
isAvailable?(editor: Editor): boolean;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* A button that shows the icon of the active option (of the first one when none is active) and
|
|
125
|
+
* opens the options as icons in a row (T-039).
|
|
126
|
+
*/
|
|
127
|
+
export interface ToolbarIconMenu {
|
|
128
|
+
/** Unique within the toolbar; written as `data-item`. */
|
|
129
|
+
id: string;
|
|
130
|
+
kind: 'iconMenu';
|
|
131
|
+
/** Key of the accessible name of the trigger and of the menu. */
|
|
132
|
+
labelKey: string;
|
|
133
|
+
options: ToolbarIconMenuOption[];
|
|
134
|
+
isAvailable?(editor: Editor): boolean;
|
|
135
|
+
}
|
|
136
|
+
/** An option of a {@link ToolbarIconMenu}. */
|
|
137
|
+
export interface ToolbarIconMenuOption {
|
|
138
|
+
/** Unique within the menu; used in the class `stilo-icon-menu__option--<id>`. */
|
|
139
|
+
id: string;
|
|
140
|
+
icon: IconNode;
|
|
141
|
+
labelKey: string;
|
|
142
|
+
/** Keymap notation shown in the tooltip. */
|
|
143
|
+
shortcut?: string;
|
|
144
|
+
run(editor: Editor): void;
|
|
145
|
+
isActive(editor: Editor): boolean;
|
|
146
|
+
/** Default: always enabled. */
|
|
147
|
+
isEnabled?(editor: Editor): boolean;
|
|
148
|
+
}
|
|
86
149
|
/** A single item in the toolbar. */
|
|
87
|
-
export type ToolbarItem = ToolbarButton | ToolbarDropdown | ToolbarColorButton;
|
|
150
|
+
export type ToolbarItem = ToolbarButton | ToolbarDropdown | ToolbarColorButton | ToolbarFontSizeInput | ToolbarIconMenu;
|