autumnnote 1.15.0 → 2.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 +53 -2
- package/dist/autumnnote.cjs +21 -21
- package/dist/autumnnote.css +1 -1
- package/dist/autumnnote.es.js +1470 -5884
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.min.js +61 -0
- package/dist/autumnnote.umd.js +21 -21
- package/dist/autumnnote.umd.js.map +1 -1
- package/dist/emoji-data-BDQX5kh-.js +2331 -0
- package/dist/emoji-data-BDQX5kh-.js.map +1 -0
- package/package.json +9 -5
- package/src/js/Context.js +216 -17
- package/src/js/editing/History.js +38 -6
- package/src/js/i18n/all.js +27 -0
- 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/index.js +45 -19
- 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 +24 -2
- package/src/js/index.umd.js +5 -0
- package/src/js/module/BaseMediaTooltip.js +142 -0
- package/src/js/module/BaseResizer.js +312 -0
- package/src/js/module/Clipboard.js +20 -6
- package/src/js/module/Editor.js +15 -1
- package/src/js/module/EmojiDialog.js +41 -494
- package/src/js/module/ImageDialog.js +34 -6
- package/src/js/module/ImageResizer.js +23 -241
- package/src/js/module/ImageTooltip.js +16 -111
- 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/module/VideoResizer.js +38 -239
- package/src/js/module/VideoTooltip.js +27 -114
- package/src/js/module/emoji-data.js +496 -0
- package/src/js/settings.js +27 -0
- package/src/styles/autumnnote.scss +49 -0
- package/types/i18n/all.d.ts +14 -0
- package/types/i18n/de.d.ts +4 -0
- package/types/i18n/en.d.ts +4 -0
- package/types/i18n/es.d.ts +4 -0
- package/types/i18n/fr.d.ts +4 -0
- package/types/i18n/ja.d.ts +4 -0
- package/types/i18n/ko.d.ts +4 -0
- package/types/i18n/vi.d.ts +4 -0
- package/types/i18n/zh.d.ts +4 -0
- package/types/index.d.ts +113 -4
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AutumnNote – TypeScript declarations
|
|
3
|
-
* @version
|
|
3
|
+
* @version 2.0.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). */
|
|
@@ -119,8 +154,13 @@ export interface AsnOptions {
|
|
|
119
154
|
focusColor?: string | null;
|
|
120
155
|
/**
|
|
121
156
|
* Display language for the editor UI.
|
|
122
|
-
*
|
|
123
|
-
*
|
|
157
|
+
*
|
|
158
|
+
* `'en'` is built in. Other codes must be registered first — the ESM bundle
|
|
159
|
+
* ships English only, so import the locale from `autumnnote/i18n/<code>` and
|
|
160
|
+
* pass it to {@link registerLocale}. The UMD/CDN build pre-registers all
|
|
161
|
+
* eight ('en', 'vi', 'ja', 'zh', 'fr', 'de', 'es', 'ko').
|
|
162
|
+
*
|
|
163
|
+
* A partial locale object works inline without registering anything.
|
|
124
164
|
*/
|
|
125
165
|
lang?: string | Partial<AsnLocale>;
|
|
126
166
|
|
|
@@ -153,6 +193,20 @@ export interface AsnOptions {
|
|
|
153
193
|
|
|
154
194
|
/** @mention autocomplete configuration. Activated when mention.onSearch is provided. */
|
|
155
195
|
mention?: MentionOptions | null;
|
|
196
|
+
|
|
197
|
+
// ---- Slash command menu ----------------------------------------------------
|
|
198
|
+
|
|
199
|
+
/** Show a "/" command palette for quick block insertion (headings, lists, table, image, ...). Default: true. */
|
|
200
|
+
slashMenu?: boolean;
|
|
201
|
+
/** Application/plugin-provided slash commands. */
|
|
202
|
+
slashCommands?: SlashCommand[];
|
|
203
|
+
/** Import/export adapters keyed by format. */
|
|
204
|
+
documentAdapters?: Record<string, DocumentAdapter>;
|
|
205
|
+
/** Optional external image processor, such as a Web Worker bridge. */
|
|
206
|
+
imageProcessor?: (file: File, helpers: { context: Context }) => string | Promise<string>;
|
|
207
|
+
collaborationAdapter?: CollaborationAdapter | null;
|
|
208
|
+
/** Adds stable IDs to top-level blocks for external collaboration adapters. */
|
|
209
|
+
blockIds?: boolean;
|
|
156
210
|
}
|
|
157
211
|
|
|
158
212
|
// ---------------------------------------------------------------------------
|
|
@@ -334,11 +388,40 @@ export interface AsnLocale {
|
|
|
334
388
|
restore: string;
|
|
335
389
|
discard: string;
|
|
336
390
|
};
|
|
391
|
+
slashMenu: {
|
|
392
|
+
noResults: string;
|
|
393
|
+
heading1: string;
|
|
394
|
+
heading2: string;
|
|
395
|
+
heading3: string;
|
|
396
|
+
bulletList: string;
|
|
397
|
+
numberedList: string;
|
|
398
|
+
checklist: string;
|
|
399
|
+
blockquote: string;
|
|
400
|
+
codeBlock: string;
|
|
401
|
+
horizontalRule: string;
|
|
402
|
+
table: string;
|
|
403
|
+
image: string;
|
|
404
|
+
};
|
|
337
405
|
}
|
|
338
406
|
|
|
339
|
-
/**
|
|
407
|
+
/**
|
|
408
|
+
* Registry of locales selectable by code. The ESM bundle ships `'en'` only;
|
|
409
|
+
* register others with {@link registerLocale}. The UMD/CDN build pre-registers
|
|
410
|
+
* all eight ('en', 'vi', 'ja', 'zh', 'fr', 'de', 'es', 'ko').
|
|
411
|
+
*/
|
|
340
412
|
export declare const locales: Record<string, AsnLocale>;
|
|
341
413
|
|
|
414
|
+
/**
|
|
415
|
+
* Registers a locale so `lang: '<code>'` can select it.
|
|
416
|
+
*
|
|
417
|
+
* ```ts
|
|
418
|
+
* import AutumnNote from 'autumnnote';
|
|
419
|
+
* import { vi } from 'autumnnote/i18n/vi';
|
|
420
|
+
* AutumnNote.registerLocale('vi', vi);
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
export declare function registerLocale(code: string, locale: Partial<AsnLocale>): void;
|
|
424
|
+
|
|
342
425
|
/**
|
|
343
426
|
* Resolves a lang value to a full AsnLocale.
|
|
344
427
|
* - string key → looks up locales registry, deep-merges with 'en' fallback.
|
|
@@ -387,6 +470,15 @@ export declare class Context {
|
|
|
387
470
|
/** Triggers an editor event. */
|
|
388
471
|
triggerEvent(eventName: string, ...args: unknown[]): void;
|
|
389
472
|
|
|
473
|
+
/** Applies runtime-safe option changes without recreating the editor. */
|
|
474
|
+
updateOptions(overrides: Partial<AsnOptions>): this;
|
|
475
|
+
|
|
476
|
+
/** Flushes any pending auto-save write. */
|
|
477
|
+
flushAutoSave(): Promise<void>;
|
|
478
|
+
|
|
479
|
+
/** Loads a draft through the configured adapter or localStorage. */
|
|
480
|
+
loadAutoSave(): Promise<string | null>;
|
|
481
|
+
|
|
390
482
|
/** Returns the current HTML content of the editor. */
|
|
391
483
|
getHTML(): string;
|
|
392
484
|
|
|
@@ -430,6 +522,15 @@ export declare class Context {
|
|
|
430
522
|
/** Returns the editor content as a Markdown string. */
|
|
431
523
|
getMarkdown(): string;
|
|
432
524
|
|
|
525
|
+
getSelectionBookmark(): { start: number; end: number } | null;
|
|
526
|
+
restoreSelectionBookmark(bookmark: { start: number; end: number }): boolean;
|
|
527
|
+
importDocument(format: string, data: unknown): Promise<this>;
|
|
528
|
+
exportDocument(format: string): Promise<unknown>;
|
|
529
|
+
ensureBlockIds(): this;
|
|
530
|
+
getDocument(): { version: 1; html: string; markdown: string };
|
|
531
|
+
loadDocument(documentData: { html: string }): this;
|
|
532
|
+
applyRemoteHTML(html: string): this;
|
|
533
|
+
|
|
433
534
|
/** Returns the current word count of the editor content. */
|
|
434
535
|
getWordCount(): number;
|
|
435
536
|
|
|
@@ -469,6 +570,7 @@ export declare class Context {
|
|
|
469
570
|
* @param ModuleClass - Class with `initialize()` and optional `destroy()`
|
|
470
571
|
*/
|
|
471
572
|
registerModule(name: string, ModuleClass: new (ctx: Context) => object): this;
|
|
573
|
+
registerSlashCommand(command: SlashCommand): this;
|
|
472
574
|
|
|
473
575
|
/**
|
|
474
576
|
* Installs a plugin on this editor instance.
|
|
@@ -629,6 +731,13 @@ export interface AutumnNoteStatic {
|
|
|
629
731
|
* referenced by string name in toolbar configuration.
|
|
630
732
|
*/
|
|
631
733
|
registerButton(btnDef: ToolbarItemDef): this;
|
|
734
|
+
registerSlashCommand(command: SlashCommand): this;
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Registers a locale so `lang: '<code>'` can select it. Only English ships
|
|
738
|
+
* in the ESM bundle; import others from `autumnnote/i18n/<code>`.
|
|
739
|
+
*/
|
|
740
|
+
registerLocale(code: string, locale: Partial<AsnLocale>): this;
|
|
632
741
|
|
|
633
742
|
/**
|
|
634
743
|
* All pre-built button definitions in a single namespace.
|