smartrte-react 1.0.0-beta.1 → 1.0.0-beta.11

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/dist/theme.js CHANGED
@@ -18,8 +18,8 @@ export const SRTE_DEFAULT_CSS = `
18
18
  --srte-input-border: var(--srte-border);
19
19
  --srte-modal-backdrop: rgba(0, 0, 0, 0.35);
20
20
  --srte-modal-backdrop-filter: blur(2px);
21
- --srte-modal-bg: #ffffff;
22
- --srte-modal-text: #000000;
21
+ --srte-modal-bg: var(--card, #ffffff);
22
+ --srte-modal-text: var(--foreground, #000000);
23
23
  --srte-menu-bg: var(--srte-background);
24
24
  --srte-menu-text: var(--srte-foreground);
25
25
  --srte-menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
@@ -32,7 +32,6 @@ export const SRTE_DEFAULT_CSS = `
32
32
  (see .srte-tool-button[aria-pressed="true"]), not a replacement for
33
33
  --srte-primary generally. */
34
34
  --srte-primary-pressed: #1d4ed8;
35
- --srte-surface-subtle: #f3f4f6;
36
35
  --srte-on-primary: #ffffff;
37
36
  --srte-cancel-bg: #f3f4f6;
38
37
  --srte-code-bg: #f6f8fa;
@@ -56,8 +55,8 @@ export const SRTE_DEFAULT_CSS = `
56
55
  --srte-input-border: var(--srte-border);
57
56
  --srte-modal-backdrop: rgba(0, 0, 0, 0.22);
58
57
  --srte-modal-backdrop-filter: blur(10px) saturate(0.9);
59
- --srte-modal-bg: #1e293b;
60
- --srte-modal-text: #e0e0e0;
58
+ --srte-modal-bg: var(--card, #1e293b);
59
+ --srte-modal-text: var(--foreground, #e0e0e0);
61
60
  --srte-menu-bg: var(--srte-background);
62
61
  --srte-menu-text: var(--srte-foreground);
63
62
  --srte-menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
@@ -66,7 +65,6 @@ export const SRTE_DEFAULT_CSS = `
66
65
  --srte-danger: #ef4444;
67
66
  --srte-primary: #3b82f6;
68
67
  --srte-primary-pressed: var(--srte-primary);
69
- --srte-surface-subtle: #333333;
70
68
  --srte-on-primary: #ffffff;
71
69
  --srte-cancel-bg: #333333;
72
70
  --srte-code-bg: #111827;
@@ -196,6 +194,20 @@ export const SRTE_DEFAULT_CSS = `
196
194
  color: var(--srte-menu-text);
197
195
  box-shadow: var(--srte-menu-shadow);
198
196
  }
197
+ /*
198
+ * ToolbarDropdown's own menu panel (docs/bugs/
199
+ * toolbar-dropdown-clipped-by-host-overflow-hidden.md): position:fixed with
200
+ * JS-measured left/top (ToolbarPrimitives.tsx) instead of the default
201
+ * position:absolute above, so it always escapes an ancestor host container's
202
+ * own overflow:hidden regardless of DOM depth - MobileMoreMenu's overflow
203
+ * menu (no data-srte-menu-fixed attribute) is unaffected and keeps its
204
+ * existing position:absolute/right-anchored behavior.
205
+ */
206
+ .srte-menu[data-srte-menu-fixed="true"] {
207
+ position: fixed;
208
+ top: 0;
209
+ left: 0;
210
+ }
199
211
  .srte-menu-item {
200
212
  display: flex;
201
213
  align-items: center;
@@ -395,34 +407,32 @@ export const SRTE_DEFAULT_CSS = `
395
407
  border-color: var(--srte-ring) !important;
396
408
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--srte-ring) 18%, transparent);
397
409
  }
398
- @media (max-width: 639px) {
399
- .srte-toolbar { gap: 3px; padding: 6px; }
400
- .srte-tool-button, .srte-toolbar select { height: 40px; min-width: 40px; }
401
- .srte-toolbar-group[data-srte-priority="3"] { display: none; }
402
- .srte-toolbar-menu[data-srte-priority="2"] { display: none; }
403
- .srte-mobile-more { display: block; }
404
- .srte-mobile-more .srte-menu {
405
- left: auto;
406
- right: 0;
407
- width: min(280px, calc(100vw - 16px));
408
- min-width: 0;
409
- max-height: min(70dvh, 480px);
410
- overflow-x: hidden;
411
- overflow-y: auto;
412
- overscroll-behavior: contain;
413
- -webkit-overflow-scrolling: touch;
414
- }
415
- .srte-menu-item { height: 40px; }
416
- }
410
+ /*
411
+ * @container (element width), not @media (viewport width): a host can embed
412
+ * the editor at any fraction of the browser window - a split pane next to a
413
+ * preview panel is the case that surfaced this (docs/bugs/
414
+ * toolbar-wide-promotion-fires-on-viewport-width-not-container-width.md). A
415
+ * plain @media breakpoint here would fire based on the *window*, wrongly
416
+ * switching tiers for an editor instance that's actually much narrower (or
417
+ * wider) than the window - .srte-editor already establishes its own
418
+ * container: srte-editor / inline-size (see the .srte-editor rule above),
419
+ * so @container always reflects this specific instance's real rendered width regardless of host
420
+ * layout, with no @media fallback needed (container queries have full
421
+ * support across this project's three target engines).
422
+ */
417
423
  @container srte-editor (max-width: 639px) {
418
424
  .srte-toolbar { gap: 3px; padding: 6px; }
419
425
  .srte-tool-button, .srte-toolbar select { height: 40px; min-width: 40px; }
420
426
  .srte-toolbar-group[data-srte-priority="3"],
421
427
  .srte-toolbar-menu[data-srte-priority="2"] { display: none; }
422
428
  .srte-mobile-more { display: block; }
429
+ /* left/top are no longer set here - ToolbarPrimitives.tsx now computes
430
+ them via inline style (JS-measured, position:fixed, viewport-clamped;
431
+ see MobileMoreMenu's own doc comment), which always wins over any
432
+ value set here regardless of specificity or source order. Sizing/
433
+ scroll behavior stays defined here since inline positioning doesn't
434
+ touch those properties. */
423
435
  .srte-mobile-more .srte-menu {
424
- left: auto;
425
- right: 0;
426
436
  width: min(280px, calc(100vw - 16px));
427
437
  min-width: 0;
428
438
  max-height: min(70dvh, 480px);
@@ -459,12 +469,16 @@ export const SRTE_DEFAULT_CSS = `
459
469
  * under them. 1440px clears that default with room to spare while still
460
470
  * comfortably covering "wide desktop" (the ~2264px width the original
461
471
  * report was filed against).
472
+ *
473
+ * @container only, no @media fallback - same reasoning as the mobile tier
474
+ * above (docs/bugs/toolbar-wide-promotion-fires-on-viewport-width-not-container-width.md):
475
+ * a plain @media(min-width:1440px) fired whenever the *browser window* was
476
+ * wide, even when this editor instance was embedded in a much narrower
477
+ * split pane - promoting 9 extra buttons into a group with no room for
478
+ * them, which squeezed/overlapped the group's existing buttons instead of
479
+ * wrapping cleanly.
462
480
  */
463
481
  .srte-tool-button[data-srte-wide-promote="true"] { display: none; }
464
- @media (min-width: 1440px) {
465
- .srte-tool-button[data-srte-wide-promote="true"] { display: inline-flex; }
466
- .srte-menu-item[data-srte-wide-promote="true"] { display: none; }
467
- }
468
482
  @container srte-editor (min-width: 1440px) {
469
483
  .srte-tool-button[data-srte-wide-promote="true"] { display: inline-flex; }
470
484
  .srte-menu-item[data-srte-wide-promote="true"] { display: none; }
@@ -473,7 +487,17 @@ export const SRTE_DEFAULT_CSS = `
473
487
  border-left: 4px solid var(--srte-accent);
474
488
  margin: 0.75em 0;
475
489
  padding: 0.5em 1em;
476
- background: var(--srte-surface-subtle);
490
+ /* --srte-muted, not the retired --srte-surface-subtle (docs/bugs/
491
+ srte-surface-subtle-not-host-theme-aware.md): every other neutral
492
+ surface/text token here (--srte-background, --srte-foreground,
493
+ --srte-muted, --srte-border) is defined as var(--host-token, fallback)
494
+ so it correctly follows a host's OWN light/dark state even if
495
+ .srte-dark never gets applied for some host-side wiring reason -
496
+ --srte-surface-subtle was the one exception, a bare hardcoded hex with
497
+ no host integration, which is exactly what let a real host (dark mode,
498
+ .srte-dark not reaching this editor instance) render this blockquote
499
+ with a light-mode background and dark-mode text simultaneously. */
500
+ background: var(--srte-muted);
477
501
  color: var(--srte-text);
478
502
  }
479
503
  .srte-editor [contenteditable] p,
@@ -552,7 +576,7 @@ export const SRTE_DEFAULT_CSS = `
552
576
  color: inherit;
553
577
  }
554
578
  .srte-editor [contenteditable] th {
555
- background: var(--srte-surface-subtle);
579
+ background: var(--srte-muted);
556
580
  font-weight: 600;
557
581
  text-align: left;
558
582
  }
@@ -613,6 +637,39 @@ export const SRTE_DEFAULT_CSS = `
613
637
  .srte-editor [contenteditable] sup {
614
638
  line-height: 0;
615
639
  }
640
+ /*
641
+ * A page break has no native visual meaning in a continuously-scrolling
642
+ * web editor - its entire purpose is what happens at export/print time
643
+ * (see atom/formats.ts's atomToHtml doc comment). This gives it a clearly
644
+ * distinct live-editor appearance from the plain solid <hr> a horizontal
645
+ * line renders as by default, so the two are never confused: a dashed
646
+ * line with an explicit "Page break" label, per the feature's own design
647
+ * decision.
648
+ */
649
+ .srte-editor [contenteditable] [data-smart-type="page_break"] {
650
+ display: block;
651
+ position: relative;
652
+ height: 0;
653
+ margin: 1.5em 0;
654
+ border: none;
655
+ border-top: 2px dashed var(--srte-border);
656
+ cursor: default;
657
+ }
658
+ .srte-editor [contenteditable] [data-smart-type="page_break"]::after {
659
+ content: "Page break";
660
+ position: absolute;
661
+ top: -0.7em;
662
+ left: 50%;
663
+ transform: translateX(-50%);
664
+ background: var(--srte-canvas);
665
+ padding: 0 0.6em;
666
+ font-size: 11px;
667
+ font-weight: 600;
668
+ text-transform: uppercase;
669
+ letter-spacing: 0.05em;
670
+ color: var(--srte-text-muted);
671
+ white-space: nowrap;
672
+ }
616
673
  `;
617
674
  const SRTE_STYLE_ID = 'srte-theme-defaults';
618
675
  export function ensureStyleSheet() {
@@ -0,0 +1,95 @@
1
+ /**
2
+ * A named, per-tool toolbar-visibility toggle - "developers should be able
3
+ * to hide tools they don't want their users to see" (e.g. Version History,
4
+ * Review, Video, Audio), without wrapping/overriding the component or
5
+ * patching it with CSS. This is a UI-visibility layer, distinct from and
6
+ * composed with (never replacing) two existing, deeper mechanisms:
7
+ *
8
+ * - `EditorCapabilityPreset` (capabilityPresets.ts) controls real document
9
+ * *capability* - which plugins the schema itself is built with (today,
10
+ * only `table`). Excluding a plugin there already, correctly, hides its
11
+ * toolbar entry (`tablesEnabled`) - this file does not duplicate that.
12
+ * - Provider presence (`mediaProvider`, `versionProvider`, `commentProvider`,
13
+ * `suggestionProvider`) already gates whether a feature can function at
14
+ * all. `tools` never turns a tool ON when its required provider is
15
+ * absent - see `resolveToolbarTools`'s own doc comment.
16
+ *
17
+ * `tools` is for the remaining, larger set of toolbar entries that have no
18
+ * other on/off mechanism at all today (Bold, Italic, Video, Audio, Special
19
+ * characters, Version history, ...) - a host that wants to hide any of
20
+ * these previously had no supported way to do so.
21
+ *
22
+ * Deliberately NOT covered by individual keys (scoping decision, not an
23
+ * oversight): purely contextual actions that only ever act on something
24
+ * already selected - block move/indent, list-item indent/move/restart
25
+ * numbering, table row/column/cell operations, and the selected-media
26
+ * edit/resize/delete actions. None of these have independent product
27
+ * meaning (there is no real case for "let people insert a table but hide
28
+ * its 'Add row' action") - they stay governed solely by their owning
29
+ * top-level tool (`insertTable`, `bulletedList`/`numberedList`/`checklist`,
30
+ * `link`, `image`/`video`/`audio`).
31
+ */
32
+ export interface ToolbarTools {
33
+ bold: boolean;
34
+ italic: boolean;
35
+ underline: boolean;
36
+ strikethrough: boolean;
37
+ code: boolean;
38
+ superscript: boolean;
39
+ subscript: boolean;
40
+ textColor: boolean;
41
+ backgroundColor: boolean;
42
+ fontSize: boolean;
43
+ fontFamily: boolean;
44
+ /** The Paragraph/Heading 1-6/Code block <select>. */
45
+ blockType: boolean;
46
+ alignLeft: boolean;
47
+ alignCenter: boolean;
48
+ alignRight: boolean;
49
+ alignJustify: boolean;
50
+ /** The line-spacing dropdown (1/1.15/1.5/2/2.5 presets plus a custom value). */
51
+ lineHeight: boolean;
52
+ quote: boolean;
53
+ bulletedList: boolean;
54
+ numberedList: boolean;
55
+ checklist: boolean;
56
+ /** The named multi-level marker preset picker (decimal/alpha/roman/outline/bullet-glyph) - independent of the plain list-type toggles above. */
57
+ listPreset: boolean;
58
+ link: boolean;
59
+ removeLink: boolean;
60
+ /** Requires `mediaProvider` to actually render - see resolveToolbarTools. */
61
+ image: boolean;
62
+ /** Requires `mediaProvider` to actually render - see resolveToolbarTools. */
63
+ video: boolean;
64
+ /** Requires `mediaProvider` to actually render - see resolveToolbarTools. */
65
+ audio: boolean;
66
+ insertFormula: boolean;
67
+ specialCharacters: boolean;
68
+ /** Inserts a `divider` atom (a horizontal rule) - see docs/bugs/ for the toolbar-tools feature this was added alongside. */
69
+ horizontalLine: boolean;
70
+ /** Inserts a `page_break` atom - a print/export pagination marker, distinct from `horizontalLine`. */
71
+ pageBreak: boolean;
72
+ /** Requires the schema to actually have the table plugin (EditorCapabilityPreset) - see resolveToolbarTools. */
73
+ insertTable: boolean;
74
+ import: boolean;
75
+ saveAsHtml: boolean;
76
+ saveAsMarkdown: boolean;
77
+ saveAsWord: boolean;
78
+ saveAsPdf: boolean;
79
+ saveAsSmartRte: boolean;
80
+ /** Requires `versionProvider` to actually render. */
81
+ versionHistory: boolean;
82
+ /** Bundles "Add comment" and the Comments panel toggle - requires `commentProvider` to actually render. */
83
+ comments: boolean;
84
+ /** Bundles Suggest insertion/deletion/removal, the Suggestions panel toggle, and "Show edits" (track changes) - requires `suggestionProvider` to actually render. */
85
+ suggestions: boolean;
86
+ undo: boolean;
87
+ redo: boolean;
88
+ }
89
+ /** Every tool defaults to visible - an existing consumer who never passes `tools` sees 100% unchanged behavior. */
90
+ export declare const DEFAULT_TOOLBAR_TOOLS: ToolbarTools;
91
+ /**
92
+ * Merges a host's partial `tools` override onto the all-enabled default -
93
+ * a host only ever needs to name the tools they want OFF.
94
+ */
95
+ export declare const resolveToolbarTools: (tools?: Partial<ToolbarTools>) => ToolbarTools;
@@ -0,0 +1,17 @@
1
+ /** Every tool defaults to visible - an existing consumer who never passes `tools` sees 100% unchanged behavior. */
2
+ export const DEFAULT_TOOLBAR_TOOLS = {
3
+ bold: true, italic: true, underline: true, strikethrough: true, code: true,
4
+ superscript: true, subscript: true, textColor: true, backgroundColor: true, fontSize: true, fontFamily: true,
5
+ blockType: true, alignLeft: true, alignCenter: true, alignRight: true, alignJustify: true, lineHeight: true, quote: true,
6
+ bulletedList: true, numberedList: true, checklist: true, listPreset: true,
7
+ link: true, removeLink: true, image: true, video: true, audio: true, insertFormula: true, specialCharacters: true,
8
+ horizontalLine: true, pageBreak: true, insertTable: true,
9
+ import: true, saveAsHtml: true, saveAsMarkdown: true, saveAsWord: true, saveAsPdf: true, saveAsSmartRte: true,
10
+ versionHistory: true, comments: true, suggestions: true,
11
+ undo: true, redo: true,
12
+ };
13
+ /**
14
+ * Merges a host's partial `tools` override onto the all-enabled default -
15
+ * a host only ever needs to name the tools they want OFF.
16
+ */
17
+ export const resolveToolbarTools = (tools) => ({ ...DEFAULT_TOOLBAR_TOOLS, ...tools });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartrte-react",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.11",
4
4
  "description": "A powerful, feature-rich Rich Text Editor for React with support for tables, mathematical formulas (LaTeX/KaTeX), and media management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -84,7 +84,7 @@
84
84
  "lucide-react": "^1.35.0",
85
85
  "mammoth": "^1.11.0",
86
86
  "pdfjs-dist": "^5.4.530",
87
- "smartrte-core": "^1.0.0-beta.1"
87
+ "smartrte-core": "^1.0.0-beta.6"
88
88
  },
89
89
  "scripts": {
90
90
  "build": "rm -rf dist && tsc -p tsconfig.json",