autumnnote 1.15.0 → 1.16.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 +22 -0
- package/dist/autumnnote.cjs +20 -20
- package/dist/autumnnote.css +1 -1
- package/dist/autumnnote.es.js +543 -62
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.min.js +61 -0
- package/dist/autumnnote.umd.js +20 -20
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/js/Context.js +154 -15
- package/src/js/editing/History.js +38 -6
- package/src/js/i18n/de.js +15 -0
- package/src/js/i18n/en.js +15 -0
- package/src/js/i18n/es.js +15 -0
- package/src/js/i18n/fr.js +15 -0
- package/src/js/i18n/ja.js +15 -0
- package/src/js/i18n/ko.js +15 -0
- package/src/js/i18n/vi.js +15 -0
- package/src/js/i18n/zh.js +15 -0
- package/src/js/index.js +13 -1
- package/src/js/module/Clipboard.js +20 -6
- package/src/js/module/Editor.js +15 -1
- package/src/js/module/ImageDialog.js +34 -6
- package/src/js/module/MarkdownShortcuts.js +2 -2
- package/src/js/module/SlashMenu.js +376 -0
- package/src/js/module/Statusbar.js +3 -9
- package/src/js/settings.js +27 -0
- package/src/styles/autumnnote.scss +49 -0
- package/types/index.d.ts +84 -1
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AutumnNote – TypeScript declarations
|
|
3
|
-
* @version 1.
|
|
3
|
+
* @version 1.16.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
@@ -16,6 +16,35 @@ export interface PasteErrorData {
|
|
|
16
16
|
maxBytes?: number;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
export interface AutoSavePayload {
|
|
20
|
+
key: string;
|
|
21
|
+
html: string;
|
|
22
|
+
savedAt: number;
|
|
23
|
+
context: Context;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface AutoSaveAdapter {
|
|
27
|
+
save(payload: AutoSavePayload): void | Promise<void>;
|
|
28
|
+
load?(payload: { key: string; context: Context }): string | null | Promise<string | null>;
|
|
29
|
+
remove?(payload: { key: string; context: Context }): void | Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SlashCommand {
|
|
33
|
+
id: string;
|
|
34
|
+
label?: string;
|
|
35
|
+
keywords?: string;
|
|
36
|
+
run(context: Context): void | Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface DocumentAdapter {
|
|
40
|
+
import?(data: unknown, context: Context): string | Promise<string>;
|
|
41
|
+
export?(context: Context, html: string): unknown | Promise<unknown>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface CollaborationAdapter {
|
|
45
|
+
onLocalChange?(html: string, context: Context): void | Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
|
|
19
48
|
export interface AsnOptions {
|
|
20
49
|
/** Placeholder text when the editor is empty. */
|
|
21
50
|
placeholder?: string;
|
|
@@ -85,6 +114,8 @@ export interface AsnOptions {
|
|
|
85
114
|
markdownPaste?: boolean;
|
|
86
115
|
/** Maximum undo/redo history steps. */
|
|
87
116
|
historyLimit?: number;
|
|
117
|
+
/** Maximum combined size (chars) of all stacked undo/redo snapshots. Default 10485760 (10 MB). */
|
|
118
|
+
historyMaxBytes?: number;
|
|
88
119
|
/** Default font family applied to the editable area on init. */
|
|
89
120
|
defaultFontFamily?: string;
|
|
90
121
|
/** Default font size applied to the editable area on init (e.g. '14px'). */
|
|
@@ -103,6 +134,10 @@ export interface AsnOptions {
|
|
|
103
134
|
autoSave?: boolean;
|
|
104
135
|
/** localStorage key used for auto-save. */
|
|
105
136
|
autoSaveKey?: string;
|
|
137
|
+
/** Debounce delay for auto-save writes. Default: 400ms. */
|
|
138
|
+
autoSaveDelay?: number;
|
|
139
|
+
/** Optional persistence adapter; localStorage remains the default. */
|
|
140
|
+
autoSaveAdapter?: AutoSaveAdapter | null;
|
|
106
141
|
/** Maximum character count for the statusbar warning (0 = unlimited). */
|
|
107
142
|
maxChars?: number;
|
|
108
143
|
/** Maximum word count for the statusbar warning (0 = unlimited). */
|
|
@@ -153,6 +188,20 @@ export interface AsnOptions {
|
|
|
153
188
|
|
|
154
189
|
/** @mention autocomplete configuration. Activated when mention.onSearch is provided. */
|
|
155
190
|
mention?: MentionOptions | null;
|
|
191
|
+
|
|
192
|
+
// ---- Slash command menu ----------------------------------------------------
|
|
193
|
+
|
|
194
|
+
/** Show a "/" command palette for quick block insertion (headings, lists, table, image, ...). Default: true. */
|
|
195
|
+
slashMenu?: boolean;
|
|
196
|
+
/** Application/plugin-provided slash commands. */
|
|
197
|
+
slashCommands?: SlashCommand[];
|
|
198
|
+
/** Import/export adapters keyed by format. */
|
|
199
|
+
documentAdapters?: Record<string, DocumentAdapter>;
|
|
200
|
+
/** Optional external image processor, such as a Web Worker bridge. */
|
|
201
|
+
imageProcessor?: (file: File, helpers: { context: Context }) => string | Promise<string>;
|
|
202
|
+
collaborationAdapter?: CollaborationAdapter | null;
|
|
203
|
+
/** Adds stable IDs to top-level blocks for external collaboration adapters. */
|
|
204
|
+
blockIds?: boolean;
|
|
156
205
|
}
|
|
157
206
|
|
|
158
207
|
// ---------------------------------------------------------------------------
|
|
@@ -334,6 +383,20 @@ export interface AsnLocale {
|
|
|
334
383
|
restore: string;
|
|
335
384
|
discard: string;
|
|
336
385
|
};
|
|
386
|
+
slashMenu: {
|
|
387
|
+
noResults: string;
|
|
388
|
+
heading1: string;
|
|
389
|
+
heading2: string;
|
|
390
|
+
heading3: string;
|
|
391
|
+
bulletList: string;
|
|
392
|
+
numberedList: string;
|
|
393
|
+
checklist: string;
|
|
394
|
+
blockquote: string;
|
|
395
|
+
codeBlock: string;
|
|
396
|
+
horizontalRule: string;
|
|
397
|
+
table: string;
|
|
398
|
+
image: string;
|
|
399
|
+
};
|
|
337
400
|
}
|
|
338
401
|
|
|
339
402
|
/** Registry of all built-in locales (keys: 'en', 'vi', 'ja', 'zh', 'fr', 'de', 'es', 'ko'). */
|
|
@@ -387,6 +450,15 @@ export declare class Context {
|
|
|
387
450
|
/** Triggers an editor event. */
|
|
388
451
|
triggerEvent(eventName: string, ...args: unknown[]): void;
|
|
389
452
|
|
|
453
|
+
/** Applies runtime-safe option changes without recreating the editor. */
|
|
454
|
+
updateOptions(overrides: Partial<AsnOptions>): this;
|
|
455
|
+
|
|
456
|
+
/** Flushes any pending auto-save write. */
|
|
457
|
+
flushAutoSave(): Promise<void>;
|
|
458
|
+
|
|
459
|
+
/** Loads a draft through the configured adapter or localStorage. */
|
|
460
|
+
loadAutoSave(): Promise<string | null>;
|
|
461
|
+
|
|
390
462
|
/** Returns the current HTML content of the editor. */
|
|
391
463
|
getHTML(): string;
|
|
392
464
|
|
|
@@ -430,6 +502,15 @@ export declare class Context {
|
|
|
430
502
|
/** Returns the editor content as a Markdown string. */
|
|
431
503
|
getMarkdown(): string;
|
|
432
504
|
|
|
505
|
+
getSelectionBookmark(): { start: number; end: number } | null;
|
|
506
|
+
restoreSelectionBookmark(bookmark: { start: number; end: number }): boolean;
|
|
507
|
+
importDocument(format: string, data: unknown): Promise<this>;
|
|
508
|
+
exportDocument(format: string): Promise<unknown>;
|
|
509
|
+
ensureBlockIds(): this;
|
|
510
|
+
getDocument(): { version: 1; html: string; markdown: string };
|
|
511
|
+
loadDocument(documentData: { html: string }): this;
|
|
512
|
+
applyRemoteHTML(html: string): this;
|
|
513
|
+
|
|
433
514
|
/** Returns the current word count of the editor content. */
|
|
434
515
|
getWordCount(): number;
|
|
435
516
|
|
|
@@ -469,6 +550,7 @@ export declare class Context {
|
|
|
469
550
|
* @param ModuleClass - Class with `initialize()` and optional `destroy()`
|
|
470
551
|
*/
|
|
471
552
|
registerModule(name: string, ModuleClass: new (ctx: Context) => object): this;
|
|
553
|
+
registerSlashCommand(command: SlashCommand): this;
|
|
472
554
|
|
|
473
555
|
/**
|
|
474
556
|
* Installs a plugin on this editor instance.
|
|
@@ -629,6 +711,7 @@ export interface AutumnNoteStatic {
|
|
|
629
711
|
* referenced by string name in toolbar configuration.
|
|
630
712
|
*/
|
|
631
713
|
registerButton(btnDef: ToolbarItemDef): this;
|
|
714
|
+
registerSlashCommand(command: SlashCommand): this;
|
|
632
715
|
|
|
633
716
|
/**
|
|
634
717
|
* All pre-built button definitions in a single namespace.
|