@dxos/react-ui-editor 0.6.5 → 0.6.6-main.e1a6e1f
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/lib/browser/index.mjs +137 -41
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +4 -0
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +5 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +7 -0
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete.d.ts +2 -1
- package/dist/types/src/extensions/autocomplete.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts +4 -0
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/debug.d.ts +3 -0
- package/dist/types/src/extensions/debug.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +1 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/action.d.ts +1 -1
- package/dist/types/src/extensions/markdown/action.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/link.d.ts +3 -1
- package/dist/types/src/extensions/markdown/link.d.ts.map +1 -1
- package/dist/types/src/extensions/modes.d.ts +7 -4
- package/dist/types/src/extensions/modes.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.stories.d.ts +4 -0
- package/dist/types/src/hooks/useTextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +4 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +27 -27
- package/src/components/TextEditor/TextEditor.stories.tsx +2 -2
- package/src/components/TextEditor/TextEditor.tsx +3 -3
- package/src/components/Toolbar/Toolbar.stories.tsx +17 -7
- package/src/components/Toolbar/Toolbar.tsx +93 -3
- package/src/extensions/autocomplete.ts +3 -3
- package/src/extensions/comments.ts +1 -0
- package/src/extensions/debug.ts +15 -0
- package/src/extensions/index.ts +1 -0
- package/src/extensions/markdown/action.ts +1 -0
- package/src/extensions/modes.ts +9 -6
- package/src/hooks/useTextEditor.stories.tsx +13 -14
- package/src/translations.ts +4 -0
|
@@ -20,7 +20,11 @@ var translations_default = [
|
|
|
20
20
|
"table label": "Create table",
|
|
21
21
|
"heading level label_zero": "Paragraph",
|
|
22
22
|
"heading level label_one": "Heading level {{count}}",
|
|
23
|
-
"heading level label_other": "Heading level {{count}}"
|
|
23
|
+
"heading level label_other": "Heading level {{count}}",
|
|
24
|
+
"view mode label": "Editor view",
|
|
25
|
+
"preview mode label": "Live preview",
|
|
26
|
+
"readonly mode label": "Read only",
|
|
27
|
+
"source mode label": "Source"
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
}
|
|
@@ -146,7 +150,7 @@ var styles = EditorView.baseTheme({
|
|
|
146
150
|
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
|
|
147
151
|
import { markdownLanguage } from "@codemirror/lang-markdown";
|
|
148
152
|
import { keymap } from "@codemirror/view";
|
|
149
|
-
var autocomplete = ({ onSearch }) => {
|
|
153
|
+
var autocomplete = ({ activateOnTyping, onSearch }) => {
|
|
150
154
|
return [
|
|
151
155
|
// https://codemirror.net/docs/ref/#view.keymap
|
|
152
156
|
// https://discuss.codemirror.net/t/how-can-i-replace-the-default-autocompletion-keymap-v6/3322
|
|
@@ -155,13 +159,12 @@ var autocomplete = ({ onSearch }) => {
|
|
|
155
159
|
// https://codemirror.net/examples/autocompletion
|
|
156
160
|
// https://codemirror.net/docs/ref/#autocomplete.autocompletion
|
|
157
161
|
autocompletion({
|
|
158
|
-
activateOnTyping
|
|
162
|
+
activateOnTyping,
|
|
159
163
|
// closeOnBlur: false,
|
|
160
164
|
// defaultKeymap: false,
|
|
161
165
|
// TODO(burdon): Styles/fragments.
|
|
162
166
|
tooltipClass: () => "shadow rounded"
|
|
163
167
|
}),
|
|
164
|
-
// TODO(burdon): Option to create new page?
|
|
165
168
|
// TODO(burdon): Optional decoration via addToOptions
|
|
166
169
|
markdownLanguage.data.of({
|
|
167
170
|
autocomplete: (context) => {
|
|
@@ -1542,7 +1545,7 @@ var commentsDecorations = EditorView7.decorations.compute([
|
|
|
1542
1545
|
if (!range) {
|
|
1543
1546
|
log4.warn("Invalid range:", range, {
|
|
1544
1547
|
F: __dxlog_file6,
|
|
1545
|
-
L:
|
|
1548
|
+
L: 182,
|
|
1546
1549
|
S: void 0,
|
|
1547
1550
|
C: (f, a) => f(...a)
|
|
1548
1551
|
});
|
|
@@ -1954,6 +1957,19 @@ var useCommentClickListener = (onCommentClick) => {
|
|
|
1954
1957
|
return observer;
|
|
1955
1958
|
};
|
|
1956
1959
|
|
|
1960
|
+
// packages/ui/react-ui-editor/src/extensions/debug.ts
|
|
1961
|
+
import { syntaxTree } from "@codemirror/language";
|
|
1962
|
+
import { StateField as StateField5 } from "@codemirror/state";
|
|
1963
|
+
var debugNodeLogger = (log9 = console.log) => {
|
|
1964
|
+
const logTokens = (state2) => syntaxTree(state2).iterate({
|
|
1965
|
+
enter: (node) => log9(node.type)
|
|
1966
|
+
});
|
|
1967
|
+
return StateField5.define({
|
|
1968
|
+
create: (state2) => logTokens(state2),
|
|
1969
|
+
update: (_, tr) => logTokens(tr.state)
|
|
1970
|
+
});
|
|
1971
|
+
};
|
|
1972
|
+
|
|
1957
1973
|
// packages/ui/react-ui-editor/src/extensions/doc.ts
|
|
1958
1974
|
import { Facet as Facet5 } from "@codemirror/state";
|
|
1959
1975
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
@@ -2386,7 +2402,7 @@ var listener = ({ onFocus, onChange }) => {
|
|
|
2386
2402
|
|
|
2387
2403
|
// packages/ui/react-ui-editor/src/extensions/markdown/formatting.ts
|
|
2388
2404
|
import { snippet } from "@codemirror/autocomplete";
|
|
2389
|
-
import { syntaxTree } from "@codemirror/language";
|
|
2405
|
+
import { syntaxTree as syntaxTree2 } from "@codemirror/language";
|
|
2390
2406
|
import { EditorSelection } from "@codemirror/state";
|
|
2391
2407
|
import { EditorView as EditorView11, keymap as keymap6 } from "@codemirror/view";
|
|
2392
2408
|
import { useMemo as useMemo2, useState as useState2 } from "react";
|
|
@@ -2411,7 +2427,7 @@ var setHeading = (level) => {
|
|
|
2411
2427
|
let prevBlock = -1;
|
|
2412
2428
|
for (const range of ranges) {
|
|
2413
2429
|
let sawBlock = false;
|
|
2414
|
-
|
|
2430
|
+
syntaxTree2(state2).iterate({
|
|
2415
2431
|
from: range.from,
|
|
2416
2432
|
to: range.to,
|
|
2417
2433
|
enter: (node) => {
|
|
@@ -2520,7 +2536,7 @@ var setStyle = (type, enable) => {
|
|
|
2520
2536
|
let startCovered = false;
|
|
2521
2537
|
let endCovered = false;
|
|
2522
2538
|
let { from, to } = range;
|
|
2523
|
-
|
|
2539
|
+
syntaxTree2(state2).iterate({
|
|
2524
2540
|
from,
|
|
2525
2541
|
to,
|
|
2526
2542
|
enter: (node) => {
|
|
@@ -2723,7 +2739,7 @@ var insertTable = (view) => {
|
|
|
2723
2739
|
snippets.table(view, null, from, from);
|
|
2724
2740
|
};
|
|
2725
2741
|
var removeLinkInner = (from, to, changes, state2) => {
|
|
2726
|
-
|
|
2742
|
+
syntaxTree2(state2).iterate({
|
|
2727
2743
|
from,
|
|
2728
2744
|
to,
|
|
2729
2745
|
enter: (node) => {
|
|
@@ -2768,7 +2784,7 @@ var addLink = ({ url, image: image2 } = {}) => {
|
|
|
2768
2784
|
let { from, to } = range;
|
|
2769
2785
|
const cutStyles = [];
|
|
2770
2786
|
let okay = null;
|
|
2771
|
-
|
|
2787
|
+
syntaxTree2(state2).iterate({
|
|
2772
2788
|
from,
|
|
2773
2789
|
to,
|
|
2774
2790
|
enter: (node) => {
|
|
@@ -2863,7 +2879,7 @@ var addList = (type) => {
|
|
|
2863
2879
|
let parentColumn = null;
|
|
2864
2880
|
const blocks = [];
|
|
2865
2881
|
for (const { from, to } of state2.selection.ranges) {
|
|
2866
|
-
|
|
2882
|
+
syntaxTree2(state2).iterate({
|
|
2867
2883
|
from,
|
|
2868
2884
|
to,
|
|
2869
2885
|
enter: (node) => {
|
|
@@ -2999,7 +3015,7 @@ var removeList = (type) => {
|
|
|
2999
3015
|
const stack = [];
|
|
3000
3016
|
const targetNodeType = type === 0 ? "OrderedList" : type === 1 ? "BulletList" : "TaskList";
|
|
3001
3017
|
for (const { from, to } of state2.selection.ranges) {
|
|
3002
|
-
|
|
3018
|
+
syntaxTree2(state2).iterate({
|
|
3003
3019
|
from,
|
|
3004
3020
|
to,
|
|
3005
3021
|
enter: (node) => {
|
|
@@ -3086,7 +3102,7 @@ var setBlockquote = (enable) => {
|
|
|
3086
3102
|
let lastBlock = -1;
|
|
3087
3103
|
for (const { from, to } of state2.selection.ranges) {
|
|
3088
3104
|
const sawBlock = false;
|
|
3089
|
-
|
|
3105
|
+
syntaxTree2(state2).iterate({
|
|
3090
3106
|
from,
|
|
3091
3107
|
to,
|
|
3092
3108
|
enter: (node) => {
|
|
@@ -3176,7 +3192,7 @@ var addCodeblock = (target) => {
|
|
|
3176
3192
|
for (const { from, to } of selection.ranges) {
|
|
3177
3193
|
let blockFrom = from;
|
|
3178
3194
|
let blockTo = to;
|
|
3179
|
-
|
|
3195
|
+
syntaxTree2(state2).iterate({
|
|
3180
3196
|
from,
|
|
3181
3197
|
to,
|
|
3182
3198
|
enter: (node) => {
|
|
@@ -3227,7 +3243,7 @@ var removeCodeblock = ({ state: state2, dispatch }) => {
|
|
|
3227
3243
|
let lastBlock = -1;
|
|
3228
3244
|
const changes = [];
|
|
3229
3245
|
for (const { from, to } of state2.selection.ranges) {
|
|
3230
|
-
|
|
3246
|
+
syntaxTree2(state2).iterate({
|
|
3231
3247
|
from,
|
|
3232
3248
|
to,
|
|
3233
3249
|
enter: (node) => {
|
|
@@ -3389,7 +3405,7 @@ var getFormatting = (state2) => {
|
|
|
3389
3405
|
}
|
|
3390
3406
|
}
|
|
3391
3407
|
}
|
|
3392
|
-
|
|
3408
|
+
syntaxTree2(state2).iterate({
|
|
3393
3409
|
from: range.from,
|
|
3394
3410
|
to: range.to,
|
|
3395
3411
|
enter: (node) => {
|
|
@@ -3739,7 +3755,7 @@ var markdownHighlightStyle = (readonly) => {
|
|
|
3739
3755
|
};
|
|
3740
3756
|
|
|
3741
3757
|
// packages/ui/react-ui-editor/src/extensions/markdown/linkPaste.ts
|
|
3742
|
-
import { syntaxTree as
|
|
3758
|
+
import { syntaxTree as syntaxTree3 } from "@codemirror/language";
|
|
3743
3759
|
import { Transaction } from "@codemirror/state";
|
|
3744
3760
|
import { ViewPlugin as ViewPlugin5 } from "@codemirror/view";
|
|
3745
3761
|
var VALID_PROTOCOLS = [
|
|
@@ -3813,7 +3829,7 @@ var linkPastePlugin = ViewPlugin5.fromClass(class {
|
|
|
3813
3829
|
* checking for CodeBlock or FencedCode nodes.
|
|
3814
3830
|
*/
|
|
3815
3831
|
isInCodeBlock(state2, pos) {
|
|
3816
|
-
const tree =
|
|
3832
|
+
const tree = syntaxTree3(state2);
|
|
3817
3833
|
let node = tree.resolveInner(pos, -1);
|
|
3818
3834
|
while (node) {
|
|
3819
3835
|
if (node.name.includes("Code") || node.name.includes("FencedCode")) {
|
|
@@ -3873,7 +3889,7 @@ var createMarkdownExtensions = ({ themeMode } = {}) => {
|
|
|
3873
3889
|
};
|
|
3874
3890
|
|
|
3875
3891
|
// packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
|
|
3876
|
-
import { syntaxTree as
|
|
3892
|
+
import { syntaxTree as syntaxTree4 } from "@codemirror/language";
|
|
3877
3893
|
import { RangeSetBuilder as RangeSetBuilder2, StateEffect as StateEffect4 } from "@codemirror/state";
|
|
3878
3894
|
import { EditorView as EditorView12, Decoration as Decoration5, WidgetType as WidgetType3, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
|
|
3879
3895
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
@@ -3974,7 +3990,7 @@ var buildDecorations = (view, options, focus) => {
|
|
|
3974
3990
|
const atomicDeco = new RangeSetBuilder2();
|
|
3975
3991
|
const { state: state2 } = view;
|
|
3976
3992
|
for (const { from, to } of view.visibleRanges) {
|
|
3977
|
-
|
|
3993
|
+
syntaxTree4(state2).iterate({
|
|
3978
3994
|
from,
|
|
3979
3995
|
to,
|
|
3980
3996
|
enter: (node) => {
|
|
@@ -4180,11 +4196,11 @@ var formattingStyles = EditorView12.baseTheme({
|
|
|
4180
4196
|
});
|
|
4181
4197
|
|
|
4182
4198
|
// packages/ui/react-ui-editor/src/extensions/markdown/image.ts
|
|
4183
|
-
import { syntaxTree as
|
|
4184
|
-
import { StateField as
|
|
4199
|
+
import { syntaxTree as syntaxTree5 } from "@codemirror/language";
|
|
4200
|
+
import { StateField as StateField6 } from "@codemirror/state";
|
|
4185
4201
|
import { Decoration as Decoration6, EditorView as EditorView13, WidgetType as WidgetType4 } from "@codemirror/view";
|
|
4186
4202
|
var image = (options = {}) => {
|
|
4187
|
-
return
|
|
4203
|
+
return StateField6.define({
|
|
4188
4204
|
create: (state2) => {
|
|
4189
4205
|
return Decoration6.set(buildDecorations2(0, state2.doc.length, state2));
|
|
4190
4206
|
},
|
|
@@ -4223,7 +4239,7 @@ var preloadImage = (url) => {
|
|
|
4223
4239
|
var buildDecorations2 = (from, to, state2) => {
|
|
4224
4240
|
const decorations = [];
|
|
4225
4241
|
const cursor = state2.selection.main.head;
|
|
4226
|
-
|
|
4242
|
+
syntaxTree5(state2).iterate({
|
|
4227
4243
|
enter: (node) => {
|
|
4228
4244
|
if (node.name === "Image") {
|
|
4229
4245
|
const urlNode = node.node.getChild("URL");
|
|
@@ -4263,11 +4279,11 @@ var imageUpload = (options = {}) => {
|
|
|
4263
4279
|
};
|
|
4264
4280
|
|
|
4265
4281
|
// packages/ui/react-ui-editor/src/extensions/markdown/link.ts
|
|
4266
|
-
import { syntaxTree as
|
|
4282
|
+
import { syntaxTree as syntaxTree6 } from "@codemirror/language";
|
|
4267
4283
|
import { hoverTooltip as hoverTooltip2 } from "@codemirror/view";
|
|
4268
4284
|
import { tooltipContent } from "@dxos/react-ui-theme";
|
|
4269
4285
|
var linkTooltip = (render) => hoverTooltip2((view, pos, side) => {
|
|
4270
|
-
const syntax =
|
|
4286
|
+
const syntax = syntaxTree6(view.state).resolveInner(pos, side);
|
|
4271
4287
|
let link = null;
|
|
4272
4288
|
for (let i = 0, node = syntax; !link && node && i < 5; node = node.parent, i++) {
|
|
4273
4289
|
link = node.name === "Link" ? node : null;
|
|
@@ -4297,11 +4313,11 @@ var linkTooltip = (render) => hoverTooltip2((view, pos, side) => {
|
|
|
4297
4313
|
});
|
|
4298
4314
|
|
|
4299
4315
|
// packages/ui/react-ui-editor/src/extensions/markdown/table.ts
|
|
4300
|
-
import { syntaxTree as
|
|
4301
|
-
import { RangeSetBuilder as RangeSetBuilder3, StateField as
|
|
4316
|
+
import { syntaxTree as syntaxTree7 } from "@codemirror/language";
|
|
4317
|
+
import { RangeSetBuilder as RangeSetBuilder3, StateField as StateField7 } from "@codemirror/state";
|
|
4302
4318
|
import { Decoration as Decoration7, EditorView as EditorView14, WidgetType as WidgetType5 } from "@codemirror/view";
|
|
4303
4319
|
var table = (options = {}) => {
|
|
4304
|
-
return
|
|
4320
|
+
return StateField7.define({
|
|
4305
4321
|
create: (state2) => update(state2, options),
|
|
4306
4322
|
update: (_, tr) => update(tr.state, options),
|
|
4307
4323
|
provide: (field) => EditorView14.decorations.from(field)
|
|
@@ -4316,7 +4332,7 @@ var update = (state2, options) => {
|
|
|
4316
4332
|
const table2 = getTable();
|
|
4317
4333
|
return table2.rows?.[table2.rows.length - 1];
|
|
4318
4334
|
};
|
|
4319
|
-
|
|
4335
|
+
syntaxTree7(state2).iterate({
|
|
4320
4336
|
enter: (node) => {
|
|
4321
4337
|
switch (node.name) {
|
|
4322
4338
|
case "Table": {
|
|
@@ -4442,14 +4458,24 @@ import { keymap as keymap8 } from "@codemirror/view";
|
|
|
4442
4458
|
import { vim } from "@replit/codemirror-vim";
|
|
4443
4459
|
import { vscodeKeymap } from "@replit/codemirror-vscode-keymap";
|
|
4444
4460
|
var focusEvent = "focus.container";
|
|
4445
|
-
var
|
|
4461
|
+
var EditorViewModes = [
|
|
4462
|
+
"preview",
|
|
4463
|
+
"readonly",
|
|
4464
|
+
"source"
|
|
4465
|
+
];
|
|
4466
|
+
var EditorInputModes = [
|
|
4467
|
+
"default",
|
|
4468
|
+
"vim",
|
|
4469
|
+
"vscode"
|
|
4470
|
+
];
|
|
4471
|
+
var editorInputMode = Facet6.define({
|
|
4446
4472
|
combine: (modes) => modes[0] ?? {}
|
|
4447
4473
|
});
|
|
4448
|
-
var
|
|
4474
|
+
var InputModeExtensions = {
|
|
4449
4475
|
default: [],
|
|
4450
4476
|
vscode: [
|
|
4451
4477
|
// https://github.com/replit/codemirror-vscode-keymap
|
|
4452
|
-
|
|
4478
|
+
editorInputMode.of({
|
|
4453
4479
|
type: "vscode"
|
|
4454
4480
|
}),
|
|
4455
4481
|
keymap8.of(vscodeKeymap)
|
|
@@ -4457,7 +4483,7 @@ var EditorModes = {
|
|
|
4457
4483
|
vim: [
|
|
4458
4484
|
// https://github.com/replit/codemirror-vim
|
|
4459
4485
|
vim(),
|
|
4460
|
-
|
|
4486
|
+
editorInputMode.of({
|
|
4461
4487
|
type: "vim",
|
|
4462
4488
|
noTabster: true
|
|
4463
4489
|
}),
|
|
@@ -4710,7 +4736,7 @@ var TextEditor = /* @__PURE__ */ forwardRef(({
|
|
|
4710
4736
|
}
|
|
4711
4737
|
});
|
|
4712
4738
|
}
|
|
4713
|
-
if (state2.facet(
|
|
4739
|
+
if (state2.facet(editorInputMode).noTabster) {
|
|
4714
4740
|
rootRef.current?.removeAttribute("data-tabster");
|
|
4715
4741
|
}
|
|
4716
4742
|
setView(view2);
|
|
@@ -4730,7 +4756,6 @@ var TextEditor = /* @__PURE__ */ forwardRef(({
|
|
|
4730
4756
|
id,
|
|
4731
4757
|
selection,
|
|
4732
4758
|
scrollTo,
|
|
4733
|
-
editorMode,
|
|
4734
4759
|
extensions
|
|
4735
4760
|
]);
|
|
4736
4761
|
const handleKeyUp = useCallback((event) => {
|
|
@@ -4756,7 +4781,7 @@ var TextEditor = /* @__PURE__ */ forwardRef(({
|
|
|
4756
4781
|
});
|
|
4757
4782
|
|
|
4758
4783
|
// packages/ui/react-ui-editor/src/components/Toolbar/Toolbar.tsx
|
|
4759
|
-
import { ChatText, Code, CodeBlock, Image, Link, ListBullets, ListChecks, ListNumbers, Paragraph, Quotes, TextStrikethrough, Table as Table2, TextB, TextHOne, TextHTwo, TextHThree, TextHFour, TextHFive, TextHSix, TextItalic, CaretDown, Check } from "@phosphor-icons/react";
|
|
4784
|
+
import { ChatText, Code, CodeBlock, Image, Link, ListBullets, ListChecks, ListNumbers, Paragraph, Quotes, TextStrikethrough, Table as Table2, TextB, TextHOne, TextHTwo, TextHThree, TextHFour, TextHFive, TextHSix, TextItalic, CaretDown, Check, PencilSimpleSlash, MarkdownLogo, PencilSimple } from "@phosphor-icons/react";
|
|
4760
4785
|
import { createContext } from "@radix-ui/react-context";
|
|
4761
4786
|
import React2, { useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
|
|
4762
4787
|
import { useDropzone } from "react-dropzone";
|
|
@@ -4783,9 +4808,12 @@ var ToolbarRoot = ({ children, onAction, classNames, state: state2 }) => {
|
|
|
4783
4808
|
elevation: "chrome"
|
|
4784
4809
|
}, /* @__PURE__ */ React2.createElement(NaturalToolbar.Root, {
|
|
4785
4810
|
classNames: [
|
|
4786
|
-
"is-full shrink-0 overflow-x-auto overflow-y-hidden
|
|
4811
|
+
"p-1 is-full shrink-0 overflow-x-auto overflow-y-hidden",
|
|
4787
4812
|
classNames
|
|
4788
|
-
]
|
|
4813
|
+
],
|
|
4814
|
+
style: {
|
|
4815
|
+
contain: "layout"
|
|
4816
|
+
}
|
|
4789
4817
|
}, children))));
|
|
4790
4818
|
};
|
|
4791
4819
|
var ToolbarToggleButton = ({ Icon, children, ...props }) => {
|
|
@@ -4814,6 +4842,70 @@ var ToolbarButton = ({ Icon, children, ...props }) => {
|
|
|
4814
4842
|
className: "sr-only"
|
|
4815
4843
|
}, children))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, tooltipProps, children, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null))));
|
|
4816
4844
|
};
|
|
4845
|
+
var ViewModeIcons = {
|
|
4846
|
+
preview: PencilSimple,
|
|
4847
|
+
readonly: PencilSimpleSlash,
|
|
4848
|
+
source: MarkdownLogo
|
|
4849
|
+
};
|
|
4850
|
+
var MarkdownView = ({ mode }) => {
|
|
4851
|
+
const { t } = useTranslation(translationKey);
|
|
4852
|
+
const { onAction } = useToolbarContext("ViewMode");
|
|
4853
|
+
const ModeIcon = ViewModeIcons[mode ?? "preview"];
|
|
4854
|
+
const suppressNextTooltip = useRef2(false);
|
|
4855
|
+
const [tooltipOpen, setTooltipOpen] = useState4(false);
|
|
4856
|
+
const [selectOpen, setSelectOpen] = useState4(false);
|
|
4857
|
+
return /* @__PURE__ */ React2.createElement(Tooltip.Root, {
|
|
4858
|
+
open: tooltipOpen,
|
|
4859
|
+
onOpenChange: (nextOpen) => {
|
|
4860
|
+
if (nextOpen && suppressNextTooltip.current) {
|
|
4861
|
+
suppressNextTooltip.current = false;
|
|
4862
|
+
return setTooltipOpen(false);
|
|
4863
|
+
} else {
|
|
4864
|
+
return setTooltipOpen(nextOpen);
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4867
|
+
}, /* @__PURE__ */ React2.createElement(DropdownMenu.Root, {
|
|
4868
|
+
open: selectOpen,
|
|
4869
|
+
onOpenChange: (nextOpen) => {
|
|
4870
|
+
if (!nextOpen) {
|
|
4871
|
+
suppressNextTooltip.current = true;
|
|
4872
|
+
}
|
|
4873
|
+
return setSelectOpen(nextOpen);
|
|
4874
|
+
}
|
|
4875
|
+
}, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
|
|
4876
|
+
asChild: true
|
|
4877
|
+
}, /* @__PURE__ */ React2.createElement(NaturalToolbar.Button, {
|
|
4878
|
+
asChild: true
|
|
4879
|
+
}, /* @__PURE__ */ React2.createElement(DropdownMenu.Trigger, {
|
|
4880
|
+
asChild: true
|
|
4881
|
+
}, /* @__PURE__ */ React2.createElement(Button, {
|
|
4882
|
+
variant: "ghost",
|
|
4883
|
+
classNames: buttonStyles
|
|
4884
|
+
}, /* @__PURE__ */ React2.createElement("span", {
|
|
4885
|
+
className: "sr-only"
|
|
4886
|
+
}, t("mode label")), /* @__PURE__ */ React2.createElement(ModeIcon, {
|
|
4887
|
+
className: iconStyles
|
|
4888
|
+
}), /* @__PURE__ */ React2.createElement(CaretDown, null))))), /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, {
|
|
4889
|
+
classNames: "is-min md:is-min",
|
|
4890
|
+
onCloseAutoFocus: (e) => e.preventDefault()
|
|
4891
|
+
}, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, EditorViewModes.map((value) => {
|
|
4892
|
+
const Icon = ViewModeIcons[value];
|
|
4893
|
+
return /* @__PURE__ */ React2.createElement(DropdownMenu.CheckboxItem, {
|
|
4894
|
+
key: value,
|
|
4895
|
+
checked: value === mode,
|
|
4896
|
+
onClick: () => onAction?.({
|
|
4897
|
+
type: "view-mode",
|
|
4898
|
+
data: value
|
|
4899
|
+
})
|
|
4900
|
+
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
4901
|
+
className: iconStyles
|
|
4902
|
+
}), /* @__PURE__ */ React2.createElement("span", {
|
|
4903
|
+
className: "whitespace-nowrap grow"
|
|
4904
|
+
}, t(`${value} mode label`)), /* @__PURE__ */ React2.createElement(Check, {
|
|
4905
|
+
className: value === mode ? "visible" : "invisible"
|
|
4906
|
+
}));
|
|
4907
|
+
})), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null)))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, tooltipProps, t("view mode label"), /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null))));
|
|
4908
|
+
};
|
|
4817
4909
|
var HeadingIcons = {
|
|
4818
4910
|
"0": Paragraph,
|
|
4819
4911
|
"1": TextHOne,
|
|
@@ -5060,6 +5152,7 @@ var Toolbar = {
|
|
|
5060
5152
|
Root: ToolbarRoot,
|
|
5061
5153
|
Button: ToolbarToggleButton,
|
|
5062
5154
|
Separator: ToolbarSeparator,
|
|
5155
|
+
View: MarkdownView,
|
|
5063
5156
|
Markdown: MarkdownStandard,
|
|
5064
5157
|
Custom: MarkdownCustom,
|
|
5065
5158
|
Actions: MarkdownActions
|
|
@@ -5196,8 +5289,10 @@ var useTextEditor = (cb = () => ({}), deps = []) => {
|
|
|
5196
5289
|
};
|
|
5197
5290
|
export {
|
|
5198
5291
|
Cursor,
|
|
5199
|
-
|
|
5292
|
+
EditorInputModes,
|
|
5293
|
+
EditorViewModes,
|
|
5200
5294
|
Inline,
|
|
5295
|
+
InputModeExtensions,
|
|
5201
5296
|
List,
|
|
5202
5297
|
RemoteSelectionsDecorator,
|
|
5203
5298
|
SpaceAwarenessProvider,
|
|
@@ -5225,6 +5320,7 @@ export {
|
|
|
5225
5320
|
createExternalCommentSync,
|
|
5226
5321
|
createMarkdownExtensions,
|
|
5227
5322
|
createThemeExtensions,
|
|
5323
|
+
debugNodeLogger,
|
|
5228
5324
|
decorateMarkdown,
|
|
5229
5325
|
defaultOptions,
|
|
5230
5326
|
defaultTheme,
|
|
@@ -5232,7 +5328,7 @@ export {
|
|
|
5232
5328
|
dropFile,
|
|
5233
5329
|
editorFillLayoutEditor,
|
|
5234
5330
|
editorFillLayoutRoot,
|
|
5235
|
-
|
|
5331
|
+
editorInputMode,
|
|
5236
5332
|
editorWithToolbarLayout,
|
|
5237
5333
|
focusEvent,
|
|
5238
5334
|
formattingEquals,
|