@dxos/react-ui-editor 0.8.2 → 0.8.3-main.672df60
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 +159 -105
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +172 -119
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +159 -105
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/extensions/command/menu.d.ts.map +1 -1
- package/dist/types/src/extensions/hashtag.d.ts +3 -0
- package/dist/types/src/extensions/hashtag.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/json.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/debug.d.ts +2 -2
- package/dist/types/src/extensions/markdown/debug.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts +1 -3
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
- package/dist/types/src/stories/Command.stories.d.ts +1 -1
- package/dist/types/src/stories/Command.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts +1 -1
- package/dist/types/src/stories/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts +1 -1
- package/dist/types/src/stories/Experimental.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts +1 -1
- package/dist/types/src/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Outliner.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts +1 -1
- package/dist/types/src/stories/Preview.stories.d.ts.map +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts +1 -1
- package/dist/types/src/stories/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/EditorStory.d.ts +43 -0
- package/dist/types/src/stories/components/EditorStory.d.ts.map +1 -0
- package/dist/types/src/stories/components/index.d.ts +3 -0
- package/dist/types/src/stories/components/index.d.ts.map +1 -0
- package/dist/types/src/stories/{util.d.ts → components/util.d.ts} +3 -18
- package/dist/types/src/stories/components/util.d.ts.map +1 -0
- package/package.json +28 -27
- package/src/extensions/command/menu.ts +31 -22
- package/src/extensions/hashtag.tsx +68 -0
- package/src/extensions/index.ts +1 -0
- package/src/extensions/json.ts +2 -1
- package/src/extensions/markdown/debug.ts +2 -2
- package/src/extensions/outliner/outliner.ts +9 -8
- package/src/stories/Command.stories.tsx +1 -1
- package/src/stories/Comments.stories.tsx +2 -2
- package/src/stories/Experimental.stories.tsx +2 -2
- package/src/stories/Markdown.stories.tsx +2 -2
- package/src/stories/Outliner.stories.tsx +19 -7
- package/src/stories/Preview.stories.tsx +2 -2
- package/src/stories/TextEditor.stories.tsx +3 -3
- package/src/stories/components/EditorStory.tsx +135 -0
- package/src/stories/components/index.ts +6 -0
- package/src/stories/{util.tsx → components/util.tsx} +5 -100
- package/dist/types/src/stories/util.d.ts.map +0 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
import '@dxos-theme';
|
2
2
|
import React from 'react';
|
3
3
|
import { type Meta } from '@dxos/storybook-utils';
|
4
|
-
import { EditorStory } from './
|
4
|
+
import { EditorStory } from './components';
|
5
5
|
declare const meta: Meta<typeof EditorStory>;
|
6
6
|
export default meta;
|
7
7
|
export declare const Typewriter: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Experimental.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Experimental.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAW,MAAM,
|
1
|
+
{"version":3,"file":"Experimental.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Experimental.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAW,MAAM,cAAc,CAAC;AAIpD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,CAKlC,CAAC;AAEF,eAAe,IAAI,CAAC;AAQpB,eAAO,MAAM,UAAU;;CAOtB,CAAC;AAMF,eAAO,MAAM,KAAK;;CAqBjB,CAAC;AAMF,eAAO,MAAM,GAAG;;CAaf,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import '@dxos-theme';
|
2
2
|
import React from 'react';
|
3
3
|
import { type Meta } from '@dxos/storybook-utils';
|
4
|
-
import { EditorStory } from './
|
4
|
+
import { EditorStory } from './components';
|
5
5
|
declare const meta: Meta<typeof EditorStory>;
|
6
6
|
export default meta;
|
7
7
|
export declare const Default: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Markdown.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Markdown.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAiE,MAAM,
|
1
|
+
{"version":3,"file":"Markdown.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Markdown.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAiE,MAAM,cAAc,CAAC;AAI1G,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,CAKlC,CAAC;AAEF,eAAe,IAAI,CAAC;AAMpB,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAEF,eAAO,MAAM,UAAU;;CAQtB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAEF,eAAO,MAAM,KAAK;;CAEjB,CAAC;AAEF,eAAO,MAAM,KAAK;;CAEjB,CAAC;AAEF,eAAO,MAAM,IAAI;;CAEhB,CAAC;AAEF,eAAO,MAAM,KAAK;;CAOjB,CAAC;AAMF,eAAO,MAAM,UAAU;;CAEtB,CAAC;AAMF,eAAO,MAAM,WAAW;;CAEvB,CAAC;AAMF,eAAO,MAAM,QAAQ;;CAIpB,CAAC;AAEF,eAAO,MAAM,aAAa;;CAEzB,CAAC;AAMF,eAAO,MAAM,KAAK;;CAEjB,CAAC;AAMF,eAAO,MAAM,YAAY;;CAWxB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Outliner.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Outliner.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;
|
1
|
+
{"version":3,"file":"Outliner.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Outliner.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAOrB,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAOzE,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAwCF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAAU,CAK1B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,KAAK;;CAEjB,CAAC;AAEF,eAAO,MAAM,KAAK;;;;CAajB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;CAalB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;CAgBxB,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import '@dxos-theme';
|
2
2
|
import React from 'react';
|
3
3
|
import { type Meta } from '@dxos/storybook-utils';
|
4
|
-
import { EditorStory } from './
|
4
|
+
import { EditorStory } from './components';
|
5
5
|
declare const meta: Meta<typeof EditorStory>;
|
6
6
|
export default meta;
|
7
7
|
export declare const Default: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Preview.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Preview.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAuC,MAAM,OAAO,CAAC;AAK5D,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"Preview.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Preview.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAuC,MAAM,OAAO,CAAC;AAK5D,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA+F3C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,CAKlC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO;;CA+BnB,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import '@dxos-theme';
|
2
2
|
import React from 'react';
|
3
3
|
import { type Meta } from '@dxos/storybook-utils';
|
4
|
-
import { EditorStory } from './
|
4
|
+
import { EditorStory } from './components';
|
5
5
|
declare const meta: Meta<typeof EditorStory>;
|
6
6
|
export default meta;
|
7
7
|
export declare const Default: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextEditor.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/TextEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAIrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EACL,WAAW,EAWZ,MAAM,
|
1
|
+
{"version":3,"file":"TextEditor.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/TextEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAIrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EACL,WAAW,EAWZ,MAAM,cAAc,CAAC;AAgBtB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,WAAW,CAKlC,CAAC;AAEF,eAAe,IAAI,CAAC;AAMpB,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAMF,eAAO,MAAM,UAAU;;CAEtB,CAAC;AAMF,eAAO,MAAM,KAAK;;CAEjB,CAAC;AAMF,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAMF,eAAO,MAAM,YAAY;;CAExB,CAAC;AAMF,eAAO,MAAM,GAAG;;CAOf,CAAC;AAMF,eAAO,MAAM,QAAQ;;CAgBpB,CAAC;AAMF,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAMF,eAAO,MAAM,SAAS;;CAUrB,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAI/B,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAepB,CAAC;AAMF,eAAO,MAAM,UAAU;;CAQtB,CAAC;AAMF,eAAO,MAAM,YAAY;;CAcxB,CAAC;AAQF,eAAO,MAAM,SAAS;;CAYrB,CAAC;AAMF,eAAO,MAAM,OAAO;;CAWnB,CAAC;AAMF,eAAO,MAAM,MAAM;;CAQlB,CAAC"}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { type EditorView } from '@codemirror/view';
|
2
|
+
import React, { type ReactNode } from 'react';
|
3
|
+
import { Expando } from '@dxos/echo-schema';
|
4
|
+
import { type ThemeExtensionsOptions } from '../../extensions';
|
5
|
+
import { type UseTextEditorProps } from '../../hooks';
|
6
|
+
export type DebugMode = 'raw' | 'tree' | 'raw+tree';
|
7
|
+
export type StoryProps = Pick<UseTextEditorProps, 'scrollTo' | 'selection' | 'extensions'> & Pick<ThemeExtensionsOptions, 'slots'> & {
|
8
|
+
id?: string;
|
9
|
+
debug?: DebugMode;
|
10
|
+
debugCustom?: (view: EditorView) => ReactNode;
|
11
|
+
text?: string;
|
12
|
+
object?: Expando;
|
13
|
+
readOnly?: boolean;
|
14
|
+
placeholder?: string;
|
15
|
+
lineNumbers?: boolean;
|
16
|
+
onReady?: (view: EditorView) => void;
|
17
|
+
};
|
18
|
+
export declare const EditorStory: React.ForwardRefExoticComponent<Pick<UseTextEditorProps, "selection" | "scrollTo" | "extensions"> & Pick<ThemeExtensionsOptions, "slots"> & {
|
19
|
+
id?: string;
|
20
|
+
debug?: DebugMode;
|
21
|
+
debugCustom?: (view: EditorView) => ReactNode;
|
22
|
+
text?: string;
|
23
|
+
object?: Expando;
|
24
|
+
readOnly?: boolean;
|
25
|
+
placeholder?: string;
|
26
|
+
lineNumbers?: boolean;
|
27
|
+
onReady?: (view: EditorView) => void;
|
28
|
+
} & React.RefAttributes<EditorView | undefined>>;
|
29
|
+
/**
|
30
|
+
* Default story component.
|
31
|
+
*/
|
32
|
+
export declare const EditorComponent: React.ForwardRefExoticComponent<Pick<UseTextEditorProps, "selection" | "scrollTo" | "extensions"> & Pick<ThemeExtensionsOptions, "slots"> & {
|
33
|
+
id?: string;
|
34
|
+
debug?: DebugMode;
|
35
|
+
debugCustom?: (view: EditorView) => ReactNode;
|
36
|
+
text?: string;
|
37
|
+
object?: Expando;
|
38
|
+
readOnly?: boolean;
|
39
|
+
placeholder?: string;
|
40
|
+
lineNumbers?: boolean;
|
41
|
+
onReady?: (view: EditorView) => void;
|
42
|
+
} & React.RefAttributes<EditorView | undefined>>;
|
43
|
+
//# sourceMappingURL=EditorStory.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"EditorStory.d.ts","sourceRoot":"","sources":["../../../../../src/stories/components/EditorStory.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAiE,MAAM,OAAO,CAAC;AAE7G,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAY5C,OAAO,EAEL,KAAK,sBAAsB,EAM5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGrE,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC;AAIpD,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC,GACxF,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,GAAG;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,SAAS,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACtC,CAAC;AAEJ,eAAO,MAAM,WAAW;SAXf,MAAM;YACH,SAAS;kBACH,CAAC,IAAI,EAAE,UAAU,KAAK,SAAS;WACtC,MAAM;aACJ,OAAO;eACL,OAAO;kBACJ,MAAM;kBACN,OAAO;cACX,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI;gDAoCvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;SAjDnB,MAAM;YACH,SAAS;kBACH,CAAC,IAAI,EAAE,UAAU,KAAK,SAAS;WACtC,MAAM;aACJ,OAAO;eACL,OAAO;kBACJ,MAAM;kBACN,OAAO;cACX,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI;gDAyFvC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/stories/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC"}
|
@@ -1,9 +1,6 @@
|
|
1
1
|
import { type Completion } from '@codemirror/autocomplete';
|
2
2
|
import { type Extension } from '@codemirror/state';
|
3
|
-
import { type
|
4
|
-
import React, { type ReactNode } from 'react';
|
5
|
-
import { type EditorSelectionState, type ThemeExtensionsOptions } from '../extensions';
|
6
|
-
import { type UseTextEditorProps } from '../hooks';
|
3
|
+
import { type EditorSelectionState } from '../../extensions';
|
7
4
|
export declare const num: () => string;
|
8
5
|
export declare const img = "";
|
9
6
|
export declare const code: string;
|
@@ -26,10 +23,10 @@ export declare const content: {
|
|
26
23
|
export declare const text: string;
|
27
24
|
export declare const links: Completion[];
|
28
25
|
export declare const names: string[];
|
29
|
-
export declare const renderLinkTooltip: import("
|
26
|
+
export declare const renderLinkTooltip: import("../..").RenderCallback<{
|
30
27
|
url: string;
|
31
28
|
}>;
|
32
|
-
export declare const renderLinkButton: import("
|
29
|
+
export declare const renderLinkButton: import("../..").RenderCallback<{
|
33
30
|
url: string;
|
34
31
|
}>;
|
35
32
|
export declare const defaultExtensions: Extension[];
|
@@ -38,16 +35,4 @@ export declare const longText: string;
|
|
38
35
|
export declare const largeWithImages: string;
|
39
36
|
export declare const headings: string;
|
40
37
|
export declare const global: Map<string, EditorSelectionState>;
|
41
|
-
export type DebugMode = 'raw' | 'tree' | 'raw+tree';
|
42
|
-
export type StoryProps = {
|
43
|
-
id?: string;
|
44
|
-
debug?: DebugMode;
|
45
|
-
debugCustom?: (view: EditorView) => ReactNode;
|
46
|
-
text?: string;
|
47
|
-
readOnly?: boolean;
|
48
|
-
placeholder?: string;
|
49
|
-
lineNumbers?: boolean;
|
50
|
-
onReady?: (view: EditorView) => void;
|
51
|
-
} & Pick<UseTextEditorProps, 'scrollTo' | 'selection' | 'extensions'> & Pick<ThemeExtensionsOptions, 'slots'>;
|
52
|
-
export declare const EditorStory: ({ id, debug, debugCustom, text, readOnly, placeholder, lineNumbers, scrollTo, selection, extensions, slots, onReady, }: StoryProps) => React.JSX.Element;
|
53
38
|
//# sourceMappingURL=util.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/stories/components/util.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAOnD,OAAO,EACL,KAAK,oBAAoB,EAO1B,MAAM,kBAAkB,CAAC;AAI1B,eAAO,MAAM,GAAG,cAAiE,CAAC;AAElF,eAAO,MAAM,GAAG,yDAAyD,CAAC;AAE1E,eAAO,MAAM,IAAI,QAOhB,CAAC;AAGF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;CA+FnB,CAAC;AAGF,eAAO,MAAM,IAAI,QAwBhB,CAAC;AAGF,eAAO,MAAM,KAAK,EAAE,UAAU,EAM7B,CAAC;AAEF,eAAO,MAAM,KAAK,UAA4E,CAAC;AAe/F,eAAO,MAAM,iBAAiB;SAVD,MAAM;EAUyB,CAAC;AAU7D,eAAO,MAAM,gBAAgB;SARD,MAAM;EAQwB,CAAC;AAG3D,eAAO,MAAM,iBAAiB,EAAE,SAAS,EAIxC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,SAAS,EAOpC,CAAC;AAGF,eAAO,MAAM,QAAQ,QAEN,CAAC;AAEhB,eAAO,MAAM,eAAe,QAGb,CAAC;AAEhB,eAAO,MAAM,QAAQ,QAIpB,CAAC;AAEF,eAAO,MAAM,MAAM,mCAA0C,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dxos/react-ui-editor",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.3-main.672df60",
|
4
4
|
"description": "Document editing experience within a DXOS shell.",
|
5
5
|
"homepage": "https://dxos.org",
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
@@ -59,20 +59,20 @@
|
|
59
59
|
"lodash.merge": "^4.6.2",
|
60
60
|
"lodash.sortby": "^4.7.0",
|
61
61
|
"style-mod": "^4.1.0",
|
62
|
-
"@dxos/
|
63
|
-
"@dxos/
|
64
|
-
"@dxos/context": "0.8.
|
65
|
-
"@dxos/
|
66
|
-
"@dxos/
|
67
|
-
"@dxos/echo-schema": "0.8.
|
68
|
-
"@dxos/invariant": "0.8.
|
69
|
-
"@dxos/lit-ui": "0.8.
|
70
|
-
"@dxos/
|
71
|
-
"@dxos/
|
72
|
-
"@dxos/
|
73
|
-
"@dxos/
|
74
|
-
"@dxos/
|
75
|
-
"@dxos/
|
62
|
+
"@dxos/app-graph": "0.8.3-main.672df60",
|
63
|
+
"@dxos/async": "0.8.3-main.672df60",
|
64
|
+
"@dxos/context": "0.8.3-main.672df60",
|
65
|
+
"@dxos/debug": "0.8.3-main.672df60",
|
66
|
+
"@dxos/display-name": "0.8.3-main.672df60",
|
67
|
+
"@dxos/echo-schema": "0.8.3-main.672df60",
|
68
|
+
"@dxos/invariant": "0.8.3-main.672df60",
|
69
|
+
"@dxos/lit-ui": "0.8.3-main.672df60",
|
70
|
+
"@dxos/live-object": "0.8.3-main.672df60",
|
71
|
+
"@dxos/log": "0.8.3-main.672df60",
|
72
|
+
"@dxos/protocols": "0.8.3-main.672df60",
|
73
|
+
"@dxos/react-hooks": "0.8.3-main.672df60",
|
74
|
+
"@dxos/util": "0.8.3-main.672df60",
|
75
|
+
"@dxos/react-ui-menu": "0.8.3-main.672df60"
|
76
76
|
},
|
77
77
|
"devDependencies": {
|
78
78
|
"@automerge/automerge": "3.0.0-beta.4",
|
@@ -101,15 +101,16 @@
|
|
101
101
|
"vite": "5.4.7",
|
102
102
|
"vite-plugin-top-level-await": "^1.4.1",
|
103
103
|
"vite-plugin-wasm": "^3.3.0",
|
104
|
-
"@dxos/
|
105
|
-
"@dxos/
|
106
|
-
"@dxos/
|
107
|
-
"@dxos/
|
108
|
-
"@dxos/react-
|
109
|
-
"@dxos/react-ui-
|
110
|
-
"@dxos/
|
111
|
-
"@dxos/
|
112
|
-
"@dxos/
|
104
|
+
"@dxos/config": "0.8.3-main.672df60",
|
105
|
+
"@dxos/keyboard": "0.8.3-main.672df60",
|
106
|
+
"@dxos/random": "0.8.3-main.672df60",
|
107
|
+
"@dxos/echo-signals": "0.8.3-main.672df60",
|
108
|
+
"@dxos/react-client": "0.8.3-main.672df60",
|
109
|
+
"@dxos/react-ui-attention": "0.8.3-main.672df60",
|
110
|
+
"@dxos/react-ui": "0.8.3-main.672df60",
|
111
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.3-main.672df60",
|
112
|
+
"@dxos/storybook-utils": "0.8.3-main.672df60",
|
113
|
+
"@dxos/react-ui-theme": "0.8.3-main.672df60"
|
113
114
|
},
|
114
115
|
"peerDependencies": {
|
115
116
|
"@effect-rx/rx-react": "^0.34.1",
|
@@ -118,9 +119,9 @@
|
|
118
119
|
"effect": "^3.13.3",
|
119
120
|
"react": "~18.2.0",
|
120
121
|
"react-dom": "~18.2.0",
|
121
|
-
"@dxos/react-ui": "0.8.
|
122
|
-
"@dxos/react-client": "0.8.
|
123
|
-
"@dxos/react-ui-theme": "0.8.
|
122
|
+
"@dxos/react-ui": "0.8.3-main.672df60",
|
123
|
+
"@dxos/react-client": "0.8.3-main.672df60",
|
124
|
+
"@dxos/react-ui-theme": "0.8.3-main.672df60"
|
124
125
|
},
|
125
126
|
"publishConfig": {
|
126
127
|
"access": "public"
|
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
import { EditorView, ViewPlugin, type ViewUpdate } from '@codemirror/view';
|
6
6
|
|
7
|
+
import { type CleanupFn, addEventListener } from '@dxos/async';
|
8
|
+
|
7
9
|
import { closeEffect, openEffect } from './action';
|
8
10
|
|
9
11
|
export type FloatingMenuOptions = {
|
@@ -17,7 +19,8 @@ export const floatingMenu = (options: FloatingMenuOptions = {}) => [
|
|
17
19
|
class {
|
18
20
|
view: EditorView;
|
19
21
|
tag: HTMLElement;
|
20
|
-
rafId
|
22
|
+
rafId?: number | null;
|
23
|
+
cleanup?: CleanupFn;
|
21
24
|
|
22
25
|
constructor(view: EditorView) {
|
23
26
|
this.view = view;
|
@@ -28,23 +31,34 @@ export const floatingMenu = (options: FloatingMenuOptions = {}) => [
|
|
28
31
|
container.style.position = 'relative';
|
29
32
|
}
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
{
|
35
|
+
const icon = document.createElement('dx-icon');
|
36
|
+
icon.setAttribute('icon', options.icon ?? 'ph--dots-three-vertical--regular');
|
37
|
+
|
38
|
+
const button = document.createElement('button');
|
39
|
+
button.appendChild(icon);
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
this.tag = document.createElement('dx-ref-tag');
|
42
|
+
this.tag.classList.add('cm-ref-tag');
|
43
|
+
this.tag.appendChild(button);
|
44
|
+
}
|
36
45
|
|
37
|
-
// TODO(burdon): Custom tag/styles?
|
38
|
-
this.tag = document.createElement('dx-ref-tag');
|
39
|
-
this.tag.classList.add('cm-ref-tag');
|
40
|
-
this.tag.appendChild(button);
|
41
46
|
container.appendChild(this.tag);
|
42
47
|
|
43
48
|
// Listen for scroll events.
|
44
|
-
|
49
|
+
const handler = () => this.scheduleUpdate();
|
50
|
+
this.cleanup = addEventListener(container, 'scroll', handler);
|
45
51
|
this.scheduleUpdate();
|
46
52
|
}
|
47
53
|
|
54
|
+
destroy() {
|
55
|
+
this.cleanup?.();
|
56
|
+
this.tag.remove();
|
57
|
+
if (this.rafId != null) {
|
58
|
+
cancelAnimationFrame(this.rafId);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
48
62
|
update(update: ViewUpdate) {
|
49
63
|
this.tag.dataset.focused = update.view.hasFocus ? 'true' : 'false';
|
50
64
|
if (!update.view.hasFocus) {
|
@@ -96,13 +110,6 @@ export const floatingMenu = (options: FloatingMenuOptions = {}) => [
|
|
96
110
|
|
97
111
|
this.rafId = requestAnimationFrame(this.updateButtonPosition.bind(this));
|
98
112
|
}
|
99
|
-
|
100
|
-
destroy() {
|
101
|
-
this.tag.remove();
|
102
|
-
if (this.rafId != null) {
|
103
|
-
cancelAnimationFrame(this.rafId);
|
104
|
-
}
|
105
|
-
}
|
106
113
|
},
|
107
114
|
),
|
108
115
|
|
@@ -111,8 +118,13 @@ export const floatingMenu = (options: FloatingMenuOptions = {}) => [
|
|
111
118
|
position: 'fixed',
|
112
119
|
padding: '0',
|
113
120
|
border: 'none',
|
114
|
-
|
115
|
-
|
121
|
+
opacity: '0',
|
122
|
+
},
|
123
|
+
'[data-has-focus] & .cm-ref-tag': {
|
124
|
+
opacity: '1',
|
125
|
+
},
|
126
|
+
'[data-is-attention-source] & .cm-ref-tag': {
|
127
|
+
opacity: '1',
|
116
128
|
},
|
117
129
|
'.cm-ref-tag button': {
|
118
130
|
display: 'grid',
|
@@ -121,8 +133,5 @@ export const floatingMenu = (options: FloatingMenuOptions = {}) => [
|
|
121
133
|
width: '2rem',
|
122
134
|
height: '2rem',
|
123
135
|
},
|
124
|
-
'.cm-ref-tag[data-focused="true"]': {
|
125
|
-
opacity: 1,
|
126
|
-
},
|
127
136
|
}),
|
128
137
|
];
|
@@ -0,0 +1,68 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2025 DXOS.org
|
3
|
+
//
|
4
|
+
|
5
|
+
import { type Extension } from '@codemirror/state';
|
6
|
+
import {
|
7
|
+
Decoration,
|
8
|
+
type DecorationSet,
|
9
|
+
EditorView,
|
10
|
+
MatchDecorator,
|
11
|
+
ViewPlugin,
|
12
|
+
type ViewUpdate,
|
13
|
+
WidgetType,
|
14
|
+
} from '@codemirror/view';
|
15
|
+
|
16
|
+
import { getHashColor, mx } from '@dxos/react-ui-theme';
|
17
|
+
|
18
|
+
class TagWidget extends WidgetType {
|
19
|
+
constructor(private _text: string) {
|
20
|
+
super();
|
21
|
+
}
|
22
|
+
|
23
|
+
toDOM(): HTMLSpanElement {
|
24
|
+
const span = document.createElement('span');
|
25
|
+
span.className = mx('cm-tag', getHashColor(this._text).tag);
|
26
|
+
span.textContent = this._text;
|
27
|
+
return span;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
const tagMatcher = new MatchDecorator({
|
32
|
+
regexp: /#(\w+)\W/g,
|
33
|
+
decoration: (match) =>
|
34
|
+
Decoration.replace({
|
35
|
+
widget: new TagWidget(match[1]),
|
36
|
+
}),
|
37
|
+
});
|
38
|
+
|
39
|
+
// TODO(burdon): Autocomplete from existing tags?
|
40
|
+
export const hashtag = (): Extension => [
|
41
|
+
ViewPlugin.fromClass(
|
42
|
+
class {
|
43
|
+
tags: DecorationSet;
|
44
|
+
constructor(view: EditorView) {
|
45
|
+
this.tags = tagMatcher.createDeco(view);
|
46
|
+
}
|
47
|
+
|
48
|
+
update(update: ViewUpdate) {
|
49
|
+
this.tags = tagMatcher.updateDeco(update, this.tags);
|
50
|
+
}
|
51
|
+
},
|
52
|
+
{
|
53
|
+
decorations: (instance) => instance.tags,
|
54
|
+
provide: (plugin) =>
|
55
|
+
EditorView.atomicRanges.of((view) => {
|
56
|
+
return view.plugin(plugin)?.tags || Decoration.none;
|
57
|
+
}),
|
58
|
+
},
|
59
|
+
),
|
60
|
+
|
61
|
+
EditorView.theme({
|
62
|
+
'.cm-tag': {
|
63
|
+
borderRadius: '4px',
|
64
|
+
marginRight: '6px',
|
65
|
+
padding: '2px 6px',
|
66
|
+
},
|
67
|
+
}),
|
68
|
+
];
|
package/src/extensions/index.ts
CHANGED
package/src/extensions/json.ts
CHANGED
@@ -16,7 +16,8 @@ export type JsonExtensionsOptions = {
|
|
16
16
|
export const createJsonExtensions = ({ schema }: JsonExtensionsOptions = {}): Extension => {
|
17
17
|
let lintSource: LintSource = jsonParseLinter();
|
18
18
|
if (schema) {
|
19
|
-
|
19
|
+
// NOTE: Relaxing strict mode to allow additional custom schema properties.
|
20
|
+
const ajv = new Ajv({ allErrors: false, strict: false });
|
20
21
|
const validate = ajv.compile(schema);
|
21
22
|
lintSource = schemaLinter(validate);
|
22
23
|
}
|
@@ -3,10 +3,10 @@
|
|
3
3
|
//
|
4
4
|
|
5
5
|
import { syntaxTree } from '@codemirror/language';
|
6
|
-
import { type EditorState, StateField } from '@codemirror/state';
|
6
|
+
import { type EditorState, type Extension, StateField } from '@codemirror/state';
|
7
7
|
import { type TreeCursor } from '@lezer/common';
|
8
8
|
|
9
|
-
export const debugTree = (cb: (tree: DebugNode) => void) =>
|
9
|
+
export const debugTree = (cb: (tree: DebugNode) => void): Extension =>
|
10
10
|
StateField.define({
|
11
11
|
create: (state) => cb(convertTreeToJson(state)),
|
12
12
|
update: (value, tr) => cb(convertTreeToJson(tr.state)),
|
@@ -28,9 +28,7 @@ import { decorateMarkdown } from '../markdown';
|
|
28
28
|
// TODO(burdon): Smart Cut-and-paste.
|
29
29
|
// TODO(burdon): DND.
|
30
30
|
|
31
|
-
export type OutlinerProps = {
|
32
|
-
showSelected?: boolean;
|
33
|
-
};
|
31
|
+
export type OutlinerProps = {};
|
34
32
|
|
35
33
|
/**
|
36
34
|
* Outliner extension.
|
@@ -56,7 +54,7 @@ export const outliner = (options: OutlinerProps = {}): Extension => [
|
|
56
54
|
floatingMenu(),
|
57
55
|
|
58
56
|
// Line decorations.
|
59
|
-
decorations(
|
57
|
+
decorations(),
|
60
58
|
|
61
59
|
// Default markdown decorations.
|
62
60
|
decorateMarkdown({ listPaddingLeft: 8 }),
|
@@ -68,7 +66,7 @@ export const outliner = (options: OutlinerProps = {}): Extension => [
|
|
68
66
|
/**
|
69
67
|
* Line decorations (for border and selection).
|
70
68
|
*/
|
71
|
-
const decorations = (
|
69
|
+
const decorations = () => [
|
72
70
|
ViewPlugin.fromClass(
|
73
71
|
class {
|
74
72
|
decorations: DecorationSet = Decoration.none;
|
@@ -157,12 +155,15 @@ const decorations = (options: OutlinerProps) => [
|
|
157
155
|
marginBottom: '2px',
|
158
156
|
},
|
159
157
|
|
160
|
-
'.cm-list-item-selected': {
|
161
|
-
borderColor: options.showSelected ? 'var(--dx-separator)' : undefined,
|
162
|
-
},
|
163
158
|
'.cm-list-item-focused': {
|
164
159
|
borderColor: 'var(--dx-accentFocusIndicator)',
|
165
160
|
},
|
161
|
+
'[data-has-focus] & .cm-list-item-selected': {
|
162
|
+
borderColor: 'var(--dx-separator)',
|
163
|
+
},
|
164
|
+
'[data-is-attention-source] & .cm-list-item-selected': {
|
165
|
+
borderColor: 'var(--dx-separator)',
|
166
|
+
},
|
166
167
|
}),
|
167
168
|
),
|
168
169
|
];
|
@@ -10,7 +10,7 @@ import { Button, Icon, Input, DropdownMenu } from '@dxos/react-ui';
|
|
10
10
|
import { mx } from '@dxos/react-ui-theme';
|
11
11
|
import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
|
12
12
|
|
13
|
-
import { EditorStory } from './
|
13
|
+
import { EditorStory } from './components';
|
14
14
|
import { RefDropdownMenu } from '../components';
|
15
15
|
import { editorWidth } from '../defaults';
|
16
16
|
import { command, type Action, floatingMenu } from '../extensions';
|
@@ -12,7 +12,7 @@ import { PublicKey } from '@dxos/keys';
|
|
12
12
|
import { log } from '@dxos/log';
|
13
13
|
import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
|
14
14
|
|
15
|
-
import { EditorStory, content, longText } from './
|
15
|
+
import { EditorStory, content, longText } from './components';
|
16
16
|
import { annotations, comments, createExternalCommentSync } from '../extensions';
|
17
17
|
import { str } from '../testing';
|
18
18
|
import { type Comment } from '../types';
|
@@ -20,8 +20,8 @@ import { createRenderer } from '../util';
|
|
20
20
|
|
21
21
|
const meta: Meta<typeof EditorStory> = {
|
22
22
|
title: 'ui/react-ui-editor/Comments',
|
23
|
+
component: EditorStory,
|
23
24
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
24
|
-
render: EditorStory,
|
25
25
|
parameters: { layout: 'fullscreen' },
|
26
26
|
};
|
27
27
|
|
@@ -11,14 +11,14 @@ import { log } from '@dxos/log';
|
|
11
11
|
import { faker } from '@dxos/random';
|
12
12
|
import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
|
13
13
|
|
14
|
-
import { EditorStory, content } from './
|
14
|
+
import { EditorStory, content } from './components';
|
15
15
|
import { typewriter, blast, defaultOptions, dropFile } from '../extensions';
|
16
16
|
import { str } from '../testing';
|
17
17
|
|
18
18
|
const meta: Meta<typeof EditorStory> = {
|
19
19
|
title: 'ui/react-ui-editor/Experimental',
|
20
|
+
component: EditorStory,
|
20
21
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
21
|
-
render: EditorStory,
|
22
22
|
parameters: { layout: 'fullscreen' },
|
23
23
|
};
|
24
24
|
|
@@ -9,14 +9,14 @@ import React from 'react';
|
|
9
9
|
|
10
10
|
import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
|
11
11
|
|
12
|
-
import { EditorStory, content, defaultExtensions, headings, renderLinkTooltip, text } from './
|
12
|
+
import { EditorStory, content, defaultExtensions, headings, renderLinkTooltip, text } from './components';
|
13
13
|
import { decorateMarkdown, image, linkTooltip, table } from '../extensions';
|
14
14
|
import { str } from '../testing';
|
15
15
|
|
16
16
|
const meta: Meta<typeof EditorStory> = {
|
17
17
|
title: 'ui/react-ui-editor/Markdown',
|
18
|
+
component: EditorStory,
|
18
19
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
19
|
-
render: EditorStory,
|
20
20
|
parameters: { layout: 'fullscreen' },
|
21
21
|
};
|
22
22
|
|
@@ -4,14 +4,16 @@
|
|
4
4
|
|
5
5
|
import '@dxos-theme';
|
6
6
|
|
7
|
-
import
|
7
|
+
import { type EditorView } from '@codemirror/view';
|
8
|
+
import React, { useRef } from 'react';
|
8
9
|
|
9
10
|
import { DropdownMenu } from '@dxos/react-ui';
|
11
|
+
import { withAttention } from '@dxos/react-ui-attention/testing';
|
10
12
|
import { withLayout, withTheme, type Meta } from '@dxos/storybook-utils';
|
11
13
|
|
12
|
-
import { EditorStory } from './
|
14
|
+
import { EditorStory } from './components';
|
13
15
|
import { RefDropdownMenu } from '../components';
|
14
|
-
import { outliner, listItemToString, treeFacet } from '../extensions';
|
16
|
+
import { outliner, listItemToString, treeFacet, deleteItem, hashtag } from '../extensions';
|
15
17
|
import { str } from '../testing';
|
16
18
|
|
17
19
|
type StoryProps = {
|
@@ -19,11 +21,20 @@ type StoryProps = {
|
|
19
21
|
};
|
20
22
|
|
21
23
|
const DefaultStory = ({ text }: StoryProps) => {
|
24
|
+
const viewRef = useRef<EditorView>(null);
|
25
|
+
|
26
|
+
const handleDelete = () => {
|
27
|
+
if (viewRef.current) {
|
28
|
+
deleteItem(viewRef.current);
|
29
|
+
}
|
30
|
+
};
|
31
|
+
|
22
32
|
return (
|
23
33
|
<RefDropdownMenu.Provider>
|
24
34
|
<EditorStory
|
35
|
+
ref={viewRef}
|
25
36
|
text={text}
|
26
|
-
extensions={[outliner()]}
|
37
|
+
extensions={[outliner(), hashtag()]}
|
27
38
|
placeholder=''
|
28
39
|
slots={{}}
|
29
40
|
debug='raw+tree'
|
@@ -31,13 +42,14 @@ const DefaultStory = ({ text }: StoryProps) => {
|
|
31
42
|
const tree = view.state.facet(treeFacet);
|
32
43
|
const lines: string[] = [];
|
33
44
|
tree.traverse((item) => lines.push(listItemToString(item)));
|
34
|
-
return <pre className='p-1 text-xs text-green-800 dark:text-green-200
|
45
|
+
return <pre className='p-1 overflow-auto text-xs text-green-800 dark:text-green-200'>{lines.join('\n')}</pre>;
|
35
46
|
}}
|
36
47
|
/>
|
48
|
+
|
37
49
|
<DropdownMenu.Portal>
|
38
50
|
<DropdownMenu.Content>
|
39
51
|
<DropdownMenu.Viewport>
|
40
|
-
<DropdownMenu.Item onClick={
|
52
|
+
<DropdownMenu.Item onClick={handleDelete}>Delete</DropdownMenu.Item>
|
41
53
|
</DropdownMenu.Viewport>
|
42
54
|
<DropdownMenu.Arrow />
|
43
55
|
</DropdownMenu.Content>
|
@@ -48,8 +60,8 @@ const DefaultStory = ({ text }: StoryProps) => {
|
|
48
60
|
|
49
61
|
const meta: Meta<StoryProps> = {
|
50
62
|
title: 'ui/react-ui-editor/Outliner',
|
51
|
-
decorators: [withTheme, withLayout({ fullscreen: true })],
|
52
63
|
render: DefaultStory,
|
64
|
+
decorators: [withAttention, withTheme, withLayout({ fullscreen: true })],
|
53
65
|
parameters: { layout: 'fullscreen' },
|
54
66
|
};
|
55
67
|
|