@dxos/react-ui-editor 0.4.8-main.c67d72c → 0.4.8-main.cd60bd2
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 +1926 -1743
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.d.ts +2 -2
- package/dist/types/src/components/TextEditor/TextEditor.d.ts.map +1 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts +2 -1
- package/dist/types/src/components/TextEditor/TextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +12 -11
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +4 -2
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.stories.d.ts +1 -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/dnd.d.ts +7 -1
- package/dist/types/src/extensions/dnd.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts +5 -1
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +1 -1
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/action.d.ts +9 -0
- package/dist/types/src/extensions/markdown/action.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts +7 -4
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/image.d.ts +6 -0
- package/dist/types/src/extensions/markdown/image.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/index.d.ts +1 -0
- package/dist/types/src/extensions/markdown/index.d.ts.map +1 -1
- package/dist/types/src/extensions/modes.d.ts +2 -1
- package/dist/types/src/extensions/modes.d.ts.map +1 -1
- package/dist/types/src/extensions/state.d.ts +20 -0
- package/dist/types/src/extensions/state.d.ts.map +1 -0
- package/dist/types/src/hooks/useActionHandler.d.ts +2 -2
- package/dist/types/src/hooks/useActionHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useDocAccessor.d.ts +4 -2
- package/dist/types/src/hooks/useDocAccessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextEditor.stories.d.ts +1 -0
- package/dist/types/src/hooks/useTextEditor.stories.d.ts.map +1 -1
- package/dist/types/src/themes/default.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +26 -24
- package/src/components/TextEditor/TextEditor.stories.tsx +30 -6
- package/src/components/TextEditor/TextEditor.tsx +13 -12
- package/src/components/Toolbar/Toolbar.stories.tsx +23 -24
- package/src/components/Toolbar/Toolbar.tsx +102 -60
- package/src/extensions/automerge/automerge.ts +4 -4
- package/src/extensions/command/state.ts +2 -2
- package/src/extensions/comments.ts +2 -2
- package/src/extensions/dnd.ts +31 -9
- package/src/extensions/factories.ts +41 -15
- package/src/extensions/index.ts +1 -1
- package/src/extensions/markdown/action.ts +112 -0
- package/src/extensions/markdown/bundle.ts +8 -11
- package/src/extensions/markdown/formatting.test.ts +13 -13
- package/src/extensions/markdown/formatting.ts +95 -87
- package/src/extensions/markdown/image.ts +6 -0
- package/src/extensions/markdown/index.ts +1 -0
- package/src/extensions/modes.ts +11 -2
- package/src/extensions/state.ts +90 -0
- package/src/hooks/useActionHandler.ts +4 -85
- package/src/hooks/useDocAccessor.ts +8 -2
- package/src/hooks/useTextEditor.stories.tsx +3 -3
- package/src/hooks/useTextEditor.ts +3 -0
- package/src/themes/default.ts +24 -8
- package/src/translations.ts +1 -0
- package/dist/types/src/extensions/cursor-line-margin.d.ts +0 -7
- package/dist/types/src/extensions/cursor-line-margin.d.ts.map +0 -1
- package/src/extensions/cursor-line-margin.ts +0 -94
|
@@ -11,7 +11,7 @@ export type Formatting = {
|
|
|
11
11
|
link: boolean;
|
|
12
12
|
listStyle: null | 'ordered' | 'bullet' | 'task';
|
|
13
13
|
};
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const formattingEquals: (a: Formatting, b: Formatting) => boolean;
|
|
15
15
|
export declare enum Inline {
|
|
16
16
|
Strong = 0,
|
|
17
17
|
Emphasis = 1,
|
|
@@ -34,7 +34,10 @@ export declare const toggleStrikethrough: StateCommand;
|
|
|
34
34
|
export declare const toggleInlineCode: StateCommand;
|
|
35
35
|
export declare const insertTable: (view: EditorView) => void;
|
|
36
36
|
export declare const removeLink: StateCommand;
|
|
37
|
-
export declare const addLink:
|
|
37
|
+
export declare const addLink: ({ url, image }?: {
|
|
38
|
+
url?: string | undefined;
|
|
39
|
+
image?: boolean | undefined;
|
|
40
|
+
}) => StateCommand;
|
|
38
41
|
export declare const addList: (type: List) => StateCommand;
|
|
39
42
|
export declare const removeList: (type: List) => StateCommand;
|
|
40
43
|
export declare const toggleList: (type: List) => StateCommand;
|
|
@@ -52,7 +55,7 @@ export declare const formattingKeymap: (options?: FormattingOptions) => Extensio
|
|
|
52
55
|
*/
|
|
53
56
|
export declare const getFormatting: (state: EditorState) => Formatting;
|
|
54
57
|
/**
|
|
55
|
-
* Hook
|
|
58
|
+
* Hook provides an extension to compute the current formatting state.
|
|
56
59
|
*/
|
|
57
|
-
export declare const useFormattingState: () => [Formatting |
|
|
60
|
+
export declare const useFormattingState: () => [Formatting | undefined, Extension];
|
|
58
61
|
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/formatting.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAKjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAU,MAAM,kBAAkB,CAAC;AAYtD,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,OAAO,CAAC;IAGnB,SAAS,EACL,WAAW,GACX,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,GACX,IAAI,CAAC;IAET,UAAU,EAAE,OAAO,CAAC;IAEpB,MAAM,EAAE,OAAO,CAAC;IAEhB,QAAQ,EAAE,OAAO,CAAC;IAElB,aAAa,EAAE,OAAO,CAAC;IAEvB,IAAI,EAAE,OAAO,CAAC;IAEd,IAAI,EAAE,OAAO,CAAC;IAEd,SAAS,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/formatting.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAKjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAU,MAAM,kBAAkB,CAAC;AAYtD,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,OAAO,CAAC;IAGnB,SAAS,EACL,WAAW,GACX,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,GACX,IAAI,CAAC;IAET,UAAU,EAAE,OAAO,CAAC;IAEpB,MAAM,EAAE,OAAO,CAAC;IAEhB,QAAQ,EAAE,OAAO,CAAC;IAElB,aAAa,EAAE,OAAO,CAAC;IAEvB,IAAI,EAAE,OAAO,CAAC;IAEd,IAAI,EAAE,OAAO,CAAC;IAEd,SAAS,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,gBAAgB,MAAO,UAAU,KAAK,UAAU,YAQ9B,CAAC;AAEhC,oBAAY,MAAM;IAChB,MAAM,IAAI;IACV,QAAQ,IAAI;IACZ,aAAa,IAAI;IACjB,IAAI,IAAI;CACT;AAED,oBAAY,IAAI;IACd,OAAO,IAAA;IACP,MAAM,IAAA;IACN,IAAI,IAAA;CACL;AAMD,eAAO,MAAM,UAAU,UACb,MAAM,KAAG,YAkEhB,CAAC;AAMJ,eAAO,MAAM,QAAQ,SACZ,MAAM,UAAU,OAAO,KAAG,YAoKhC,CAAC;AAEJ,eAAO,MAAM,QAAQ,UAAW,MAAM,KAAG,YAAqC,CAAC;AAE/E,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,YAAsC,CAAC;AAEnF,eAAO,MAAM,WAAW,UACd,MAAM,KAAG,YAahB,CAAC;AAEJ,eAAO,MAAM,YAAY,cAA6B,CAAC;AACvD,eAAO,MAAM,cAAc,cAA+B,CAAC;AAC3D,eAAO,MAAM,mBAAmB,cAAoC,CAAC;AACrE,eAAO,MAAM,gBAAgB,cAA2B,CAAC;AA0EzD,eAAO,MAAM,WAAW,SAAU,UAAU,SAS3C,CAAC;AA4BF,eAAO,MAAM,UAAU,EAAE,YAUxB,CAAC;AAGF,eAAO,MAAM,OAAO;;;MACwC,YAsFzD,CAAC;AAMJ,eAAO,MAAM,OAAO,SACX,IAAI,KAAG,YAmJb,CAAC;AAEJ,eAAO,MAAM,UAAU,SACd,IAAI,KAAG,YAwDb,CAAC;AAEJ,eAAO,MAAM,UAAU,SACd,IAAI,KAAG,YAMb,CAAC;AAqBJ,eAAO,MAAM,aAAa,WACf,OAAO,KAAG,YAwElB,CAAC;AAEJ,eAAO,MAAM,aAAa,cAAsB,CAAC;AAEjD,eAAO,MAAM,gBAAgB,cAAuB,CAAC;AAErD,eAAO,MAAM,gBAAgB,EAAE,YAE9B,CAAC;AAMF,eAAO,MAAM,YAAY,EAAE,YAsD1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,YAyC7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,YAE7B,CAAC;AAMF,MAAM,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEnC,eAAO,MAAM,gBAAgB,aAAa,iBAAiB,KAAQ,SASlE,CAAC;AA4CF;;GAEG;AACH,eAAO,MAAM,aAAa,UAAW,WAAW,KAAG,UAqKlD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAAO,CAAC,UAAU,GAAG,SAAS,EAAE,SAAS,CAoBvE,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type Extension } from '@codemirror/state';
|
|
2
2
|
export type ImageOptions = {};
|
|
3
3
|
export declare const image: (options?: ImageOptions) => Extension;
|
|
4
|
+
export type ImageUploadOptions = {
|
|
5
|
+
onSelect: () => {
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const imageUpload: (options?: ImageOptions) => void;
|
|
4
10
|
//# sourceMappingURL=image.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/image.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,SAAS,EAA4C,MAAM,mBAAmB,CAAC;AAG/G,MAAM,MAAM,YAAY,GAAG,EAAE,CAAC;AAE9B,eAAO,MAAM,KAAK,aAAa,YAAY,KAAQ,SA8BlD,CAAC"}
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/image.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,SAAS,EAA4C,MAAM,mBAAmB,CAAC;AAG/G,MAAM,MAAM,YAAY,GAAG,EAAE,CAAC;AAE9B,eAAO,MAAM,KAAK,aAAa,YAAY,KAAQ,SA8BlD,CAAC;AA4DF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,WAAW,aAAa,YAAY,SAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/markdown/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Extension, Facet } from '@codemirror/state';
|
|
2
|
-
export
|
|
2
|
+
export declare const focusEvent = "focus.container";
|
|
3
|
+
export type EditorMode = 'default' | 'vim' | 'vscode' | undefined;
|
|
3
4
|
export type EditorConfig = {
|
|
4
5
|
type: string;
|
|
5
6
|
noTabster?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modes.d.ts","sourceRoot":"","sources":["../../../../src/extensions/modes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"modes.d.ts","sourceRoot":"","sources":["../../../../src/extensions/modes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK1D,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAE5C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,UAAU,mCAErB,CAAC;AAEH,eAAO,MAAM,WAAW,EAAE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CAsBpD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Extension } from '@codemirror/state';
|
|
2
|
+
export type SelectionState = {
|
|
3
|
+
scrollTo: {
|
|
4
|
+
from: number;
|
|
5
|
+
};
|
|
6
|
+
selection: {
|
|
7
|
+
anchor: number;
|
|
8
|
+
head?: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export type StateOptions = {
|
|
12
|
+
setState: (id: string, state: SelectionState) => void;
|
|
13
|
+
getState: (id: string) => SelectionState | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare const localStorageStateStoreAdapter: StateOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Track scrolling and selection state to be restored when switching to document.
|
|
18
|
+
*/
|
|
19
|
+
export declare const state: ({ getState, setState }?: Partial<StateOptions>) => Extension;
|
|
20
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/extensions/state.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,mBAAmB,CAAC;AAYhE,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,SAAS,EAAE;QACT,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAC;CACtD,CAAC;AAGF,eAAO,MAAM,6BAA6B,EAAE,YAU3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,4BAA4B,QAAQ,YAAY,CAAC,KAAQ,SA0C1E,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type EditorView } from '@codemirror/view';
|
|
2
|
+
import { type ToolbarProps } from '../components';
|
|
3
3
|
export declare const useActionHandler: (view?: EditorView | null) => ToolbarProps['onAction'];
|
|
4
4
|
//# sourceMappingURL=useActionHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionHandler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActionHandler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useActionHandler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActionHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,eAAO,MAAM,gBAAgB,UAAW,UAAU,GAAG,IAAI,KAAG,YAAY,CAAC,UAAU,CAElF,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { type DocAccessor, type TextObject } from '@dxos/echo-schema';
|
|
2
|
-
export declare const useDocAccessor: <T = any>(text: TextObject
|
|
1
|
+
import { type DocAccessor, type TextObject, type EchoReactiveObject } from '@dxos/echo-schema';
|
|
2
|
+
export declare const useDocAccessor: <T = any>(text: TextObject | EchoReactiveObject<{
|
|
3
|
+
content: string;
|
|
4
|
+
}>) => {
|
|
3
5
|
id: string;
|
|
4
6
|
doc: string | undefined;
|
|
5
7
|
accessor: DocAccessor<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDocAccessor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDocAccessor.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"useDocAccessor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDocAccessor.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,cAAc,kBACnB,UAAU,GAAG,mBAAmB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;QACnD,MAAM;SAAO,MAAM,GAAG,SAAS;;CASvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextEditor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextEditor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAwC,MAAM,OAAO,CAAC;AAKlG,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,YAAY,CAAC,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,aAAa,QAAQ,MAAM,kBAAkB,4BAA2C,
|
|
1
|
+
{"version":3,"file":"useTextEditor.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextEditor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAwC,MAAM,OAAO,CAAC;AAKlG,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,YAAY,CAAC,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,aAAa,QAAQ,MAAM,kBAAkB,4BAA2C,aA4EpG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextEditor.stories.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAwBpB,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;;;;mBA2Ee,UAAU
|
|
1
|
+
{"version":3,"file":"useTextEditor.stories.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTextEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAwBpB,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;;;;mBA2Ee,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;AAH3B,wBASE;AAEF,eAAO,MAAM,OAAO;;CAKnB,CAAC;AAEF,eAAO,MAAM,KAAK;;CAQjB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;CAMpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/themes/default.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAU,MAAM,WAAW,CAAC;AAKrD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/themes/default.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAU,MAAM,WAAW,CAAC;AAKrD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,WAgQ1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,oBAAoB,CAAC
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;AAEhD,wBAqBE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-editor",
|
|
3
|
-
"version": "0.4.8-main.
|
|
3
|
+
"version": "0.4.8-main.cd60bd2",
|
|
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",
|
|
@@ -30,27 +30,29 @@
|
|
|
30
30
|
"@lezer/markdown": "^1.2.0",
|
|
31
31
|
"@radix-ui/react-context": "^1.0.0",
|
|
32
32
|
"@replit/codemirror-vim": "^6.0.14",
|
|
33
|
+
"@replit/codemirror-vscode-keymap": "^6.0.2",
|
|
33
34
|
"codemirror": "^6.0.1",
|
|
34
35
|
"lib0": "^0.2.65",
|
|
35
36
|
"lodash.defaultsdeep": "^4.6.1",
|
|
36
37
|
"lodash.get": "^4.4.2",
|
|
37
38
|
"lodash.pick": "^4.4.0",
|
|
38
39
|
"lodash.sortby": "^4.7.0",
|
|
40
|
+
"react-dropzone": "^14.2.3",
|
|
39
41
|
"style-mod": "^4.1.0",
|
|
40
|
-
"@dxos/async": "0.4.8-main.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/automerge": "0.4.8-main.
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/invariant": "0.4.8-main.
|
|
47
|
-
"@dxos/log": "0.4.8-main.
|
|
48
|
-
"@dxos/protocols": "0.4.8-main.
|
|
49
|
-
"@dxos/react-async": "0.4.8-main.
|
|
50
|
-
"@dxos/react-ui": "0.4.8-main.
|
|
51
|
-
"@dxos/react-ui-theme": "0.4.8-main.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
42
|
+
"@dxos/async": "0.4.8-main.cd60bd2",
|
|
43
|
+
"@dxos/debug": "0.4.8-main.cd60bd2",
|
|
44
|
+
"@dxos/automerge": "0.4.8-main.cd60bd2",
|
|
45
|
+
"@dxos/context": "0.4.8-main.cd60bd2",
|
|
46
|
+
"@dxos/display-name": "0.4.8-main.cd60bd2",
|
|
47
|
+
"@dxos/echo-schema": "0.4.8-main.cd60bd2",
|
|
48
|
+
"@dxos/invariant": "0.4.8-main.cd60bd2",
|
|
49
|
+
"@dxos/log": "0.4.8-main.cd60bd2",
|
|
50
|
+
"@dxos/protocols": "0.4.8-main.cd60bd2",
|
|
51
|
+
"@dxos/react-async": "0.4.8-main.cd60bd2",
|
|
52
|
+
"@dxos/react-ui": "0.4.8-main.cd60bd2",
|
|
53
|
+
"@dxos/react-ui-theme": "0.4.8-main.cd60bd2",
|
|
54
|
+
"@dxos/text-model": "0.4.8-main.cd60bd2",
|
|
55
|
+
"@dxos/util": "0.4.8-main.cd60bd2"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
58
|
"@automerge/automerge-repo-network-broadcastchannel": "^1.1.1",
|
|
@@ -77,20 +79,20 @@
|
|
|
77
79
|
"vite-plugin-top-level-await": "^1.4.1",
|
|
78
80
|
"vite-plugin-wasm": "^3.3.0",
|
|
79
81
|
"vitest": "^1.3.1",
|
|
80
|
-
"@dxos/config": "0.4.8-main.
|
|
81
|
-
"@dxos/echo-signals": "0.4.8-main.
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/random": "0.4.8-main.
|
|
85
|
-
"@dxos/react-client": "0.4.8-main.
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/
|
|
82
|
+
"@dxos/config": "0.4.8-main.cd60bd2",
|
|
83
|
+
"@dxos/echo-signals": "0.4.8-main.cd60bd2",
|
|
84
|
+
"@dxos/echo-typegen": "0.4.8-main.cd60bd2",
|
|
85
|
+
"@dxos/keyboard": "0.4.8-main.cd60bd2",
|
|
86
|
+
"@dxos/random": "0.4.8-main.cd60bd2",
|
|
87
|
+
"@dxos/react-client": "0.4.8-main.cd60bd2",
|
|
88
|
+
"@dxos/react-ui": "0.4.8-main.cd60bd2",
|
|
89
|
+
"@dxos/storybook-utils": "0.4.8-main.cd60bd2"
|
|
88
90
|
},
|
|
89
91
|
"peerDependencies": {
|
|
90
92
|
"@phosphor-icons/react": "^2.0.5",
|
|
91
93
|
"react": "^18.2.0",
|
|
92
94
|
"react-dom": "^18.2.0",
|
|
93
|
-
"@dxos/react-client": "0.4.8-main.
|
|
95
|
+
"@dxos/react-client": "0.4.8-main.cd60bd2"
|
|
94
96
|
},
|
|
95
97
|
"publishConfig": {
|
|
96
98
|
"access": "public"
|
|
@@ -13,6 +13,7 @@ import { createRoot } from 'react-dom/client';
|
|
|
13
13
|
import { TextObject } from '@dxos/echo-schema';
|
|
14
14
|
import { keySymbols, parseShortcut } from '@dxos/keyboard';
|
|
15
15
|
import { PublicKey } from '@dxos/keys';
|
|
16
|
+
import { log } from '@dxos/log';
|
|
16
17
|
import { faker } from '@dxos/random';
|
|
17
18
|
import { Button, DensityProvider, Input, ThemeProvider, useThemeContext } from '@dxos/react-ui';
|
|
18
19
|
import { baseSurface, defaultTx, getSize, mx, textBlockWidth } from '@dxos/react-ui-theme';
|
|
@@ -20,6 +21,7 @@ import { withTheme } from '@dxos/storybook-utils';
|
|
|
20
21
|
|
|
21
22
|
import { TextEditor, type TextEditorProps } from './TextEditor';
|
|
22
23
|
import {
|
|
24
|
+
EditorModes,
|
|
23
25
|
annotations,
|
|
24
26
|
autocomplete,
|
|
25
27
|
blast,
|
|
@@ -31,20 +33,21 @@ import {
|
|
|
31
33
|
createThemeExtensions,
|
|
32
34
|
decorateMarkdown,
|
|
33
35
|
defaultOptions,
|
|
34
|
-
|
|
36
|
+
dropFile,
|
|
35
37
|
formattingKeymap,
|
|
36
38
|
image,
|
|
37
39
|
linkTooltip,
|
|
38
40
|
listener,
|
|
39
41
|
mention,
|
|
40
|
-
|
|
42
|
+
state,
|
|
41
43
|
table,
|
|
42
44
|
typewriter,
|
|
43
|
-
|
|
45
|
+
useComments,
|
|
44
46
|
type CommandAction,
|
|
45
47
|
type CommandOptions,
|
|
46
48
|
type Comment,
|
|
47
49
|
type CommentsOptions,
|
|
50
|
+
type SelectionState,
|
|
48
51
|
} from '../../extensions';
|
|
49
52
|
import { useDocAccessor } from '../../hooks';
|
|
50
53
|
import translations from '../../translations';
|
|
@@ -241,7 +244,7 @@ type StoryProps = {
|
|
|
241
244
|
} & Pick<TextEditorProps, 'extensions'>;
|
|
242
245
|
|
|
243
246
|
const Story = ({
|
|
244
|
-
id = '
|
|
247
|
+
id = 'editor-' + PublicKey.random().toHex().slice(0, 8),
|
|
245
248
|
text,
|
|
246
249
|
comments,
|
|
247
250
|
extensions: _extensions = [],
|
|
@@ -325,8 +328,18 @@ export const Empty = {
|
|
|
325
328
|
render: () => <Story />,
|
|
326
329
|
};
|
|
327
330
|
|
|
331
|
+
const global = new Map<string, SelectionState>();
|
|
332
|
+
|
|
328
333
|
export const Scrolling = {
|
|
329
|
-
render: () =>
|
|
334
|
+
render: () => (
|
|
335
|
+
<Story
|
|
336
|
+
text={str('# Large Document', '', large)}
|
|
337
|
+
extensions={state({
|
|
338
|
+
setState: (id, state) => global.set(id, state),
|
|
339
|
+
getState: (id) => global.get(id),
|
|
340
|
+
})}
|
|
341
|
+
/>
|
|
342
|
+
),
|
|
330
343
|
};
|
|
331
344
|
|
|
332
345
|
export const ScrollingWithImages = {
|
|
@@ -489,7 +502,18 @@ export const Annotations = {
|
|
|
489
502
|
};
|
|
490
503
|
|
|
491
504
|
export const DND = {
|
|
492
|
-
render: () =>
|
|
505
|
+
render: () => (
|
|
506
|
+
<Story
|
|
507
|
+
text={str('# DND', '')}
|
|
508
|
+
extensions={[
|
|
509
|
+
dropFile({
|
|
510
|
+
onDrop: (view, event) => {
|
|
511
|
+
log.info('drop', event);
|
|
512
|
+
},
|
|
513
|
+
}),
|
|
514
|
+
]}
|
|
515
|
+
/>
|
|
516
|
+
),
|
|
493
517
|
};
|
|
494
518
|
|
|
495
519
|
const typewriterItems = localStorage.getItem('dxos.org/plugin/markdown/typewriter')?.split(',');
|
|
@@ -18,7 +18,7 @@ import React, {
|
|
|
18
18
|
import { log } from '@dxos/log';
|
|
19
19
|
import { isNotFalsy } from '@dxos/util';
|
|
20
20
|
|
|
21
|
-
import { documentId, editorMode } from '../../extensions';
|
|
21
|
+
import { documentId, editorMode, focusEvent } from '../../extensions';
|
|
22
22
|
import { logChanges } from '../../util';
|
|
23
23
|
|
|
24
24
|
export type CursorInfo = {
|
|
@@ -34,7 +34,7 @@ export type TextEditorProps = Pick<EditorStateConfig, 'doc' | 'selection' | 'ext
|
|
|
34
34
|
id?: string;
|
|
35
35
|
className?: string;
|
|
36
36
|
autoFocus?: boolean;
|
|
37
|
-
scrollTo?: StateEffect<
|
|
37
|
+
scrollTo?: StateEffect<unknown>;
|
|
38
38
|
moveToEndOfLine?: boolean;
|
|
39
39
|
debug?: boolean;
|
|
40
40
|
dataTestId?: string;
|
|
@@ -56,14 +56,14 @@ export const TextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
|
56
56
|
extensions,
|
|
57
57
|
className,
|
|
58
58
|
autoFocus,
|
|
59
|
-
scrollTo = EditorView.scrollIntoView(0),
|
|
59
|
+
scrollTo = EditorView.scrollIntoView(0, { yMargin: 0 }),
|
|
60
60
|
moveToEndOfLine,
|
|
61
61
|
debug,
|
|
62
62
|
dataTestId,
|
|
63
63
|
},
|
|
64
64
|
forwardedRef,
|
|
65
65
|
) => {
|
|
66
|
-
//
|
|
66
|
+
// NOTE: Increments by 2 in strict mode.
|
|
67
67
|
const [instanceId] = useState(() => `text-editor-${++instanceCount}`);
|
|
68
68
|
|
|
69
69
|
// TODO(burdon): Make tabster optional.
|
|
@@ -85,7 +85,7 @@ export const TextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
|
85
85
|
// Create editor state and view.
|
|
86
86
|
// The view is recreated if the model or extensions are changed.
|
|
87
87
|
useEffect(() => {
|
|
88
|
-
log('
|
|
88
|
+
log('create', { id, instanceId });
|
|
89
89
|
|
|
90
90
|
//
|
|
91
91
|
// EditorState
|
|
@@ -104,7 +104,7 @@ export const TextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
|
104
104
|
// Focus.
|
|
105
105
|
EditorView.updateListener.of((update) => {
|
|
106
106
|
update.transactions.forEach((transaction) => {
|
|
107
|
-
if (transaction.isUserEvent(
|
|
107
|
+
if (transaction.isUserEvent(focusEvent)) {
|
|
108
108
|
rootRef.current?.focus();
|
|
109
109
|
}
|
|
110
110
|
});
|
|
@@ -122,6 +122,7 @@ export const TextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
|
122
122
|
state,
|
|
123
123
|
parent: rootRef.current!,
|
|
124
124
|
scrollTo,
|
|
125
|
+
|
|
125
126
|
// NOTE: Uncomment to debug/monitor all transactions.
|
|
126
127
|
// https://codemirror.net/docs/ref/#view.EditorView.dispatch
|
|
127
128
|
dispatchTransactions: (trs, view) => {
|
|
@@ -132,12 +133,10 @@ export const TextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
|
132
133
|
},
|
|
133
134
|
});
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// Position cursor at end of line.
|
|
138
|
-
if (moveToEndOfLine) {
|
|
136
|
+
// Position cursor at end of first line.
|
|
137
|
+
if (moveToEndOfLine && !(scrollTo || selection)) {
|
|
139
138
|
const { to } = view.state.doc.lineAt(0);
|
|
140
|
-
view
|
|
139
|
+
view.dispatch({ selection: { anchor: to } });
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
// Remove tabster attribute (rely on custom keymap).
|
|
@@ -145,9 +144,11 @@ export const TextEditor = forwardRef<EditorView | null, TextEditorProps>(
|
|
|
145
144
|
rootRef.current?.removeAttribute('data-tabster');
|
|
146
145
|
}
|
|
147
146
|
|
|
147
|
+
setView(view);
|
|
148
|
+
|
|
148
149
|
return () => {
|
|
150
|
+
log('destroy', { id, instanceId });
|
|
149
151
|
view?.destroy();
|
|
150
|
-
setView(null);
|
|
151
152
|
};
|
|
152
153
|
}, [doc, selection, extensions]);
|
|
153
154
|
|
|
@@ -16,17 +16,17 @@ import { withTheme } from '@dxos/storybook-utils';
|
|
|
16
16
|
import { Toolbar } from './Toolbar';
|
|
17
17
|
import {
|
|
18
18
|
type Comment,
|
|
19
|
-
decorateMarkdown,
|
|
20
19
|
comments,
|
|
21
20
|
createBasicExtensions,
|
|
22
21
|
createDataExtensions,
|
|
22
|
+
createMarkdownExtensions,
|
|
23
23
|
createThemeExtensions,
|
|
24
|
+
decorateMarkdown,
|
|
24
25
|
formattingKeymap,
|
|
26
|
+
image,
|
|
25
27
|
table,
|
|
26
28
|
useComments,
|
|
27
29
|
useFormattingState,
|
|
28
|
-
createMarkdownExtensions,
|
|
29
|
-
image,
|
|
30
30
|
} from '../../extensions';
|
|
31
31
|
import { useActionHandler, useDocAccessor, useTextEditor } from '../../hooks';
|
|
32
32
|
import translations from '../../translations';
|
|
@@ -34,15 +34,17 @@ import translations from '../../translations';
|
|
|
34
34
|
faker.seed(101);
|
|
35
35
|
|
|
36
36
|
const Story: FC<{ content: string }> = ({ content }) => {
|
|
37
|
+
console.log('STORY');
|
|
37
38
|
const { themeMode } = useThemeContext();
|
|
38
39
|
const [item] = useState({ text: new TextObject(content) });
|
|
39
40
|
const { id, doc, accessor } = useDocAccessor(item.text);
|
|
40
41
|
const [formattingState, formattingObserver] = useFormattingState();
|
|
41
|
-
const { parentRef, view } = useTextEditor(
|
|
42
|
-
|
|
42
|
+
const { parentRef, view } = useTextEditor(() => {
|
|
43
|
+
return {
|
|
43
44
|
id,
|
|
44
45
|
doc,
|
|
45
46
|
extensions: [
|
|
47
|
+
formattingObserver,
|
|
46
48
|
createBasicExtensions(),
|
|
47
49
|
createMarkdownExtensions({ themeMode }),
|
|
48
50
|
createThemeExtensions({ themeMode, slots: { editor: { className: 'p-2' } } }),
|
|
@@ -58,39 +60,36 @@ const Story: FC<{ content: string }> = ({ content }) => {
|
|
|
58
60
|
formattingKeymap(),
|
|
59
61
|
image(),
|
|
60
62
|
table(),
|
|
61
|
-
formattingObserver,
|
|
62
63
|
],
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
};
|
|
65
|
+
}, [id, accessor, formattingObserver, themeMode]);
|
|
66
|
+
|
|
67
|
+
const handleAction = useActionHandler(view);
|
|
66
68
|
|
|
67
69
|
const [_comments, setComments] = useState<Comment[]>([]);
|
|
68
70
|
useComments(view, id, _comments);
|
|
69
71
|
|
|
70
|
-
const handleAction = useActionHandler(view);
|
|
71
|
-
|
|
72
72
|
return (
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
<Toolbar.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
<Tooltip.Provider>
|
|
74
|
+
<div role='none' className='fixed inset-0 flex flex-col'>
|
|
75
|
+
<Toolbar.Root onAction={handleAction} state={formattingState} classNames={textBlockWidth}>
|
|
76
|
+
<Toolbar.Markdown />
|
|
77
|
+
<Toolbar.Custom onUpload={async (file) => ({ url: file.name })} />
|
|
78
|
+
<Toolbar.Separator />
|
|
79
|
+
<Toolbar.Actions />
|
|
80
|
+
</Toolbar.Root>
|
|
81
|
+
<div ref={parentRef} className={textBlockWidth} />
|
|
82
|
+
</div>
|
|
83
|
+
</Tooltip.Provider>
|
|
81
84
|
);
|
|
82
85
|
};
|
|
83
86
|
|
|
84
87
|
export default {
|
|
85
88
|
title: 'react-ui-editor/Toolbar',
|
|
86
89
|
component: Toolbar,
|
|
87
|
-
render: (args: any) => (
|
|
88
|
-
<Tooltip.Provider>
|
|
89
|
-
<Story {...args} />
|
|
90
|
-
</Tooltip.Provider>
|
|
91
|
-
),
|
|
92
90
|
decorators: [withTheme],
|
|
93
91
|
parameters: { translations, layout: 'fullscreen' },
|
|
92
|
+
render: (args: any) => <Story {...args} />,
|
|
94
93
|
};
|
|
95
94
|
|
|
96
95
|
const content = [
|