@notectl/core 0.0.10 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.d.ts +369 -38
- package/dist/notectl-core.js +403 -134
- package/dist/notectl-core.js.map +1 -1
- package/dist/notectl-core.mjs +5227 -3068
- package/dist/notectl-core.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# notectl
|
|
4
4
|
|
|
5
|
-
**A
|
|
5
|
+
## **A framework-agnostic rich text editor as a Web Component — ship only what you use.**
|
|
6
6
|
|
|
7
7
|
Built on immutable state, a transaction-based architecture, and a plugin system that powers every feature — from bold text to full table editing.
|
|
8
8
|
|
|
@@ -33,7 +33,7 @@ Most editors bolt formatting on top of `contenteditable` and hope for the best.
|
|
|
33
33
|
<br />
|
|
34
34
|
|
|
35
35
|
## Wanna try?
|
|
36
|
-
Check out the [live playground](
|
|
36
|
+
Check out the [live playground](https://samyssmile.github.io/notectl/playground/) — no install required.
|
|
37
37
|
|
|
38
38
|
## Wanna see full working example?
|
|
39
39
|
`examples/vanillajs/` is a great place to see everything in action.
|
|
@@ -92,7 +92,7 @@ Every capability is a plugin. Compose exactly the editor you need.
|
|
|
92
92
|
| **LinkPlugin** | Hyperlink insertion and editing |
|
|
93
93
|
| **TablePlugin** | Full table support with row/column controls |
|
|
94
94
|
| **TextColorPlugin** | Text color picker |
|
|
95
|
-
| **
|
|
95
|
+
| **AlignmentPlugin** | Left, center, right, justify |
|
|
96
96
|
| **FontPlugin** | Font family selection with custom font support |
|
|
97
97
|
| **FontSizePlugin** | Configurable font sizes |
|
|
98
98
|
| **HorizontalRulePlugin** | Horizontal dividers |
|
|
@@ -188,7 +188,7 @@ const editor = await createEditor({
|
|
|
188
188
|
[new FontPlugin(), new FontSizePlugin()],
|
|
189
189
|
[new TextFormattingPlugin(), new StrikethroughPlugin(), new TextColorPlugin()],
|
|
190
190
|
[new HeadingPlugin(), new BlockquotePlugin()],
|
|
191
|
-
[new
|
|
191
|
+
[new AlignmentPlugin()],
|
|
192
192
|
[new ListPlugin()],
|
|
193
193
|
[new LinkPlugin(), new TablePlugin(), new HorizontalRulePlugin()],
|
|
194
194
|
],
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,58 @@ export declare interface AddMarkStep {
|
|
|
18
18
|
readonly path?: readonly BlockId[];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
export declare const ALIGNMENT_ICONS: Readonly<Record<BlockAlignment, string>>;
|
|
22
|
+
|
|
23
|
+
declare interface AlignmentConfig {
|
|
24
|
+
/** Which alignments to expose. Defaults to all four. */
|
|
25
|
+
readonly alignments: readonly BlockAlignment[];
|
|
26
|
+
/** Block types that support alignment. Defaults to paragraph + heading + title + subtitle + table_cell + image. */
|
|
27
|
+
readonly alignableTypes: readonly string[];
|
|
28
|
+
/** Per-type default alignment (e.g. `{ image: 'center' }`). Falls back to `'left'`. */
|
|
29
|
+
readonly defaults: Readonly<Record<string, BlockAlignment>>;
|
|
30
|
+
/** When true, a separator is rendered after the toolbar item. */
|
|
31
|
+
readonly separatorAfter?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export { AlignmentConfig }
|
|
34
|
+
export { AlignmentConfig as TextAlignmentConfig }
|
|
35
|
+
|
|
36
|
+
declare class AlignmentPlugin implements Plugin_2 {
|
|
37
|
+
readonly id = "alignment";
|
|
38
|
+
readonly name = "Alignment";
|
|
39
|
+
readonly priority = 90;
|
|
40
|
+
private readonly config;
|
|
41
|
+
private alignableTypes;
|
|
42
|
+
constructor(config?: Partial<AlignmentConfig>);
|
|
43
|
+
init(context: PluginContext): void;
|
|
44
|
+
/**
|
|
45
|
+
* Patches existing NodeSpecs for alignable block types to support the
|
|
46
|
+
* `align` attribute and render it as an inline style. Skips types
|
|
47
|
+
* that already define an `align` attribute in their spec.
|
|
48
|
+
*/
|
|
49
|
+
private patchNodeSpecs;
|
|
50
|
+
private registerCommands;
|
|
51
|
+
private registerKeymaps;
|
|
52
|
+
private registerToolbarItem;
|
|
53
|
+
/**
|
|
54
|
+
* Preserves the `align` attribute when other plugins change the block
|
|
55
|
+
* type (e.g. paragraph → heading) via `setBlockType`, which replaces attrs.
|
|
56
|
+
*/
|
|
57
|
+
private registerMiddleware;
|
|
58
|
+
/**
|
|
59
|
+
* Gets the selected block, handling both TextSelection and NodeSelection.
|
|
60
|
+
*/
|
|
61
|
+
private getSelectedBlock;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the block ID of the selected block, handling both selection types.
|
|
64
|
+
*/
|
|
65
|
+
private getSelectedBlockId;
|
|
66
|
+
private setAlignment;
|
|
67
|
+
private isNonDefaultAlignment;
|
|
68
|
+
private isAlignable;
|
|
69
|
+
}
|
|
70
|
+
export { AlignmentPlugin }
|
|
71
|
+
export { AlignmentPlugin as TextAlignmentPlugin }
|
|
72
|
+
|
|
21
73
|
/** Applies a single step to a document and returns the new document. */
|
|
22
74
|
export declare function applyStep(doc: Document_2, step: Step): Document_2;
|
|
23
75
|
|
|
@@ -25,6 +77,10 @@ export declare interface AttrSpec {
|
|
|
25
77
|
readonly default?: string | number | boolean;
|
|
26
78
|
}
|
|
27
79
|
|
|
80
|
+
declare type BlockAlignment = 'left' | 'center' | 'right' | 'justify';
|
|
81
|
+
export { BlockAlignment }
|
|
82
|
+
export { BlockAlignment as TextAlignment }
|
|
83
|
+
|
|
28
84
|
export declare interface BlockAttrs {
|
|
29
85
|
readonly [key: string]: string | number | boolean;
|
|
30
86
|
}
|
|
@@ -93,6 +149,112 @@ export declare interface CellRange {
|
|
|
93
149
|
declare type ChildNode_2 = TextNode | InlineNode | BlockNode;
|
|
94
150
|
export { ChildNode_2 as ChildNode }
|
|
95
151
|
|
|
152
|
+
export declare class ClipboardHandler {
|
|
153
|
+
private readonly element;
|
|
154
|
+
private readonly getState;
|
|
155
|
+
private readonly dispatch;
|
|
156
|
+
private readonly schemaRegistry?;
|
|
157
|
+
private readonly syncSelection?;
|
|
158
|
+
private readonly handleCopy;
|
|
159
|
+
private readonly handleCut;
|
|
160
|
+
constructor(element: HTMLElement, options: ClipboardHandlerOptions);
|
|
161
|
+
private onCopy;
|
|
162
|
+
private onCut;
|
|
163
|
+
private writeNodeSelectionToClipboard;
|
|
164
|
+
private writeTextSelectionToClipboard;
|
|
165
|
+
/** Serializes a range of inline content within a block to an HTML string. */
|
|
166
|
+
private serializeBlockRangeToHTML;
|
|
167
|
+
/** Wraps escaped text in mark HTML tags using MarkSpec.toHTMLString when available. */
|
|
168
|
+
private serializeTextWithMarks;
|
|
169
|
+
destroy(): void;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
declare interface ClipboardHandlerOptions {
|
|
173
|
+
readonly getState: GetStateFn;
|
|
174
|
+
readonly dispatch: DispatchFn;
|
|
175
|
+
readonly schemaRegistry?: SchemaRegistry;
|
|
176
|
+
/** Force-sync DOM selection to state (selectionchange may fire async). */
|
|
177
|
+
readonly syncSelection?: () => void;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export declare const CODE_BLOCK_SERVICE_KEY: ServiceKey<CodeBlockService>;
|
|
181
|
+
|
|
182
|
+
export declare interface CodeBlockConfig {
|
|
183
|
+
readonly highlighter?: SyntaxHighlighter;
|
|
184
|
+
readonly defaultLanguage?: string;
|
|
185
|
+
readonly useSpaces?: boolean;
|
|
186
|
+
readonly spaceCount?: number;
|
|
187
|
+
readonly showCopyButton?: boolean;
|
|
188
|
+
readonly separatorAfter?: boolean;
|
|
189
|
+
/** Default body background color (overrides --notectl-code-block-bg). */
|
|
190
|
+
readonly background?: string;
|
|
191
|
+
/** Default header background color (overrides --notectl-code-block-header-bg). */
|
|
192
|
+
readonly headerBackground?: string;
|
|
193
|
+
/** Default text color (overrides --notectl-code-block-color). */
|
|
194
|
+
readonly textColor?: string;
|
|
195
|
+
/** Default header/label text color (overrides --notectl-code-block-header-color). */
|
|
196
|
+
readonly headerColor?: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export declare class CodeBlockPlugin implements Plugin_2 {
|
|
200
|
+
readonly id = "code-block";
|
|
201
|
+
readonly name = "Code Block";
|
|
202
|
+
readonly priority = 36;
|
|
203
|
+
private readonly config;
|
|
204
|
+
private context;
|
|
205
|
+
constructor(config?: Partial<CodeBlockConfig>);
|
|
206
|
+
init(context: PluginContext): void;
|
|
207
|
+
destroy(): void;
|
|
208
|
+
decorations(state: EditorState): DecorationSet;
|
|
209
|
+
private registerNodeSpec;
|
|
210
|
+
private registerNodeView;
|
|
211
|
+
private registerCommands;
|
|
212
|
+
private registerKeymaps;
|
|
213
|
+
private registerInputRule;
|
|
214
|
+
private registerToolbarItem;
|
|
215
|
+
private registerMiddleware;
|
|
216
|
+
private registerService;
|
|
217
|
+
private patchTableCellContent;
|
|
218
|
+
/**
|
|
219
|
+
* Handles Backspace at the start of a code block.
|
|
220
|
+
* Converts the code block back to a paragraph, preserving text.
|
|
221
|
+
*/
|
|
222
|
+
private handleBackspace;
|
|
223
|
+
private handleEnter;
|
|
224
|
+
private handleTab;
|
|
225
|
+
private handleShiftTab;
|
|
226
|
+
private handleEscape;
|
|
227
|
+
/**
|
|
228
|
+
* Handles ArrowDown at the last line of a code block.
|
|
229
|
+
* Exits to the next block or creates a paragraph below.
|
|
230
|
+
*/
|
|
231
|
+
private handleArrowDown;
|
|
232
|
+
/**
|
|
233
|
+
* Handles ArrowUp at the first line of a code block.
|
|
234
|
+
* Exits to the previous block.
|
|
235
|
+
*/
|
|
236
|
+
private handleArrowUp;
|
|
237
|
+
private toggleCodeBlock;
|
|
238
|
+
private insertCodeBlock;
|
|
239
|
+
private exitOnDoubleEnter;
|
|
240
|
+
private insertParagraphAfter;
|
|
241
|
+
private setAttr;
|
|
242
|
+
/**
|
|
243
|
+
* Strips all marks from a block's inline content.
|
|
244
|
+
* Used when converting to code_block so no formatting carries over.
|
|
245
|
+
*/
|
|
246
|
+
private stripAllMarks;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export declare interface CodeBlockService {
|
|
250
|
+
setLanguage(blockId: BlockId, language: string): void;
|
|
251
|
+
getLanguage(blockId: BlockId): string;
|
|
252
|
+
setBackground(blockId: BlockId, color: string): void;
|
|
253
|
+
getBackground(blockId: BlockId): string;
|
|
254
|
+
isCodeBlock(blockId: BlockId): boolean;
|
|
255
|
+
getSupportedLanguages(): readonly string[];
|
|
256
|
+
}
|
|
257
|
+
|
|
96
258
|
export declare interface CommandEntry {
|
|
97
259
|
readonly name: string;
|
|
98
260
|
readonly handler: CommandHandler;
|
|
@@ -154,6 +316,15 @@ export declare function createSelection(anchor: Position, head: Position): Selec
|
|
|
154
316
|
/** Creates a new {@link TextNode}. */
|
|
155
317
|
export declare function createTextNode(text: string, marks?: readonly Mark[]): TextNode;
|
|
156
318
|
|
|
319
|
+
/** Creates a custom theme by extending a base theme with partial overrides. */
|
|
320
|
+
export declare function createTheme(base: Theme, overrides: PartialTheme): Theme;
|
|
321
|
+
|
|
322
|
+
/** Creates a CSSStyleSheet populated with theme CSS variables. */
|
|
323
|
+
export declare function createThemeStyleSheet(theme: Theme): CSSStyleSheet;
|
|
324
|
+
|
|
325
|
+
/** Built-in dark theme. */
|
|
326
|
+
export declare const DARK_THEME: Theme;
|
|
327
|
+
|
|
157
328
|
export declare type Decoration = InlineDecoration | NodeDecoration | WidgetDecoration;
|
|
158
329
|
|
|
159
330
|
export declare interface DecorationAttrs {
|
|
@@ -228,6 +399,8 @@ export declare interface DeleteTextStep {
|
|
|
228
399
|
readonly path?: readonly BlockId[];
|
|
229
400
|
}
|
|
230
401
|
|
|
402
|
+
declare type DispatchFn = (tr: Transaction) => void;
|
|
403
|
+
|
|
231
404
|
declare interface Document_2 {
|
|
232
405
|
readonly children: readonly BlockNode[];
|
|
233
406
|
}
|
|
@@ -502,6 +675,9 @@ export declare class FontSizePlugin implements Plugin_2 {
|
|
|
502
675
|
*/
|
|
503
676
|
export declare function formatShortcut(binding: string): string;
|
|
504
677
|
|
|
678
|
+
/** Generates CSS text with all theme custom properties on :host. */
|
|
679
|
+
export declare function generateThemeCSS(theme: Theme): string;
|
|
680
|
+
|
|
505
681
|
/** Returns only the BlockNode children of a block. */
|
|
506
682
|
export declare function getBlockChildren(node: BlockNode): readonly BlockNode[];
|
|
507
683
|
|
|
@@ -527,6 +703,8 @@ export declare function getContentAtOffset(block: BlockNode, offset: number): {
|
|
|
527
703
|
/** Returns the inline content children (TextNode | InlineNode) of a block. */
|
|
528
704
|
export declare function getInlineChildren(node: BlockNode): readonly (TextNode | InlineNode)[];
|
|
529
705
|
|
|
706
|
+
declare type GetStateFn = () => EditorState;
|
|
707
|
+
|
|
530
708
|
/** Returns only the TextNode children of a block. */
|
|
531
709
|
export declare function getTextChildren(node: BlockNode): readonly TextNode[];
|
|
532
710
|
|
|
@@ -536,6 +714,16 @@ export declare interface GridPickerConfig {
|
|
|
536
714
|
onSelect(rows: number, cols: number): void;
|
|
537
715
|
}
|
|
538
716
|
|
|
717
|
+
export declare class HardBreakPlugin implements Plugin_2 {
|
|
718
|
+
readonly id = "hard-break";
|
|
719
|
+
readonly name = "Hard Break";
|
|
720
|
+
readonly priority = 10;
|
|
721
|
+
init(context: PluginContext): void;
|
|
722
|
+
private registerInlineNodeSpec;
|
|
723
|
+
private registerCommands;
|
|
724
|
+
private registerKeymap;
|
|
725
|
+
}
|
|
726
|
+
|
|
539
727
|
/** Returns true if the mark set contains a mark of the given type. */
|
|
540
728
|
export declare function hasMark(marks: readonly Mark[], markType: MarkTypeName): boolean;
|
|
541
729
|
|
|
@@ -569,6 +757,14 @@ export declare class HeadingPlugin implements Plugin_2 {
|
|
|
569
757
|
private dismissPopup;
|
|
570
758
|
private renderHeadingPopup;
|
|
571
759
|
private createPickerItem;
|
|
760
|
+
private static readonly HEADING_TYPES;
|
|
761
|
+
/**
|
|
762
|
+
* Handles Enter inside a heading block.
|
|
763
|
+
* Empty heading → convert to paragraph.
|
|
764
|
+
* Cursor at end → split and convert new block to paragraph.
|
|
765
|
+
* Cursor in middle → normal split (both stay heading).
|
|
766
|
+
*/
|
|
767
|
+
private handleEnter;
|
|
572
768
|
/**
|
|
573
769
|
* Toggles between a special block type (title/subtitle) and paragraph.
|
|
574
770
|
* If the block is already that type, resets to paragraph.
|
|
@@ -580,6 +776,16 @@ export declare class HeadingPlugin implements Plugin_2 {
|
|
|
580
776
|
*/
|
|
581
777
|
private toggleHeading;
|
|
582
778
|
private setBlockType;
|
|
779
|
+
/**
|
|
780
|
+
* Adds removeMark steps for each excluded mark type found
|
|
781
|
+
* on the block's inline text content.
|
|
782
|
+
*/
|
|
783
|
+
private stripExcludedMarks;
|
|
784
|
+
/**
|
|
785
|
+
* Clears excluded mark types from stored marks so that
|
|
786
|
+
* subsequent typing does not reintroduce them.
|
|
787
|
+
*/
|
|
788
|
+
private clearExcludedStoredMarks;
|
|
583
789
|
}
|
|
584
790
|
|
|
585
791
|
export declare interface HighlightConfig {
|
|
@@ -672,6 +878,55 @@ export declare class HorizontalRulePlugin implements Plugin_2 {
|
|
|
672
878
|
private insertHorizontalRule;
|
|
673
879
|
}
|
|
674
880
|
|
|
881
|
+
export declare const IMAGE_UPLOAD_SERVICE: ServiceKey<ImageUploadService>;
|
|
882
|
+
|
|
883
|
+
export declare interface ImageAttrs {
|
|
884
|
+
readonly src: string;
|
|
885
|
+
readonly alt: string;
|
|
886
|
+
readonly width?: number;
|
|
887
|
+
readonly height?: number;
|
|
888
|
+
readonly align: 'left' | 'center' | 'right';
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
export declare class ImagePlugin implements Plugin_2 {
|
|
892
|
+
readonly id = "image";
|
|
893
|
+
readonly name = "Image";
|
|
894
|
+
readonly priority = 45;
|
|
895
|
+
private readonly config;
|
|
896
|
+
private readonly uploadStates;
|
|
897
|
+
private readonly blobUrls;
|
|
898
|
+
constructor(config?: Partial<ImagePluginConfig>);
|
|
899
|
+
init(context: PluginContext): void;
|
|
900
|
+
destroy(): void;
|
|
901
|
+
onStateChange(_oldState: EditorState, newState: EditorState, _tr: Transaction): void;
|
|
902
|
+
private registerNodeSpec;
|
|
903
|
+
private registerNodeView;
|
|
904
|
+
private registerFileHandler;
|
|
905
|
+
private handleFileInsert;
|
|
906
|
+
private uploadFile;
|
|
907
|
+
private registerToolbarItem;
|
|
908
|
+
private renderImagePopup;
|
|
909
|
+
private isAcceptedType;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
export declare interface ImagePluginConfig {
|
|
913
|
+
readonly maxWidth: number;
|
|
914
|
+
readonly maxFileSize: number;
|
|
915
|
+
readonly acceptedTypes: readonly string[];
|
|
916
|
+
readonly resizable: boolean;
|
|
917
|
+
readonly separatorAfter?: boolean;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
export declare interface ImageUploadResult {
|
|
921
|
+
readonly url: string;
|
|
922
|
+
readonly width?: number;
|
|
923
|
+
readonly height?: number;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
export declare interface ImageUploadService {
|
|
927
|
+
upload(file: File): Promise<ImageUploadResult>;
|
|
928
|
+
}
|
|
929
|
+
|
|
675
930
|
export declare interface InlineDecoration {
|
|
676
931
|
readonly type: 'inline';
|
|
677
932
|
readonly blockId: BlockId;
|
|
@@ -725,6 +980,9 @@ export declare interface InputRule {
|
|
|
725
980
|
handler(state: EditorState, match: RegExpMatchArray, start: number, end: number): Transaction | null;
|
|
726
981
|
}
|
|
727
982
|
|
|
983
|
+
/** Inserts a hard line break (InlineNode) at the current cursor position. */
|
|
984
|
+
export declare function insertHardBreakCommand(state: EditorState): Transaction | null;
|
|
985
|
+
|
|
728
986
|
export declare interface InsertInlineNodeStep {
|
|
729
987
|
readonly type: 'insertInlineNode';
|
|
730
988
|
readonly blockId: BlockId;
|
|
@@ -837,6 +1095,9 @@ export declare type Keymap = Readonly<Record<string, KeymapHandler>>;
|
|
|
837
1095
|
*/
|
|
838
1096
|
export declare type KeymapHandler = () => boolean;
|
|
839
1097
|
|
|
1098
|
+
/** Built-in light theme. */
|
|
1099
|
+
export declare const LIGHT_THEME: Theme;
|
|
1100
|
+
|
|
840
1101
|
export declare interface LinkConfig {
|
|
841
1102
|
/** Whether to add rel="noopener noreferrer" and target="_blank" by default. */
|
|
842
1103
|
readonly openInNewTab: boolean;
|
|
@@ -973,7 +1234,7 @@ export declare function navigateArrowIntoVoid(state: EditorState, direction: 'le
|
|
|
973
1234
|
/** Plugins augment this interface to register typed node attributes. */
|
|
974
1235
|
export declare interface NodeAttrRegistry {
|
|
975
1236
|
paragraph: {
|
|
976
|
-
|
|
1237
|
+
align?: BlockAlignment;
|
|
977
1238
|
};
|
|
978
1239
|
}
|
|
979
1240
|
|
|
@@ -1013,6 +1274,12 @@ export declare interface NodeSpec<T extends string = string> {
|
|
|
1013
1274
|
readonly isolating?: boolean;
|
|
1014
1275
|
/** If true, node can be selected as an object via mouse interaction. */
|
|
1015
1276
|
readonly selectable?: boolean;
|
|
1277
|
+
/**
|
|
1278
|
+
* Mark types that are incompatible with this block type.
|
|
1279
|
+
* When a block is converted to this type, marks listed here
|
|
1280
|
+
* are stripped from the block's inline content.
|
|
1281
|
+
*/
|
|
1282
|
+
readonly excludeMarks?: readonly string[];
|
|
1016
1283
|
/** Serializes the block to an HTML string. `content` is the pre-serialized inline children. */
|
|
1017
1284
|
readonly toHTML?: (node: BlockNode, content: string) => string;
|
|
1018
1285
|
/** Rules for matching HTML elements to this block type during parsing. */
|
|
@@ -1065,6 +1332,9 @@ export declare class NotectlEditor extends HTMLElement {
|
|
|
1065
1332
|
private readonly readyPromise;
|
|
1066
1333
|
private initialized;
|
|
1067
1334
|
private preInitPlugins;
|
|
1335
|
+
private themeStyleSheet;
|
|
1336
|
+
private systemThemeQuery;
|
|
1337
|
+
private systemThemeHandler;
|
|
1068
1338
|
constructor();
|
|
1069
1339
|
static get observedAttributes(): string[];
|
|
1070
1340
|
connectedCallback(): void;
|
|
@@ -1118,8 +1388,18 @@ export declare class NotectlEditor extends HTMLElement {
|
|
|
1118
1388
|
whenReady(): Promise<void>;
|
|
1119
1389
|
/** Updates configuration at runtime. */
|
|
1120
1390
|
configure(config: Partial<NotectlEditorConfig>): void;
|
|
1391
|
+
/** Changes the theme at runtime. */
|
|
1392
|
+
setTheme(theme: ThemePreset | Theme): void;
|
|
1393
|
+
/** Returns the current theme setting. */
|
|
1394
|
+
getTheme(): ThemePreset | Theme;
|
|
1121
1395
|
/** Cleans up the editor. Awaiting ensures async plugin teardown completes. */
|
|
1122
1396
|
destroy(): Promise<void>;
|
|
1397
|
+
/** Applies a theme. Called during init() and on runtime changes. */
|
|
1398
|
+
private applyTheme;
|
|
1399
|
+
private setThemeStyleSheet;
|
|
1400
|
+
private setupSystemThemeListener;
|
|
1401
|
+
private cleanupSystemThemeListener;
|
|
1402
|
+
private getSystemTheme;
|
|
1123
1403
|
/**
|
|
1124
1404
|
* Processes the declarative `toolbar` config: registers a ToolbarPlugin
|
|
1125
1405
|
* with layout groups, then registers all plugins from the toolbar groups.
|
|
@@ -1158,6 +1438,8 @@ export declare interface NotectlEditorConfig {
|
|
|
1158
1438
|
readonly?: boolean;
|
|
1159
1439
|
autofocus?: boolean;
|
|
1160
1440
|
maxHistoryDepth?: number;
|
|
1441
|
+
/** Theme preset or custom Theme object. Defaults to ThemePreset.Light. */
|
|
1442
|
+
theme?: ThemePreset | Theme;
|
|
1161
1443
|
}
|
|
1162
1444
|
|
|
1163
1445
|
/**
|
|
@@ -1171,6 +1453,15 @@ export declare interface ParseRule {
|
|
|
1171
1453
|
readonly priority?: number;
|
|
1172
1454
|
}
|
|
1173
1455
|
|
|
1456
|
+
/** Partial custom theme — deeply partial for creating overrides. */
|
|
1457
|
+
export declare interface PartialTheme {
|
|
1458
|
+
readonly name: string;
|
|
1459
|
+
readonly primitives?: Partial<ThemePrimitives>;
|
|
1460
|
+
readonly toolbar?: Partial<ThemeToolbar>;
|
|
1461
|
+
readonly codeBlock?: Partial<ThemeCodeBlock>;
|
|
1462
|
+
readonly tooltip?: Partial<ThemeTooltip>;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1174
1465
|
declare interface Plugin_2<TConfig extends Record<string, unknown> = Record<string, unknown>> {
|
|
1175
1466
|
readonly id: string;
|
|
1176
1467
|
readonly name: string;
|
|
@@ -1337,6 +1628,9 @@ export declare function resolveParentByPath(doc: Document_2, path: readonly stri
|
|
|
1337
1628
|
index: number;
|
|
1338
1629
|
} | undefined;
|
|
1339
1630
|
|
|
1631
|
+
/** Resolves a ThemePreset string or Theme object to a full Theme. */
|
|
1632
|
+
export declare function resolveTheme(theme: ThemePreset | Theme): Theme;
|
|
1633
|
+
|
|
1340
1634
|
/**
|
|
1341
1635
|
* SanitizeConfig: declares which HTML tags and attributes a spec needs
|
|
1342
1636
|
* to survive DOMPurify sanitization.
|
|
@@ -1562,6 +1856,17 @@ export declare interface SuperSubToolbarConfig {
|
|
|
1562
1856
|
readonly subscript?: boolean;
|
|
1563
1857
|
}
|
|
1564
1858
|
|
|
1859
|
+
export declare interface SyntaxHighlighter {
|
|
1860
|
+
tokenize(code: string, language: string): readonly SyntaxToken[];
|
|
1861
|
+
getSupportedLanguages(): readonly string[];
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
export declare interface SyntaxToken {
|
|
1865
|
+
readonly from: number;
|
|
1866
|
+
readonly to: number;
|
|
1867
|
+
readonly type: string;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1565
1870
|
export declare interface TableConfig {
|
|
1566
1871
|
/** Maximum rows in grid picker. Defaults to 8. */
|
|
1567
1872
|
readonly maxPickerRows?: number;
|
|
@@ -1611,43 +1916,6 @@ export declare interface TableSelectionService {
|
|
|
1611
1916
|
|
|
1612
1917
|
export declare const TableSelectionServiceKey: ServiceKey<TableSelectionService>;
|
|
1613
1918
|
|
|
1614
|
-
export declare type TextAlignment = 'left' | 'center' | 'right' | 'justify';
|
|
1615
|
-
|
|
1616
|
-
export declare interface TextAlignmentConfig {
|
|
1617
|
-
/** Which alignments to expose. Defaults to all four. */
|
|
1618
|
-
readonly alignments: readonly TextAlignment[];
|
|
1619
|
-
/** Block types that support alignment. Defaults to paragraph + heading. */
|
|
1620
|
-
readonly alignableTypes: readonly string[];
|
|
1621
|
-
/** When true, a separator is rendered after the toolbar item. */
|
|
1622
|
-
readonly separatorAfter?: boolean;
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
export declare class TextAlignmentPlugin implements Plugin_2 {
|
|
1626
|
-
readonly id = "text-alignment";
|
|
1627
|
-
readonly name = "Text Alignment";
|
|
1628
|
-
readonly priority = 90;
|
|
1629
|
-
private readonly config;
|
|
1630
|
-
private alignableTypes;
|
|
1631
|
-
constructor(config?: Partial<TextAlignmentConfig>);
|
|
1632
|
-
init(context: PluginContext): void;
|
|
1633
|
-
/**
|
|
1634
|
-
* Patches existing NodeSpecs for alignable block types to support the
|
|
1635
|
-
* `textAlign` attribute and render it as an inline style.
|
|
1636
|
-
*/
|
|
1637
|
-
private patchNodeSpecs;
|
|
1638
|
-
private registerCommands;
|
|
1639
|
-
private registerKeymaps;
|
|
1640
|
-
private registerToolbarItem;
|
|
1641
|
-
/**
|
|
1642
|
-
* Preserves the `textAlign` attribute when other plugins change the block
|
|
1643
|
-
* type (e.g. paragraph → heading) via `setBlockType`, which replaces attrs.
|
|
1644
|
-
*/
|
|
1645
|
-
private registerMiddleware;
|
|
1646
|
-
private setAlignment;
|
|
1647
|
-
private isNonDefaultAlignment;
|
|
1648
|
-
private isAlignable;
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
1919
|
export declare interface TextColorConfig {
|
|
1652
1920
|
/**
|
|
1653
1921
|
* Restricts the color picker to a specific set of hex colors.
|
|
@@ -1724,6 +1992,69 @@ export declare interface TextSegment {
|
|
|
1724
1992
|
readonly marks: readonly Mark[];
|
|
1725
1993
|
}
|
|
1726
1994
|
|
|
1995
|
+
/** Full theme definition. */
|
|
1996
|
+
export declare interface Theme {
|
|
1997
|
+
readonly name: string;
|
|
1998
|
+
readonly primitives: ThemePrimitives;
|
|
1999
|
+
readonly toolbar?: Partial<ThemeToolbar>;
|
|
2000
|
+
readonly codeBlock?: Partial<ThemeCodeBlock>;
|
|
2001
|
+
readonly tooltip?: Partial<ThemeTooltip>;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
/** Component-level code block overrides. */
|
|
2005
|
+
export declare interface ThemeCodeBlock {
|
|
2006
|
+
readonly background: string;
|
|
2007
|
+
readonly foreground: string;
|
|
2008
|
+
readonly headerBackground: string;
|
|
2009
|
+
readonly headerForeground: string;
|
|
2010
|
+
readonly headerBorder: string;
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
/** Built-in theme presets. */
|
|
2014
|
+
export declare const ThemePreset: {
|
|
2015
|
+
readonly Light: "light";
|
|
2016
|
+
readonly Dark: "dark";
|
|
2017
|
+
readonly System: "system";
|
|
2018
|
+
};
|
|
2019
|
+
|
|
2020
|
+
export declare type ThemePreset = (typeof ThemePreset)[keyof typeof ThemePreset];
|
|
2021
|
+
|
|
2022
|
+
/**
|
|
2023
|
+
* Theme token types, built-in themes, and theme creation helpers.
|
|
2024
|
+
*/
|
|
2025
|
+
/** Primitive color palette a theme defines. */
|
|
2026
|
+
export declare interface ThemePrimitives {
|
|
2027
|
+
readonly background: string;
|
|
2028
|
+
readonly foreground: string;
|
|
2029
|
+
readonly mutedForeground: string;
|
|
2030
|
+
readonly border: string;
|
|
2031
|
+
readonly borderFocus: string;
|
|
2032
|
+
readonly primary: string;
|
|
2033
|
+
readonly primaryForeground: string;
|
|
2034
|
+
readonly primaryMuted: string;
|
|
2035
|
+
readonly surfaceRaised: string;
|
|
2036
|
+
readonly surfaceOverlay: string;
|
|
2037
|
+
readonly hoverBackground: string;
|
|
2038
|
+
readonly activeBackground: string;
|
|
2039
|
+
readonly danger: string;
|
|
2040
|
+
readonly dangerMuted: string;
|
|
2041
|
+
readonly success: string;
|
|
2042
|
+
readonly shadow: string;
|
|
2043
|
+
readonly focusRing: string;
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
/** Component-level toolbar overrides. */
|
|
2047
|
+
export declare interface ThemeToolbar {
|
|
2048
|
+
readonly background: string;
|
|
2049
|
+
readonly borderColor: string;
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
/** Component-level tooltip overrides. */
|
|
2053
|
+
export declare interface ThemeTooltip {
|
|
2054
|
+
readonly background: string;
|
|
2055
|
+
readonly foreground: string;
|
|
2056
|
+
}
|
|
2057
|
+
|
|
1727
2058
|
export declare function toggleBold(state: EditorState, features?: FeatureConfig): Transaction | null;
|
|
1728
2059
|
|
|
1729
2060
|
export declare function toggleItalic(state: EditorState, features?: FeatureConfig): Transaction | null;
|