autumnnote 1.6.7 → 1.8.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.
@@ -108,6 +108,12 @@
108
108
  user-select: none;
109
109
  // Round the top corners to match the container border-radius
110
110
  border-radius: $an-radius $an-radius 0 0;
111
+ overflow-x: auto;
112
+ scrollbar-width: none;
113
+
114
+ &::-webkit-scrollbar {
115
+ display: none;
116
+ }
111
117
  }
112
118
 
113
119
  .an-btn-group {
@@ -477,6 +483,26 @@
477
483
  padding: 0;
478
484
  }
479
485
  }
486
+
487
+ // Code block line numbers (toggled via CodeTooltip)
488
+ .an-code-line-numbers {
489
+ position: relative;
490
+ padding-left: 3.5em !important;
491
+
492
+ &::before {
493
+ content: '';
494
+ position: absolute;
495
+ left: 0;
496
+ top: 0;
497
+ bottom: 0;
498
+ width: 3em;
499
+ background: rgba(0, 0, 0, 0.04);
500
+ border-right: 1px solid rgba(0, 0, 0, 0.1);
501
+ pointer-events: none;
502
+ z-index: 0;
503
+ }
504
+ }
505
+
480
506
  a { color: $an-primary; }
481
507
  hr { border: none; border-top: 2px solid $an-border; margin: 1em 0; }
482
508
  img.an-image {
@@ -1938,6 +1964,11 @@ $an-video-accent: #8b5cf6; // violet-500
1938
1964
  color: #cdd6f4;
1939
1965
  }
1940
1966
 
1967
+ .an-code-line-numbers::before {
1968
+ background: rgba(255, 255, 255, 0.05);
1969
+ border-right-color: rgba(255, 255, 255, 0.1);
1970
+ }
1971
+
1941
1972
  hr { border-color: #3f3f5f; }
1942
1973
 
1943
1974
  table, .an-table {
@@ -2328,6 +2359,156 @@ $an-video-accent: #8b5cf6; // violet-500
2328
2359
  color: $an-dark-muted;
2329
2360
  }
2330
2361
 
2362
+ // =============================================================================
2363
+ // Auto theme — mirrors dark theme when OS prefers dark and no explicit theme set
2364
+ // =============================================================================
2365
+
2366
+ @media (prefers-color-scheme: dark) {
2367
+ .an-theme-auto {
2368
+ border-color: #3f3f5f;
2369
+ background: #1e1e2e;
2370
+ color: #cdd6f4;
2371
+
2372
+ &.an-focused {
2373
+ border-color: #89b4fa;
2374
+ box-shadow: 0 0 0 3px rgba(#89b4fa, 0.2);
2375
+ }
2376
+
2377
+ .an-toolbar {
2378
+ background: #181825;
2379
+ border-color: #3f3f5f;
2380
+ }
2381
+
2382
+ .an-btn {
2383
+ color: #cdd6f4;
2384
+
2385
+ &:hover {
2386
+ background: #2a2a3e;
2387
+ border-color: #3f3f5f;
2388
+ color: #cdd6f4;
2389
+
2390
+ svg { stroke: #cdd6f4; }
2391
+ }
2392
+
2393
+ &.active {
2394
+ background: #1a3a5c;
2395
+ border-color: #89b4fa;
2396
+ color: #89b4fa;
2397
+
2398
+ svg { stroke: #89b4fa; }
2399
+ }
2400
+
2401
+ &.an-btn-primary {
2402
+ background: #3b5bdb;
2403
+ border-color: #3b5bdb;
2404
+ color: #fff;
2405
+ }
2406
+ }
2407
+
2408
+ .an-select {
2409
+ background-color: #1e1e2e;
2410
+ border-color: #3f3f5f;
2411
+ color: #cdd6f4;
2412
+
2413
+ &:hover, &:focus { border-color: #89b4fa; }
2414
+ }
2415
+
2416
+ .an-editable {
2417
+ background: #1e1e2e;
2418
+ color: #cdd6f4;
2419
+
2420
+ a { color: #89b4fa; }
2421
+
2422
+ blockquote {
2423
+ border-color: #3f3f5f;
2424
+ color: #a6adc8;
2425
+ }
2426
+
2427
+ pre:not([class*='language-']),
2428
+ code:not([class*='language-']) {
2429
+ background: #313244;
2430
+ color: #cdd6f4;
2431
+ }
2432
+
2433
+ hr { border-color: #3f3f5f; }
2434
+
2435
+ table, .an-table {
2436
+ td, th { border-color: #3f3f5f; }
2437
+ th { background: #313244; }
2438
+ }
2439
+
2440
+ &.an-placeholder::before { color: #6c7086; }
2441
+
2442
+ figcaption.an-figcaption { color: #6c7086; }
2443
+ }
2444
+
2445
+ .an-statusbar {
2446
+ background: #181825;
2447
+ border-color: #3f3f5f;
2448
+ color: #6c7086;
2449
+ }
2450
+
2451
+ .an-link-tooltip,
2452
+ .an-contextmenu {
2453
+ background: #24273a;
2454
+ border-color: #3f3f5f;
2455
+ color: #cdd6f4;
2456
+ }
2457
+
2458
+ .an-link-tooltip-url { color: #89b4fa; }
2459
+
2460
+ .an-link-tooltip-btn {
2461
+ color: #a6adc8;
2462
+
2463
+ &:hover {
2464
+ background: #2a2a3e;
2465
+ color: #cdd6f4;
2466
+ }
2467
+ }
2468
+
2469
+ .an-dialog-overlay { background: rgba(0, 0, 0, 0.65); }
2470
+
2471
+ .an-dialog-box {
2472
+ background: #24273a;
2473
+ color: #cdd6f4;
2474
+ border: 1px solid #3f3f5f;
2475
+ }
2476
+
2477
+ .an-dialog-title { color: #cdd6f4; }
2478
+
2479
+ .an-input {
2480
+ background: #313244;
2481
+ border-color: #3f3f5f;
2482
+ color: #cdd6f4;
2483
+
2484
+ &:focus {
2485
+ border-color: #89b4fa;
2486
+ box-shadow: 0 0 0 3px rgba(#89b4fa, 0.15);
2487
+ }
2488
+ }
2489
+
2490
+ .an-color-popup,
2491
+ .an-table-picker-popup,
2492
+ .an-size-popover,
2493
+ .an-cell-shade-popover {
2494
+ background: #24273a;
2495
+ border-color: #3f3f5f;
2496
+ color: #cdd6f4;
2497
+ }
2498
+
2499
+ .an-context-color-swatch {
2500
+ border-color: rgba(255, 255, 255, 0.15);
2501
+ &:hover { border-color: rgba(255, 255, 255, 0.5); }
2502
+ }
2503
+
2504
+ .an-label { color: #cdd6f4; }
2505
+ }
2506
+
2507
+ .an-theme-auto .an-editable ul.an-checklist li:has(input[type='checkbox']:checked) {
2508
+ color: $an-dark-muted;
2509
+ }
2510
+ }
2511
+
2331
2512
  // =============================================================================
2332
2513
  // Print styles
2333
2514
  // =============================================================================
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * AutumnNote – TypeScript declarations
3
- * @version 1.0.9
3
+ * @version 1.8.0
4
4
  */
5
5
 
6
6
  // ---------------------------------------------------------------------------
@@ -67,7 +67,7 @@ export interface AsnOptions {
67
67
  /** Top offset in px for sticky toolbar (e.g. height of a fixed nav bar). */
68
68
  stickyToolbarOffset?: number;
69
69
  /** Colour theme: 'light' (default) | 'dark'. */
70
- theme?: 'light' | 'dark';
70
+ theme?: 'light' | 'dark' | 'auto';
71
71
  /** Auto-load Prism.js for syntax highlighting inside code blocks. */
72
72
  codeHighlight?: boolean;
73
73
  /** CDN base URL for Prism assets. */
@@ -119,6 +119,10 @@ export interface AsnOptions {
119
119
  autoSaveRestoreTimeout?: number;
120
120
  /** Callback fired after the user chooses to restore a draft. */
121
121
  onAutoSaveRestore?: (html: string, context: Context) => void;
122
+ /** Maximum paste size in MB before paste is silently dropped (0 = unlimited). Default: 5. */
123
+ maxPasteSize?: number;
124
+ /** Minimum image dimension in px during resize (width and height). Default: 20. */
125
+ minImageSize?: number;
122
126
 
123
127
  // ---- Markdown input shortcuts (#3) ----------------------------------------
124
128
 
@@ -158,8 +162,15 @@ export interface MentionOptions {
158
162
  maxResults?: number;
159
163
  /** Debounce delay in ms before calling onSearch. Default: 200. */
160
164
  debounce?: number;
161
- /** Required. Called with (query, callback) to fetch matching items. */
162
- onSearch: (query: string, callback: (items: MentionItem[]) => void) => void;
165
+ /**
166
+ * Called to fetch matching items for the given query.
167
+ * Supports both callback and Promise styles:
168
+ * - Callback: `onSearch(query, callback) { callback(items); }`
169
+ * - Promise: `async onSearch(query) { return items; }`
170
+ */
171
+ onSearch: (query: string, callback: (items: MentionItem[]) => void) => void | Promise<MentionItem[]>;
172
+ /** Called when onSearch rejects with an error (Promise style only). */
173
+ onError?: (error: unknown) => void;
163
174
  /** Optional. Return custom HTML string for the inserted chip, or null to use the default. */
164
175
  onInsert?: (item: MentionItem) => string | null;
165
176
  /** CSS class added to the inserted mention chip. Default: 'an-mention'. */
@@ -304,6 +315,12 @@ export interface AsnLocale {
304
315
  imageFormat: (type: string) => string;
305
316
  imageSize: (maxMb: number) => string;
306
317
  };
318
+ autoSaveRestore: {
319
+ found: string;
320
+ foundAt: string;
321
+ restore: string;
322
+ discard: string;
323
+ };
307
324
  }
308
325
 
309
326
  /** Registry of all built-in locales (keys: 'en', 'vi', 'ja', 'zh', 'fr'). */
@@ -379,6 +396,12 @@ export declare class Context {
379
396
  */
380
397
  clearHistory(): void;
381
398
 
399
+ /** Returns the number of available undo steps. */
400
+ getUndoCount(): number;
401
+
402
+ /** Returns the number of available redo steps. */
403
+ getRedoCount(): number;
404
+
382
405
  /** Returns true when the editor has no meaningful content. */
383
406
  isEmpty(): boolean;
384
407
 
@@ -400,6 +423,9 @@ export declare class Context {
400
423
  /** Returns the current character count (excluding newlines) of the editor content. */
401
424
  getCharCount(): number;
402
425
 
426
+ /** Returns an array of heading objects representing the table of contents. */
427
+ getTableOfContents(): { level: number; text: string; element: HTMLElement }[];
428
+
403
429
  /** Downloads the editor content as an HTML file. */
404
430
  downloadHTML(filename?: string): void;
405
431
 
@@ -409,6 +435,18 @@ export declare class Context {
409
435
  /** Downloads the editor content as a Markdown file. */
410
436
  downloadMarkdown(filename?: string): void;
411
437
 
438
+ /** Moves keyboard focus into the editable area. */
439
+ focus(): void;
440
+
441
+ /** Removes keyboard focus from the editable area. */
442
+ blur(): void;
443
+
444
+ /** Returns true when the editor is currently in fullscreen mode. */
445
+ isFullscreen(): boolean;
446
+
447
+ /** Opens a print dialog with the editor content. */
448
+ print(title?: string): void;
449
+
412
450
  /** Enables or disables (read-only) mode on this instance. */
413
451
  setDisabled(disabled: boolean): void;
414
452
 
@@ -480,6 +518,56 @@ export declare const foreColorBtn: ColorPickerDef;
480
518
  export declare const backColorBtn: ColorPickerDef;
481
519
  export declare const defaultToolbar: Array<Array<ToolbarItemDef>>;
482
520
 
521
+ /**
522
+ * All pre-built button definitions grouped in a single namespace object.
523
+ * Use this to access individual buttons in UMD / CJS environments where
524
+ * named imports are not available: `AutumnNote.buttons.boldBtn`.
525
+ */
526
+ export interface ButtonsNamespace {
527
+ boldBtn: ButtonDef;
528
+ italicBtn: ButtonDef;
529
+ underlineBtn: ButtonDef;
530
+ strikeBtn: ButtonDef;
531
+ superscriptBtn: ButtonDef;
532
+ subscriptBtn: ButtonDef;
533
+ alignLeftBtn: ButtonDef;
534
+ alignCenterBtn: ButtonDef;
535
+ alignRightBtn: ButtonDef;
536
+ alignJustifyBtn: ButtonDef;
537
+ ulBtn: ButtonDef;
538
+ olBtn: ButtonDef;
539
+ indentBtn: ButtonDef;
540
+ outdentBtn: ButtonDef;
541
+ undoBtn: ButtonDef;
542
+ redoBtn: ButtonDef;
543
+ hrBtn: ButtonDef;
544
+ linkBtn: ButtonDef;
545
+ imageBtn: ButtonDef;
546
+ videoBtn: ButtonDef;
547
+ emojiBtn: ButtonDef;
548
+ iconBtn: ButtonDef;
549
+ tableBtn: GridButtonDef;
550
+ fontSizeBtn: DropdownDef;
551
+ removeFormatBtn: ButtonDef;
552
+ directionBtn: ButtonDef;
553
+ fontFamilyBtn: DropdownDef;
554
+ paragraphStyleBtn: DropdownDef;
555
+ lineHeightBtn: DropdownDef;
556
+ codeviewBtn: ButtonDef;
557
+ fullscreenBtn: ButtonDef;
558
+ shortcutsBtn: ButtonDef;
559
+ findBtn: ButtonDef;
560
+ findReplaceBtn: ButtonDef;
561
+ inlineCodeBtn: ButtonDef;
562
+ checklistBtn: ButtonDef;
563
+ printBtn: ButtonDef;
564
+ foreColorBtn: ColorPickerDef;
565
+ backColorBtn: ColorPickerDef;
566
+ defaultToolbar: Array<Array<ToolbarItemDef>>;
567
+ }
568
+
569
+ export declare const buttons: ButtonsNamespace;
570
+
483
571
  // ---------------------------------------------------------------------------
484
572
  // Main AutumnNote API
485
573
  // ---------------------------------------------------------------------------
@@ -529,6 +617,13 @@ export interface AutumnNoteStatic {
529
617
  */
530
618
  registerButton(btnDef: ToolbarItemDef): this;
531
619
 
620
+ /**
621
+ * All pre-built button definitions in a single namespace.
622
+ * Use in UMD / CJS builds where named imports are unavailable:
623
+ * `AutumnNote.buttons.boldBtn`, `AutumnNote.buttons.defaultToolbar`, etc.
624
+ */
625
+ readonly buttons: ButtonsNamespace;
626
+
532
627
  /** Library version string. */
533
628
  readonly version: string;
534
629
  }