autumnnote 1.5.0 → 1.6.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.
Files changed (46) hide show
  1. package/README.md +6 -4
  2. package/dist/autumnnote.css +324 -2
  3. package/dist/autumnnote.es.js +638 -227
  4. package/dist/autumnnote.es.js.map +1 -1
  5. package/dist/autumnnote.umd.js +637 -226
  6. package/dist/autumnnote.umd.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/js/Context.js +8 -3
  9. package/src/js/core/detectLang.js +98 -0
  10. package/src/js/core/dom.js +62 -6
  11. package/src/js/core/markdown.js +14 -13
  12. package/src/js/core/range.js +2 -2
  13. package/src/js/editing/History.js +6 -6
  14. package/src/js/editing/Style.js +19 -19
  15. package/src/js/editing/Table.js +4 -6
  16. package/src/js/editing/Typing.js +6 -6
  17. package/src/js/i18n/en.js +2 -0
  18. package/src/js/i18n/vi.js +2 -0
  19. package/src/js/index.js +3 -2
  20. package/src/js/module/BubbleToolbar.js +30 -13
  21. package/src/js/module/Buttons.js +16 -14
  22. package/src/js/module/Clipboard.js +5 -5
  23. package/src/js/module/CodeTooltip.js +42 -16
  24. package/src/js/module/Codeview.js +2 -2
  25. package/src/js/module/ContextMenu.js +12 -12
  26. package/src/js/module/Editor.js +64 -12
  27. package/src/js/module/EmojiDialog.js +19 -13
  28. package/src/js/module/FindReplace.js +85 -59
  29. package/src/js/module/Fullscreen.js +1 -1
  30. package/src/js/module/IconDialog.js +26 -20
  31. package/src/js/module/ImageCropOverlay.js +6 -6
  32. package/src/js/module/ImageDialog.js +18 -12
  33. package/src/js/module/ImageResizer.js +1 -1
  34. package/src/js/module/ImageTooltip.js +8 -4
  35. package/src/js/module/LinkDialog.js +18 -12
  36. package/src/js/module/LinkTooltip.js +5 -2
  37. package/src/js/module/Mention.js +3 -3
  38. package/src/js/module/Statusbar.js +2 -2
  39. package/src/js/module/TableTooltip.js +180 -18
  40. package/src/js/module/Toolbar.js +16 -15
  41. package/src/js/module/VideoDialog.js +8 -2
  42. package/src/js/module/VideoResizer.js +3 -3
  43. package/src/js/module/VideoTooltip.js +11 -6
  44. package/src/js/renderer.js +4 -2
  45. package/src/js/settings.js +53 -36
  46. package/src/styles/autumnnote.scss +332 -4
package/README.md CHANGED
@@ -67,7 +67,8 @@ A modern WYSIWYG rich-text editor built with vanilla JavaScript (ES2022+) — no
67
67
  - **FA Icon picker** — FontAwesome 6 Free Solid icons across 8 categories; keyword search; configurable style, size, and colour; inserts as `<i>` element; auto-injects FA CDN if not on the page
68
68
 
69
69
  ### Search
70
- - **Find and Replace** — `Ctrl+F` to find, `Ctrl+H` for find-and-replace; TreeWalker text matching; `<mark>` highlighting; case-sensitive toggle; Prev/Next navigation; single and replace-all modes
70
+ - **Find and Replace** — `Ctrl+F` to find, `Ctrl+H` for find-and-replace; compact non-blocking floating panel (top-right); TreeWalker text matching; `<mark>` highlighting; case-sensitive `Aa` toggle; icon-button Prev/Next navigation (↑ ↓); single and replace-all modes
71
+ - **Auto language detection** — when selected text is formatted as a code block the editor automatically analyses the content and applies Prism.js syntax highlighting; 20 languages detected: JavaScript, TypeScript, Python, HTML, CSS, SCSS, JSON, SQL, Bash, Java, C#, PHP, Ruby, Go, Rust, C++, C, Kotlin, Swift, XML
71
72
 
72
73
  ### Inline tooltips
73
74
  Floating toolbars appear automatically when the user clicks on an editable element:
@@ -77,8 +78,8 @@ Floating toolbars appear automatically when the user clicks on an editable eleme
77
78
  | **Link** | Open in new tab, Edit (reopens dialog), Unlink |
78
79
  | **Image** | Edit alt/URL (reopens dialog), Crop, Delete |
79
80
  | **Video** | Edit (reopens dialog), Delete |
80
- | **Table cell** | Row above/below, Delete row, Column left/right, Delete column, Merge cells, Unmerge cells, Cell selection mode, Column width, Row height, Border width, Delete table |
81
- | **Code block** | Copy code, Delete block |
81
+ | **Table cell** | Row above/below, Delete row, Column left/right, Delete column, Merge cells, Unmerge cells, Cell selection mode, Column width, Row height, Border width, **Cell background colour**, Delete table |
82
+ | **Code block** | Copy code, Language selector (20 languages + SCSS), Delete block |
82
83
 
83
84
  ### Context menu
84
85
  Right-click inside the editor opens a context menu with: **Undo**, **Redo**, **Cut**, **Copy**, **Paste**, **Bold**, **Italic**, **Underline**, **Copy Format**, **Paste Format**, **Remove Format**, and a **colour palette** for quick text/highlight colour changes.
@@ -92,7 +93,8 @@ Right-click inside the editor opens a context menu with: **Undo**, **Redo**, **C
92
93
  ### UI
93
94
  - **Toolbar** — fully configurable button groups; overflow strategy: `wrap` (default) or `scroll`; on viewports ≤ 640 px the toolbar automatically switches to a single horizontally-scrollable row regardless of the `toolbarOverflow` setting; FontAwesome icons with built-in SVG fallback
94
95
  - **Sticky toolbar** — `stickyToolbar: true` pins the toolbar to the viewport top; configurable offset for fixed nav bars
95
- - **Dark / light theme** — `theme: 'dark'` or `theme: 'light'` (default); full SCSS variable coverage
96
+ - **Dark / light theme** — `theme: 'dark'` or `theme: 'light'` (default); full SCSS variable coverage; dark styles propagate to all floating elements (dialogs, tooltips, colour pickers)
97
+ - **Draggable dialogs** — all dialogs (Link, Image, Video, Emoji, Icon, Find & Replace) can be repositioned by dragging their title bar; position is clamped to the viewport
96
98
  - **Image resizer** — drag handle on selected image to resize proportionally
97
99
  - **Video resizer** — drag handle on selected video embed to resize
98
100
  - **Statusbar** — live word and character count; drag handle to resize editor height; limit warnings when `maxChars` or `maxWords` is reached
@@ -560,6 +560,30 @@
560
560
  letter-spacing: 0.02em;
561
561
  }
562
562
 
563
+ .an-link-tooltip-btn--shade {
564
+ flex-direction: column;
565
+ gap: 1px;
566
+ padding: 4px 0 3px;
567
+ height: auto;
568
+ }
569
+ .an-link-tooltip-btn--shade .an-bubble-btn-svg {
570
+ display: flex;
571
+ align-items: center;
572
+ justify-content: center;
573
+ line-height: 0;
574
+ }
575
+ .an-link-tooltip-btn--shade .an-bubble-btn-svg svg {
576
+ display: block;
577
+ }
578
+ .an-link-tooltip-btn--shade .an-link-tooltip-color-strip {
579
+ display: block;
580
+ width: 13px;
581
+ height: 3px;
582
+ border-radius: 1px;
583
+ pointer-events: none;
584
+ background: transparent;
585
+ }
586
+
563
587
  .an-link-tooltip-btn--active {
564
588
  background: rgba(59, 130, 246, 0.12) !important;
565
589
  color: #3b82f6 !important;
@@ -626,6 +650,51 @@
626
650
  gap: 6px;
627
651
  }
628
652
 
653
+ .an-cell-shade-popover {
654
+ position: fixed;
655
+ z-index: 1200;
656
+ background: #ffffff;
657
+ border: 1px solid #d1d5db;
658
+ border-radius: 8px;
659
+ padding: 10px 10px 6px;
660
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
661
+ min-width: 166px;
662
+ }
663
+ .an-cell-shade-popover .an-size-popover-title {
664
+ font-size: 11px;
665
+ font-weight: 600;
666
+ color: #6b7280;
667
+ text-transform: uppercase;
668
+ letter-spacing: 0.5px;
669
+ margin-bottom: 8px;
670
+ }
671
+ .an-cell-shade-popover .an-shade-no-color {
672
+ display: inline-flex;
673
+ align-items: center;
674
+ gap: 4px;
675
+ padding: 3px 8px;
676
+ font-size: 12px;
677
+ color: #6b7280;
678
+ background: transparent;
679
+ border: 1px solid #d1d5db;
680
+ border-radius: 4px;
681
+ cursor: pointer;
682
+ font-family: inherit;
683
+ }
684
+ .an-cell-shade-popover .an-shade-no-color:hover {
685
+ background: #f3f4f6;
686
+ color: #111827;
687
+ }
688
+ .an-cell-shade-popover .an-shade-color-input {
689
+ width: 24px;
690
+ height: 24px;
691
+ padding: 0;
692
+ border: 1px solid #d1d5db;
693
+ border-radius: 4px;
694
+ cursor: pointer;
695
+ background: transparent;
696
+ }
697
+
629
698
  .an-codeview {
630
699
  flex: 1;
631
700
  width: 100%;
@@ -698,8 +767,31 @@
698
767
  gap: 10px;
699
768
  }
700
769
 
770
+ .an-dialog-header {
771
+ display: flex;
772
+ align-items: center;
773
+ gap: 12px;
774
+ margin-bottom: 4px;
775
+ }
776
+
777
+ .an-dialog-icon {
778
+ display: flex;
779
+ align-items: center;
780
+ justify-content: center;
781
+ width: 38px;
782
+ height: 38px;
783
+ flex-shrink: 0;
784
+ border-radius: 10px;
785
+ background: rgba(59, 130, 246, 0.1);
786
+ color: #3b82f6;
787
+ }
788
+ .an-dialog-icon svg {
789
+ display: block;
790
+ stroke: currentColor;
791
+ }
792
+
701
793
  .an-dialog-title {
702
- margin: 0 0 4px;
794
+ margin: 0;
703
795
  font-size: 16px;
704
796
  font-weight: 600;
705
797
  color: #111827;
@@ -750,6 +842,102 @@
750
842
  cursor: pointer;
751
843
  }
752
844
 
845
+ .an-fr-dialog {
846
+ background: transparent;
847
+ pointer-events: none;
848
+ align-items: flex-start;
849
+ justify-content: flex-end;
850
+ padding: 56px 16px 0 0;
851
+ }
852
+ .an-fr-dialog .an-fr-box {
853
+ pointer-events: auto;
854
+ width: 360px;
855
+ padding: 14px 16px 16px;
856
+ gap: 8px;
857
+ }
858
+
859
+ .an-fr-header {
860
+ display: flex;
861
+ align-items: center;
862
+ justify-content: space-between;
863
+ margin-bottom: 2px;
864
+ }
865
+ .an-fr-header .an-dialog-title {
866
+ margin: 0;
867
+ font-size: 14px;
868
+ }
869
+
870
+ .an-fr-search-bar {
871
+ display: flex;
872
+ align-items: center;
873
+ gap: 4px;
874
+ }
875
+ .an-fr-search-bar .an-fr-input {
876
+ flex: 1;
877
+ min-width: 0;
878
+ padding: 6px 8px;
879
+ font-size: 13px;
880
+ }
881
+
882
+ .an-fr-replace-row {
883
+ display: flex;
884
+ align-items: center;
885
+ gap: 6px;
886
+ }
887
+ .an-fr-replace-row .an-fr-input {
888
+ flex: 1;
889
+ min-width: 0;
890
+ padding: 6px 8px;
891
+ font-size: 13px;
892
+ }
893
+ .an-fr-replace-row .an-fr-replace-btn {
894
+ flex-shrink: 0;
895
+ padding: 5px 10px;
896
+ font-size: 12px;
897
+ white-space: nowrap;
898
+ }
899
+
900
+ .an-fr-icon-btn {
901
+ display: flex;
902
+ align-items: center;
903
+ justify-content: center;
904
+ flex-shrink: 0;
905
+ width: 28px;
906
+ height: 28px;
907
+ padding: 0;
908
+ font-size: 12px;
909
+ font-weight: 600;
910
+ font-family: inherit;
911
+ border: 1px solid transparent;
912
+ border-radius: 4px;
913
+ background: transparent;
914
+ color: #6b7280;
915
+ cursor: pointer;
916
+ }
917
+ .an-fr-icon-btn svg {
918
+ display: block;
919
+ stroke: currentColor;
920
+ }
921
+ .an-fr-icon-btn:hover {
922
+ background: #f3f4f6;
923
+ color: #111827;
924
+ border-color: #d1d5db;
925
+ }
926
+ .an-fr-icon-btn.an-fr-icon-btn--active {
927
+ background: rgba(59, 130, 246, 0.1);
928
+ color: #3b82f6;
929
+ border-color: rgba(59, 130, 246, 0.3);
930
+ }
931
+
932
+ .an-fr-counter {
933
+ font-size: 11px;
934
+ color: #6b7280;
935
+ white-space: nowrap;
936
+ min-width: 36px;
937
+ text-align: right;
938
+ flex-shrink: 0;
939
+ }
940
+
753
941
  .an-input {
754
942
  width: 100%;
755
943
  padding: 7px 10px;
@@ -1127,6 +1315,28 @@
1127
1315
  margin: 0;
1128
1316
  }
1129
1317
 
1318
+ .an-dialog-title-group {
1319
+ display: flex;
1320
+ align-items: center;
1321
+ gap: 10px;
1322
+ }
1323
+
1324
+ .an-dialog-icon--sm {
1325
+ width: 32px;
1326
+ height: 32px;
1327
+ border-radius: 8px;
1328
+ background: rgba(59, 130, 246, 0.1);
1329
+ color: #3b82f6;
1330
+ display: flex;
1331
+ align-items: center;
1332
+ justify-content: center;
1333
+ flex-shrink: 0;
1334
+ }
1335
+ .an-dialog-icon--sm svg {
1336
+ display: block;
1337
+ stroke: currentColor;
1338
+ }
1339
+
1130
1340
  .an-icon-close {
1131
1341
  display: flex;
1132
1342
  align-items: center;
@@ -1608,6 +1818,27 @@
1608
1818
  .an-theme-dark .an-dialog-title {
1609
1819
  color: #cdd6f4;
1610
1820
  }
1821
+ .an-theme-dark .an-dialog-icon,
1822
+ .an-theme-dark .an-dialog-icon--sm {
1823
+ background: rgba(129, 140, 248, 0.15);
1824
+ color: #818cf8;
1825
+ }
1826
+ .an-theme-dark .an-fr-icon-btn {
1827
+ color: #a6adc8;
1828
+ }
1829
+ .an-theme-dark .an-fr-icon-btn:hover {
1830
+ background: #313244;
1831
+ color: #cdd6f4;
1832
+ border-color: #45475a;
1833
+ }
1834
+ .an-theme-dark .an-fr-icon-btn.an-fr-icon-btn--active {
1835
+ background: rgba(129, 140, 248, 0.15);
1836
+ color: #818cf8;
1837
+ border-color: rgba(129, 140, 248, 0.3);
1838
+ }
1839
+ .an-theme-dark .an-fr-counter {
1840
+ color: #6c7086;
1841
+ }
1611
1842
  .an-theme-dark .an-label {
1612
1843
  color: #cdd6f4;
1613
1844
  }
@@ -1642,11 +1873,20 @@
1642
1873
  }
1643
1874
  .an-theme-dark .an-color-popup,
1644
1875
  .an-theme-dark .an-table-picker-popup,
1645
- .an-theme-dark .an-size-popover {
1876
+ .an-theme-dark .an-size-popover,
1877
+ .an-theme-dark .an-cell-shade-popover {
1646
1878
  background: #24273a;
1647
1879
  border-color: #3f3f5f;
1648
1880
  color: #cdd6f4;
1649
1881
  }
1882
+ .an-theme-dark .an-cell-shade-popover .an-shade-no-color {
1883
+ border-color: #3f3f5f;
1884
+ color: #a6adc8;
1885
+ }
1886
+ .an-theme-dark .an-cell-shade-popover .an-shade-no-color:hover {
1887
+ background: #313244;
1888
+ color: #cdd6f4;
1889
+ }
1650
1890
  .an-theme-dark .an-link-tooltip-btn--active {
1651
1891
  background: rgba(99, 102, 241, 0.2) !important;
1652
1892
  color: #818cf8 !important;
@@ -1666,6 +1906,19 @@
1666
1906
  background: rgba(99, 102, 241, 0.3);
1667
1907
  border-color: #6366f1;
1668
1908
  }
1909
+ .an-theme-dark .an-color-custom {
1910
+ border-top-color: #3f3f5f;
1911
+ color: #cdd6f4;
1912
+ }
1913
+ .an-theme-dark .an-color-arrow:hover {
1914
+ border-left-color: #45475a;
1915
+ }
1916
+ .an-theme-dark .an-table-label {
1917
+ color: #6c7086;
1918
+ }
1919
+ .an-theme-dark .an-context-table-grid-panel {
1920
+ border-top-color: #3f3f5f;
1921
+ }
1669
1922
  .an-theme-dark .an-context-item {
1670
1923
  color: #cdd6f4;
1671
1924
  }
@@ -1703,10 +1956,22 @@
1703
1956
  color: #cdd6f4;
1704
1957
  }
1705
1958
  .an-theme-dark .an-icon-cell {
1959
+ color: #a6adc8;
1960
+ }
1961
+ .an-theme-dark .an-icon-cell i {
1706
1962
  color: #cdd6f4;
1707
1963
  }
1708
1964
  .an-theme-dark .an-icon-cell:hover {
1709
1965
  background: #2a2a3e;
1966
+ border-color: #45475a;
1967
+ }
1968
+ .an-theme-dark .an-icon-cell.active {
1969
+ background: rgba(129, 140, 248, 0.15);
1970
+ border-color: #818cf8;
1971
+ color: #818cf8;
1972
+ }
1973
+ .an-theme-dark .an-icon-cell.active i {
1974
+ color: #818cf8;
1710
1975
  }
1711
1976
  .an-theme-dark .an-icon-close {
1712
1977
  color: #a6adc8;
@@ -1715,6 +1980,63 @@
1715
1980
  background: #2a2a3e;
1716
1981
  color: #cdd6f4;
1717
1982
  }
1983
+ .an-theme-dark .an-emoji-box {
1984
+ background: #1e1e2e;
1985
+ border-color: #45475a;
1986
+ }
1987
+ .an-theme-dark .an-emoji-cell {
1988
+ color: inherit;
1989
+ }
1990
+ .an-theme-dark .an-emoji-cell:hover {
1991
+ background: #313244;
1992
+ }
1993
+ .an-theme-dark .an-emoji-grid {
1994
+ scrollbar-color: #45475a transparent;
1995
+ }
1996
+ .an-theme-dark .an-icon-box {
1997
+ background: #1e1e2e;
1998
+ border-color: #45475a;
1999
+ }
2000
+ .an-theme-dark .an-icon-grid {
2001
+ background: #181825;
2002
+ border-color: #45475a;
2003
+ }
2004
+ .an-theme-dark .an-icon-options {
2005
+ background: #181825;
2006
+ border-color: #45475a;
2007
+ }
2008
+ .an-theme-dark .an-icon-preview {
2009
+ background: #181825;
2010
+ border-color: #45475a;
2011
+ color: #cdd6f4;
2012
+ }
2013
+ .an-theme-dark .an-icon-preview .an-icon-preview-empty {
2014
+ color: #6c7086;
2015
+ }
2016
+ .an-theme-dark .an-icon-option-select {
2017
+ background: #313244;
2018
+ border-color: #45475a;
2019
+ color: #cdd6f4;
2020
+ }
2021
+ .an-theme-dark .an-icon-empty {
2022
+ color: #6c7086;
2023
+ }
2024
+ .an-theme-dark .an-bubble-color-picker {
2025
+ background: #24273a;
2026
+ border-color: #3f3f5f;
2027
+ }
2028
+ .an-theme-dark .an-bubble-color-picker .an-context-color-custom {
2029
+ border-color: #3f3f5f;
2030
+ color: #a6adc8;
2031
+ }
2032
+ .an-theme-dark .an-table-tooltip {
2033
+ background: #24273a;
2034
+ border-color: #3f3f5f;
2035
+ }
2036
+ .an-theme-dark .an-fr-box {
2037
+ background: #1e1e2e;
2038
+ border-color: #45475a;
2039
+ }
1718
2040
 
1719
2041
  .an-toolbar-overflow-scroll .an-toolbar {
1720
2042
  flex-wrap: nowrap;