@dxos/react-ui-editor 0.3.10-main.ee543cf → 0.3.10-next.3e4f36f
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 +735 -731
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/automerge/automerge-plugin/PatchSemaphore.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge-plugin/amToCodemirror.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge-plugin/codeMirrorToAm.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge-plugin/handle.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge-plugin/index.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge-plugin/plugin.d.ts.map +1 -0
- package/dist/types/src/automerge/automerge.stories.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +2 -4
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +4 -9
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/{basic.d.ts → basic/bundle.d.ts} +1 -1
- package/dist/types/src/components/TextEditor/extensions/basic/bundle.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/basic/index.d.ts +3 -0
- package/dist/types/src/components/TextEditor/extensions/basic/index.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/basic/theme.d.ts +10 -0
- package/dist/types/src/components/TextEditor/extensions/basic/theme.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/change.d.ts +7 -0
- package/dist/types/src/components/TextEditor/extensions/change.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkDecoration.d.ts +11 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkDecoration.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkTooltip.d.ts +8 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkTooltip.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/{experimental.d.ts → hyperlink/hyperlinkWidget.d.ts} +2 -2
- package/dist/types/src/components/TextEditor/extensions/hyperlink/hyperlinkWidget.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/index.d.ts +4 -0
- package/dist/types/src/components/TextEditor/extensions/hyperlink/index.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/index.d.ts +2 -5
- package/dist/types/src/components/TextEditor/extensions/index.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/index.d.ts +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/index.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/tags.d.ts +17 -0
- package/dist/types/src/components/TextEditor/extensions/markdown/tags.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/extensions/markdown/theme.d.ts +21 -0
- package/dist/types/src/components/TextEditor/extensions/markdown/theme.d.ts.map +1 -0
- package/dist/types/src/components/TextEditor/index.d.ts +0 -2
- package/dist/types/src/components/TextEditor/index.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts +0 -1
- package/dist/types/src/components/TextEditor/yjs.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useCollaboration.d.ts +9 -0
- package/dist/types/src/hooks/useCollaboration.d.ts.map +1 -0
- package/dist/types/src/hooks/useTextModel.d.ts +4 -4
- package/dist/types/src/hooks/useTextModel.d.ts.map +1 -1
- package/dist/types/src/styles/markdown.d.ts +10 -12
- package/dist/types/src/styles/markdown.d.ts.map +1 -1
- package/package.json +32 -20
- package/src/{hooks/automerge → automerge}/automerge.stories.tsx +1 -2
- package/src/components/TextEditor/TextEditor.stories.tsx +43 -46
- package/src/components/TextEditor/TextEditor.tsx +45 -59
- package/src/components/TextEditor/extensions/{basic.ts → basic/bundle.ts} +2 -4
- package/src/components/TextEditor/extensions/basic/index.ts +6 -0
- package/src/components/TextEditor/extensions/basic/theme.ts +49 -0
- package/src/components/TextEditor/extensions/{listener.ts → change.ts} +3 -3
- package/src/components/TextEditor/extensions/{link.ts → hyperlink/hyperlinkDecoration.ts} +31 -68
- package/src/components/TextEditor/extensions/{tooltip.tsx → hyperlink/hyperlinkTooltip.tsx} +9 -9
- package/src/components/TextEditor/extensions/{experimental.tsx → hyperlink/hyperlinkWidget.tsx} +2 -17
- package/src/components/TextEditor/extensions/hyperlink/index.ts +7 -0
- package/src/components/TextEditor/extensions/index.ts +2 -5
- package/src/components/TextEditor/extensions/markdown/bundle.ts +11 -15
- package/src/components/TextEditor/extensions/markdown/index.ts +1 -1
- package/src/components/TextEditor/extensions/markdown/tags.ts +38 -0
- package/src/components/TextEditor/extensions/markdown/theme.ts +265 -0
- package/src/components/TextEditor/index.ts +0 -3
- package/src/components/TextEditor/yjs.stories.tsx +0 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useCollaboration.ts +45 -0
- package/src/hooks/useTextModel.ts +40 -50
- package/src/styles/markdown.ts +24 -26
- package/src/testing/replicator.ts +2 -2
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts +0 -35
- package/dist/types/src/components/TextEditor/MarkdownEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/autocomplete.d.ts +0 -9
- package/dist/types/src/components/TextEditor/extensions/autocomplete.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/basic.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/experimental.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/link.d.ts +0 -11
- package/dist/types/src/components/TextEditor/extensions/link.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/listener.d.ts +0 -7
- package/dist/types/src/components/TextEditor/extensions/listener.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts +0 -31
- package/dist/types/src/components/TextEditor/extensions/markdown/highlight.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts +0 -5
- package/dist/types/src/components/TextEditor/extensions/tasklist.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/extensions/tooltip.d.ts +0 -12
- package/dist/types/src/components/TextEditor/extensions/tooltip.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/themes/default.d.ts +0 -17
- package/dist/types/src/components/TextEditor/themes/default.d.ts.map +0 -1
- package/dist/types/src/components/TextEditor/themes/index.d.ts +0 -2
- package/dist/types/src/components/TextEditor/themes/index.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/PatchSemaphore.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/amToCodemirror.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/automerge.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/codeMirrorToAm.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/handle.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/index.d.ts.map +0 -1
- package/dist/types/src/hooks/automerge/plugin.d.ts.map +0 -1
- package/src/components/TextEditor/MarkdownEditor.stories.tsx +0 -242
- package/src/components/TextEditor/extensions/autocomplete.ts +0 -72
- package/src/components/TextEditor/extensions/markdown/highlight.ts +0 -166
- package/src/components/TextEditor/extensions/tasklist.ts +0 -113
- package/src/components/TextEditor/themes/default.ts +0 -170
- package/src/components/TextEditor/themes/index.ts +0 -5
- /package/dist/types/src/{hooks/automerge → automerge/automerge-plugin}/PatchSemaphore.d.ts +0 -0
- /package/dist/types/src/{hooks/automerge → automerge/automerge-plugin}/amToCodemirror.d.ts +0 -0
- /package/dist/types/src/{hooks/automerge → automerge/automerge-plugin}/codeMirrorToAm.d.ts +0 -0
- /package/dist/types/src/{hooks/automerge → automerge/automerge-plugin}/handle.d.ts +0 -0
- /package/dist/types/src/{hooks/automerge → automerge/automerge-plugin}/index.d.ts +0 -0
- /package/dist/types/src/{hooks/automerge → automerge/automerge-plugin}/plugin.d.ts +0 -0
- /package/dist/types/src/{hooks/automerge → automerge}/automerge.stories.d.ts +0 -0
- /package/src/{hooks/automerge → automerge/automerge-plugin}/PatchSemaphore.ts +0 -0
- /package/src/{hooks/automerge → automerge/automerge-plugin}/amToCodemirror.ts +0 -0
- /package/src/{hooks/automerge → automerge/automerge-plugin}/codeMirrorToAm.ts +0 -0
- /package/src/{hooks/automerge → automerge/automerge-plugin}/handle.ts +0 -0
- /package/src/{hooks/automerge → automerge/automerge-plugin}/index.ts +0 -0
- /package/src/{hooks/automerge → automerge/automerge-plugin}/plugin.ts +0 -0
package/src/styles/markdown.ts
CHANGED
|
@@ -6,43 +6,41 @@ import { mx } from '@dxos/react-ui-theme';
|
|
|
6
6
|
|
|
7
7
|
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
8
8
|
|
|
9
|
-
// https://tailwindcss.com/docs/font-weight
|
|
10
9
|
export const heading: Record<HeadingLevel, string> = {
|
|
11
|
-
1: 'mbs-4 mbe-2 font-
|
|
12
|
-
2: 'mbs-4 mbe-2 font-
|
|
13
|
-
3: 'mbs-4 mbe-2 font-
|
|
14
|
-
4: 'mbs-4 mbe-2 font-
|
|
15
|
-
5: 'mbs-4 mbe-2 font-
|
|
16
|
-
6: 'mbs-4 mbe-2 font-
|
|
10
|
+
1: 'mbs-4 mbe-2 text-4xl font-semibold text-inherit no-underline',
|
|
11
|
+
2: 'mbs-4 mbe-2 text-3xl font-bold text-inherit no-underline',
|
|
12
|
+
3: 'mbs-4 mbe-2 text-2xl font-bold text-inherit no-underline',
|
|
13
|
+
4: 'mbs-4 mbe-2 text-xl font-extrabold text-inherit no-underline',
|
|
14
|
+
5: 'mbs-4 mbe-2 text-lg font-extrabold text-inherit no-underline',
|
|
15
|
+
6: 'mbs-4 mbe-2 font-black text-inherit no-underline',
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
export const
|
|
20
|
-
export const light = 'text-neutral-200 dark:text-neutral-800';
|
|
18
|
+
export const blockquote = 'mlb-2 border-is-4 border-neutral-500/50 pis-5';
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
// TODO(thure): Tailwind was not seeing `[&>li:before]:content-["•"]` as a utility class, but it would work if instead of `"•"` it was `"X"`… why?
|
|
21
|
+
export const unorderedList =
|
|
22
|
+
'mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[attr(marker)] [&>li:before]:mlb-1 [&>li:before]:mie-2';
|
|
23
|
+
export const orderedList =
|
|
24
|
+
'mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[counters(section,_".")_"._"] [counter-reset:section] [&>li:before]:mlb-1';
|
|
25
|
+
|
|
26
|
+
export const listItem = 'contents before:[counter-increment:section]';
|
|
27
|
+
|
|
28
|
+
export const codeBlock = 'mlb-2 font-mono bg-neutral-500/10 p-3 rounded';
|
|
29
|
+
|
|
30
|
+
export const horizontalRule = 'mlb-4 border-neutral-500/50';
|
|
23
31
|
|
|
24
32
|
export const paragraph = 'mlb-1';
|
|
25
33
|
|
|
26
34
|
export const bold = 'font-bold';
|
|
27
|
-
export const italic = 'italic';
|
|
28
|
-
export const strikethrough = 'line-through';
|
|
29
35
|
|
|
30
|
-
export const code = 'font-mono
|
|
31
|
-
export const codeMark = 'font-mono text-primary-500';
|
|
32
|
-
export const codeBlock = 'mlb-2 font-mono bg-neutral-500/10 p-3 rounded';
|
|
36
|
+
export const code = 'font-mono bg-neutral-500/10 rounded pli-0.5 plb-0.5 -mlb-0.5';
|
|
33
37
|
|
|
34
|
-
export const
|
|
38
|
+
export const placeholder = 'font-mono';
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
export const blockquote = mx('pl-1 mr-1 border-is-4 border-primary-500/70 dark:border-primary-500/30', light);
|
|
40
|
+
export const codeWithoutMarks = mx(code, 'pli-1.5 mli-0.5');
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
export const horizontalRule = 'flex mlb-4 border-b text-neutral-100 dark:text-neutral-900 border-neutral-500/50';
|
|
42
|
+
export const italic = 'italic';
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
export const unorderedList =
|
|
44
|
-
'mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[attr(marker)] [&>li:before]:mlb-1 [&>li:before]:mie-2';
|
|
45
|
-
export const orderedList =
|
|
46
|
-
'mlb-2 grid grid-cols-[min-content_1fr] [&>li:before]:content-[counters(section,_".")_"._"] [counter-reset:section] [&>li:before]:mlb-1';
|
|
44
|
+
export const strikethrough = 'line-through';
|
|
47
45
|
|
|
48
|
-
export const
|
|
46
|
+
export const mark = '!font-normal !no-underline !text-inherit opacity-40';
|
|
@@ -163,11 +163,11 @@ export class Replicator {
|
|
|
163
163
|
colorLight: cursorColor.light,
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
+
// TODO(burdon): Create concrete class that implements SyncModel?
|
|
166
167
|
const model: EditorModel = {
|
|
167
168
|
id: doc.guid,
|
|
168
169
|
content: this._kind === TextKind.PLAIN ? doc.getText('content') : doc.getXmlFragment('content'),
|
|
169
|
-
|
|
170
|
-
awareness: provider.awareness,
|
|
170
|
+
provider,
|
|
171
171
|
peer: { id },
|
|
172
172
|
};
|
|
173
173
|
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import '@dxosTheme';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { type TextEditorProps, type TextEditorRef } from './TextEditor';
|
|
4
|
-
declare const _default: {
|
|
5
|
-
title: string;
|
|
6
|
-
component: React.ForwardRefExoticComponent<TextEditorProps & React.RefAttributes<TextEditorRef>>;
|
|
7
|
-
decorators: import("@storybook/react").Decorator[];
|
|
8
|
-
render: ({ text, automerge, ...props }: {
|
|
9
|
-
text?: string | undefined;
|
|
10
|
-
automerge?: boolean | undefined;
|
|
11
|
-
} & Pick<TextEditorProps, "extensions" | "slots">) => JSX.Element | null;
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
14
|
-
export declare const Default: {
|
|
15
|
-
render: () => JSX.Element;
|
|
16
|
-
};
|
|
17
|
-
export declare const Simple: {
|
|
18
|
-
render: () => JSX.Element;
|
|
19
|
-
};
|
|
20
|
-
export declare const Tooltips: {
|
|
21
|
-
render: () => JSX.Element;
|
|
22
|
-
};
|
|
23
|
-
export declare const Links: {
|
|
24
|
-
render: () => JSX.Element;
|
|
25
|
-
};
|
|
26
|
-
export declare const TaskList: {
|
|
27
|
-
render: () => JSX.Element;
|
|
28
|
-
};
|
|
29
|
-
export declare const Autocomplete: {
|
|
30
|
-
render: () => JSX.Element;
|
|
31
|
-
};
|
|
32
|
-
export declare const Diagnostics: {
|
|
33
|
-
render: () => JSX.Element;
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=MarkdownEditor.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEditor.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/TextEditor/MarkdownEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAIpB,OAAO,KAAuC,MAAM,OAAO,CAAC;AAO5D,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;;;;;;;;;;AAuJxF,wBAKE;AAEF,eAAO,MAAM,OAAO;;CAcnB,CAAC;AAEF,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAEF,eAAO,MAAM,KAAK;;CAEjB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAYpB,CAAC;AAEF,eAAO,MAAM,YAAY;;CAYxB,CAAC;AAEF,eAAO,MAAM,WAAW;;CAYvB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Completion } from '@codemirror/autocomplete';
|
|
2
|
-
export type AutocompleteOptions = {
|
|
3
|
-
getOptions: (text: string) => Completion[];
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Autocomplete extension.
|
|
7
|
-
*/
|
|
8
|
-
export declare const autocomplete: ({ getOptions }: AutocompleteOptions) => import("@codemirror/state").Extension[];
|
|
9
|
-
//# sourceMappingURL=autocomplete.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/autocomplete.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEL,KAAK,UAAU,EAIhB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;CAC5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,mBAAoB,mBAAmB,4CAuC/D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/basic.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,WAAW,6CAA8C,kBAAkB,KAAG,SAAS,EAYlE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/experimental.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAEL,KAAK,aAAa,EAElB,cAAc,EACd,UAAU,EACV,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAsE1B,wBAAgB,kBAAkB;wBAGR,cAAc;;mBAOnB,UAAU;GAwB9B;AAED,eAAO,MAAM,MAAM,WAYjB,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,SAA0C,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Extension } from '@codemirror/state';
|
|
2
|
-
export type LinkOptions = {
|
|
3
|
-
link?: boolean;
|
|
4
|
-
onRender?: (el: Element, url: string) => void;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Creates a state field to replace AST elements with a hyperlink widget.
|
|
8
|
-
* https://codemirror.net/docs/ref/#state.StateField
|
|
9
|
-
*/
|
|
10
|
-
export declare const link: (options?: LinkOptions) => Extension;
|
|
11
|
-
//# sourceMappingURL=link.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/link.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,mBAAmB,CAAC;AA2G3B,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,IAAI,aAAa,WAAW,KAAQ,SAMhD,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { StateField } from '@codemirror/state';
|
|
2
|
-
export type TextListener = (text: string) => void;
|
|
3
|
-
/**
|
|
4
|
-
* Based on https://github.com/codemirror/dev/issues/44#issuecomment-789093799
|
|
5
|
-
*/
|
|
6
|
-
export declare const listener: (onChange: TextListener) => StateField<null>;
|
|
7
|
-
//# sourceMappingURL=listener.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/listener.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,QAAQ,aAAc,YAAY,qBAU3C,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { HighlightStyle } from '@codemirror/language';
|
|
2
|
-
import { Tag } from '@lezer/highlight';
|
|
3
|
-
import { type MarkdownConfig } from '@lezer/markdown';
|
|
4
|
-
/**
|
|
5
|
-
* Custom tags defined and processed by the GFM lezer extension.
|
|
6
|
-
* https://github.com/lezer-parser/markdown
|
|
7
|
-
* https://github.com/lezer-parser/markdown/blob/main/src/markdown.ts
|
|
8
|
-
*/
|
|
9
|
-
export declare const markdownTags: {
|
|
10
|
-
Blockquote: Tag;
|
|
11
|
-
CodeMark: Tag;
|
|
12
|
-
CodeText: Tag;
|
|
13
|
-
EmphasisMark: Tag;
|
|
14
|
-
HeaderMark: Tag;
|
|
15
|
-
HorizontalRule: Tag;
|
|
16
|
-
InlineCode: Tag;
|
|
17
|
-
LinkLabel: Tag;
|
|
18
|
-
LinkReference: Tag;
|
|
19
|
-
ListMark: Tag;
|
|
20
|
-
QuoteMark: Tag;
|
|
21
|
-
URL: Tag;
|
|
22
|
-
};
|
|
23
|
-
export declare const markdownTagsExtension: MarkdownConfig;
|
|
24
|
-
/**
|
|
25
|
-
* Styling based on `lezer` parser tags.
|
|
26
|
-
* https://codemirror.net/examples/styling
|
|
27
|
-
* https://github.com/lezer-parser/highlight
|
|
28
|
-
* https://lezer.codemirror.net/docs/ref/#highlight (list of tags)
|
|
29
|
-
*/
|
|
30
|
-
export declare const markdownHighlightStyle: HighlightStyle;
|
|
31
|
-
//# sourceMappingURL=highlight.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/TextEditor/extensions/markdown/highlight.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAmB,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAiBtD;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;CAaxB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,cAEnC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,gBA+GlC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tasklist.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/tasklist.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,mBAAmB,CAAC;AAyD3B,eAAO,MAAM,UAAU,QAAO,SAkC7B,CAAC;AAGF,eAAO,MAAM,MAAM,WAIjB,CAAC;AAEH,eAAO,MAAM,QAAQ,mBAA+B,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Extension } from '@codemirror/state';
|
|
2
|
-
export type TooltipOptions = {
|
|
3
|
-
onHover: (el: Element, url: string) => void;
|
|
4
|
-
regexp?: RegExp;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* https://codemirror.net/examples/tooltip
|
|
8
|
-
* https://codemirror.net/docs/ref/#view.hoverTooltip
|
|
9
|
-
* https://github.com/codemirror/view/blob/main/src/tooltip.ts
|
|
10
|
-
*/
|
|
11
|
-
export declare const tooltip: ({ onHover, regexp }: TooltipOptions) => Extension;
|
|
12
|
-
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/extensions/tooltip.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOnD,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,wBAA8C,cAAc,KAAG,SAuC/E,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type StyleSpec } from 'style-mod';
|
|
2
|
-
/**
|
|
3
|
-
* Minimal styles.
|
|
4
|
-
* https://codemirror.net/examples/styling
|
|
5
|
-
* NOTE: Use one of '&', '&light', and '&dark' prefix to scope instance.
|
|
6
|
-
* NOTE: `light` and `dark` selectors are preprocessed by CodeMirror and can only be in the base theme.
|
|
7
|
-
*/
|
|
8
|
-
export declare const defaultTheme: {
|
|
9
|
-
[selector: string]: StyleSpec;
|
|
10
|
-
};
|
|
11
|
-
export declare const textTheme: {
|
|
12
|
-
[selector: string]: StyleSpec;
|
|
13
|
-
};
|
|
14
|
-
export declare const codeTheme: {
|
|
15
|
-
[selector: string]: StyleSpec;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=default.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/themes/default.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAI3C;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE;IACzB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAyI/B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE;IACtB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAK/B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE;IACtB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAK/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TextEditor/themes/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PatchSemaphore.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/PatchSemaphore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAI9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAA8E,MAAM,UAAU,CAAC;AAElH,KAAK,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/B,KAAK,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;AAE7B,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,KAAK,GAAG,SAAS,CAAC;AAE3F,qBAAa,cAAc;IACzB,MAAM,EAAG,KAAK,CAAC;IACf,YAAY,UAAS;IACrB,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAM;gBAEjB,KAAK,CAAC,EAAE,KAAK;IAMzB,SAAS,WAAY,UAAU,QAAQ,UAAU,UA2C/C;CACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"amToCodemirror.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/amToCodemirror.ts"],"names":[],"mappings":"AAIA,OAAO,EAA8B,KAAK,eAAe,EAAoB,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,IAAI,EAGV,MAAM,2BAA2B,CAAC;+BAIb,UAAU,aAAa,eAAe,UAAU,IAAI,EAAE,WAAW,KAAK,EAAE;AAA9F,wBAgBE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"automerge.stories.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/automerge.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,uBAAuB,CAAC;;;;AA+E/B,wBAEE;AAEF,eAAO,MAAM,aAAa;;CAEzB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codeMirrorToAm.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/codeMirrorToAm.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAa,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElF,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;+CAI5B,UAAU,gBACJ,WAAW,EAAE,SACpB,WAAW,KACjB,KAAK,GAAG,SAAS;AALpB,wBA6BE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/handle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,CAAC,MAAM,2BAA2B,CAAC;AAEpD,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,GAAG,IAAI;IAChC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACpE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IAEtG,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACzD,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAC7D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/automerge/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EAEd,WAAW,EACX,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,KAAK,CAAC;IACjB,IAAI,EAAE,IAAI,EAAE,CAAC;IACb,wBAAwB,EAAE,WAAW,EAAE,CAAC;CACzC,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,UAAU,0DAAsC,CAAC;AAE9D,eAAO,MAAM,WAAW,sCAAsB,YAAY,WAAW,CAAgC,CAAC;AAEtG,eAAO,MAAM,YAAY,UAAW,WAAW,uCAAsD,CAAC;AAEtG,eAAO,MAAM,OAAO,UAAW,WAAW,mBAAiB,IAAI,EAA6B,CAAC;AAE7F,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;AAMtC,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,UAAU,QAAQ,IAAI,EAAE,KAAG,eA8DlE,CAAC;AAEF,eAAO,MAAM,uBAAuB,qDAA+B,CAAC;AAEpE,eAAO,MAAM,aAAa,OAAQ,WAAW,KAAG,OAAmD,CAAC;AAEpG,eAAO,MAAM,aAAa,OAAQ,eAAe,SAchD,CAAC"}
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxosTheme';
|
|
6
|
-
import { EditorView } from '@codemirror/view';
|
|
7
|
-
import { faker } from '@faker-js/faker';
|
|
8
|
-
import { ArrowSquareOut } from '@phosphor-icons/react';
|
|
9
|
-
import React, { StrictMode, useRef, useState } from 'react';
|
|
10
|
-
import { createRoot } from 'react-dom/client';
|
|
11
|
-
|
|
12
|
-
import { TextObject } from '@dxos/echo-schema';
|
|
13
|
-
import { fixedInsetFlexLayout, getSize, groupSurface, mx } from '@dxos/react-ui-theme';
|
|
14
|
-
import { withTheme } from '@dxos/storybook-utils';
|
|
15
|
-
|
|
16
|
-
import { MarkdownEditor, type TextEditorProps, type TextEditorRef } from './TextEditor';
|
|
17
|
-
import { autocomplete, listener, link, tasklist, tooltip, type TooltipOptions, type LinkOptions } from './extensions';
|
|
18
|
-
import { useTextModel } from '../../hooks';
|
|
19
|
-
|
|
20
|
-
// TODO(burdon): Read-only render mode (presentation).
|
|
21
|
-
// TODO(burdon): Slides.
|
|
22
|
-
// TODO(burdon): Autocomplete.
|
|
23
|
-
// TODO(burdon): Block quote.
|
|
24
|
-
// TODO(burdon): Images.
|
|
25
|
-
// TODO(burdon): Tables.
|
|
26
|
-
|
|
27
|
-
const str = (...lines: string[]) => lines.join('\n');
|
|
28
|
-
|
|
29
|
-
// prettier-ignore
|
|
30
|
-
const text = {
|
|
31
|
-
tasks: str(
|
|
32
|
-
'## Tasks',
|
|
33
|
-
'',
|
|
34
|
-
'- [x] parsing',
|
|
35
|
-
'- [ ] styling',
|
|
36
|
-
'- [ ] rendering',
|
|
37
|
-
),
|
|
38
|
-
|
|
39
|
-
list: str(
|
|
40
|
-
'## List',
|
|
41
|
-
'',
|
|
42
|
-
'- new york',
|
|
43
|
-
'- london',
|
|
44
|
-
'- tokyo',
|
|
45
|
-
),
|
|
46
|
-
|
|
47
|
-
numbered: str(
|
|
48
|
-
'## Numbered',
|
|
49
|
-
'',
|
|
50
|
-
'1. one',
|
|
51
|
-
'2. two',
|
|
52
|
-
'3. three',
|
|
53
|
-
''
|
|
54
|
-
),
|
|
55
|
-
|
|
56
|
-
code: str(
|
|
57
|
-
'## Code',
|
|
58
|
-
'',
|
|
59
|
-
'```',
|
|
60
|
-
'const x = 100;',
|
|
61
|
-
'```',
|
|
62
|
-
'',
|
|
63
|
-
'```tsx',
|
|
64
|
-
'const Component = () => {',
|
|
65
|
-
' const x = 100;',
|
|
66
|
-
' return () => <div>Test</div>;',
|
|
67
|
-
'};',
|
|
68
|
-
'```'
|
|
69
|
-
),
|
|
70
|
-
|
|
71
|
-
links: str(
|
|
72
|
-
'## Links',
|
|
73
|
-
'',
|
|
74
|
-
'This is a naked link https://dxos.org within a sentence.',
|
|
75
|
-
'',
|
|
76
|
-
'Take a look at [DXOS](https://dxos.org) and how to [get started](https://docs.dxos.org/guide/getting-started.html).',
|
|
77
|
-
'',
|
|
78
|
-
),
|
|
79
|
-
|
|
80
|
-
headings: str(
|
|
81
|
-
...[1, 2, 3, 4, 5, 6].map((level) => ['#'.repeat(level) + ` Heading ${level}`, faker.lorem.sentences(), '']).flat(),
|
|
82
|
-
),
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const document = str(
|
|
86
|
-
'# Markdown',
|
|
87
|
-
'',
|
|
88
|
-
'> This is a block quote.',
|
|
89
|
-
'',
|
|
90
|
-
'This is all about https://dxos.org and related technologies.',
|
|
91
|
-
'',
|
|
92
|
-
'This this is **bold**, __underlined__, _italic_, and `f(INLINE)`.',
|
|
93
|
-
'',
|
|
94
|
-
'__NOTE__: Fenced code uses the base font.',
|
|
95
|
-
'',
|
|
96
|
-
'---',
|
|
97
|
-
text.links,
|
|
98
|
-
'---',
|
|
99
|
-
text.list,
|
|
100
|
-
'---',
|
|
101
|
-
text.tasks,
|
|
102
|
-
'---',
|
|
103
|
-
text.numbered,
|
|
104
|
-
'---',
|
|
105
|
-
text.code,
|
|
106
|
-
'---',
|
|
107
|
-
text.headings,
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const links = [
|
|
111
|
-
{ label: 'DXOS', apply: '[DXOS](https://dxos.org)' },
|
|
112
|
-
{ label: 'GitHub', apply: '[DXOS GitHub](https://github.com/dxos)' },
|
|
113
|
-
{ label: 'Automerge', apply: '[Automerge](https://automerge.org/)' },
|
|
114
|
-
{ label: 'IPFS', apply: '[Protocol Labs](https://docs.ipfs.tech)' },
|
|
115
|
-
{ label: 'StackEdit', apply: '[StackEdit](https://stackedit.io/app)' },
|
|
116
|
-
];
|
|
117
|
-
|
|
118
|
-
const hover =
|
|
119
|
-
'rounded-sm text-base text-primary-600 hover:text-primary-500 dark:text-primary-300 hover:dark:text-primary-200';
|
|
120
|
-
|
|
121
|
-
const onHover: TooltipOptions['onHover'] = (el, url) => {
|
|
122
|
-
const web = new URL(url);
|
|
123
|
-
createRoot(el).render(
|
|
124
|
-
<StrictMode>
|
|
125
|
-
<a href={url} target='_blank' rel='noreferrer' className={hover}>
|
|
126
|
-
{web.origin}
|
|
127
|
-
<ArrowSquareOut weight='bold' className={mx(getSize(4), 'inline-block leading-none mis-1')} />
|
|
128
|
-
</a>
|
|
129
|
-
</StrictMode>,
|
|
130
|
-
);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const onRender: LinkOptions['onRender'] = (el, url) => {
|
|
134
|
-
createRoot(el).render(
|
|
135
|
-
<StrictMode>
|
|
136
|
-
<a href={url} target='_blank' rel='noreferrer' className={hover}>
|
|
137
|
-
<ArrowSquareOut weight='bold' className={mx(getSize(4), 'inline-block leading-none mis-1 mb-1')} />
|
|
138
|
-
</a>
|
|
139
|
-
</StrictMode>,
|
|
140
|
-
);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const Story = ({
|
|
144
|
-
text,
|
|
145
|
-
automerge,
|
|
146
|
-
...props
|
|
147
|
-
}: { text?: string; automerge?: boolean } & Pick<TextEditorProps, 'extensions' | 'slots'>) => {
|
|
148
|
-
const ref = useRef<TextEditorRef>(null);
|
|
149
|
-
const [item] = useState({ text: new TextObject(text, undefined, undefined, { useAutomergeBackend: automerge }) });
|
|
150
|
-
const model = useTextModel({ text: item.text });
|
|
151
|
-
if (!model) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<div className={mx(fixedInsetFlexLayout, groupSurface)}>
|
|
157
|
-
<div className='flex justify-center overflow-y-scroll'>
|
|
158
|
-
<div className='flex flex-col w-[800px] py-16'>
|
|
159
|
-
<MarkdownEditor ref={ref} model={model} {...props} />
|
|
160
|
-
<div className='flex shrink-0 h-[300px]'></div>
|
|
161
|
-
</div>
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export default {
|
|
168
|
-
title: 'react-ui-editor/MarkdownEditor',
|
|
169
|
-
component: MarkdownEditor,
|
|
170
|
-
decorators: [withTheme],
|
|
171
|
-
render: Story,
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
export const Default = {
|
|
175
|
-
render: () => (
|
|
176
|
-
<Story
|
|
177
|
-
text={document}
|
|
178
|
-
extensions={[
|
|
179
|
-
link({ onRender }),
|
|
180
|
-
tooltip({ onHover }),
|
|
181
|
-
tasklist(),
|
|
182
|
-
autocomplete({
|
|
183
|
-
getOptions: (text) => links.filter(({ label }) => label.toLowerCase().includes(text.toLowerCase())),
|
|
184
|
-
}),
|
|
185
|
-
]}
|
|
186
|
-
/>
|
|
187
|
-
),
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export const Simple = {
|
|
191
|
-
render: () => <Story text={document} />,
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
export const Tooltips = {
|
|
195
|
-
render: () => <Story text={text.links} extensions={[tooltip({ onHover })]} />,
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export const Links = {
|
|
199
|
-
render: () => <Story text={text.links} extensions={[link({ onRender })]} />,
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
export const TaskList = {
|
|
203
|
-
render: () => (
|
|
204
|
-
<Story
|
|
205
|
-
text={str(text.tasks, '', text.list)}
|
|
206
|
-
extensions={[
|
|
207
|
-
tasklist(),
|
|
208
|
-
listener((text) => {
|
|
209
|
-
console.log(text);
|
|
210
|
-
}),
|
|
211
|
-
]}
|
|
212
|
-
/>
|
|
213
|
-
),
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export const Autocomplete = {
|
|
217
|
-
render: () => (
|
|
218
|
-
<Story
|
|
219
|
-
text={str('# Autocomplete', '', '', '', '', '', '')}
|
|
220
|
-
extensions={[
|
|
221
|
-
link({ onRender }),
|
|
222
|
-
autocomplete({
|
|
223
|
-
getOptions: (text) => links.filter(({ label }) => label.toLowerCase().includes(text.toLowerCase())),
|
|
224
|
-
}),
|
|
225
|
-
]}
|
|
226
|
-
/>
|
|
227
|
-
),
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export const Diagnostics = {
|
|
231
|
-
render: () => (
|
|
232
|
-
<Story
|
|
233
|
-
text={document}
|
|
234
|
-
extensions={[
|
|
235
|
-
// Cursor moved.
|
|
236
|
-
EditorView.updateListener.of((update) => {
|
|
237
|
-
console.log('update', update.view.state.selection.main.head);
|
|
238
|
-
}),
|
|
239
|
-
]}
|
|
240
|
-
/>
|
|
241
|
-
),
|
|
242
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// TODO(burdon): Automcomplete: https://codemirror.net/5/doc/manual.html#addon_runmode
|
|
6
|
-
// TODO(burdon): Modes: parallel parsing and decoration (e.g., associated with language).
|
|
7
|
-
// TODO(burdon): Add-on: runmode: run lexer over content (with rendering codemirror).
|
|
8
|
-
// https://codemirror.net/5/doc/manual.html#addon_runmode
|
|
9
|
-
// TODO(burdon): Add-on: dialog.
|
|
10
|
-
// TODO(burdon): Comments: https://codemirror.net/5/doc/manual.html#setBookmark
|
|
11
|
-
// TODO(burdon): Split view: https://codemirror.net/examples/split
|
|
12
|
-
|
|
13
|
-
// https://codemirror.net/examples/autocompletion
|
|
14
|
-
// https://codemirror.net/docs/ref/#autocomplete.autocompletion
|
|
15
|
-
// https://codemirror.net/docs/ref/#autocomplete.Completion
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
autocompletion,
|
|
19
|
-
type Completion,
|
|
20
|
-
type CompletionContext,
|
|
21
|
-
completionKeymap,
|
|
22
|
-
type CompletionResult,
|
|
23
|
-
} from '@codemirror/autocomplete';
|
|
24
|
-
import { keymap } from '@codemirror/view';
|
|
25
|
-
|
|
26
|
-
export type AutocompleteOptions = {
|
|
27
|
-
getOptions: (text: string) => Completion[];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Autocomplete extension.
|
|
32
|
-
*/
|
|
33
|
-
export const autocomplete = ({ getOptions }: AutocompleteOptions) => {
|
|
34
|
-
return [
|
|
35
|
-
// https://codemirror.net/docs/ref/#view.keymap
|
|
36
|
-
// https://discuss.codemirror.net/t/how-can-i-replace-the-default-autocompletion-keymap-v6/3322
|
|
37
|
-
keymap.of(completionKeymap),
|
|
38
|
-
|
|
39
|
-
// https://codemirror.net/examples/autocompletion
|
|
40
|
-
// https://codemirror.net/docs/ref/#autocomplete.autocompletion
|
|
41
|
-
autocompletion({
|
|
42
|
-
// TODO(burdon): Set custom keymap.
|
|
43
|
-
// defaultKeymap: false,
|
|
44
|
-
|
|
45
|
-
// Don't start unless key press.
|
|
46
|
-
activateOnTyping: false,
|
|
47
|
-
|
|
48
|
-
// TODO(burdon): Option to create new page?
|
|
49
|
-
// TODO(burdon): Optional decoration via addToOptions
|
|
50
|
-
override: [
|
|
51
|
-
(context: CompletionContext): CompletionResult | null => {
|
|
52
|
-
const word = context.matchBefore(/\w*/);
|
|
53
|
-
if (!word || (word.from === word.to && !context.explicit)) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// TODO(burdon): Option to convert to links?
|
|
58
|
-
return {
|
|
59
|
-
from: word.from,
|
|
60
|
-
options: getOptions(word.text.toLowerCase()),
|
|
61
|
-
// options: [
|
|
62
|
-
// { label: 'apple', type: 'keyword' },
|
|
63
|
-
// { label: 'amazon', type: 'keyword' },
|
|
64
|
-
// { label: 'hello', type: 'variable', info: '(World)' },
|
|
65
|
-
// { label: 'magic', type: 'text', apply: '⠁⭒*.✩.*⭒⠁', detail: 'macro' },
|
|
66
|
-
// ],
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
}),
|
|
71
|
-
];
|
|
72
|
-
};
|