mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[Editor] Fix test failures in m-c because of the new FreeText undo/redo stuff
This commit is contained in:
parent
22d350cae6
commit
baebf7b26d
4 changed files with 51 additions and 39 deletions
|
@ -330,36 +330,6 @@ class AnnotationEditorLayer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new editor and make this addition undoable.
|
||||
* @param {AnnotationEditor} editor
|
||||
*/
|
||||
addANewEditor(editor) {
|
||||
const cmd = () => {
|
||||
this.addOrRebuild(editor);
|
||||
};
|
||||
const undo = () => {
|
||||
editor.remove();
|
||||
};
|
||||
|
||||
this.addCommands({ cmd, undo, mustExec: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new editor and make this addition undoable.
|
||||
* @param {AnnotationEditor} editor
|
||||
*/
|
||||
addUndoableEditor(editor) {
|
||||
const cmd = () => {
|
||||
this.addOrRebuild(editor);
|
||||
};
|
||||
const undo = () => {
|
||||
editor.remove();
|
||||
};
|
||||
|
||||
this.addCommands({ cmd, undo, mustExec: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an id for an editor.
|
||||
* @returns {string}
|
||||
|
|
|
@ -472,6 +472,7 @@ class AnnotationEditor {
|
|||
*/
|
||||
rebuild() {
|
||||
this.div?.addEventListener("focusin", this.#boundFocusin);
|
||||
this.div?.addEventListener("focusout", this.#boundFocusout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,8 +46,6 @@ class FreeTextEditor extends AnnotationEditor {
|
|||
|
||||
#editorDivId = `${this.id}-editor`;
|
||||
|
||||
#hasAlreadyBeenCommitted = false;
|
||||
|
||||
#fontSize;
|
||||
|
||||
static _freeTextDefaultContent = "";
|
||||
|
@ -355,13 +353,6 @@ class FreeTextEditor extends AnnotationEditor {
|
|||
}
|
||||
|
||||
super.commit();
|
||||
if (!this.#hasAlreadyBeenCommitted) {
|
||||
// This editor has something and it's the first time
|
||||
// it's commited so we can add it in the undo/redo stack.
|
||||
this.#hasAlreadyBeenCommitted = true;
|
||||
this.parent.addUndoableEditor(this);
|
||||
}
|
||||
|
||||
this.disableEditMode();
|
||||
const savedText = this.#content;
|
||||
const newText = (this.#content = this.#extractText().trimEnd());
|
||||
|
@ -371,7 +362,12 @@ class FreeTextEditor extends AnnotationEditor {
|
|||
|
||||
const setText = text => {
|
||||
this.#content = text;
|
||||
if (!text) {
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
this.#setContent();
|
||||
this.rebuild();
|
||||
this.#setEditorDimensions();
|
||||
};
|
||||
this.addCommands({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue