@blocklet/editor 1.6.201 → 1.6.203
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
2
|
import { useEffect, useRef, useCallback } from 'react';
|
|
3
|
-
import { useMutationObserver } from 'ahooks';
|
|
4
|
-
import debounce from 'lodash/debounce';
|
|
3
|
+
import { useMutationObserver, useDebounceFn } from 'ahooks';
|
|
5
4
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
6
5
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
7
6
|
const id = 'translate-check-dom';
|
|
@@ -46,17 +45,16 @@ export const useTranslationListener = () => {
|
|
|
46
45
|
// only not editable
|
|
47
46
|
if (!editor.isEditable()) {
|
|
48
47
|
const translated = !!translateRef.current.originalNode;
|
|
48
|
+
const withTranslateFlag = document.querySelector('html.translated-ltr, head.translated-rtl, ya-tr-span, *[_msthash], *[_msttexthash], body[data-immersive-translate-walked]') || translateRef.current.defaultLang !== document.documentElement.lang;
|
|
49
49
|
// if not translated or need to reload
|
|
50
|
-
if ((!translated || reload) &&
|
|
51
|
-
(document.querySelector('html.translated-ltr, head.translated-rtl, ya-tr-span, *[_msthash], *[_msttexthash], body[data-immersive-translate-walked]') ||
|
|
52
|
-
translateRef.current.defaultLang !== document.documentElement.lang)) {
|
|
50
|
+
if ((!translated || reload) && withTranslateFlag) {
|
|
53
51
|
const originalNode = editor.getRootElement();
|
|
54
52
|
if (originalNode) {
|
|
55
53
|
setTimeout(() => {
|
|
56
54
|
const clonedNode = originalNode.cloneNode(true);
|
|
57
55
|
clonedNode.classList.remove('notranslate');
|
|
58
56
|
clonedNode.addEventListener('click', showTranslationTip);
|
|
59
|
-
clonedNode.style.cursor = 'not-allowed';
|
|
57
|
+
// clonedNode.style.cursor = 'not-allowed';
|
|
60
58
|
originalNode?.replaceWith(clonedNode);
|
|
61
59
|
translateRef.current.originalNode = originalNode;
|
|
62
60
|
translateRef.current.clonedNode = clonedNode;
|
|
@@ -73,6 +71,7 @@ export const useTranslationListener = () => {
|
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
73
|
};
|
|
74
|
+
const { run: debounceAddTranslationDOMListener } = useDebounceFn(addTranslationDOMListener, { wait: 500 });
|
|
76
75
|
useEffect(() => {
|
|
77
76
|
if (!document.getElementById(id)) {
|
|
78
77
|
const defaultTranslationCheckDiv = document.createElement('div');
|
|
@@ -86,9 +85,9 @@ export const useTranslationListener = () => {
|
|
|
86
85
|
document.body.insertBefore(defaultTranslationCheckDiv.cloneNode(true), document.body.firstChild);
|
|
87
86
|
}
|
|
88
87
|
// listen for editor
|
|
89
|
-
return editor.registerRootListener(
|
|
88
|
+
return editor.registerRootListener(() => debounceAddTranslationDOMListener({ reload: true }));
|
|
90
89
|
}, []);
|
|
91
|
-
useMutationObserver(
|
|
90
|
+
useMutationObserver(() => debounceAddTranslationDOMListener(), document.getElementById(id), {
|
|
92
91
|
attributes: true,
|
|
93
92
|
childList: true,
|
|
94
93
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.203",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npm run storybook",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
]
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@arcblock/ux": "^2.9.
|
|
40
|
+
"@arcblock/ux": "^2.9.65",
|
|
41
41
|
"@blocklet/embed": "^0.1.11",
|
|
42
|
-
"@blocklet/pdf": "1.6.
|
|
42
|
+
"@blocklet/pdf": "1.6.203",
|
|
43
43
|
"@excalidraw/excalidraw": "^0.14.2",
|
|
44
44
|
"@iconify/iconify": "^3.0.1",
|
|
45
45
|
"@lexical/clipboard": "0.13.1",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"react": "*",
|
|
109
109
|
"react-dom": "*"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "978eaa872271df22a81472ec2a8acb7395a658fd"
|
|
112
112
|
}
|