@blocklet/editor 2.4.36 → 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.
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/editor",
3
- "version": "2.4.36",
3
+ "version": "2.4.37",
4
4
  "main": "lib/index.js",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -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.36"
72
+ "@blocklet/pdf": "2.4.37"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@babel/core": "^7.25.2",