@blocklet/editor 2.2.46 → 2.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/lib/ext/PostLinkEmbedPlugin/PostLinkNode.d.ts +2 -2
- package/lib/ext/PostLinkEmbedPlugin/PostLinkNode.js +3 -3
- package/lib/main/editor.js +3 -7
- package/lib/main/index.css +16 -18
- package/lib/main/markdown-editor/editor.js +1 -1
- package/lib/main/markdown-editor/transformers.js +7 -6
- package/lib/main/nodes/EmojiNode.d.ts +1 -2
- package/lib/main/nodes/EmojiNode.js +4 -9
- package/lib/main/nodes/EquationNode.js +14 -7
- package/lib/main/nodes/ImageComponent.js +2 -2
- package/lib/main/nodes/PlaygroundNodes.js +0 -2
- package/lib/main/nodes/StickyComponent.js +1 -1
- package/lib/main/plugins/CodeActionMenuPlugin/index.js +24 -28
- package/lib/main/plugins/MarkdownTransformers/index.d.ts +1 -4
- package/lib/main/plugins/MarkdownTransformers/index.js +48 -79
- package/lib/main/plugins/TableActionMenuPlugin/index.js +229 -171
- package/lib/main/plugins/TableCellResizer/index.css +8 -2
- package/lib/main/plugins/TableCellResizer/index.js +168 -120
- package/lib/main/plugins/TableOfContentsPlugin/index.js +2 -2
- package/lib/main/plugins/TablePlugin.d.ts +3 -4
- package/lib/main/plugins/TablePlugin.js +7 -24
- package/lib/main/plugins/ToolbarPlugin/index.js +0 -1
- package/lib/main/themes/defaultTheme.js +3 -1
- package/lib/main/ui/ContentEditable.d.ts +1 -4
- package/lib/main/ui/Modal.css +1 -1
- package/lib/main/ui/TextInput.d.ts +4 -3
- package/lib/main/ui/TextInput.js +3 -19
- package/package.json +20 -21
- package/lib/main/nodes/AutocompleteNode.d.ts +0 -34
- package/lib/main/nodes/AutocompleteNode.js +0 -52
- package/lib/main/nodes/EquationComponent.d.ts +0 -16
- package/lib/main/nodes/EquationComponent.js +0 -64
- package/lib/main/plugins/ActionsPlugin/index.d.ts +0 -11
- package/lib/main/plugins/ActionsPlugin/index.js +0 -129
- package/lib/main/plugins/AutocompletePlugin/index.d.ts +0 -10
- package/lib/main/plugins/AutocompletePlugin/index.js +0 -2461
- package/lib/main/plugins/CodeActionMenuPlugin/components/PrettierButton/index.css +0 -14
- package/lib/main/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +0 -17
- package/lib/main/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +0 -95
- package/lib/main/plugins/EquationsPlugin/index.d.ts +0 -21
- package/lib/main/plugins/EquationsPlugin/index.js +0 -42
- package/lib/main/plugins/SpeechToTextPlugin/index.d.ts +0 -12
- package/lib/main/plugins/SpeechToTextPlugin/index.js +0 -87
- package/lib/main/ui/EquationEditor.css +0 -38
- package/lib/main/ui/EquationEditor.d.ts +0 -19
- package/lib/main/ui/EquationEditor.js +0 -26
- package/lib/main/ui/KatexEquationAlterer.css +0 -41
- package/lib/main/ui/KatexEquationAlterer.d.ts +0 -15
- package/lib/main/ui/KatexEquationAlterer.js +0 -34
- package/lib/main/ui/KatexRenderer.d.ts +0 -13
- package/lib/main/ui/KatexRenderer.js +0 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,30 +32,29 @@
|
|
|
32
32
|
"@excalidraw/excalidraw": "^0.14.2",
|
|
33
33
|
"@iconify/iconify": "^3.1.1",
|
|
34
34
|
"@iconify/icons-tabler": "^1.2.95",
|
|
35
|
-
"@lexical/clipboard": "0.
|
|
36
|
-
"@lexical/code": "0.
|
|
37
|
-
"@lexical/file": "0.
|
|
38
|
-
"@lexical/hashtag": "0.
|
|
39
|
-
"@lexical/headless": "0.
|
|
40
|
-
"@lexical/html": "0.
|
|
41
|
-
"@lexical/link": "0.
|
|
42
|
-
"@lexical/list": "0.
|
|
43
|
-
"@lexical/mark": "0.
|
|
44
|
-
"@lexical/markdown": "0.
|
|
45
|
-
"@lexical/overflow": "0.
|
|
46
|
-
"@lexical/react": "0.
|
|
47
|
-
"@lexical/rich-text": "0.
|
|
48
|
-
"@lexical/selection": "0.
|
|
49
|
-
"@lexical/table": "0.
|
|
50
|
-
"@lexical/utils": "0.
|
|
51
|
-
"@lexical/yjs": "0.
|
|
35
|
+
"@lexical/clipboard": "^0.30.0",
|
|
36
|
+
"@lexical/code": "^0.30.0",
|
|
37
|
+
"@lexical/file": "^0.30.0",
|
|
38
|
+
"@lexical/hashtag": "^0.30.0",
|
|
39
|
+
"@lexical/headless": "^0.30.0",
|
|
40
|
+
"@lexical/html": "^0.30.0",
|
|
41
|
+
"@lexical/link": "^0.30.0",
|
|
42
|
+
"@lexical/list": "^0.30.0",
|
|
43
|
+
"@lexical/mark": "^0.30.0",
|
|
44
|
+
"@lexical/markdown": "^0.30.0",
|
|
45
|
+
"@lexical/overflow": "^0.30.0",
|
|
46
|
+
"@lexical/react": "^0.30.0",
|
|
47
|
+
"@lexical/rich-text": "^0.30.0",
|
|
48
|
+
"@lexical/selection": "^0.30.0",
|
|
49
|
+
"@lexical/table": "^0.30.0",
|
|
50
|
+
"@lexical/utils": "^0.30.0",
|
|
51
|
+
"@lexical/yjs": "^0.30.0",
|
|
52
52
|
"@microsoft/fetch-event-source": "^2.0.1",
|
|
53
53
|
"@popperjs/core": "^2.11.8",
|
|
54
54
|
"ahooks": "^3.8.1",
|
|
55
55
|
"joi": "^17.13.3",
|
|
56
|
-
"katex": "^0.15.6",
|
|
57
56
|
"leven": "^4.0.0",
|
|
58
|
-
"lexical": "0.
|
|
57
|
+
"lexical": "^0.30.0",
|
|
59
58
|
"lodash": "^4.17.21",
|
|
60
59
|
"lottie-react": "^2.4.0",
|
|
61
60
|
"marked": "^15.0.8",
|
|
@@ -69,7 +68,7 @@
|
|
|
69
68
|
"ufo": "^1.5.4",
|
|
70
69
|
"url-join": "^4.0.1",
|
|
71
70
|
"zustand": "^4.5.5",
|
|
72
|
-
"@blocklet/pdf": "^2.
|
|
71
|
+
"@blocklet/pdf": "^2.3.0"
|
|
73
72
|
},
|
|
74
73
|
"devDependencies": {
|
|
75
74
|
"@babel/core": "^7.25.2",
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
/// <reference types="react" />
|
|
9
|
-
import type { Spread } from 'lexical';
|
|
10
|
-
import { DecoratorNode, EditorConfig, NodeKey, SerializedLexicalNode } from 'lexical';
|
|
11
|
-
declare global {
|
|
12
|
-
interface Navigator {
|
|
13
|
-
userAgentData?: {
|
|
14
|
-
mobile: boolean;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export type SerializedAutocompleteNode = Spread<{
|
|
19
|
-
type: 'autocomplete';
|
|
20
|
-
version: 1;
|
|
21
|
-
uuid: string;
|
|
22
|
-
}, SerializedLexicalNode>;
|
|
23
|
-
export declare class AutocompleteNode extends DecoratorNode<JSX.Element | null> {
|
|
24
|
-
__uuid: string;
|
|
25
|
-
static clone(node: AutocompleteNode): AutocompleteNode;
|
|
26
|
-
static getType(): 'autocomplete';
|
|
27
|
-
static importJSON(serializedNode: SerializedAutocompleteNode): AutocompleteNode;
|
|
28
|
-
exportJSON(): SerializedAutocompleteNode;
|
|
29
|
-
constructor(uuid: string, key?: NodeKey);
|
|
30
|
-
updateDOM(prevNode: unknown, dom: HTMLElement, config: EditorConfig): boolean;
|
|
31
|
-
createDOM(config: EditorConfig): HTMLElement;
|
|
32
|
-
decorate(): JSX.Element | null;
|
|
33
|
-
}
|
|
34
|
-
export declare function $createAutocompleteNode(uuid: string): AutocompleteNode;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DecoratorNode } from 'lexical';
|
|
3
|
-
import { useSharedAutocompleteContext } from '../context/SharedAutocompleteContext';
|
|
4
|
-
import { uuid as UUID } from '../plugins/AutocompletePlugin';
|
|
5
|
-
export class AutocompleteNode extends DecoratorNode {
|
|
6
|
-
// TODO add comment
|
|
7
|
-
__uuid;
|
|
8
|
-
static clone(node) {
|
|
9
|
-
return new AutocompleteNode(node.__key);
|
|
10
|
-
}
|
|
11
|
-
static getType() {
|
|
12
|
-
return 'autocomplete';
|
|
13
|
-
}
|
|
14
|
-
static importJSON(serializedNode) {
|
|
15
|
-
const node = $createAutocompleteNode(serializedNode.uuid);
|
|
16
|
-
return node;
|
|
17
|
-
}
|
|
18
|
-
exportJSON() {
|
|
19
|
-
return {
|
|
20
|
-
...super.exportJSON(),
|
|
21
|
-
type: 'autocomplete',
|
|
22
|
-
uuid: this.__uuid,
|
|
23
|
-
version: 1,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
constructor(uuid, key) {
|
|
27
|
-
super(key);
|
|
28
|
-
this.__uuid = uuid;
|
|
29
|
-
}
|
|
30
|
-
updateDOM(prevNode, dom, config) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
createDOM(config) {
|
|
34
|
-
return document.createElement('span');
|
|
35
|
-
}
|
|
36
|
-
decorate() {
|
|
37
|
-
if (this.__uuid !== UUID) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return _jsx(AutocompleteComponent, {});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export function $createAutocompleteNode(uuid) {
|
|
44
|
-
return new AutocompleteNode(uuid);
|
|
45
|
-
}
|
|
46
|
-
function AutocompleteComponent() {
|
|
47
|
-
const [suggestion] = useSharedAutocompleteContext();
|
|
48
|
-
const { userAgentData } = window.navigator;
|
|
49
|
-
const isMobile = userAgentData !== undefined ? userAgentData.mobile : window.innerWidth <= 800 && window.innerHeight <= 600;
|
|
50
|
-
// TODO Move to theme
|
|
51
|
-
return (_jsxs("span", { style: { color: '#ccc' }, spellCheck: "false", children: [suggestion, " ", isMobile ? '(SWIPE \u2B95)' : '(TAB)'] }));
|
|
52
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
/// <reference types="react" />
|
|
9
|
-
import type { NodeKey } from 'lexical';
|
|
10
|
-
type EquationComponentProps = {
|
|
11
|
-
equation: string;
|
|
12
|
-
inline: boolean;
|
|
13
|
-
nodeKey: NodeKey;
|
|
14
|
-
};
|
|
15
|
-
export default function EquationComponent({ equation, inline, nodeKey }: EquationComponentProps): JSX.Element;
|
|
16
|
-
export {};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
-
import { mergeRegister } from '@lexical/utils';
|
|
4
|
-
import { $getNodeByKey, $getSelection, $isNodeSelection, COMMAND_PRIORITY_HIGH, KEY_ESCAPE_COMMAND, SELECTION_CHANGE_COMMAND, } from 'lexical';
|
|
5
|
-
import { lazyRetry as lazy } from '@arcblock/ux/lib/Util';
|
|
6
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
|
-
import EquationEditor from '../ui/EquationEditor';
|
|
8
|
-
import { $isEquationNode } from './EquationNode';
|
|
9
|
-
const KatexRenderer = lazy(() => import('../ui/KatexRenderer'));
|
|
10
|
-
export default function EquationComponent({ equation, inline, nodeKey }) {
|
|
11
|
-
const [editor] = useLexicalComposerContext();
|
|
12
|
-
const [equationValue, setEquationValue] = useState(equation);
|
|
13
|
-
const [showEquationEditor, setShowEquationEditor] = useState(false);
|
|
14
|
-
const inputRef = useRef(null);
|
|
15
|
-
const onHide = useCallback((restoreSelection) => {
|
|
16
|
-
setShowEquationEditor(false);
|
|
17
|
-
editor.update(() => {
|
|
18
|
-
const node = $getNodeByKey(nodeKey);
|
|
19
|
-
if ($isEquationNode(node)) {
|
|
20
|
-
node.setEquation(equationValue);
|
|
21
|
-
if (restoreSelection) {
|
|
22
|
-
node.selectNext(0, 0);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}, [editor, equationValue, nodeKey]);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!showEquationEditor && equationValue !== equation) {
|
|
29
|
-
setEquationValue(equation);
|
|
30
|
-
}
|
|
31
|
-
}, [showEquationEditor, equation, equationValue]);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (showEquationEditor) {
|
|
34
|
-
return mergeRegister(editor.registerCommand(SELECTION_CHANGE_COMMAND, (payload) => {
|
|
35
|
-
const { activeElement } = document;
|
|
36
|
-
const inputElem = inputRef.current;
|
|
37
|
-
if (inputElem !== activeElement) {
|
|
38
|
-
onHide();
|
|
39
|
-
}
|
|
40
|
-
return false;
|
|
41
|
-
}, COMMAND_PRIORITY_HIGH), editor.registerCommand(KEY_ESCAPE_COMMAND, (payload) => {
|
|
42
|
-
const { activeElement } = document;
|
|
43
|
-
const inputElem = inputRef.current;
|
|
44
|
-
if (inputElem === activeElement) {
|
|
45
|
-
onHide(true);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}, COMMAND_PRIORITY_HIGH));
|
|
50
|
-
}
|
|
51
|
-
return editor.registerUpdateListener(({ editorState }) => {
|
|
52
|
-
const isSelected = editorState.read(() => {
|
|
53
|
-
const selection = $getSelection();
|
|
54
|
-
return $isNodeSelection(selection) && selection.has(nodeKey) && selection.getNodes().length === 1;
|
|
55
|
-
});
|
|
56
|
-
if (isSelected) {
|
|
57
|
-
setShowEquationEditor(true);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}, [editor, nodeKey, onHide, showEquationEditor]);
|
|
61
|
-
return showEquationEditor ? (_jsx(EquationEditor, { equation: equationValue, setEquation: setEquationValue, inline: inline, inputRef: inputRef })) : (_jsx(KatexRenderer, { equation: equationValue, inline: inline, onClick: () => {
|
|
62
|
-
setShowEquationEditor(true);
|
|
63
|
-
} }));
|
|
64
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
/// <reference types="react" />
|
|
9
|
-
export default function ActionsPlugin({ isRichText }: {
|
|
10
|
-
isRichText: boolean;
|
|
11
|
-
}): JSX.Element;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { $createCodeNode, $isCodeNode } from '@lexical/code';
|
|
3
|
-
import { exportFile, importFile } from '@lexical/file';
|
|
4
|
-
import { $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown';
|
|
5
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
6
|
-
import { mergeRegister } from '@lexical/utils';
|
|
7
|
-
import { CONNECTED_COMMAND } from '@lexical/yjs';
|
|
8
|
-
import { $createTextNode, $getRoot, $isParagraphNode, CLEAR_EDITOR_COMMAND, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
9
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
10
|
-
import useModal from '../../hooks/useModal';
|
|
11
|
-
import Button from '../../ui/Button';
|
|
12
|
-
import { PLAYGROUND_TRANSFORMERS } from '../MarkdownTransformers';
|
|
13
|
-
import { SPEECH_TO_TEXT_COMMAND, SUPPORT_SPEECH_RECOGNITION } from '../SpeechToTextPlugin';
|
|
14
|
-
async function sendEditorState(editor) {
|
|
15
|
-
const stringifiedEditorState = JSON.stringify(editor.getEditorState());
|
|
16
|
-
try {
|
|
17
|
-
await fetch('http://localhost:1235/setEditorState', {
|
|
18
|
-
body: stringifiedEditorState,
|
|
19
|
-
headers: {
|
|
20
|
-
Accept: 'application/json',
|
|
21
|
-
'Content-type': 'application/json',
|
|
22
|
-
},
|
|
23
|
-
method: 'POST',
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
// NO-OP
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async function validateEditorState(editor) {
|
|
31
|
-
const stringifiedEditorState = JSON.stringify(editor.getEditorState());
|
|
32
|
-
let response = null;
|
|
33
|
-
try {
|
|
34
|
-
response = await fetch('http://localhost:1235/validateEditorState', {
|
|
35
|
-
body: stringifiedEditorState,
|
|
36
|
-
headers: {
|
|
37
|
-
Accept: 'application/json',
|
|
38
|
-
'Content-type': 'application/json',
|
|
39
|
-
},
|
|
40
|
-
method: 'POST',
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
// NO-OP
|
|
45
|
-
}
|
|
46
|
-
if (response !== null && response.status === 403) {
|
|
47
|
-
throw new Error('Editor state validation failed! Server did not accept changes.');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export default function ActionsPlugin({ isRichText }) {
|
|
51
|
-
const [editor] = useLexicalComposerContext();
|
|
52
|
-
const [isEditable, setIsEditable] = useState(() => editor.isEditable());
|
|
53
|
-
const [isSpeechToText, setIsSpeechToText] = useState(false);
|
|
54
|
-
const [connected, setConnected] = useState(false);
|
|
55
|
-
const [isEditorEmpty, setIsEditorEmpty] = useState(true);
|
|
56
|
-
const [modal, showModal] = useModal();
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
return mergeRegister(editor.registerEditableListener((editable) => {
|
|
59
|
-
setIsEditable(editable);
|
|
60
|
-
}), editor.registerCommand(CONNECTED_COMMAND, (payload) => {
|
|
61
|
-
const isConnected = payload;
|
|
62
|
-
setConnected(isConnected);
|
|
63
|
-
return false;
|
|
64
|
-
}, COMMAND_PRIORITY_EDITOR));
|
|
65
|
-
}, [editor]);
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
return editor.registerUpdateListener(({ dirtyElements, prevEditorState, tags }) => {
|
|
68
|
-
// If we are in read only mode, send the editor state
|
|
69
|
-
// to server and ask for validation if possible.
|
|
70
|
-
if (!isEditable && dirtyElements.size > 0 && !tags.has('historic')) {
|
|
71
|
-
validateEditorState(editor);
|
|
72
|
-
}
|
|
73
|
-
editor.getEditorState().read(() => {
|
|
74
|
-
const root = $getRoot();
|
|
75
|
-
const children = root.getChildren();
|
|
76
|
-
if (children.length > 1) {
|
|
77
|
-
setIsEditorEmpty(false);
|
|
78
|
-
}
|
|
79
|
-
else if ($isParagraphNode(children[0])) {
|
|
80
|
-
const paragraphChildren = children[0].getChildren();
|
|
81
|
-
setIsEditorEmpty(paragraphChildren.length === 0);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
setIsEditorEmpty(false);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}, [editor, isEditable]);
|
|
89
|
-
const handleMarkdownToggle = useCallback(() => {
|
|
90
|
-
editor.update(() => {
|
|
91
|
-
const root = $getRoot();
|
|
92
|
-
const firstChild = root.getFirstChild();
|
|
93
|
-
if ($isCodeNode(firstChild) && firstChild.getLanguage() === 'markdown') {
|
|
94
|
-
$convertFromMarkdownString(firstChild.getTextContent(), PLAYGROUND_TRANSFORMERS);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
const markdown = $convertToMarkdownString(PLAYGROUND_TRANSFORMERS);
|
|
98
|
-
root.clear().append($createCodeNode('markdown').append($createTextNode(markdown)));
|
|
99
|
-
}
|
|
100
|
-
root.selectEnd();
|
|
101
|
-
});
|
|
102
|
-
}, [editor]);
|
|
103
|
-
return (_jsxs("div", { className: "actions", children: [SUPPORT_SPEECH_RECOGNITION && (_jsx("button", { onClick: () => {
|
|
104
|
-
editor.dispatchCommand(SPEECH_TO_TEXT_COMMAND, !isSpeechToText);
|
|
105
|
-
setIsSpeechToText(!isSpeechToText);
|
|
106
|
-
}, className: `action-button action-button-mic ${isSpeechToText ? 'active' : ''}`, title: "Speech To Text", "aria-label": `${isSpeechToText ? 'Enable' : 'Disable'} speech to text`, children: _jsx("i", { className: "mic" }) })), _jsx("button", { className: "action-button import", onClick: () => importFile(editor), title: "Import", "aria-label": "Import editor state from JSON", children: _jsx("i", { className: "import" }) }), _jsx("button", { className: "action-button export", onClick: () => exportFile(editor, {
|
|
107
|
-
fileName: `Playground ${new Date().toISOString()}`,
|
|
108
|
-
source: 'Playground',
|
|
109
|
-
}), title: "Export", "aria-label": "Export editor state to JSON", children: _jsx("i", { className: "export" }) }), _jsx("button", { className: "action-button clear", disabled: isEditorEmpty, onClick: () => {
|
|
110
|
-
// eslint-disable-next-line react/no-unstable-nested-components
|
|
111
|
-
showModal('Clear editor', (onClose) => _jsx(ShowClearDialog, { editor: editor, onClose: onClose }));
|
|
112
|
-
}, title: "Clear", "aria-label": "Clear editor contents", children: _jsx("i", { className: "clear" }) }), _jsx("button", { className: `action-button ${!isEditable ? 'unlock' : 'lock'}`, onClick: () => {
|
|
113
|
-
// Send latest editor state to commenting validation server
|
|
114
|
-
if (isEditable) {
|
|
115
|
-
sendEditorState(editor);
|
|
116
|
-
}
|
|
117
|
-
editor.setEditable(!editor.isEditable());
|
|
118
|
-
}, title: "Read-Only Mode", "aria-label": `${!isEditable ? 'Unlock' : 'Lock'} read-only mode`, children: _jsx("i", { className: !isEditable ? 'unlock' : 'lock' }) }), _jsx("button", { className: "action-button", onClick: handleMarkdownToggle, title: "Convert From Markdown", "aria-label": "Convert from markdown", children: _jsx("i", { className: "markdown" }) }), modal] }));
|
|
119
|
-
}
|
|
120
|
-
function ShowClearDialog({ editor, onClose }) {
|
|
121
|
-
return (_jsxs(_Fragment, { children: ["Are you sure you want to clear the editor?", _jsxs("div", { className: "Modal__content", children: [_jsx(Button, { onClick: () => {
|
|
122
|
-
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
|
|
123
|
-
editor.focus();
|
|
124
|
-
onClose();
|
|
125
|
-
}, children: "Clear" }), ' ', _jsx(Button, { onClick: () => {
|
|
126
|
-
editor.focus();
|
|
127
|
-
onClose();
|
|
128
|
-
}, children: "Cancel" })] })] }));
|
|
129
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
/// <reference types="react" />
|
|
9
|
-
export declare const uuid: string;
|
|
10
|
-
export default function AutocompletePlugin(): JSX.Element | null;
|