Merge pull request #20248 from calixteman/toolbar_button_position
[Editor] Make sure the comment button is at the right place when adding it in the toolbar
This commit is contained in:
commit
d009c434f5
@ -135,6 +135,10 @@ class Comment {
|
|||||||
return this.#deleted || this.#text === "";
|
return this.#deleted || this.#text === "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEmpty() {
|
||||||
|
return this.#text === null;
|
||||||
|
}
|
||||||
|
|
||||||
hasBeenEdited() {
|
hasBeenEdited() {
|
||||||
return this.isDeleted() || this.#text !== this.#initialText;
|
return this.isDeleted() || this.#text !== this.#initialText;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1103,6 +1103,17 @@ class AnnotationEditor {
|
|||||||
return this._editToolbar;
|
return this._editToolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addCommentButtonInToolbar() {
|
||||||
|
if (!this._editToolbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._editToolbar.addButtonBefore(
|
||||||
|
"comment",
|
||||||
|
this.addCommentButton(),
|
||||||
|
".deleteButton"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
removeEditToolbar() {
|
removeEditToolbar() {
|
||||||
if (!this._editToolbar) {
|
if (!this._editToolbar) {
|
||||||
return;
|
return;
|
||||||
@ -1214,10 +1225,14 @@ class AnnotationEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set comment(text) {
|
set comment(text) {
|
||||||
if (!this.#comment) {
|
this.#comment ||= new Comment(this);
|
||||||
this.#comment = new Comment(this);
|
|
||||||
}
|
|
||||||
this.#comment.data = text;
|
this.#comment.data = text;
|
||||||
|
if (this.hasComment) {
|
||||||
|
this.addStandaloneCommentButton();
|
||||||
|
} else {
|
||||||
|
this.addCommentButtonInToolbar();
|
||||||
|
this.removeStandaloneCommentButton();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setCommentData({ comment, richText }) {
|
setCommentData({ comment, richText }) {
|
||||||
@ -1232,7 +1247,9 @@ class AnnotationEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get hasComment() {
|
get hasComment() {
|
||||||
return !!this.#comment && !this.#comment.isDeleted();
|
return (
|
||||||
|
!!this.#comment && !this.#comment.isEmpty() && !this.#comment.isDeleted()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async editComment() {
|
async editComment() {
|
||||||
|
|||||||
@ -158,7 +158,7 @@ class EditorToolbar {
|
|||||||
this.#altText = altText;
|
this.#altText = altText;
|
||||||
}
|
}
|
||||||
|
|
||||||
addComment(comment) {
|
addComment(comment, beforeElement = null) {
|
||||||
if (this.#comment) {
|
if (this.#comment) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -167,7 +167,12 @@ class EditorToolbar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.#addListenersToElement(button);
|
this.#addListenersToElement(button);
|
||||||
this.#buttons.append(button, this.#divider);
|
if (!beforeElement) {
|
||||||
|
this.#buttons.append(button, this.#divider);
|
||||||
|
} else {
|
||||||
|
this.#buttons.insertBefore(button, beforeElement);
|
||||||
|
this.#buttons.insertBefore(this.#divider, beforeElement);
|
||||||
|
}
|
||||||
this.#comment = comment;
|
this.#comment = comment;
|
||||||
comment.toolbar = this;
|
comment.toolbar = this;
|
||||||
}
|
}
|
||||||
@ -209,6 +214,16 @@ class EditorToolbar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async addButtonBefore(name, tool, beforeSelector) {
|
||||||
|
const beforeElement = this.#buttons.querySelector(beforeSelector);
|
||||||
|
if (!beforeElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (name === "comment") {
|
||||||
|
this.addComment(tool, beforeElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateEditSignatureButton(description) {
|
updateEditSignatureButton(description) {
|
||||||
if (this.#signatureDescriptionButton) {
|
if (this.#signatureDescriptionButton) {
|
||||||
this.#signatureDescriptionButton.title = description;
|
this.#signatureDescriptionButton.title = description;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user