@blocklet/editor 2.4.35 → 2.4.37
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/InlineTranslationPlugin/EditorTranslator.d.ts +1 -0
- package/lib/ext/InlineTranslationPlugin/EditorTranslator.js +6 -0
- package/lib/ext/InlineTranslationPlugin/InlineTranslationPlugin.js +1 -1
- package/lib/ext/InlineTranslationPlugin/store.js +1 -1
- package/lib/ext/PagesKitComponent/PagesKitComponentPlugin.js +1 -1
- package/package.json +8 -8
|
@@ -21,6 +21,7 @@ export declare class EditorTranslator {
|
|
|
21
21
|
private sidToNodeKeyMap;
|
|
22
22
|
private translations;
|
|
23
23
|
private sourceItems;
|
|
24
|
+
isTranslating: boolean;
|
|
24
25
|
constructor(editor: LexicalEditor, options: EditorTranslatorOptions);
|
|
25
26
|
get isTranslated(): boolean;
|
|
26
27
|
setEditor(editor: LexicalEditor): void;
|
|
@@ -18,6 +18,7 @@ export class EditorTranslator {
|
|
|
18
18
|
sidToNodeKeyMap = new Map();
|
|
19
19
|
translations = [];
|
|
20
20
|
sourceItems = [];
|
|
21
|
+
isTranslating = false;
|
|
21
22
|
constructor(editor, options) {
|
|
22
23
|
this.editor = editor;
|
|
23
24
|
this.options = options;
|
|
@@ -44,6 +45,10 @@ export class EditorTranslator {
|
|
|
44
45
|
}, 10);
|
|
45
46
|
}
|
|
46
47
|
async translate({ targetLanguage, translateService, detectLanguage, useCache, }) {
|
|
48
|
+
if (this.isTranslating) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.isTranslating = true;
|
|
47
52
|
// 翻译前备份 editor state (fix 恢复原文时图片路径错误的问题)
|
|
48
53
|
this.originalEditorState = this.editor.getEditorState().clone();
|
|
49
54
|
await this.preprocessNodes();
|
|
@@ -91,6 +96,7 @@ export class EditorTranslator {
|
|
|
91
96
|
if (this.isTranslated) {
|
|
92
97
|
this.applyTranslations();
|
|
93
98
|
}
|
|
99
|
+
this.isTranslating = false;
|
|
94
100
|
}
|
|
95
101
|
applyTranslations() {
|
|
96
102
|
this.editor.update(() => {
|
|
@@ -78,7 +78,7 @@ function InternalInlineTranslationPlugin({ translateService, detectLanguage, onT
|
|
|
78
78
|
useEffect(() => {
|
|
79
79
|
const onClick = (event) => {
|
|
80
80
|
const target = event.target;
|
|
81
|
-
if (editorTranslator.isTranslated && target.closest('li[role="checkbox"]')) {
|
|
81
|
+
if ((editorTranslator.isTranslating || editorTranslator.isTranslated) && target.closest('li[role="checkbox"]')) {
|
|
82
82
|
event.preventDefault();
|
|
83
83
|
event.stopPropagation();
|
|
84
84
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import { create } from 'zustand';
|
|
3
3
|
import { persist } from 'zustand/middleware';
|
|
4
|
-
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
4
|
+
import { SessionContext } from '@arcblock/did-connect-react/lib/Session';
|
|
5
5
|
import { useContext } from 'react';
|
|
6
6
|
export const useInlineTranslationStore = create()(persist((set, get) => ({
|
|
7
7
|
targetLanguage: null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
-
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
2
|
+
import { SessionContext } from '@arcblock/did-connect-react/lib/Session';
|
|
3
3
|
import { $insertNodeToNearestRoot } from '@lexical/utils';
|
|
4
4
|
import { COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
5
5
|
import { useContext, useEffect } from 'react';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.37",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
]
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@blocklet/code-editor": "^0.5.
|
|
27
|
+
"@blocklet/code-editor": "^0.5.3",
|
|
28
28
|
"@blocklet/embed": "^0.2.5",
|
|
29
|
-
"@blocklet/js-sdk": "^1.16.
|
|
30
|
-
"@blocklet/pages-kit": "^0.6.
|
|
31
|
-
"@blocklet/pages-kit-runtime": "^0.6.
|
|
29
|
+
"@blocklet/js-sdk": "^1.16.47",
|
|
30
|
+
"@blocklet/pages-kit": "^0.6.40",
|
|
31
|
+
"@blocklet/pages-kit-runtime": "^0.6.40",
|
|
32
32
|
"@excalidraw/excalidraw": "^0.18.0",
|
|
33
33
|
"@iconify/iconify": "^3.1.1",
|
|
34
34
|
"@iconify/icons-tabler": "^1.2.95",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"ufo": "^1.5.4",
|
|
70
70
|
"url-join": "^4.0.1",
|
|
71
71
|
"zustand": "^4.5.5",
|
|
72
|
-
"@blocklet/pdf": "2.4.
|
|
72
|
+
"@blocklet/pdf": "2.4.37"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@babel/core": "^7.25.2",
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"vite-plugin-svgr": "^4.3.0"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@arcblock/did-connect": "^3.
|
|
102
|
-
"@arcblock/ux": "^3.
|
|
101
|
+
"@arcblock/did-connect-react": "^3.1.4",
|
|
102
|
+
"@arcblock/ux": "^3.1.4",
|
|
103
103
|
"@emotion/css": "^11.13.5",
|
|
104
104
|
"@emotion/react": "^11.14.0",
|
|
105
105
|
"@emotion/styled": "^11.14.1",
|