@webround/editor 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks.d.ts +90 -0
- package/dist/blocks.js +119 -0
- package/dist/bridge.d.ts +96 -0
- package/dist/bridge.js +970 -0
- package/dist/check/aria.d.ts +19 -0
- package/dist/check/aria.js +106 -0
- package/dist/check/cli.d.ts +3 -0
- package/dist/check/cli.js +30 -0
- package/dist/check/css.d.ts +13 -0
- package/dist/check/css.js +63 -0
- package/dist/check/html.d.ts +8 -0
- package/dist/check/html.js +29 -0
- package/dist/check/index.d.ts +4 -0
- package/dist/check/index.js +5 -0
- package/dist/check/links.d.ts +7 -0
- package/dist/check/links.js +23 -0
- package/dist/check/orphans.d.ts +20 -0
- package/dist/check/orphans.js +57 -0
- package/dist/check/producer-code.d.ts +53 -0
- package/dist/check/producer-code.js +379 -0
- package/dist/check/producer-dom.d.ts +21 -0
- package/dist/check/producer-dom.js +52 -0
- package/dist/check/project.d.ts +20 -0
- package/dist/check/project.js +51 -0
- package/dist/check/rules.d.ts +7 -0
- package/dist/check/rules.js +517 -0
- package/dist/check/types.d.ts +160 -0
- package/dist/check/types.js +22 -0
- package/dist/components/WrAltcha.d.ts +5 -0
- package/dist/components/WrAltcha.js +8 -0
- package/dist/components/WrButton.d.ts +8 -0
- package/dist/components/WrButton.js +34 -0
- package/dist/components/WrForm.d.ts +6 -0
- package/dist/components/WrForm.js +29 -0
- package/dist/components/WrFormPrivacy.d.ts +4 -0
- package/dist/components/WrFormPrivacy.js +7 -0
- package/dist/components/WrFormSuccess.d.ts +4 -0
- package/dist/components/WrFormSuccess.js +12 -0
- package/dist/components/WrIframe.d.ts +12 -0
- package/dist/components/WrIframe.js +30 -0
- package/dist/components/WrImage.d.ts +9 -0
- package/dist/components/WrImage.js +28 -0
- package/dist/components/WrInput.d.ts +8 -0
- package/dist/components/WrInput.js +29 -0
- package/dist/components/WrLink.d.ts +10 -0
- package/dist/components/WrLink.js +38 -0
- package/dist/components/WrNav.d.ts +26 -0
- package/dist/components/WrNav.js +30 -0
- package/dist/components/WrSection.d.ts +11 -0
- package/dist/components/WrSection.js +5 -0
- package/dist/components/WrShared.d.ts +12 -0
- package/dist/components/WrShared.js +20 -0
- package/dist/components/WrText.d.ts +11 -0
- package/dist/components/WrText.js +41 -0
- package/dist/components/WrVideo.d.ts +9 -0
- package/dist/components/WrVideo.js +73 -0
- package/dist/components/text-editor/CodeThemeContext.d.ts +8 -0
- package/dist/components/text-editor/CodeThemeContext.js +10 -0
- package/dist/components/text-editor/ExampleTheme.d.ts +77 -0
- package/dist/components/text-editor/ExampleTheme.js +76 -0
- package/dist/components/text-editor/ToolbarContext.d.ts +17 -0
- package/dist/components/text-editor/ToolbarContext.js +32 -0
- package/dist/components/text-editor/WrTextEditor.d.ts +13 -0
- package/dist/components/text-editor/WrTextEditor.js +48 -0
- package/dist/components/text-editor/common/constants.d.ts +109 -0
- package/dist/components/text-editor/common/constants.js +58 -0
- package/dist/components/text-editor/common/surface.d.ts +3 -0
- package/dist/components/text-editor/common/surface.js +8 -0
- package/dist/components/text-editor/common/utils.d.ts +7 -0
- package/dist/components/text-editor/common/utils.js +78 -0
- package/dist/components/text-editor/hooks/useLexicalCommitOnBlur.d.ts +5 -0
- package/dist/components/text-editor/hooks/useLexicalCommitOnBlur.js +41 -0
- package/dist/components/text-editor/hooks/useLexicalMarkdown.d.ts +33 -0
- package/dist/components/text-editor/hooks/useLexicalMarkdown.js +284 -0
- package/dist/components/text-editor/nodes/CodeBlockNode.d.ts +23 -0
- package/dist/components/text-editor/nodes/CodeBlockNode.js +138 -0
- package/dist/components/text-editor/nodes/HorizontalRuleNode.d.ts +13 -0
- package/dist/components/text-editor/nodes/HorizontalRuleNode.js +22 -0
- package/dist/components/text-editor/plugins/CodeBlockPlugin.d.ts +2 -0
- package/dist/components/text-editor/plugins/CodeBlockPlugin.js +38 -0
- package/dist/components/text-editor/plugins/FontPlugin.d.ts +12 -0
- package/dist/components/text-editor/plugins/FontPlugin.js +114 -0
- package/dist/components/text-editor/plugins/FontSizePlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/FontSizePlugin.js +105 -0
- package/dist/components/text-editor/plugins/FontWeightPlugin.d.ts +6 -0
- package/dist/components/text-editor/plugins/FontWeightPlugin.js +103 -0
- package/dist/components/text-editor/plugins/HTMLTagPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/HTMLTagPlugin.js +82 -0
- package/dist/components/text-editor/plugins/HorizontalRulePlugin.d.ts +2 -0
- package/dist/components/text-editor/plugins/HorizontalRulePlugin.js +35 -0
- package/dist/components/text-editor/plugins/LineSpacingPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/LineSpacingPlugin.js +83 -0
- package/dist/components/text-editor/plugins/LinkPlugin.d.ts +8 -0
- package/dist/components/text-editor/plugins/LinkPlugin.js +183 -0
- package/dist/components/text-editor/plugins/ListToolbarPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/ListToolbarPlugin.js +40 -0
- package/dist/components/text-editor/plugins/LoadContentPlugin.d.ts +4 -0
- package/dist/components/text-editor/plugins/LoadContentPlugin.js +63 -0
- package/dist/components/text-editor/plugins/MarkdownExportPlugin.d.ts +4 -0
- package/dist/components/text-editor/plugins/MarkdownExportPlugin.js +17 -0
- package/dist/components/text-editor/plugins/MarkdownPastePlugin.d.ts +2 -0
- package/dist/components/text-editor/plugins/MarkdownPastePlugin.js +45 -0
- package/dist/components/text-editor/plugins/SanitizePastePlugin.d.ts +3 -0
- package/dist/components/text-editor/plugins/SanitizePastePlugin.js +40 -0
- package/dist/components/text-editor/plugins/TextAlignPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/TextAlignPlugin.js +65 -0
- package/dist/components/text-editor/plugins/TextColorPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/TextColorPlugin.js +117 -0
- package/dist/components/text-editor/plugins/ToolbarPlugin.d.ts +10 -0
- package/dist/components/text-editor/plugins/ToolbarPlugin.js +73 -0
- package/dist/components/text-editor/theme-colors.d.ts +11 -0
- package/dist/components/text-editor/theme-colors.js +28 -0
- package/dist/context/WrAppContext.d.ts +35 -0
- package/dist/context/WrAppContext.js +113 -0
- package/dist/context/WrLayout.d.ts +15 -0
- package/dist/context/WrLayout.js +22 -0
- package/dist/context/WrPageContext.d.ts +28 -0
- package/dist/context/WrPageContext.js +282 -0
- package/dist/context/restoreValues.d.ts +2 -0
- package/dist/context/restoreValues.js +6 -0
- package/dist/contrast.d.ts +45 -0
- package/dist/contrast.js +122 -0
- package/dist/drop.d.ts +7 -0
- package/dist/drop.js +51 -0
- package/dist/gaps.d.ts +14 -0
- package/dist/gaps.js +50 -0
- package/dist/hooks/useWrMessage.d.ts +5 -0
- package/dist/hooks/useWrMessage.js +24 -0
- package/dist/hooks/useWrSave.d.ts +2 -0
- package/dist/hooks/useWrSave.js +11 -0
- package/dist/index.css +467 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/interactive.d.ts +8 -0
- package/dist/interactive.js +13 -0
- package/dist/measure-rules.d.ts +34 -0
- package/dist/measure-rules.js +54 -0
- package/dist/measure.d.ts +11 -0
- package/dist/measure.js +139 -0
- package/dist/messages.d.ts +860 -0
- package/dist/messages.js +2 -0
- package/dist/nav.d.ts +5 -0
- package/dist/nav.js +10 -0
- package/dist/operations/animations-store.d.ts +6 -0
- package/dist/operations/animations-store.js +63 -0
- package/dist/operations/cli.d.ts +3 -0
- package/dist/operations/cli.js +52 -0
- package/dist/operations/comments-store.d.ts +17 -0
- package/dist/operations/comments-store.js +62 -0
- package/dist/operations/context.d.ts +12 -0
- package/dist/operations/context.js +35 -0
- package/dist/operations/define.d.ts +81 -0
- package/dist/operations/define.js +86 -0
- package/dist/operations/index.d.ts +6 -0
- package/dist/operations/index.js +6 -0
- package/dist/operations/ops/check.d.ts +5 -0
- package/dist/operations/ops/check.js +53 -0
- package/dist/operations/ops/comments.d.ts +6 -0
- package/dist/operations/ops/comments.js +133 -0
- package/dist/operations/ops/content.d.ts +16 -0
- package/dist/operations/ops/content.js +73 -0
- package/dist/operations/ops/json.d.ts +4 -0
- package/dist/operations/ops/json.js +27 -0
- package/dist/operations/ops/langs.d.ts +4 -0
- package/dist/operations/ops/langs.js +32 -0
- package/dist/operations/ops/nodes.d.ts +8 -0
- package/dist/operations/ops/nodes.js +270 -0
- package/dist/operations/ops/pages.d.ts +8 -0
- package/dist/operations/ops/pages.js +154 -0
- package/dist/operations/ops/project.d.ts +36 -0
- package/dist/operations/ops/project.js +97 -0
- package/dist/operations/ops/seo.d.ts +17 -0
- package/dist/operations/ops/seo.js +358 -0
- package/dist/operations/ops/style.d.ts +76 -0
- package/dist/operations/ops/style.js +268 -0
- package/dist/operations/ops/stylesets.d.ts +9 -0
- package/dist/operations/ops/stylesets.js +145 -0
- package/dist/operations/ops/theme.d.ts +6 -0
- package/dist/operations/ops/theme.js +304 -0
- package/dist/operations/registry.d.ts +8 -0
- package/dist/operations/registry.js +19 -0
- package/dist/operations/stylesets-store.d.ts +50 -0
- package/dist/operations/stylesets-store.js +216 -0
- package/dist/registry.d.ts +5 -0
- package/dist/registry.js +24 -0
- package/dist/save.d.ts +65 -0
- package/dist/save.js +86 -0
- package/dist/schema.d.ts +69 -0
- package/dist/schema.js +110 -0
- package/dist/scope.d.ts +41 -0
- package/dist/scope.js +44 -0
- package/dist/vite-plugins/ast.d.ts +3 -0
- package/dist/vite-plugins/ast.js +238 -0
- package/dist/vite-plugins/core-swap.d.ts +3 -0
- package/dist/vite-plugins/core-swap.js +57 -0
- package/dist/vite-plugins/create-page.d.ts +4 -0
- package/dist/vite-plugins/create-page.js +59 -0
- package/dist/vite-plugins/guard.d.ts +15 -0
- package/dist/vite-plugins/guard.js +35 -0
- package/dist/vite-plugins/head.d.ts +13 -0
- package/dist/vite-plugins/head.js +53 -0
- package/dist/vite-plugins/index.d.ts +7 -0
- package/dist/vite-plugins/index.js +7 -0
- package/dist/vite-plugins/jsx-tree.d.ts +118 -0
- package/dist/vite-plugins/jsx-tree.js +686 -0
- package/dist/vite-plugins/langs.d.ts +3 -0
- package/dist/vite-plugins/langs.js +44 -0
- package/dist/vite-plugins/operations.d.ts +10 -0
- package/dist/vite-plugins/operations.js +66 -0
- package/dist/vite-plugins/pages-api.d.ts +3 -0
- package/dist/vite-plugins/pages-api.js +112 -0
- package/dist/vite-plugins/pages.d.ts +3 -0
- package/dist/vite-plugins/pages.js +64 -0
- package/dist/vite-plugins/read.d.ts +3 -0
- package/dist/vite-plugins/read.js +45 -0
- package/dist/vite-plugins/seo-files.d.ts +8 -0
- package/dist/vite-plugins/seo-files.js +42 -0
- package/dist/vite-plugins/theme.d.ts +3 -0
- package/dist/vite-plugins/theme.js +207 -0
- package/dist/vite-plugins/update.d.ts +3 -0
- package/dist/vite-plugins/update.js +46 -0
- package/dist/vite-plugins/wr-plugins.d.ts +15 -0
- package/dist/vite-plugins/wr-plugins.js +34 -0
- package/dist/vite-plugins.d.ts +11 -0
- package/dist/vite-plugins.js +518 -0
- package/package.json +96 -5
- package/README.md +0 -3
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: {
|
|
9
|
+
code: string;
|
|
10
|
+
codeHighlight: {
|
|
11
|
+
atrule: string;
|
|
12
|
+
attr: string;
|
|
13
|
+
boolean: string;
|
|
14
|
+
builtin: string;
|
|
15
|
+
cdata: string;
|
|
16
|
+
char: string;
|
|
17
|
+
class: string;
|
|
18
|
+
'class-name': string;
|
|
19
|
+
comment: string;
|
|
20
|
+
constant: string;
|
|
21
|
+
deleted: string;
|
|
22
|
+
doctype: string;
|
|
23
|
+
entity: string;
|
|
24
|
+
function: string;
|
|
25
|
+
important: string;
|
|
26
|
+
inserted: string;
|
|
27
|
+
keyword: string;
|
|
28
|
+
namespace: string;
|
|
29
|
+
number: string;
|
|
30
|
+
operator: string;
|
|
31
|
+
prolog: string;
|
|
32
|
+
property: string;
|
|
33
|
+
punctuation: string;
|
|
34
|
+
regex: string;
|
|
35
|
+
selector: string;
|
|
36
|
+
string: string;
|
|
37
|
+
symbol: string;
|
|
38
|
+
tag: string;
|
|
39
|
+
url: string;
|
|
40
|
+
variable: string;
|
|
41
|
+
};
|
|
42
|
+
heading: {
|
|
43
|
+
h1: string;
|
|
44
|
+
h2: string;
|
|
45
|
+
h3: string;
|
|
46
|
+
h4: string;
|
|
47
|
+
h5: string;
|
|
48
|
+
h6: string;
|
|
49
|
+
};
|
|
50
|
+
image: string;
|
|
51
|
+
link: string;
|
|
52
|
+
list: {
|
|
53
|
+
listitem: string;
|
|
54
|
+
nested: {
|
|
55
|
+
listitem: string;
|
|
56
|
+
};
|
|
57
|
+
ol: string;
|
|
58
|
+
ul: string;
|
|
59
|
+
};
|
|
60
|
+
ltr: string;
|
|
61
|
+
paragraph: string;
|
|
62
|
+
placeholder: string;
|
|
63
|
+
quote: string;
|
|
64
|
+
rtl: string;
|
|
65
|
+
text: {
|
|
66
|
+
bold: string;
|
|
67
|
+
code: string;
|
|
68
|
+
hashtag: string;
|
|
69
|
+
italic: string;
|
|
70
|
+
overflowed: string;
|
|
71
|
+
strikethrough: string;
|
|
72
|
+
underline: string;
|
|
73
|
+
underlineStrikethrough: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export default _default;
|
|
77
|
+
//# sourceMappingURL=ExampleTheme.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export default {
|
|
9
|
+
code: 'editor-code',
|
|
10
|
+
codeHighlight: {
|
|
11
|
+
atrule: 'editor-tokenAttr',
|
|
12
|
+
attr: 'editor-tokenAttr',
|
|
13
|
+
boolean: 'editor-tokenProperty',
|
|
14
|
+
builtin: 'editor-tokenSelector',
|
|
15
|
+
cdata: 'editor-tokenComment',
|
|
16
|
+
char: 'editor-tokenSelector',
|
|
17
|
+
class: 'editor-tokenFunction',
|
|
18
|
+
'class-name': 'editor-tokenFunction',
|
|
19
|
+
comment: 'editor-tokenComment',
|
|
20
|
+
constant: 'editor-tokenProperty',
|
|
21
|
+
deleted: 'editor-tokenProperty',
|
|
22
|
+
doctype: 'editor-tokenComment',
|
|
23
|
+
entity: 'editor-tokenOperator',
|
|
24
|
+
function: 'editor-tokenFunction',
|
|
25
|
+
important: 'editor-tokenVariable',
|
|
26
|
+
inserted: 'editor-tokenSelector',
|
|
27
|
+
keyword: 'editor-tokenAttr',
|
|
28
|
+
namespace: 'editor-tokenVariable',
|
|
29
|
+
number: 'editor-tokenProperty',
|
|
30
|
+
operator: 'editor-tokenOperator',
|
|
31
|
+
prolog: 'editor-tokenComment',
|
|
32
|
+
property: 'editor-tokenProperty',
|
|
33
|
+
punctuation: 'editor-tokenPunctuation',
|
|
34
|
+
regex: 'editor-tokenVariable',
|
|
35
|
+
selector: 'editor-tokenSelector',
|
|
36
|
+
string: 'editor-tokenSelector',
|
|
37
|
+
symbol: 'editor-tokenProperty',
|
|
38
|
+
tag: 'editor-tokenProperty',
|
|
39
|
+
url: 'editor-tokenOperator',
|
|
40
|
+
variable: 'editor-tokenVariable',
|
|
41
|
+
},
|
|
42
|
+
heading: {
|
|
43
|
+
h1: 'editor-heading-h1',
|
|
44
|
+
h2: 'editor-heading-h2',
|
|
45
|
+
h3: 'editor-heading-h3',
|
|
46
|
+
h4: 'editor-heading-h4',
|
|
47
|
+
h5: 'editor-heading-h5',
|
|
48
|
+
h6: 'editor-heading-h6',
|
|
49
|
+
},
|
|
50
|
+
image: 'editor-image',
|
|
51
|
+
link: 'editor-link',
|
|
52
|
+
list: {
|
|
53
|
+
listitem: 'editor-listitem',
|
|
54
|
+
nested: {
|
|
55
|
+
listitem: 'editor-nested-listitem',
|
|
56
|
+
},
|
|
57
|
+
ol: 'editor-list-ol',
|
|
58
|
+
ul: 'editor-list-ul',
|
|
59
|
+
},
|
|
60
|
+
ltr: 'ltr',
|
|
61
|
+
paragraph: 'editor-paragraph',
|
|
62
|
+
placeholder: 'editor-placeholder',
|
|
63
|
+
quote: 'editor-quote',
|
|
64
|
+
rtl: 'rtl',
|
|
65
|
+
text: {
|
|
66
|
+
bold: 'editor-text-bold',
|
|
67
|
+
code: 'editor-text-code',
|
|
68
|
+
hashtag: 'editor-text-hashtag',
|
|
69
|
+
italic: 'editor-text-italic',
|
|
70
|
+
overflowed: 'editor-text-overflowed',
|
|
71
|
+
strikethrough: 'editor-text-strikethrough',
|
|
72
|
+
underline: 'editor-text-underline',
|
|
73
|
+
underlineStrikethrough: 'editor-text-underlineStrikethrough',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=ExampleTheme.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ToolbarContextValue = {
|
|
3
|
+
isMenuOpen: boolean;
|
|
4
|
+
openMenu: () => void;
|
|
5
|
+
closeMenu: () => void;
|
|
6
|
+
toolbarVisible: boolean;
|
|
7
|
+
toggleToolbar: () => void;
|
|
8
|
+
setToolbarVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
9
|
+
editorFocused: boolean;
|
|
10
|
+
handleEditorClick: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare function useToolbar(): ToolbarContextValue;
|
|
13
|
+
export declare function ToolbarProvider({ children }: {
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}): React.JSX.Element;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=ToolbarContext.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useState, useCallback, useEffect } from 'react';
|
|
3
|
+
const ToolbarContext = createContext(null);
|
|
4
|
+
export function useToolbar() {
|
|
5
|
+
return useContext(ToolbarContext);
|
|
6
|
+
}
|
|
7
|
+
export function ToolbarProvider({ children }) {
|
|
8
|
+
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
9
|
+
const [toolbarVisible, setToolbarVisible] = useState(true);
|
|
10
|
+
const [editorFocused, setEditorFocused] = useState(false);
|
|
11
|
+
const toggleToolbar = useCallback(() => {
|
|
12
|
+
setToolbarVisible(prev => !prev);
|
|
13
|
+
}, []);
|
|
14
|
+
const openMenu = useCallback(() => setIsMenuOpen(true), []);
|
|
15
|
+
const closeMenu = useCallback(() => setIsMenuOpen(false), []);
|
|
16
|
+
const handleEditorClick = useCallback(() => setEditorFocused(true), []);
|
|
17
|
+
const handleOutsideClick = useCallback((event) => {
|
|
18
|
+
if (!event.target.closest('.editor-container')) {
|
|
19
|
+
setEditorFocused(false);
|
|
20
|
+
}
|
|
21
|
+
}, []);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
document.addEventListener('click', handleOutsideClick);
|
|
24
|
+
return () => document.removeEventListener('click', handleOutsideClick);
|
|
25
|
+
}, [handleOutsideClick]);
|
|
26
|
+
return (_jsx(ToolbarContext.Provider, { value: {
|
|
27
|
+
isMenuOpen, openMenu, closeMenu,
|
|
28
|
+
toolbarVisible, toggleToolbar, setToolbarVisible,
|
|
29
|
+
editorFocused, handleEditorClick,
|
|
30
|
+
}, children: children }));
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ToolbarContext.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
editorPathKey: string;
|
|
4
|
+
availablePages?: string[];
|
|
5
|
+
initialHtml: string;
|
|
6
|
+
onSave: (html: string) => void;
|
|
7
|
+
onCancel: () => void;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function WrTextEditor({ editorPathKey, availablePages, initialHtml, onSave, onCancel, style, className }: Props): React.JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=WrTextEditor.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useCallback, useRef } from 'react';
|
|
3
|
+
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
4
|
+
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
5
|
+
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
6
|
+
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
7
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
8
|
+
import { ListPlugin } from '@lexical/react/LexicalListPlugin';
|
|
9
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
10
|
+
import { $generateHtmlFromNodes } from '@lexical/html';
|
|
11
|
+
import { ToolbarProvider } from './ToolbarContext';
|
|
12
|
+
import { useLexicalCommitOnBlur } from './hooks/useLexicalCommitOnBlur';
|
|
13
|
+
import LoadContentPlugin from './plugins/LoadContentPlugin';
|
|
14
|
+
import ToolbarPlugin from './plugins/ToolbarPlugin';
|
|
15
|
+
import { editorConfig } from './common/constants';
|
|
16
|
+
function KeyboardPlugin({ onSave, onCancel }) {
|
|
17
|
+
const [editor] = useLexicalComposerContext();
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
const onKey = (e) => {
|
|
20
|
+
if (e.key === 'Escape') {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
onCancel();
|
|
23
|
+
}
|
|
24
|
+
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
editor.getEditorState().read(() => onSave());
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
document.addEventListener('keydown', onKey);
|
|
30
|
+
return () => document.removeEventListener('keydown', onKey);
|
|
31
|
+
}, [editor, onSave, onCancel]);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function EditorInner({ editorPathKey, availablePages, initialHtml, onSave, onCancel, style, className }) {
|
|
35
|
+
const [editor] = useLexicalComposerContext();
|
|
36
|
+
const editorRef = useRef(null);
|
|
37
|
+
const { commit: commitOnBlur, finish } = useLexicalCommitOnBlur(initialHtml, onSave, onCancel);
|
|
38
|
+
const saveNow = useCallback(() => {
|
|
39
|
+
editor.getEditorState().read(() => {
|
|
40
|
+
onSave($generateHtmlFromNodes(editor));
|
|
41
|
+
});
|
|
42
|
+
}, [editor, onSave]);
|
|
43
|
+
return (_jsx(ToolbarProvider, { children: _jsxs("div", { "data-wr-editing": true, style: { position: 'relative', outline: '2px solid #3b82f6', ...style }, className: className, children: [_jsx(ToolbarPlugin, { editorRef: editorRef, editorPathKey: editorPathKey, availablePages: availablePages, onOutside: finish }), _jsx("div", { style: { position: 'relative' }, children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { ref: editorRef, onBlur: commitOnBlur, style: { outline: 'none', minHeight: 24 } }), placeholder: _jsx("div", { className: "editor-placeholder", children: "Type something..." }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(HistoryPlugin, {}), _jsx(ListPlugin, {}), _jsx(LoadContentPlugin, { html: initialHtml }), _jsx(KeyboardPlugin, { onSave: saveNow, onCancel: onCancel })] }) }));
|
|
44
|
+
}
|
|
45
|
+
export function WrTextEditor({ editorPathKey, availablePages, initialHtml, onSave, onCancel, style, className }) {
|
|
46
|
+
return (_jsx(LexicalComposer, { initialConfig: editorConfig, children: _jsx(EditorInner, { editorPathKey: editorPathKey, availablePages: availablePages, initialHtml: initialHtml, onSave: onSave, onCancel: onCancel, style: style, className: className }) }));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=WrTextEditor.js.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ListItemNode, ListNode } from "@lexical/list";
|
|
2
|
+
import { LinkNode } from '@lexical/link';
|
|
3
|
+
import { HeadingNode } from '@lexical/rich-text';
|
|
4
|
+
import { HorizontalRuleNode } from "../nodes/HorizontalRuleNode";
|
|
5
|
+
import { CodeBlockNode } from "../nodes/CodeBlockNode";
|
|
6
|
+
export declare const defaultState: {
|
|
7
|
+
root: {
|
|
8
|
+
children: {
|
|
9
|
+
children: {
|
|
10
|
+
detail: number;
|
|
11
|
+
format: number;
|
|
12
|
+
mode: string;
|
|
13
|
+
style: string;
|
|
14
|
+
text: string;
|
|
15
|
+
type: string;
|
|
16
|
+
version: number;
|
|
17
|
+
formats: never[];
|
|
18
|
+
}[];
|
|
19
|
+
direction: string;
|
|
20
|
+
format: string;
|
|
21
|
+
indent: number;
|
|
22
|
+
type: string;
|
|
23
|
+
version: number;
|
|
24
|
+
textFormat: number;
|
|
25
|
+
}[];
|
|
26
|
+
direction: string;
|
|
27
|
+
format: string;
|
|
28
|
+
indent: number;
|
|
29
|
+
type: string;
|
|
30
|
+
version: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export declare const editorConfig: {
|
|
34
|
+
namespace: string;
|
|
35
|
+
nodes: (typeof HorizontalRuleNode | typeof CodeBlockNode | typeof HeadingNode | typeof LinkNode | typeof ListNode | typeof ListItemNode)[];
|
|
36
|
+
onError(error: any): never;
|
|
37
|
+
theme: {
|
|
38
|
+
code: string;
|
|
39
|
+
codeHighlight: {
|
|
40
|
+
atrule: string;
|
|
41
|
+
attr: string;
|
|
42
|
+
boolean: string;
|
|
43
|
+
builtin: string;
|
|
44
|
+
cdata: string;
|
|
45
|
+
char: string;
|
|
46
|
+
class: string;
|
|
47
|
+
'class-name': string;
|
|
48
|
+
comment: string;
|
|
49
|
+
constant: string;
|
|
50
|
+
deleted: string;
|
|
51
|
+
doctype: string;
|
|
52
|
+
entity: string;
|
|
53
|
+
function: string;
|
|
54
|
+
important: string;
|
|
55
|
+
inserted: string;
|
|
56
|
+
keyword: string;
|
|
57
|
+
namespace: string;
|
|
58
|
+
number: string;
|
|
59
|
+
operator: string;
|
|
60
|
+
prolog: string;
|
|
61
|
+
property: string;
|
|
62
|
+
punctuation: string;
|
|
63
|
+
regex: string;
|
|
64
|
+
selector: string;
|
|
65
|
+
string: string;
|
|
66
|
+
symbol: string;
|
|
67
|
+
tag: string;
|
|
68
|
+
url: string;
|
|
69
|
+
variable: string;
|
|
70
|
+
};
|
|
71
|
+
heading: {
|
|
72
|
+
h1: string;
|
|
73
|
+
h2: string;
|
|
74
|
+
h3: string;
|
|
75
|
+
h4: string;
|
|
76
|
+
h5: string;
|
|
77
|
+
h6: string;
|
|
78
|
+
};
|
|
79
|
+
image: string;
|
|
80
|
+
link: string;
|
|
81
|
+
list: {
|
|
82
|
+
listitem: string;
|
|
83
|
+
nested: {
|
|
84
|
+
listitem: string;
|
|
85
|
+
};
|
|
86
|
+
ol: string;
|
|
87
|
+
ul: string;
|
|
88
|
+
};
|
|
89
|
+
ltr: string;
|
|
90
|
+
paragraph: string;
|
|
91
|
+
placeholder: string;
|
|
92
|
+
quote: string;
|
|
93
|
+
rtl: string;
|
|
94
|
+
text: {
|
|
95
|
+
bold: string;
|
|
96
|
+
code: string;
|
|
97
|
+
hashtag: string;
|
|
98
|
+
italic: string;
|
|
99
|
+
overflowed: string;
|
|
100
|
+
strikethrough: string;
|
|
101
|
+
underline: string;
|
|
102
|
+
underlineStrikethrough: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
editable: boolean;
|
|
106
|
+
readonly: boolean;
|
|
107
|
+
};
|
|
108
|
+
export declare const lexicalPlaceholder = "Type some text";
|
|
109
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ListItemNode, ListNode } from "@lexical/list";
|
|
2
|
+
import ExampleTheme from "../ExampleTheme";
|
|
3
|
+
import { LinkNode } from '@lexical/link';
|
|
4
|
+
import { HeadingNode } from '@lexical/rich-text';
|
|
5
|
+
import { HorizontalRuleNode } from "../nodes/HorizontalRuleNode";
|
|
6
|
+
import { CodeBlockNode } from "../nodes/CodeBlockNode";
|
|
7
|
+
// Stato di default dell'editor, utile per fornire un punto di partenza coerente
|
|
8
|
+
export const defaultState = {
|
|
9
|
+
"root": {
|
|
10
|
+
"children": [
|
|
11
|
+
{
|
|
12
|
+
"children": [
|
|
13
|
+
{
|
|
14
|
+
"detail": 0,
|
|
15
|
+
"format": 0,
|
|
16
|
+
"mode": "normal",
|
|
17
|
+
"style": "font-family: Manrope;line-height: 1; color: #000000",
|
|
18
|
+
"text": "webround",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"version": 1,
|
|
21
|
+
"formats": []
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"direction": "ltr",
|
|
25
|
+
"format": "left",
|
|
26
|
+
"indent": 0,
|
|
27
|
+
"type": "paragraph",
|
|
28
|
+
"version": 1,
|
|
29
|
+
"textFormat": 0
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"direction": "ltr",
|
|
33
|
+
"format": "",
|
|
34
|
+
"indent": 0,
|
|
35
|
+
"type": "root",
|
|
36
|
+
"version": 1
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// Configurazione di base dell'editor Lexical
|
|
40
|
+
export const editorConfig = {
|
|
41
|
+
namespace: 'Webround',
|
|
42
|
+
nodes: [
|
|
43
|
+
HeadingNode,
|
|
44
|
+
LinkNode,
|
|
45
|
+
ListNode,
|
|
46
|
+
ListItemNode,
|
|
47
|
+
HorizontalRuleNode,
|
|
48
|
+
CodeBlockNode
|
|
49
|
+
],
|
|
50
|
+
onError(error) {
|
|
51
|
+
throw error; // Gestione degli errori
|
|
52
|
+
},
|
|
53
|
+
theme: ExampleTheme, // Tema personalizzato
|
|
54
|
+
editable: true,
|
|
55
|
+
readonly: true
|
|
56
|
+
};
|
|
57
|
+
export const lexicalPlaceholder = "Type some text";
|
|
58
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Colori FISSI delle superfici dei plugin (barra e menu): sfondo bianco, testo nero.
|
|
2
|
+
// Vanno come stile in linea, non da una classe CSS: i plugin vivono dentro la pagina del sito e uno stile
|
|
3
|
+
// in linea non può essere cambiato dal tema, da `data-theme` o dal colore del body.
|
|
4
|
+
export const WR_SURFACE_STYLE = {
|
|
5
|
+
backgroundColor: '#ffffff',
|
|
6
|
+
color: '#000000',
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=surface.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EditorState, LexicalNode, TextNode } from "lexical";
|
|
2
|
+
export declare function decodeFormat(format: number): string[];
|
|
3
|
+
export declare function onChangeHandler(editorState: EditorState): void;
|
|
4
|
+
export declare function exportEditorState(editorState: EditorState): string;
|
|
5
|
+
export declare function getFirstTextNode(node: LexicalNode): TextNode | null;
|
|
6
|
+
export declare function isPartOfActiveEditor(target: Node | null, path: any): boolean;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { $getRoot, $getSelection } from "lexical";
|
|
2
|
+
export function decodeFormat(format) {
|
|
3
|
+
const formats = [];
|
|
4
|
+
if (format & 1)
|
|
5
|
+
formats.push('bold');
|
|
6
|
+
if (format & 2)
|
|
7
|
+
formats.push('italic');
|
|
8
|
+
if (format & 4)
|
|
9
|
+
formats.push('underline');
|
|
10
|
+
if (format & 8)
|
|
11
|
+
formats.push('strikethrough');
|
|
12
|
+
if (format & 16)
|
|
13
|
+
formats.push('code');
|
|
14
|
+
if (format & 32)
|
|
15
|
+
formats.push('subscript');
|
|
16
|
+
if (format & 64)
|
|
17
|
+
formats.push('superscript');
|
|
18
|
+
return formats;
|
|
19
|
+
}
|
|
20
|
+
export function onChangeHandler(editorState) {
|
|
21
|
+
editorState.read(() => {
|
|
22
|
+
const root = $getRoot();
|
|
23
|
+
const selection = $getSelection();
|
|
24
|
+
const jsonContent = exportEditorState(editorState);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function exportEditorState(editorState) {
|
|
28
|
+
const content = editorState.toJSON();
|
|
29
|
+
const root = content.root;
|
|
30
|
+
function traverseNode(node) {
|
|
31
|
+
delete node.textStyle;
|
|
32
|
+
if (node.type === 'text') {
|
|
33
|
+
node.formats = decodeFormat(node.format);
|
|
34
|
+
}
|
|
35
|
+
if (node.children) {
|
|
36
|
+
node.children = node.children.map(traverseNode);
|
|
37
|
+
}
|
|
38
|
+
return node;
|
|
39
|
+
}
|
|
40
|
+
const updatedRoot = traverseNode(root);
|
|
41
|
+
return JSON.stringify({ root: updatedRoot }, null, 2);
|
|
42
|
+
}
|
|
43
|
+
export function getFirstTextNode(node) {
|
|
44
|
+
if (node.getType() === 'text')
|
|
45
|
+
return node;
|
|
46
|
+
if ('getFirstChild' in node && typeof node.getFirstChild === 'function') {
|
|
47
|
+
const child = node.getFirstChild();
|
|
48
|
+
if (child)
|
|
49
|
+
return getFirstTextNode(child);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
export function isPartOfActiveEditor(target, path) {
|
|
54
|
+
if (!target)
|
|
55
|
+
return false;
|
|
56
|
+
const editorPathKey = path.join('-');
|
|
57
|
+
const isMatchingEditorPath = (el) => el instanceof HTMLElement && el.dataset.editorPath === editorPathKey;
|
|
58
|
+
const isInsideToolbarClass = (el) => el instanceof HTMLElement &&
|
|
59
|
+
el.classList.contains('toolbarClass') &&
|
|
60
|
+
el.dataset.editorPath === editorPathKey;
|
|
61
|
+
if (target instanceof HTMLElement) {
|
|
62
|
+
if (isMatchingEditorPath(target))
|
|
63
|
+
return true;
|
|
64
|
+
if (isInsideToolbarClass(target.closest('.toolbarClass')))
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
while (target) {
|
|
68
|
+
if (target instanceof HTMLElement) {
|
|
69
|
+
if (isMatchingEditorPath(target))
|
|
70
|
+
return true;
|
|
71
|
+
if (isInsideToolbarClass(target.closest('.toolbarClass')))
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
target = target.parentNode;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
import { $generateHtmlFromNodes } from "@lexical/html";
|
|
4
|
+
export function useLexicalCommitOnBlur(initialHtml, onSave, onUnchanged) {
|
|
5
|
+
const [editor] = useLexicalComposerContext();
|
|
6
|
+
const hasChangesRef = useRef(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
return editor.registerUpdateListener(() => {
|
|
9
|
+
hasChangesRef.current = true;
|
|
10
|
+
});
|
|
11
|
+
}, [editor]);
|
|
12
|
+
// `commit`: the field lost the focus (to the toolbar too, so nothing is closed when nothing changed). `finish`: the person is done with this text (they clicked or tapped
|
|
13
|
+
// somewhere else): what changed is saved, and the editing ends either way, so its outline goes with it.
|
|
14
|
+
const commit = useCallback(() => {
|
|
15
|
+
if (!hasChangesRef.current)
|
|
16
|
+
return;
|
|
17
|
+
hasChangesRef.current = false;
|
|
18
|
+
editor.getEditorState().read(() => {
|
|
19
|
+
const html = $generateHtmlFromNodes(editor);
|
|
20
|
+
if (html !== initialHtml)
|
|
21
|
+
onSave(html);
|
|
22
|
+
});
|
|
23
|
+
}, [editor, initialHtml, onSave]);
|
|
24
|
+
const finish = useCallback(() => {
|
|
25
|
+
const changed = hasChangesRef.current;
|
|
26
|
+
hasChangesRef.current = false;
|
|
27
|
+
if (!changed) {
|
|
28
|
+
onUnchanged();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
editor.getEditorState().read(() => {
|
|
32
|
+
const html = $generateHtmlFromNodes(editor);
|
|
33
|
+
if (html !== initialHtml)
|
|
34
|
+
onSave(html);
|
|
35
|
+
else
|
|
36
|
+
onUnchanged();
|
|
37
|
+
});
|
|
38
|
+
}, [editor, initialHtml, onSave, onUnchanged]);
|
|
39
|
+
return { commit, finish };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=useLexicalCommitOnBlur.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TextNode } from "lexical";
|
|
2
|
+
import { LinkNode } from "@lexical/link";
|
|
3
|
+
type InlineToken = {
|
|
4
|
+
kind: "text";
|
|
5
|
+
text: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "bold";
|
|
8
|
+
text: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "italic";
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "code";
|
|
14
|
+
text: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "strike";
|
|
17
|
+
text: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "under";
|
|
20
|
+
text: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "link";
|
|
23
|
+
text: string;
|
|
24
|
+
url: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function tokenizeInline(raw: string): InlineToken[];
|
|
27
|
+
export declare function buildNodes(tokens: InlineToken[], style: string): (TextNode | LinkNode)[];
|
|
28
|
+
export declare function useLexicalMarkdown(): {
|
|
29
|
+
toMarkdown: () => string;
|
|
30
|
+
fromMarkdown: (md: string) => void;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=useLexicalMarkdown.d.ts.map
|