autumnnote 1.2.1 → 1.4.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 +66 -10
- package/dist/autumnnote.es.js +463 -108
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.umd.js +433 -91
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/js/Context.js +64 -0
- package/src/js/core/dom.js +6 -3
- package/src/js/core/func.js +24 -13
- package/src/js/core/markdown.js +26 -8
- package/src/js/core/sanitise.js +57 -46
- package/src/js/editing/History.js +12 -1
- package/src/js/editing/Style.js +49 -21
- package/src/js/editing/Table.js +53 -13
- package/src/js/editing/Typing.js +9 -2
- package/src/js/i18n/de.js +1 -0
- package/src/js/i18n/en.js +1 -0
- package/src/js/i18n/es.js +1 -0
- package/src/js/i18n/fr.js +1 -0
- package/src/js/i18n/ja.js +1 -0
- package/src/js/i18n/ko.js +1 -0
- package/src/js/i18n/vi.js +1 -0
- package/src/js/i18n/zh.js +1 -0
- package/src/js/index.js +42 -2
- package/src/js/module/BubbleToolbar.js +26 -7
- package/src/js/module/Buttons.js +37 -0
- package/src/js/module/Clipboard.js +2 -2
- package/src/js/module/ContextMenu.js +1 -1
- package/src/js/module/FindReplace.js +6 -5
- package/src/js/module/ImageCropOverlay.js +46 -8
- package/src/js/module/ImageResizer.js +7 -0
- package/src/js/module/Mention.js +18 -4
- package/src/js/module/Statusbar.js +2 -1
- package/src/js/module/Toolbar.js +47 -2
- package/types/index.d.ts +54 -1
package/types/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface AsnOptions {
|
|
|
21
21
|
/** Show the resize handle in the statusbar. */
|
|
22
22
|
resizable?: boolean;
|
|
23
23
|
/** Toolbar button group configuration. */
|
|
24
|
-
toolbar?: Array<Array<ToolbarItemDef>>;
|
|
24
|
+
toolbar?: Array<Array<ToolbarItemDef | string>>;
|
|
25
25
|
/** Use Bootstrap button classes on toolbar buttons. */
|
|
26
26
|
useBootstrap?: boolean;
|
|
27
27
|
/** CSS class(es) applied to Bootstrap toolbar buttons. */
|
|
@@ -234,6 +234,31 @@ export interface DropdownDef {
|
|
|
234
234
|
|
|
235
235
|
export type ToolbarItemDef = ButtonDef | DropdownDef | GridButtonDef | ColorPickerDef;
|
|
236
236
|
|
|
237
|
+
// ---------------------------------------------------------------------------
|
|
238
|
+
// Plugin API
|
|
239
|
+
// ---------------------------------------------------------------------------
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Plugin descriptor passed to `AutumnNote.use()` or `context.use()`.
|
|
243
|
+
* `T` is the shape of the public API returned by `install()`, accessible
|
|
244
|
+
* via `context.getPlugin<T>(name)`.
|
|
245
|
+
*/
|
|
246
|
+
export interface AsnPlugin<T = unknown> {
|
|
247
|
+
/** Unique plugin identifier. */
|
|
248
|
+
name: string;
|
|
249
|
+
/** Semantic version string (informational only). */
|
|
250
|
+
version?: string;
|
|
251
|
+
/** Button definitions to register in the global button registry. */
|
|
252
|
+
buttons?: ToolbarItemDef[];
|
|
253
|
+
/**
|
|
254
|
+
* Called after all built-in modules have initialised.
|
|
255
|
+
* Return an object to expose it as the plugin's public API.
|
|
256
|
+
*/
|
|
257
|
+
install?: (context: Context, options: Record<string, unknown>) => T | null | void;
|
|
258
|
+
/** Called when the editor instance is destroyed. */
|
|
259
|
+
uninstall?: (context: Context) => void;
|
|
260
|
+
}
|
|
261
|
+
|
|
237
262
|
// ---------------------------------------------------------------------------
|
|
238
263
|
// Entry-point re-exports
|
|
239
264
|
// ---------------------------------------------------------------------------
|
|
@@ -394,6 +419,18 @@ export declare class Context {
|
|
|
394
419
|
*/
|
|
395
420
|
registerModule(name: string, ModuleClass: new (ctx: Context) => object): this;
|
|
396
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Installs a plugin on this editor instance.
|
|
424
|
+
* If called after create(), call `ctx.invoke('toolbar.rebuild')` to render new buttons.
|
|
425
|
+
*/
|
|
426
|
+
use<T = unknown>(plugin: AsnPlugin<T>, options?: Record<string, unknown>): this;
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Returns the public API returned by `plugin.install()`, or null.
|
|
430
|
+
* Cast to your plugin's return type: `ctx.getPlugin<MyPluginApi>('my-plugin')`.
|
|
431
|
+
*/
|
|
432
|
+
getPlugin<T = unknown>(name: string): T | null;
|
|
433
|
+
|
|
397
434
|
/** Completely removes the editor and restores the original element. */
|
|
398
435
|
destroy(): void;
|
|
399
436
|
}
|
|
@@ -476,6 +513,22 @@ export interface AutumnNoteStatic {
|
|
|
476
513
|
*/
|
|
477
514
|
registerModule(name: string, ModuleClass: new (ctx: Context) => object): void;
|
|
478
515
|
|
|
516
|
+
/**
|
|
517
|
+
* Installs a plugin globally — applied to every future editor instance.
|
|
518
|
+
* Plugin `buttons` are registered immediately so Toolbar can resolve them by name.
|
|
519
|
+
* Plugin `install()` is called after all built-in modules have initialised.
|
|
520
|
+
*/
|
|
521
|
+
use<T = unknown>(plugin: AsnPlugin<T>, options?: Record<string, unknown>): this;
|
|
522
|
+
|
|
523
|
+
/** Returns true if a plugin with the given name has been registered globally. */
|
|
524
|
+
hasPlugin(name: string): boolean;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Registers a single button in the global button registry so it can be
|
|
528
|
+
* referenced by string name in toolbar configuration.
|
|
529
|
+
*/
|
|
530
|
+
registerButton(btnDef: ToolbarItemDef): this;
|
|
531
|
+
|
|
479
532
|
/** Library version string. */
|
|
480
533
|
readonly version: string;
|
|
481
534
|
}
|