@notectl/core 0.0.11 → 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 +3 -3
- package/dist/index.d.ts +353 -38
- package/dist/notectl-core.js +403 -134
- package/dist/notectl-core.js.map +1 -1
- package/dist/notectl-core.mjs +5207 -3083
- 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
|
|
|
@@ -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.
|
|
@@ -682,6 +878,55 @@ export declare class HorizontalRulePlugin implements Plugin_2 {
|
|
|
682
878
|
private insertHorizontalRule;
|
|
683
879
|
}
|
|
684
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
|
+
|
|
685
930
|
export declare interface InlineDecoration {
|
|
686
931
|
readonly type: 'inline';
|
|
687
932
|
readonly blockId: BlockId;
|
|
@@ -735,6 +980,9 @@ export declare interface InputRule {
|
|
|
735
980
|
handler(state: EditorState, match: RegExpMatchArray, start: number, end: number): Transaction | null;
|
|
736
981
|
}
|
|
737
982
|
|
|
983
|
+
/** Inserts a hard line break (InlineNode) at the current cursor position. */
|
|
984
|
+
export declare function insertHardBreakCommand(state: EditorState): Transaction | null;
|
|
985
|
+
|
|
738
986
|
export declare interface InsertInlineNodeStep {
|
|
739
987
|
readonly type: 'insertInlineNode';
|
|
740
988
|
readonly blockId: BlockId;
|
|
@@ -847,6 +1095,9 @@ export declare type Keymap = Readonly<Record<string, KeymapHandler>>;
|
|
|
847
1095
|
*/
|
|
848
1096
|
export declare type KeymapHandler = () => boolean;
|
|
849
1097
|
|
|
1098
|
+
/** Built-in light theme. */
|
|
1099
|
+
export declare const LIGHT_THEME: Theme;
|
|
1100
|
+
|
|
850
1101
|
export declare interface LinkConfig {
|
|
851
1102
|
/** Whether to add rel="noopener noreferrer" and target="_blank" by default. */
|
|
852
1103
|
readonly openInNewTab: boolean;
|
|
@@ -983,7 +1234,7 @@ export declare function navigateArrowIntoVoid(state: EditorState, direction: 'le
|
|
|
983
1234
|
/** Plugins augment this interface to register typed node attributes. */
|
|
984
1235
|
export declare interface NodeAttrRegistry {
|
|
985
1236
|
paragraph: {
|
|
986
|
-
|
|
1237
|
+
align?: BlockAlignment;
|
|
987
1238
|
};
|
|
988
1239
|
}
|
|
989
1240
|
|
|
@@ -1081,6 +1332,9 @@ export declare class NotectlEditor extends HTMLElement {
|
|
|
1081
1332
|
private readonly readyPromise;
|
|
1082
1333
|
private initialized;
|
|
1083
1334
|
private preInitPlugins;
|
|
1335
|
+
private themeStyleSheet;
|
|
1336
|
+
private systemThemeQuery;
|
|
1337
|
+
private systemThemeHandler;
|
|
1084
1338
|
constructor();
|
|
1085
1339
|
static get observedAttributes(): string[];
|
|
1086
1340
|
connectedCallback(): void;
|
|
@@ -1134,8 +1388,18 @@ export declare class NotectlEditor extends HTMLElement {
|
|
|
1134
1388
|
whenReady(): Promise<void>;
|
|
1135
1389
|
/** Updates configuration at runtime. */
|
|
1136
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;
|
|
1137
1395
|
/** Cleans up the editor. Awaiting ensures async plugin teardown completes. */
|
|
1138
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;
|
|
1139
1403
|
/**
|
|
1140
1404
|
* Processes the declarative `toolbar` config: registers a ToolbarPlugin
|
|
1141
1405
|
* with layout groups, then registers all plugins from the toolbar groups.
|
|
@@ -1174,6 +1438,8 @@ export declare interface NotectlEditorConfig {
|
|
|
1174
1438
|
readonly?: boolean;
|
|
1175
1439
|
autofocus?: boolean;
|
|
1176
1440
|
maxHistoryDepth?: number;
|
|
1441
|
+
/** Theme preset or custom Theme object. Defaults to ThemePreset.Light. */
|
|
1442
|
+
theme?: ThemePreset | Theme;
|
|
1177
1443
|
}
|
|
1178
1444
|
|
|
1179
1445
|
/**
|
|
@@ -1187,6 +1453,15 @@ export declare interface ParseRule {
|
|
|
1187
1453
|
readonly priority?: number;
|
|
1188
1454
|
}
|
|
1189
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
|
+
|
|
1190
1465
|
declare interface Plugin_2<TConfig extends Record<string, unknown> = Record<string, unknown>> {
|
|
1191
1466
|
readonly id: string;
|
|
1192
1467
|
readonly name: string;
|
|
@@ -1353,6 +1628,9 @@ export declare function resolveParentByPath(doc: Document_2, path: readonly stri
|
|
|
1353
1628
|
index: number;
|
|
1354
1629
|
} | undefined;
|
|
1355
1630
|
|
|
1631
|
+
/** Resolves a ThemePreset string or Theme object to a full Theme. */
|
|
1632
|
+
export declare function resolveTheme(theme: ThemePreset | Theme): Theme;
|
|
1633
|
+
|
|
1356
1634
|
/**
|
|
1357
1635
|
* SanitizeConfig: declares which HTML tags and attributes a spec needs
|
|
1358
1636
|
* to survive DOMPurify sanitization.
|
|
@@ -1578,6 +1856,17 @@ export declare interface SuperSubToolbarConfig {
|
|
|
1578
1856
|
readonly subscript?: boolean;
|
|
1579
1857
|
}
|
|
1580
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
|
+
|
|
1581
1870
|
export declare interface TableConfig {
|
|
1582
1871
|
/** Maximum rows in grid picker. Defaults to 8. */
|
|
1583
1872
|
readonly maxPickerRows?: number;
|
|
@@ -1627,43 +1916,6 @@ export declare interface TableSelectionService {
|
|
|
1627
1916
|
|
|
1628
1917
|
export declare const TableSelectionServiceKey: ServiceKey<TableSelectionService>;
|
|
1629
1918
|
|
|
1630
|
-
export declare type TextAlignment = 'left' | 'center' | 'right' | 'justify';
|
|
1631
|
-
|
|
1632
|
-
export declare interface TextAlignmentConfig {
|
|
1633
|
-
/** Which alignments to expose. Defaults to all four. */
|
|
1634
|
-
readonly alignments: readonly TextAlignment[];
|
|
1635
|
-
/** Block types that support alignment. Defaults to paragraph + heading. */
|
|
1636
|
-
readonly alignableTypes: readonly string[];
|
|
1637
|
-
/** When true, a separator is rendered after the toolbar item. */
|
|
1638
|
-
readonly separatorAfter?: boolean;
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
export declare class TextAlignmentPlugin implements Plugin_2 {
|
|
1642
|
-
readonly id = "text-alignment";
|
|
1643
|
-
readonly name = "Text Alignment";
|
|
1644
|
-
readonly priority = 90;
|
|
1645
|
-
private readonly config;
|
|
1646
|
-
private alignableTypes;
|
|
1647
|
-
constructor(config?: Partial<TextAlignmentConfig>);
|
|
1648
|
-
init(context: PluginContext): void;
|
|
1649
|
-
/**
|
|
1650
|
-
* Patches existing NodeSpecs for alignable block types to support the
|
|
1651
|
-
* `textAlign` attribute and render it as an inline style.
|
|
1652
|
-
*/
|
|
1653
|
-
private patchNodeSpecs;
|
|
1654
|
-
private registerCommands;
|
|
1655
|
-
private registerKeymaps;
|
|
1656
|
-
private registerToolbarItem;
|
|
1657
|
-
/**
|
|
1658
|
-
* Preserves the `textAlign` attribute when other plugins change the block
|
|
1659
|
-
* type (e.g. paragraph → heading) via `setBlockType`, which replaces attrs.
|
|
1660
|
-
*/
|
|
1661
|
-
private registerMiddleware;
|
|
1662
|
-
private setAlignment;
|
|
1663
|
-
private isNonDefaultAlignment;
|
|
1664
|
-
private isAlignable;
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1667
1919
|
export declare interface TextColorConfig {
|
|
1668
1920
|
/**
|
|
1669
1921
|
* Restricts the color picker to a specific set of hex colors.
|
|
@@ -1740,6 +1992,69 @@ export declare interface TextSegment {
|
|
|
1740
1992
|
readonly marks: readonly Mark[];
|
|
1741
1993
|
}
|
|
1742
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
|
+
|
|
1743
2058
|
export declare function toggleBold(state: EditorState, features?: FeatureConfig): Transaction | null;
|
|
1744
2059
|
|
|
1745
2060
|
export declare function toggleItalic(state: EditorState, features?: FeatureConfig): Transaction | null;
|