@lobehub/editor 4.24.1 → 4.25.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/es/codemirror/style.js +42 -0
- package/es/editor-kernel/kernel.js +3 -0
- package/es/editor-kernel/react/useDecorators.js +2 -4
- package/es/headless/collapsible-plugin.js +74 -0
- package/es/headless/index.js +2 -0
- package/es/headless.d.ts +18 -0
- package/es/headless.js +2479 -71
- package/es/index.d.ts +26 -3
- package/es/index.js +17 -2
- package/es/locale/index.d.ts +14 -0
- package/es/locale/index.js +14 -0
- package/es/plugins/block/command/index.js +24 -0
- package/es/plugins/block/plugin/index.js +7 -5
- package/es/plugins/block/react/ReactBlockPlugin.js +43 -1
- package/es/plugins/block/react/core/menu-position.js +20 -0
- package/es/plugins/block/react/drag/drag-session.js +3 -2
- package/es/plugins/block/react/drag/drag-utils.js +13 -1
- package/es/plugins/codemirror-block/index.d.ts +2 -1
- package/es/plugins/codemirror-block/plugin/index.js +2 -0
- package/es/plugins/codemirror-block/react/CodemirrorNode.js +95 -5
- package/es/plugins/codemirror-block/react/useCodemirrorEditLock.js +33 -0
- package/es/plugins/codemirror-block/service/index.d.ts +40 -0
- package/es/plugins/codemirror-block/service/index.js +59 -0
- package/es/plugins/collapsible/command/index.d.ts +17 -0
- package/es/plugins/collapsible/command/index.js +72 -0
- package/es/plugins/collapsible/index.d.ts +7 -0
- package/es/plugins/collapsible/node/CollapsibleNode.d.ts +30 -0
- package/es/plugins/collapsible/node/CollapsibleNode.js +138 -0
- package/es/plugins/collapsible/plugin/index.d.ts +11 -0
- package/es/plugins/collapsible/plugin/index.js +535 -0
- package/es/plugins/collapsible/react/ReactCollapsiblePlugin.d.ts +6 -0
- package/es/plugins/collapsible/react/ReactCollapsiblePlugin.js +19 -0
- package/es/plugins/collapsible/react/index.d.ts +3 -0
- package/es/plugins/collapsible/react/style.js +67 -0
- package/es/plugins/collapsible/react/type.d.ts +6 -0
- package/es/plugins/common/plugin/index.js +3 -2
- package/es/plugins/common/plugin/progressive-select-all.js +81 -0
- package/es/plugins/common/plugin/register.js +73 -4
- package/es/plugins/link/command/index.js +26 -3
- package/es/plugins/link/conversion/index.js +237 -0
- package/es/plugins/link/index.d.ts +5 -3
- package/es/plugins/link/node/LinkBlockCardNode.d.ts +16 -0
- package/es/plugins/link/node/LinkBlockCardNode.js +66 -0
- package/es/plugins/link/node/LinkCardNode.d.ts +42 -0
- package/es/plugins/link/node/LinkCardNode.js +161 -0
- package/es/plugins/link/node/LinkIframeNode.d.ts +33 -0
- package/es/plugins/link/node/LinkIframeNode.js +131 -0
- package/es/plugins/link/node/LinkNode.d.ts +48 -2
- package/es/plugins/link/node/LinkNode.js +14 -6
- package/es/plugins/link/node/SchemaNode.d.ts +36 -0
- package/es/plugins/link/node/SchemaNode.js +149 -0
- package/es/plugins/link/normalization/index.d.ts +7 -0
- package/es/plugins/link/normalization/index.js +38 -0
- package/es/plugins/link/plugin/index.d.ts +26 -1
- package/es/plugins/link/plugin/index.js +124 -4
- package/es/plugins/link/react/ReactLinkPlugin.js +165 -7
- package/es/plugins/link/react/components/LinkCard.js +235 -0
- package/es/plugins/link/react/components/LinkEdit.js +93 -14
- package/es/plugins/link/react/components/LinkIframe.js +128 -0
- package/es/plugins/link/react/components/LinkToolbar.js +440 -111
- package/es/plugins/link/react/components/SchemaLink.js +49 -0
- package/es/plugins/link/react/index.d.ts +2 -2
- package/es/plugins/link/react/renderer-registry.d.ts +81 -0
- package/es/plugins/link/react/renderer-registry.js +80 -0
- package/es/plugins/link/react/style.js +63 -1
- package/es/plugins/link/react/type.d.ts +24 -1
- package/es/plugins/link/service/i-link-service.d.ts +156 -1
- package/es/plugins/link/service/i-link-service.js +258 -5
- package/es/plugins/list/plugin/index.js +9 -2
- package/es/plugins/litexml/command/diffCommand.js +94 -14
- package/es/plugins/litexml/command/index.js +187 -6
- package/es/plugins/litexml/diff-validation.js +237 -0
- package/es/plugins/litexml/node/DiffContentNode.js +67 -0
- package/es/plugins/litexml/node/DiffNode.d.ts +1 -1
- package/es/plugins/litexml/node/DiffNode.js +5 -2
- package/es/plugins/litexml/node/TableCellDiffNode.js +77 -0
- package/es/plugins/litexml/node/TableRowDiffNode.js +73 -0
- package/es/plugins/litexml/plugin/index.d.ts +2 -0
- package/es/plugins/litexml/plugin/index.js +62 -9
- package/es/plugins/litexml/react/DiffNodeToolbar/index.js +10 -12
- package/es/plugins/litexml/react/TableRowDiffToolbar.js +123 -0
- package/es/plugins/litexml/react/hooks/useHasDiffNode.js +5 -2
- package/es/plugins/litexml/react/index.js +6 -2
- package/es/plugins/litexml/react/style.js +18 -5
- package/es/plugins/litexml/table-cell-diff.js +153 -0
- package/es/plugins/litexml/table-row-diff.js +82 -0
- package/es/plugins/markdown/data-source/markdown/parse.js +25 -1
- package/es/plugins/markdown/plugin/index.js +5 -3
- package/es/plugins/slash/react/ReactSlashPlugin.js +22 -43
- package/es/plugins/slash/react/components/DefaultSlashMenu.js +76 -16
- package/es/plugins/slash/react/menu-utils.js +84 -0
- package/es/plugins/slash/service/i-slash-service.d.ts +3 -0
- package/es/plugins/table/plugin/index.js +4 -1
- package/es/plugins/table/plugin/single-cell-paste.js +79 -0
- package/es/plugins/table/react/TableController/hooks.js +7 -4
- package/es/plugins/table/react/hooks.js +2 -2
- package/es/plugins/table/react/index.js +2 -0
- package/es/plugins/table/react/style.js +15 -5
- package/es/plugins/table/react/useScrollFocusedTableCellIntoView.js +46 -0
- package/es/plugins/toc/index.d.ts +10 -0
- package/es/plugins/toc/plugin/index.d.ts +8 -0
- package/es/plugins/toc/plugin/index.js +56 -0
- package/es/plugins/toc/react/ReactTocPlugin.d.ts +6 -0
- package/es/plugins/toc/react/ReactTocPlugin.js +36 -0
- package/es/plugins/toc/react/getNearestScrollContainer.d.ts +6 -0
- package/es/plugins/toc/react/getNearestScrollContainer.js +18 -0
- package/es/plugins/toc/react/hooks/useActiveHeading.js +59 -0
- package/es/plugins/toc/react/hooks/useTocItems.js +50 -0
- package/es/plugins/toc/react/index.d.ts +5 -0
- package/es/plugins/toc/react/type.d.ts +30 -0
- package/es/plugins/toc/react/useToc.d.ts +5 -0
- package/es/plugins/toc/react/useToc.js +41 -0
- package/es/plugins/toc/service/i-toc-service.d.ts +39 -0
- package/es/plugins/toc/service/i-toc-service.js +125 -0
- package/es/plugins/toc/service/index.d.ts +3 -0
- package/es/plugins/toc/types.d.ts +23 -0
- package/es/plugins/toc/utils/index.d.ts +6 -0
- package/es/plugins/toc/utils/index.js +30 -0
- package/es/plugins/toolbar/react/index.js +26 -12
- package/es/plugins/toolbar/react/style.js +3 -2
- package/es/plugins/virtual-block/plugin/register.js +34 -12
- package/es/plugins/yjs/index.d.ts +6 -0
- package/es/plugins/yjs/plugin/index.d.ts +7 -0
- package/es/plugins/yjs/plugin/index.js +191 -0
- package/es/plugins/yjs/plugin/types.d.ts +16 -0
- package/es/plugins/yjs/plugin/utils/awareness.js +9 -0
- package/es/plugins/yjs/plugin/utils/editor-state.js +47 -0
- package/es/plugins/yjs/plugin/utils/history.js +31 -0
- package/es/plugins/yjs/plugin/utils/node-properties.js +39 -0
- package/es/plugins/yjs/plugin/utils/sync.js +24 -0
- package/es/plugins/yjs/react/codemirrorEditLockProvider.js +59 -0
- package/es/plugins/yjs/react/index.d.ts +23 -0
- package/es/plugins/yjs/react/index.js +200 -0
- package/es/plugins/yjs/service/index.d.ts +47 -0
- package/es/plugins/yjs/service/index.js +84 -0
- package/es/plugins/yjs/websocket-provider.d.ts +78 -0
- package/es/plugins/yjs/websocket-provider.js +263 -0
- package/es/renderer/LexicalRenderer.js +9 -2
- package/es/types/kernel.d.ts +4 -0
- package/es/utils/updatePosition.js +5 -2
- package/package.json +3 -1
- package/patches/@lexical__yjs@0.42.0.patch +42 -0
- package/scripts/postinstall-lexical-patch.cjs +62 -36
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useLexicalEditor } from "../../../../editor-kernel/react/useLexicalEditor.js";
|
|
2
2
|
import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
|
|
3
3
|
import { UPDATE_LINK_TEXT_COMMAND } from "../../command/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { EDIT_LINK_CARD_COMMAND } from "../../node/LinkCardNode.js";
|
|
5
5
|
import { cleanPosition, updatePosition } from "../../../../utils/updatePosition.js";
|
|
6
6
|
import { styles } from "../style.js";
|
|
7
7
|
import { Block, Button, Flexbox, Hotkey, Icon, Input, Text } from "@lobehub/ui";
|
|
8
8
|
import { BaselineIcon, LinkIcon } from "lucide-react";
|
|
9
9
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { cssVar } from "antd-style";
|
|
12
12
|
import { COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_NORMAL, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, createCommand } from "lexical";
|
|
13
13
|
import { mergeRegister } from "@lexical/utils";
|
|
@@ -16,27 +16,43 @@ const EDIT_LINK_COMMAND = createCommand();
|
|
|
16
16
|
const LinkEdit = ({ editor }) => {
|
|
17
17
|
const divRef = useRef(null);
|
|
18
18
|
const linkNodeRef = useRef(null);
|
|
19
|
+
const cardNodeRef = useRef(null);
|
|
19
20
|
const linkInputRef = useRef(null);
|
|
20
21
|
const linkTextInputRef = useRef(null);
|
|
21
22
|
const [linkUrl, setLinkUrl] = useState("");
|
|
22
23
|
const [linkText, setLinkText] = useState("");
|
|
24
|
+
const [openTarget, setOpenTarget] = useState("_blank");
|
|
23
25
|
const [linkDom, setLinkDom] = useState(null);
|
|
24
|
-
const { editable } = useEditable();
|
|
25
26
|
const t = useTranslation();
|
|
26
27
|
const handleCancel = useCallback(() => {
|
|
27
28
|
if (!editor) return;
|
|
28
29
|
editor.focus();
|
|
29
30
|
cleanPosition(divRef.current);
|
|
30
31
|
linkNodeRef.current = null;
|
|
32
|
+
cardNodeRef.current = null;
|
|
31
33
|
setLinkUrl("");
|
|
32
34
|
setLinkText("");
|
|
35
|
+
setOpenTarget("_blank");
|
|
33
36
|
setLinkDom(null);
|
|
34
37
|
}, [editor]);
|
|
35
38
|
const handleSubmit = useCallback(() => {
|
|
36
|
-
if (!
|
|
37
|
-
|
|
39
|
+
if (!editor.isEditable()) return;
|
|
40
|
+
if (!linkInputRef.current || !linkTextInputRef.current || !editor) return;
|
|
38
41
|
const inputDOM = linkInputRef.current.input;
|
|
39
42
|
const textInputDOM = linkTextInputRef.current.input;
|
|
43
|
+
if (cardNodeRef.current) {
|
|
44
|
+
const cardNode = cardNodeRef.current;
|
|
45
|
+
editor.update(() => {
|
|
46
|
+
cardNode.setTitle(textInputDOM.value);
|
|
47
|
+
cardNode.setURL(inputDOM.value);
|
|
48
|
+
cardNode.setOpenTarget(openTarget);
|
|
49
|
+
});
|
|
50
|
+
editor.focus();
|
|
51
|
+
handleCancel();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!linkNodeRef.current) return;
|
|
55
|
+
const linkNode = linkNodeRef.current;
|
|
40
56
|
if (editor.getEditorState().read(() => linkNode.getURL()) !== inputDOM.value) editor.update(() => {
|
|
41
57
|
linkNode.setURL(inputDOM.value);
|
|
42
58
|
});
|
|
@@ -51,10 +67,11 @@ const LinkEdit = ({ editor }) => {
|
|
|
51
67
|
linkNodeRef,
|
|
52
68
|
linkInputRef,
|
|
53
69
|
linkTextInputRef,
|
|
70
|
+
openTarget,
|
|
54
71
|
handleCancel
|
|
55
72
|
]);
|
|
56
73
|
const handleKeyDown = useCallback((event) => {
|
|
57
|
-
if (!linkNodeRef.current || !linkInputRef.current || !linkTextInputRef.current || !editor) return;
|
|
74
|
+
if (!linkNodeRef.current && !cardNodeRef.current || !linkInputRef.current || !linkTextInputRef.current || !editor) return;
|
|
58
75
|
const linkNode = linkNodeRef.current;
|
|
59
76
|
const inputDOM = linkInputRef.current.input;
|
|
60
77
|
const textInputDOM = linkTextInputRef.current.input;
|
|
@@ -62,6 +79,11 @@ const LinkEdit = ({ editor }) => {
|
|
|
62
79
|
case "Enter":
|
|
63
80
|
event.preventDefault();
|
|
64
81
|
if (event.currentTarget === textInputDOM) {
|
|
82
|
+
if (cardNodeRef.current) {
|
|
83
|
+
inputDOM.focus();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!linkNode) return;
|
|
65
87
|
if (editor.getEditorState().read(() => linkNode.getTextContent()) !== textInputDOM.value) {
|
|
66
88
|
editor.dispatchCommand(UPDATE_LINK_TEXT_COMMAND, {
|
|
67
89
|
key: linkNode.getKey(),
|
|
@@ -88,11 +110,18 @@ const LinkEdit = ({ editor }) => {
|
|
|
88
110
|
handleCancel
|
|
89
111
|
]);
|
|
90
112
|
useEffect(() => {
|
|
91
|
-
if (linkDom)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
113
|
+
if (linkDom) {
|
|
114
|
+
updatePosition({
|
|
115
|
+
floating: divRef.current,
|
|
116
|
+
reference: linkDom
|
|
117
|
+
});
|
|
118
|
+
const focusTimer = setTimeout(() => {
|
|
119
|
+
linkInputRef.current?.focus();
|
|
120
|
+
});
|
|
121
|
+
return () => {
|
|
122
|
+
clearTimeout(focusTimer);
|
|
123
|
+
};
|
|
124
|
+
} else cleanPosition(divRef.current);
|
|
96
125
|
}, [linkDom]);
|
|
97
126
|
useEffect(() => {
|
|
98
127
|
const handlePointerDown = (event) => {
|
|
@@ -111,16 +140,33 @@ const LinkEdit = ({ editor }) => {
|
|
|
111
140
|
}, [linkDom]);
|
|
112
141
|
useLexicalEditor((editor) => {
|
|
113
142
|
return mergeRegister(editor.registerCommand(EDIT_LINK_COMMAND, (payload) => {
|
|
143
|
+
if (!editor.isEditable()) return false;
|
|
114
144
|
if (!payload.linkNode || !payload.linkNodeDOM) {
|
|
115
145
|
handleCancel();
|
|
116
146
|
return false;
|
|
117
147
|
}
|
|
118
148
|
linkNodeRef.current = payload.linkNode;
|
|
149
|
+
cardNodeRef.current = null;
|
|
119
150
|
setLinkUrl(payload.linkNode.getURL());
|
|
120
151
|
setLinkText(payload.linkNode.getTextContent());
|
|
152
|
+
setOpenTarget(payload.linkNode.getTarget() || "_blank");
|
|
121
153
|
setLinkDom(payload.linkNodeDOM);
|
|
122
154
|
return true;
|
|
155
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(EDIT_LINK_CARD_COMMAND, (payload) => {
|
|
156
|
+
if (!editor.isEditable()) return false;
|
|
157
|
+
if (!payload.cardNode || !payload.cardNodeDOM) {
|
|
158
|
+
handleCancel();
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
cardNodeRef.current = payload.cardNode;
|
|
162
|
+
linkNodeRef.current = null;
|
|
163
|
+
setLinkUrl(payload.cardNode.getURL());
|
|
164
|
+
setLinkText(payload.cardNode.getTitle());
|
|
165
|
+
setOpenTarget(payload.cardNode.getOpenTarget() || "_blank");
|
|
166
|
+
setLinkDom(payload.cardNodeDOM);
|
|
167
|
+
return true;
|
|
123
168
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ESCAPE_COMMAND, () => {
|
|
169
|
+
if (!linkNodeRef.current && !cardNodeRef.current) return false;
|
|
124
170
|
handleCancel();
|
|
125
171
|
return true;
|
|
126
172
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_TAB_COMMAND, (payload) => {
|
|
@@ -133,7 +179,8 @@ const LinkEdit = ({ editor }) => {
|
|
|
133
179
|
return false;
|
|
134
180
|
}, COMMAND_PRIORITY_NORMAL));
|
|
135
181
|
}, [editor]);
|
|
136
|
-
if (!linkNodeRef.current
|
|
182
|
+
if (!linkNodeRef.current && !cardNodeRef.current) return null;
|
|
183
|
+
const isCardEdit = Boolean(cardNodeRef.current);
|
|
137
184
|
return /* @__PURE__ */ jsxs(Block, {
|
|
138
185
|
className: styles.linkEdit,
|
|
139
186
|
ref: divRef,
|
|
@@ -145,7 +192,7 @@ const LinkEdit = ({ editor }) => {
|
|
|
145
192
|
children: [
|
|
146
193
|
/* @__PURE__ */ jsx(Text, {
|
|
147
194
|
weight: 500,
|
|
148
|
-
children: t("link.editTextTitle")
|
|
195
|
+
children: isCardEdit ? "Title" : t("link.editTextTitle")
|
|
149
196
|
}),
|
|
150
197
|
/* @__PURE__ */ jsx(Input, {
|
|
151
198
|
onChange: (e) => {
|
|
@@ -175,7 +222,39 @@ const LinkEdit = ({ editor }) => {
|
|
|
175
222
|
}),
|
|
176
223
|
ref: linkInputRef,
|
|
177
224
|
value: linkUrl
|
|
178
|
-
})
|
|
225
|
+
}),
|
|
226
|
+
isCardEdit ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
|
|
227
|
+
weight: 500,
|
|
228
|
+
children: "Open target"
|
|
229
|
+
}), /* @__PURE__ */ jsxs("select", {
|
|
230
|
+
onChange: (e) => {
|
|
231
|
+
setOpenTarget(e.target.value);
|
|
232
|
+
},
|
|
233
|
+
onKeyDown: (e) => {
|
|
234
|
+
if (e.key === "Enter") {
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
handleSubmit();
|
|
237
|
+
}
|
|
238
|
+
if (e.key === "Escape") {
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
handleCancel();
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
style: {
|
|
244
|
+
border: `1px solid ${cssVar.colorBorder}`,
|
|
245
|
+
borderRadius: 6,
|
|
246
|
+
height: 32,
|
|
247
|
+
paddingInline: 8
|
|
248
|
+
},
|
|
249
|
+
value: openTarget,
|
|
250
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
251
|
+
value: "_blank",
|
|
252
|
+
children: "New page"
|
|
253
|
+
}), /* @__PURE__ */ jsx("option", {
|
|
254
|
+
value: "_self",
|
|
255
|
+
children: "Current page"
|
|
256
|
+
})]
|
|
257
|
+
})] }) : null
|
|
179
258
|
]
|
|
180
259
|
}), /* @__PURE__ */ jsx(Flexbox, {
|
|
181
260
|
className: styles.linkEditFooter,
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { $createNodeSelection, $getNodeByKey, $setSelection } from "lexical";
|
|
4
|
+
//#region src/plugins/link/react/components/LinkIframe.tsx
|
|
5
|
+
const LinkIframe = ({ editor, node, rendererRegistry, src, title, url }) => {
|
|
6
|
+
const key = node.getKey();
|
|
7
|
+
const [isSelected, setIsSelected] = useState(() => isNodeSelected(editor, key));
|
|
8
|
+
const [loadedSrc, setLoadedSrc] = useState(null);
|
|
9
|
+
const isLoading = loadedSrc !== src;
|
|
10
|
+
const [, setRendererVersion] = useState(0);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
return editor.registerUpdateListener(() => {
|
|
13
|
+
setIsSelected(isNodeSelected(editor, key));
|
|
14
|
+
});
|
|
15
|
+
}, [editor, key]);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const handleChange = () => {
|
|
18
|
+
setRendererVersion((version) => version + 1);
|
|
19
|
+
};
|
|
20
|
+
rendererRegistry.on("change", handleChange);
|
|
21
|
+
return () => {
|
|
22
|
+
rendererRegistry.off("change", handleChange);
|
|
23
|
+
};
|
|
24
|
+
}, [rendererRegistry]);
|
|
25
|
+
const onLoad = useCallback(() => {
|
|
26
|
+
setLoadedSrc(src);
|
|
27
|
+
}, [src]);
|
|
28
|
+
const onMouseDownCapture = useCallback((event) => {
|
|
29
|
+
if (!editor.isEditable()) return;
|
|
30
|
+
event.currentTarget.focus();
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
event.stopPropagation();
|
|
33
|
+
editor.focus();
|
|
34
|
+
editor.update(() => {
|
|
35
|
+
const selection = $createNodeSelection();
|
|
36
|
+
selection.add(key);
|
|
37
|
+
$setSelection(selection);
|
|
38
|
+
});
|
|
39
|
+
}, [editor, key]);
|
|
40
|
+
const props = {
|
|
41
|
+
editor,
|
|
42
|
+
isEditable: editor.isEditable(),
|
|
43
|
+
isLoading,
|
|
44
|
+
isSelected,
|
|
45
|
+
node,
|
|
46
|
+
onLoad,
|
|
47
|
+
onMouseDownCapture,
|
|
48
|
+
src,
|
|
49
|
+
title,
|
|
50
|
+
url
|
|
51
|
+
};
|
|
52
|
+
return rendererRegistry.renderIframeNode(props) || /* @__PURE__ */ jsx(DefaultLinkIframe, { ...props });
|
|
53
|
+
};
|
|
54
|
+
LinkIframe.displayName = "LinkIframe";
|
|
55
|
+
function isNodeSelected(editor, key) {
|
|
56
|
+
return editor.getEditorState().read(() => {
|
|
57
|
+
return $getNodeByKey(key)?.isSelected() ?? false;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function DefaultLinkIframe(props) {
|
|
61
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
62
|
+
style: {
|
|
63
|
+
border: "1px solid rgba(0,0,0,0.12)",
|
|
64
|
+
borderRadius: 8,
|
|
65
|
+
boxShadow: props.isSelected ? "0 0 0 2px rgba(22,119,255,0.18)" : void 0,
|
|
66
|
+
overflow: "hidden",
|
|
67
|
+
position: "relative",
|
|
68
|
+
width: "100%",
|
|
69
|
+
...props.isSelected ? { borderColor: "#1677ff" } : {}
|
|
70
|
+
},
|
|
71
|
+
tabIndex: 0,
|
|
72
|
+
children: [
|
|
73
|
+
props.isLoading && /* @__PURE__ */ jsx("style", { children: "@keyframes lobe-link-iframe-spin{to{transform:rotate(360deg)}}" }),
|
|
74
|
+
/* @__PURE__ */ jsx("div", {
|
|
75
|
+
onMouseDownCapture: props.onMouseDownCapture,
|
|
76
|
+
style: {
|
|
77
|
+
borderBottom: "1px solid rgba(0,0,0,0.08)",
|
|
78
|
+
color: "rgba(0,0,0,0.55)",
|
|
79
|
+
cursor: props.isEditable ? "pointer" : "default",
|
|
80
|
+
fontSize: 12,
|
|
81
|
+
padding: "8px 10px"
|
|
82
|
+
},
|
|
83
|
+
children: props.title
|
|
84
|
+
}),
|
|
85
|
+
props.isLoading && /* @__PURE__ */ jsxs("div", {
|
|
86
|
+
style: {
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
background: "rgba(0,0,0,0.03)",
|
|
89
|
+
bottom: 0,
|
|
90
|
+
color: "rgba(0,0,0,0.45)",
|
|
91
|
+
display: "flex",
|
|
92
|
+
fontSize: 13,
|
|
93
|
+
gap: 8,
|
|
94
|
+
height: 320,
|
|
95
|
+
justifyContent: "center",
|
|
96
|
+
left: 0,
|
|
97
|
+
position: "absolute",
|
|
98
|
+
right: 0,
|
|
99
|
+
zIndex: 1
|
|
100
|
+
},
|
|
101
|
+
children: [/* @__PURE__ */ jsx("span", { style: {
|
|
102
|
+
animation: "lobe-link-iframe-spin 1s linear infinite",
|
|
103
|
+
border: "2px solid rgba(0,0,0,0.12)",
|
|
104
|
+
borderRadius: "50%",
|
|
105
|
+
borderTopColor: "#1677ff",
|
|
106
|
+
display: "inline-block",
|
|
107
|
+
height: 14,
|
|
108
|
+
width: 14
|
|
109
|
+
} }), "Loading embed..."]
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ jsx("iframe", {
|
|
112
|
+
loading: "lazy",
|
|
113
|
+
onLoad: props.onLoad,
|
|
114
|
+
src: props.src,
|
|
115
|
+
style: {
|
|
116
|
+
border: 0,
|
|
117
|
+
display: "block",
|
|
118
|
+
height: 320,
|
|
119
|
+
visibility: props.isLoading ? "hidden" : "visible",
|
|
120
|
+
width: "100%"
|
|
121
|
+
},
|
|
122
|
+
title: props.title
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { DefaultLinkIframe, LinkIframe as default };
|