Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(editor): control state (#1649)
Univerc39799fb54cc
diff --git a/packages/ui/src/components/editor/TextEditor.tsx b/packages/ui/src/components/editor/TextEditor.tsxindex df50068195..a43e7310fa 100644--- a/packages/ui/src/components/editor/TextEditor.tsx+++ b/packages/ui/src/components/editor/TextEditor.tsx@@ -233,7 +233,7 @@ export function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onCif (value == null) {return;}- editorService.setValue(value, id);+ editorService.setValueNoRefresh(value, id);}, [value]);function hasValue() {diff --git a/packages/ui/src/services/editor/editor.service.ts b/packages/ui/src/services/editor/editor.service.tsindex 6a3e4853fa..e61d64ce66 100644--- a/packages/ui/src/services/editor/editor.service.ts+++ b/packages/ui/src/services/editor/editor.service.ts@@ -279,6 +279,8 @@ export interface IEditorService {setValue(val: string, editorUnitId?: string): void;+ setValueNoRefresh(val: string, editorUnitId?: string): void;+setRichValue(body: IDocumentBody, editorUnitId?: string): void;getFirstEditor(): Editor;@@ -493,15 +495,15 @@ export class EditorService extends Disposable implements IEditorService, IDisposeditorUnitId = this._getCurrentEditorUnitId();}- if (val.substring(0, 1) === '=') {- this.setFormula(val, editorUnitId);- } else {- this._setValue$.next({ body: {- dataStream: val,- }, editorUnitId });- }+ this.setValueNoRefresh(val, editorUnitId);this._refreshValueChange(editorUnitId);+ }++ setValueNoRefresh(val: string, editorUnitId: string) {+ this._setValue$.next({ body: {+ dataStream: val,+ }, editorUnitId });this.resize(editorUnitId);}