mdwysiwyg 0.4.0 → 0.5.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 +22 -6
- package/dist/index.cjs +161 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +159 -118
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +197 -32
- package/dist/index.d.ts +197 -32
- package/dist/index.js +215 -65
- package/dist/index.js.map +1 -1
- package/docs/THEMING.md +329 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -85,8 +85,24 @@ export default function App() {
|
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
That's it — no configuration required.
|
|
89
|
-
|
|
88
|
+
That's it — no configuration required. Every prop is documented in the code itself (hover it in your editor to
|
|
89
|
+
see what it does, its default and how it relates to other props).
|
|
90
|
+
|
|
91
|
+
- **All props, API and examples**: [component documentation](./src/components/MarkdownEditor/README.md)
|
|
92
|
+
- **Styling it for your app** (dark theme, brand colors, fonts — every CSS variable, recipes, troubleshooting):
|
|
93
|
+
[How to style mdwysiwyg in your host](https://github.com/ferkiernan/mdwysiwyg/blob/master/docs/THEMING.md) (Spanish)
|
|
94
|
+
- **Try every prop and build your theme live**: [playground](https://ferkiernan.github.io/mdwysiwyg/)
|
|
95
|
+
|
|
96
|
+
To match your product's look, declare `--mdw-*` variables on a class and pass it in `className` (or declare them on any
|
|
97
|
+
ancestor / `:root` for every editor on the page):
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
.my-editor { --mdw-bg: #0b1220; --mdw-fg: #e5e7eb; --mdw-accent: #60a5fa; }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
<MarkdownEditor className="my-editor" />
|
|
105
|
+
```
|
|
90
106
|
|
|
91
107
|
### Cloning the repository instead
|
|
92
108
|
|
|
@@ -122,13 +138,13 @@ Try it in your browser, no install required: **[ferkiernan.github.io/mdwysiwyg](
|
|
|
122
138
|
| Diagrams | ` ```mermaid ` blocks render as live diagrams; pasted Mermaid syntax is auto-detected on HTML insert. Lazy-loaded, `securityLevel: strict` |
|
|
123
139
|
| Export | Copy as Markdown or as HTML, one click |
|
|
124
140
|
| Modes | Full editor (default) or read-only viewer (`onlyView`, with a configurable notice via `onlyViewNotice`) |
|
|
125
|
-
| Sizing | Fixed (`width`/`height` props)
|
|
126
|
-
| Toolbar | Shown by default; hide/show it at runtime with `showToolbar` (no content, caret or undo loss) |
|
|
141
|
+
| Sizing | Fixed (`width`/`height` props), user-resizable (`resizable`, default on) or growing with its content (`autoHeight`: no inner vertical scrollbar, `height` becomes the minimum) |
|
|
142
|
+
| Toolbar | Shown by default; hide/show it at runtime with `showToolbar` (no content, caret or undo loss), or only while the editor has focus with `autoHideBar` |
|
|
127
143
|
| Version history | Opt-in `historyUndo`: a version is saved after 3 s without changes; a clock icon right after the HTML button opens a history mode with ← Undo / Redo →, Confirm / Cancel (back to last version) and a right-hand list of versions with their time (click one to jump to it; document read-only while browsing; `Ctrl+Z` / `Ctrl+Shift+Z` map to Undo / Redo) |
|
|
128
144
|
| Compare mode | `mode="compare"` + `compareOrientation` (`side-to-side` / `up-and-down`) + `compareContent`: read-only original next to an editable new version with changed words highlighted in yellow, and a second bar to accept, reject or restore the change (`onCompareDecision`) |
|
|
129
145
|
| Compare scroll sync | In compare mode the two panes follow each other by matching content (top edge ↔ top edge; added/removed passages are crossed proportionally; vertical only). On by default; turn it off with `compareSyncScroll={false}` |
|
|
130
|
-
| Theming | CSS Custom Properties
|
|
131
|
-
| Imperative API | `ref` exposing `reset()` and `
|
|
146
|
+
| Theming | 47 CSS Custom Properties (`--mdw-*`) covering toolbar, content, tables, code and syntax highlighting, quotes, menus/dialogs, compare highlight and scrollbars; declare them on your class, a wrapper or `:root`, in any load order — see the [theming guide](https://github.com/ferkiernan/mdwysiwyg/blob/master/docs/THEMING.md) |
|
|
147
|
+
| Imperative API | `ref` exposing `reset()`, `isModified()`, `insertMarkdown()` and `setMarkdown()` |
|
|
132
148
|
|
|
133
149
|
## Tech under the hood
|
|
134
150
|
|
package/dist/index.cjs
CHANGED
|
@@ -3479,7 +3479,8 @@ var MarkdownEditor_default = {
|
|
|
3479
3479
|
menu: "MarkdownEditor_menu",
|
|
3480
3480
|
menuItem: "MarkdownEditor_menuItem",
|
|
3481
3481
|
menuSeparator: "MarkdownEditor_menuSeparator",
|
|
3482
|
-
dangerLink: "MarkdownEditor_dangerLink"
|
|
3482
|
+
dangerLink: "MarkdownEditor_dangerLink",
|
|
3483
|
+
autoHeight: "MarkdownEditor_autoHeight"
|
|
3483
3484
|
};
|
|
3484
3485
|
|
|
3485
3486
|
// src/components/MarkdownEditor/compare/CompareBar.tsx
|
|
@@ -3535,11 +3536,43 @@ function RenderedView({ editor }) {
|
|
|
3535
3536
|
// src/components/MarkdownEditor/views/MarkdownSourceView.tsx
|
|
3536
3537
|
var import_react2 = require("react");
|
|
3537
3538
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
3538
|
-
|
|
3539
|
+
function fitToContent(textarea) {
|
|
3540
|
+
textarea.style.height = "auto";
|
|
3541
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
3542
|
+
}
|
|
3543
|
+
var MarkdownSourceView = (0, import_react2.forwardRef)(function MarkdownSourceView2({
|
|
3544
|
+
value,
|
|
3545
|
+
onChange,
|
|
3546
|
+
readOnly = false,
|
|
3547
|
+
ariaLabel = "C\xF3digo fuente Markdown",
|
|
3548
|
+
autoSize = false
|
|
3549
|
+
}, ref) {
|
|
3550
|
+
const innerRef = (0, import_react2.useRef)(null);
|
|
3551
|
+
(0, import_react2.useImperativeHandle)(ref, () => innerRef.current);
|
|
3552
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
3553
|
+
const textarea = innerRef.current;
|
|
3554
|
+
if (textarea === null) return;
|
|
3555
|
+
if (autoSize) fitToContent(textarea);
|
|
3556
|
+
else textarea.style.height = "";
|
|
3557
|
+
}, [autoSize, value]);
|
|
3558
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
3559
|
+
const textarea = innerRef.current;
|
|
3560
|
+
if (!autoSize || textarea === null || typeof ResizeObserver === "undefined") {
|
|
3561
|
+
return;
|
|
3562
|
+
}
|
|
3563
|
+
let width = textarea.clientWidth;
|
|
3564
|
+
const observer = new ResizeObserver(() => {
|
|
3565
|
+
if (textarea.clientWidth === width) return;
|
|
3566
|
+
width = textarea.clientWidth;
|
|
3567
|
+
fitToContent(textarea);
|
|
3568
|
+
});
|
|
3569
|
+
observer.observe(textarea);
|
|
3570
|
+
return () => observer.disconnect();
|
|
3571
|
+
}, [autoSize]);
|
|
3539
3572
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
3540
3573
|
"textarea",
|
|
3541
3574
|
{
|
|
3542
|
-
ref,
|
|
3575
|
+
ref: innerRef,
|
|
3543
3576
|
className: MarkdownEditor_default["source"],
|
|
3544
3577
|
"aria-label": ariaLabel,
|
|
3545
3578
|
spellCheck: false,
|
|
@@ -3555,7 +3588,14 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
|
3555
3588
|
function noop() {
|
|
3556
3589
|
}
|
|
3557
3590
|
var OriginalPane = (0, import_react3.forwardRef)(
|
|
3558
|
-
function OriginalPane2({
|
|
3591
|
+
function OriginalPane2({
|
|
3592
|
+
markdown,
|
|
3593
|
+
viewMode,
|
|
3594
|
+
sanitizeEmbeddedHtml,
|
|
3595
|
+
resolveImageSrc,
|
|
3596
|
+
onEditor,
|
|
3597
|
+
autoSize = false
|
|
3598
|
+
}, ref) {
|
|
3559
3599
|
const hasImageResolver = resolveImageSrc !== void 0;
|
|
3560
3600
|
const extensions = (0, import_react3.useMemo)(
|
|
3561
3601
|
() => createEditorExtensions({
|
|
@@ -3599,7 +3639,8 @@ var OriginalPane = (0, import_react3.forwardRef)(
|
|
|
3599
3639
|
value: markdown,
|
|
3600
3640
|
onChange: noop,
|
|
3601
3641
|
readOnly: true,
|
|
3602
|
-
ariaLabel: "C\xF3digo fuente Markdown original (solo lectura)"
|
|
3642
|
+
ariaLabel: "C\xF3digo fuente Markdown original (solo lectura)",
|
|
3643
|
+
autoSize
|
|
3603
3644
|
}
|
|
3604
3645
|
)
|
|
3605
3646
|
}
|
|
@@ -3921,7 +3962,7 @@ function segments(value, ranges) {
|
|
|
3921
3962
|
nodes.push(value.slice(cursor));
|
|
3922
3963
|
return nodes;
|
|
3923
3964
|
}
|
|
3924
|
-
var HighlightedSource = (0, import_react6.forwardRef)(function HighlightedSource2({ value, onChange, readOnly, ranges }, ref) {
|
|
3965
|
+
var HighlightedSource = (0, import_react6.forwardRef)(function HighlightedSource2({ value, onChange, readOnly, ranges, autoSize }, ref) {
|
|
3925
3966
|
const layerRef = (0, import_react6.useRef)(null);
|
|
3926
3967
|
const syncScroll = (event) => {
|
|
3927
3968
|
const layer = layerRef.current;
|
|
@@ -3945,7 +3986,8 @@ var HighlightedSource = (0, import_react6.forwardRef)(function HighlightedSource
|
|
|
3945
3986
|
ref,
|
|
3946
3987
|
value,
|
|
3947
3988
|
onChange,
|
|
3948
|
-
...readOnly !== void 0 ? { readOnly } : {}
|
|
3989
|
+
...readOnly !== void 0 ? { readOnly } : {},
|
|
3990
|
+
...autoSize !== void 0 ? { autoSize } : {}
|
|
3949
3991
|
}
|
|
3950
3992
|
)
|
|
3951
3993
|
]
|
|
@@ -4558,6 +4600,69 @@ function CodeLanguagePicker({
|
|
|
4558
4600
|
// src/components/MarkdownEditor/Toolbar/buttons/FloatingPanel.tsx
|
|
4559
4601
|
var import_react14 = require("react");
|
|
4560
4602
|
var import_react_dom = require("react-dom");
|
|
4603
|
+
|
|
4604
|
+
// src/components/MarkdownEditor/theme/themeTokens.ts
|
|
4605
|
+
var THEME_TOKENS = [
|
|
4606
|
+
{ name: "--mdw-border", group: "base", kind: "color", default: "#d0d4da", description: "Bordes del componente, tablas y paneles" },
|
|
4607
|
+
{ name: "--mdw-bg", group: "base", kind: "color", default: "#ffffff", description: "Fondo del componente; base del fondo del contenido y de los paneles flotantes" },
|
|
4608
|
+
{ name: "--mdw-fg", group: "base", kind: "color", default: "#1f2328", description: "Color de texto; base del texto del contenido" },
|
|
4609
|
+
{ name: "--mdw-muted", group: "base", kind: "color", default: "#f6f7f9", description: "Fondos suaves: encabezados de tabla, c\xF3digo, Mermaid, lista de versiones" },
|
|
4610
|
+
{ name: "--mdw-accent", group: "base", kind: "color", default: "#3d6fd8", description: "Anillos de foco y estados seleccionados" },
|
|
4611
|
+
{ name: "--mdw-toolbar-gradient-from", group: "toolbar", kind: "color", default: "#eeeeee", description: "Color inicial del degradado de la barra" },
|
|
4612
|
+
{ name: "--mdw-toolbar-gradient-via", group: "toolbar", kind: "color", default: "#dcdcdc", description: "Color intermedio del degradado" },
|
|
4613
|
+
{ name: "--mdw-toolbar-gradient-to", group: "toolbar", kind: "color", default: "#cfcfcf", description: "Color final del degradado" },
|
|
4614
|
+
{ name: "--mdw-toolbar-fg", group: "toolbar", kind: "color", default: "#222222", description: "Texto e iconos de la barra" },
|
|
4615
|
+
{ name: "--mdw-toolbar-font-family", group: "toolbar", kind: "font", default: "Arial, sans-serif", description: "Fuente de la barra" },
|
|
4616
|
+
{ name: "--mdw-toolbar-select-bg", group: "toolbar", kind: "color", default: "#e9e9e9", description: "Fondo del selector de encabezado" },
|
|
4617
|
+
{ name: "--mdw-button-active-bg", group: "toolbar", kind: "color", default: "#c8c8c8", description: "Fondo de un bot\xF3n presionado o activo" },
|
|
4618
|
+
{ name: "--mdw-button-hover-gradient-from", group: "toolbar", kind: "color", default: "#ffffff", description: "Degradado de un bot\xF3n en hover (inicio)" },
|
|
4619
|
+
{ name: "--mdw-button-hover-gradient-to", group: "toolbar", kind: "color", default: "#d8d8d8", description: "Degradado de un bot\xF3n en hover (fin)" },
|
|
4620
|
+
{ name: "--mdw-content-bg", group: "content", kind: "background", default: "var(--mdw-bg)", description: "Fondo del \xE1rea de contenido (color, degradado o imagen)" },
|
|
4621
|
+
{ name: "--mdw-content-wysiwyg-fg", group: "content", kind: "color", default: "var(--mdw-fg)", description: "Texto de la vista renderizada" },
|
|
4622
|
+
{ name: "--mdw-content-wysiwyg-font-family", group: "content", kind: "font", default: "inherit", description: "Fuente de la vista renderizada" },
|
|
4623
|
+
{ name: "--mdw-content-markdown-fg", group: "content", kind: "color", default: "var(--mdw-fg)", description: "Texto de la vista Markdown" },
|
|
4624
|
+
{ name: "--mdw-content-markdown-font-family", group: "content", kind: "font", default: "ui-monospace, Consolas, monospace", description: "Fuente de la vista Markdown" },
|
|
4625
|
+
{ name: "--mdw-table-header-bg", group: "tables-code", kind: "color", default: "var(--mdw-muted)", description: "Fondo de los encabezados de tabla" },
|
|
4626
|
+
{ name: "--mdw-table-menu-trigger-color", group: "tables-code", kind: "color", default: "var(--mdw-scrollbar-thumb)", description: "Tri\xE1ngulo que abre el men\xFA de columna/fila" },
|
|
4627
|
+
{ name: "--mdw-table-menu-trigger-size", group: "tables-code", kind: "length", default: "0.7em", description: "Tama\xF1o del tri\xE1ngulo del men\xFA de tabla" },
|
|
4628
|
+
{ name: "--mdw-table-picker-selected-bg", group: "tables-code", kind: "color", default: "#dbe4f8", description: "Celdas seleccionadas al elegir el tama\xF1o de una tabla" },
|
|
4629
|
+
{ name: "--mdw-code-block-bg", group: "tables-code", kind: "color", default: "var(--mdw-muted)", description: "Fondo de los bloques de c\xF3digo" },
|
|
4630
|
+
{ name: "--mdw-mermaid-bg", group: "tables-code", kind: "color", default: "var(--mdw-muted)", description: "Fondo de los diagramas Mermaid" },
|
|
4631
|
+
{ name: "--mdw-code-keyword", group: "syntax", kind: "color", default: "#a626a4", description: "Palabras clave, etiquetas y literales" },
|
|
4632
|
+
{ name: "--mdw-code-string", group: "syntax", kind: "color", default: "#50a14f", description: "Cadenas y atributos" },
|
|
4633
|
+
{ name: "--mdw-code-comment", group: "syntax", kind: "color", default: "#a0a1a7", description: "Comentarios" },
|
|
4634
|
+
{ name: "--mdw-code-number", group: "syntax", kind: "color", default: "#986801", description: "N\xFAmeros y funciones integradas" },
|
|
4635
|
+
{ name: "--mdw-code-title", group: "syntax", kind: "color", default: "#4078f2", description: "T\xEDtulos y nombres de funci\xF3n o clase" },
|
|
4636
|
+
{ name: "--mdw-link-fg", group: "content", kind: "color", default: "#0000ee", description: "Enlaces de la vista renderizada (el azul por defecto del navegador)" },
|
|
4637
|
+
{ name: "--mdw-link-visited-fg", group: "content", kind: "color", default: "#551a8b", description: "Enlaces ya visitados" },
|
|
4638
|
+
{ name: "--mdw-blockquote-fg", group: "quote", kind: "color", default: "#57606a", description: "Texto de las citas" },
|
|
4639
|
+
{ name: "--mdw-blockquote-border", group: "quote", kind: "color", default: "var(--mdw-border)", description: "L\xEDnea izquierda de las citas" },
|
|
4640
|
+
{ name: "--mdw-control-border", group: "controls", kind: "color", default: "#999", description: "Bordes de botones, selectores, barras y celdas del selector de tabla" },
|
|
4641
|
+
{ name: "--mdw-control-highlight", group: "controls", kind: "color", default: "#fff", description: "Borde claro interior de botones y barras" },
|
|
4642
|
+
{ name: "--mdw-control-shadow", group: "controls", kind: "color", default: "rgba(0, 0, 0, 0.15)", description: "Sombra de botones y de la barra" },
|
|
4643
|
+
{ name: "--mdw-control-pressed-shadow", group: "controls", kind: "color", default: "rgba(0, 0, 0, 0.25)", description: "Sombra interior de un bot\xF3n presionado" },
|
|
4644
|
+
{ name: "--mdw-separator-color", group: "controls", kind: "color", default: "#aaa", description: "Separadores de la barra" },
|
|
4645
|
+
{ name: "--mdw-popover-bg", group: "floating", kind: "color", default: "var(--mdw-bg)", description: "Fondo de men\xFAs, di\xE1logos y popovers" },
|
|
4646
|
+
{ name: "--mdw-popover-shadow", group: "floating", kind: "shadow", default: "0 4px 12px rgba(0, 0, 0, 0.12)", description: "Sombra de los paneles flotantes" },
|
|
4647
|
+
{ name: "--mdw-menu-hover-bg", group: "floating", kind: "color", default: "#e4e7eb", description: "Fondo de un elemento de men\xFA en hover o foco" },
|
|
4648
|
+
{ name: "--mdw-danger-fg", group: "floating", kind: "color", default: "#b42318", description: "Acciones destructivas (eliminar fila/columna, quitar enlace)" },
|
|
4649
|
+
{ name: "--mdw-danger-hover-fg", group: "floating", kind: "color", default: "#8c1c11", description: "Acciones destructivas en hover o foco" },
|
|
4650
|
+
{ name: "--mdw-compare-highlight-bg", group: "compare", kind: "color", default: "#fff176", description: "Resaltado de diferencias en modo comparaci\xF3n" },
|
|
4651
|
+
{ name: "--mdw-scrollbar-thumb", group: "scroll", kind: "color", default: "#c1c1c1", description: "Pulgar de las barras de desplazamiento" },
|
|
4652
|
+
{ name: "--mdw-scrollbar-track", group: "scroll", kind: "color", default: "transparent", description: "Riel de las barras de desplazamiento" }
|
|
4653
|
+
];
|
|
4654
|
+
function copyThemeTokens(source, target) {
|
|
4655
|
+
const view = source.ownerDocument.defaultView;
|
|
4656
|
+
if (view === null) return;
|
|
4657
|
+
const computed = view.getComputedStyle(source);
|
|
4658
|
+
for (const token of THEME_TOKENS) {
|
|
4659
|
+
const value = computed.getPropertyValue(token.name).trim();
|
|
4660
|
+
if (value === "") target.style.removeProperty(token.name);
|
|
4661
|
+
else target.style.setProperty(token.name, value);
|
|
4662
|
+
}
|
|
4663
|
+
}
|
|
4664
|
+
|
|
4665
|
+
// src/components/MarkdownEditor/Toolbar/buttons/FloatingPanel.tsx
|
|
4561
4666
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4562
4667
|
function FloatingPanel({
|
|
4563
4668
|
anchor,
|
|
@@ -4579,6 +4684,15 @@ function FloatingPanel({
|
|
|
4579
4684
|
setStyle({ top: rect.bottom, left: rect.left });
|
|
4580
4685
|
}
|
|
4581
4686
|
}, [anchor, align]);
|
|
4687
|
+
(0, import_react14.useLayoutEffect)(() => {
|
|
4688
|
+
const panel = panelRef.current;
|
|
4689
|
+
const rootClass = MarkdownEditor_default["root"];
|
|
4690
|
+
if (style === null || panel === null || anchor === null || rootClass === void 0) {
|
|
4691
|
+
return;
|
|
4692
|
+
}
|
|
4693
|
+
const source = anchor.closest(`.${CSS.escape(rootClass)}`);
|
|
4694
|
+
if (source !== null) copyThemeTokens(source, panel);
|
|
4695
|
+
}, [style === null, anchor]);
|
|
4582
4696
|
(0, import_react14.useLayoutEffect)(() => {
|
|
4583
4697
|
if (style === null || !autoFocus) return;
|
|
4584
4698
|
panelRef.current?.querySelector(
|
|
@@ -5305,7 +5419,9 @@ var MarkdownEditor = (0, import_react19.forwardRef)(function MarkdownEditor2({
|
|
|
5305
5419
|
className,
|
|
5306
5420
|
onlyView = false,
|
|
5307
5421
|
showToolbar = true,
|
|
5422
|
+
autoHideBar = false,
|
|
5308
5423
|
resizable = true,
|
|
5424
|
+
autoHeight = false,
|
|
5309
5425
|
onlyViewNotice,
|
|
5310
5426
|
resolveImageSrc,
|
|
5311
5427
|
mode = "default",
|
|
@@ -5744,12 +5860,42 @@ var MarkdownEditor = (0, import_react19.forwardRef)(function MarkdownEditor2({
|
|
|
5744
5860
|
editor.chain().focus().setTextSelection(linkPopover.range).extendMarkRange("link").unsetLink().run();
|
|
5745
5861
|
closeLinkPopover();
|
|
5746
5862
|
};
|
|
5863
|
+
const rootRef = (0, import_react19.useRef)(null);
|
|
5864
|
+
const [focusInside, setFocusInside] = (0, import_react19.useState)(false);
|
|
5865
|
+
const focusOutTimer = (0, import_react19.useRef)(null);
|
|
5866
|
+
const handleFocusIn = () => {
|
|
5867
|
+
if (focusOutTimer.current !== null) {
|
|
5868
|
+
clearTimeout(focusOutTimer.current);
|
|
5869
|
+
focusOutTimer.current = null;
|
|
5870
|
+
}
|
|
5871
|
+
setFocusInside(true);
|
|
5872
|
+
};
|
|
5873
|
+
const handleFocusOut = () => {
|
|
5874
|
+
if (focusOutTimer.current !== null) clearTimeout(focusOutTimer.current);
|
|
5875
|
+
focusOutTimer.current = setTimeout(() => {
|
|
5876
|
+
focusOutTimer.current = null;
|
|
5877
|
+
setFocusInside(false);
|
|
5878
|
+
}, 0);
|
|
5879
|
+
};
|
|
5880
|
+
(0, import_react19.useLayoutEffect)(() => {
|
|
5881
|
+
if (!autoHideBar) return;
|
|
5882
|
+
const root = rootRef.current;
|
|
5883
|
+
setFocusInside(root !== null && root.contains(document.activeElement));
|
|
5884
|
+
}, [autoHideBar]);
|
|
5885
|
+
(0, import_react19.useEffect)(
|
|
5886
|
+
() => () => {
|
|
5887
|
+
if (focusOutTimer.current !== null) clearTimeout(focusOutTimer.current);
|
|
5888
|
+
},
|
|
5889
|
+
[]
|
|
5890
|
+
);
|
|
5747
5891
|
const rootClassName = [
|
|
5748
5892
|
MarkdownEditor_default["root"],
|
|
5749
|
-
resizable ? MarkdownEditor_default["resizable"] : void 0,
|
|
5893
|
+
resizable && !autoHeight ? MarkdownEditor_default["resizable"] : void 0,
|
|
5894
|
+
autoHeight ? MarkdownEditor_default["autoHeight"] : void 0,
|
|
5750
5895
|
className
|
|
5751
5896
|
].filter(Boolean).join(" ");
|
|
5752
5897
|
const orientation = compareOrientation ?? "side-to-side";
|
|
5898
|
+
const toolbarVisible = showToolbar && (!autoHideBar || focusInside);
|
|
5753
5899
|
const panesClassName = [
|
|
5754
5900
|
MarkdownEditor_default["panes"],
|
|
5755
5901
|
session !== null ? MarkdownEditor_default["panesCompare"] : void 0,
|
|
@@ -5759,10 +5905,12 @@ var MarkdownEditor = (0, import_react19.forwardRef)(function MarkdownEditor2({
|
|
|
5759
5905
|
"div",
|
|
5760
5906
|
{
|
|
5761
5907
|
className: rootClassName,
|
|
5762
|
-
style: { width: toCssSize(width), height: toCssSize(height) },
|
|
5908
|
+
style: autoHeight ? { width: toCssSize(width), minHeight: toCssSize(height) } : { width: toCssSize(width), height: toCssSize(height) },
|
|
5763
5909
|
...historyOpen ? { onKeyDownCapture: handleHistoryKeyDown } : {},
|
|
5910
|
+
...autoHideBar ? { onFocus: handleFocusIn, onBlur: handleFocusOut } : {},
|
|
5911
|
+
ref: rootRef,
|
|
5764
5912
|
children: [
|
|
5765
|
-
|
|
5913
|
+
toolbarVisible && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ToolbarSlot, { onFocusLost: () => editor?.view.focus(), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5766
5914
|
Toolbar,
|
|
5767
5915
|
{
|
|
5768
5916
|
editor,
|
|
@@ -5815,6 +5963,7 @@ var MarkdownEditor = (0, import_react19.forwardRef)(function MarkdownEditor2({
|
|
|
5815
5963
|
{
|
|
5816
5964
|
ref: originalPaneRef,
|
|
5817
5965
|
onEditor: setOriginalEditor,
|
|
5966
|
+
autoSize: autoHeight,
|
|
5818
5967
|
markdown: session.original,
|
|
5819
5968
|
viewMode: effectiveViewMode,
|
|
5820
5969
|
sanitizeEmbeddedHtml,
|
|
@@ -5845,7 +5994,8 @@ var MarkdownEditor = (0, import_react19.forwardRef)(function MarkdownEditor2({
|
|
|
5845
5994
|
value: source,
|
|
5846
5995
|
onChange: handleSourceChange,
|
|
5847
5996
|
readOnly: onlyView || historyOpen,
|
|
5848
|
-
ranges: session !== null ? textDiff?.ranges ?? [] : null
|
|
5997
|
+
ranges: session !== null ? textDiff?.ranges ?? [] : null,
|
|
5998
|
+
autoSize: autoHeight
|
|
5849
5999
|
}
|
|
5850
6000
|
),
|
|
5851
6001
|
tableTriggerEnabled && triggerCell !== null && triggerCell.isConnected && contentRef.current !== null && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|