Merge pull request #20245 from calixteman/comment_richtext
[Editor] Add the dates and rich text if any to the editors in order to use them when displaying the popup
This commit is contained in:
commit
17a27806c6
@ -26,6 +26,8 @@ class Comment {
|
||||
|
||||
#initialText = null;
|
||||
|
||||
#richText = null;
|
||||
|
||||
#text = null;
|
||||
|
||||
#date = null;
|
||||
@ -144,8 +146,9 @@ class Comment {
|
||||
get data() {
|
||||
return {
|
||||
text: this.#text,
|
||||
richText: this.#richText,
|
||||
date: this.#date,
|
||||
deleted: this.#deleted,
|
||||
deleted: this.isDeleted(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -153,6 +156,9 @@ class Comment {
|
||||
* Set the comment data.
|
||||
*/
|
||||
set data(text) {
|
||||
if (text !== this.#text) {
|
||||
this.#richText = null;
|
||||
}
|
||||
if (text === null) {
|
||||
this.#text = "";
|
||||
this.#deleted = true;
|
||||
@ -163,9 +169,11 @@ class Comment {
|
||||
this.#deleted = false;
|
||||
}
|
||||
|
||||
setInitialText(text) {
|
||||
setInitialText(text, richText = null) {
|
||||
this.#initialText = text;
|
||||
this.data = text;
|
||||
this.#date = null;
|
||||
this.#richText = richText;
|
||||
}
|
||||
|
||||
shown() {}
|
||||
@ -176,6 +184,7 @@ class Comment {
|
||||
this.#commentStandaloneButton?.remove();
|
||||
this.#commentStandaloneButton = null;
|
||||
this.#text = "";
|
||||
this.#richText = null;
|
||||
this.#date = null;
|
||||
this.#editor = null;
|
||||
this.#commentWasFromKeyBoard = false;
|
||||
|
||||
@ -191,7 +191,8 @@ class AnnotationEditor {
|
||||
this._initialOptions.isCentered = parameters.isCentered;
|
||||
this._structTreeParentId = null;
|
||||
this.annotationElementId = parameters.annotationElementId || null;
|
||||
this.creationDate = new Date();
|
||||
this.creationDate = parameters.creationDate || new Date();
|
||||
this.modificationDate = parameters.modificationDate || null;
|
||||
|
||||
const {
|
||||
rotation,
|
||||
@ -1200,11 +1201,14 @@ class AnnotationEditor {
|
||||
}
|
||||
|
||||
get comment() {
|
||||
const comment = this.#comment;
|
||||
const {
|
||||
data: { richText, text, date, deleted },
|
||||
} = this.#comment;
|
||||
return {
|
||||
text: comment.data.text,
|
||||
date: comment.data.date,
|
||||
deleted: comment.isDeleted(),
|
||||
text,
|
||||
richText,
|
||||
date,
|
||||
deleted,
|
||||
color: this.commentColor,
|
||||
};
|
||||
}
|
||||
@ -1216,11 +1220,11 @@ class AnnotationEditor {
|
||||
this.#comment.data = text;
|
||||
}
|
||||
|
||||
setCommentData(text) {
|
||||
setCommentData({ comment, richText }) {
|
||||
if (!this.#comment) {
|
||||
this.#comment = new Comment(this);
|
||||
}
|
||||
this.#comment.setInitialText(text);
|
||||
this.#comment.setInitialText(comment, richText);
|
||||
}
|
||||
|
||||
get hasEditedComment() {
|
||||
@ -1611,13 +1615,22 @@ class AnnotationEditor {
|
||||
}
|
||||
|
||||
getData() {
|
||||
const {
|
||||
comment: { text: str, date, deleted, richText },
|
||||
uid: id,
|
||||
pageIndex,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
} = this;
|
||||
return {
|
||||
id: this.uid,
|
||||
pageIndex: this.pageIndex,
|
||||
id,
|
||||
pageIndex,
|
||||
rect: this.getPDFRect(),
|
||||
contentsObj: { str: this.comment.text },
|
||||
creationDate: this.creationDate,
|
||||
popupRef: !this.#comment.isDeleted(),
|
||||
richText,
|
||||
contentsObj: { str },
|
||||
creationDate,
|
||||
modificationDate: date || modificationDate,
|
||||
popupRef: !deleted,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1774,6 +1787,8 @@ class AnnotationEditor {
|
||||
id: parent.getNextId(),
|
||||
uiManager,
|
||||
annotationElementId: data.annotationElementId,
|
||||
creationDate: data.creationDate,
|
||||
modificationDate: data.modificationDate,
|
||||
});
|
||||
editor.rotation = data.rotation;
|
||||
editor.#accessibilityData = data.accessibilityData;
|
||||
|
||||
@ -781,7 +781,10 @@ class FreeTextEditor extends AnnotationEditor {
|
||||
rotation,
|
||||
id,
|
||||
popupRef,
|
||||
richText,
|
||||
contentsObj,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
},
|
||||
textContent,
|
||||
textPosition,
|
||||
@ -809,6 +812,9 @@ class FreeTextEditor extends AnnotationEditor {
|
||||
deleted: false,
|
||||
popupRef,
|
||||
comment: contentsObj?.str || null,
|
||||
richText,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
};
|
||||
}
|
||||
const editor = await super.deserialize(data, parent, uiManager);
|
||||
@ -817,7 +823,7 @@ class FreeTextEditor extends AnnotationEditor {
|
||||
editor.#content = FreeTextEditor.#deserializeContent(data.value);
|
||||
editor._initialData = initialData;
|
||||
if (data.comment) {
|
||||
editor.setCommentData(data.comment);
|
||||
editor.setCommentData(data);
|
||||
}
|
||||
|
||||
return editor;
|
||||
|
||||
@ -151,10 +151,6 @@ class HighlightEditor extends AnnotationEditor {
|
||||
};
|
||||
}
|
||||
|
||||
get commentColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
static computeTelemetryFinalData(data) {
|
||||
// We want to know how many colors have been used.
|
||||
return { numberOfColors: data.get("color").size };
|
||||
@ -891,7 +887,10 @@ class HighlightEditor extends AnnotationEditor {
|
||||
color,
|
||||
opacity,
|
||||
popupRef,
|
||||
richText,
|
||||
contentsObj,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
},
|
||||
parent: {
|
||||
page: { pageNumber },
|
||||
@ -910,7 +909,10 @@ class HighlightEditor extends AnnotationEditor {
|
||||
id,
|
||||
deleted: false,
|
||||
popupRef,
|
||||
richText,
|
||||
comment: contentsObj?.str || null,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
};
|
||||
} else if (data instanceof InkAnnotationElement) {
|
||||
const {
|
||||
@ -922,7 +924,10 @@ class HighlightEditor extends AnnotationEditor {
|
||||
color,
|
||||
borderStyle: { rawWidth: thickness },
|
||||
popupRef,
|
||||
richText,
|
||||
contentsObj,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
},
|
||||
parent: {
|
||||
page: { pageNumber },
|
||||
@ -941,7 +946,10 @@ class HighlightEditor extends AnnotationEditor {
|
||||
id,
|
||||
deleted: false,
|
||||
popupRef,
|
||||
richText,
|
||||
comment: contentsObj?.str || null,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
};
|
||||
}
|
||||
|
||||
@ -955,7 +963,7 @@ class HighlightEditor extends AnnotationEditor {
|
||||
}
|
||||
editor._initialData = initialData;
|
||||
if (data.comment) {
|
||||
editor.setCommentData(data.comment);
|
||||
editor.setCommentData(data);
|
||||
}
|
||||
|
||||
const [pageWidth, pageHeight] = editor.pageDimensions;
|
||||
|
||||
@ -150,7 +150,10 @@ class InkEditor extends DrawingEditor {
|
||||
opacity,
|
||||
borderStyle: { rawWidth: thickness },
|
||||
popupRef,
|
||||
richText,
|
||||
contentsObj,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
},
|
||||
parent: {
|
||||
page: { pageNumber },
|
||||
@ -170,14 +173,17 @@ class InkEditor extends DrawingEditor {
|
||||
id,
|
||||
deleted: false,
|
||||
popupRef,
|
||||
richText,
|
||||
comment: contentsObj?.str || null,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
};
|
||||
}
|
||||
|
||||
const editor = await super.deserialize(data, parent, uiManager);
|
||||
editor._initialData = initialData;
|
||||
if (data.comment) {
|
||||
editor.setCommentData(data.comment);
|
||||
editor.setCommentData(data);
|
||||
}
|
||||
|
||||
return editor;
|
||||
|
||||
@ -751,7 +751,17 @@ class StampEditor extends AnnotationEditor {
|
||||
let missingCanvas = false;
|
||||
if (data instanceof StampAnnotationElement) {
|
||||
const {
|
||||
data: { rect, rotation, id, structParent, popupRef, contentsObj },
|
||||
data: {
|
||||
rect,
|
||||
rotation,
|
||||
id,
|
||||
structParent,
|
||||
popupRef,
|
||||
richText,
|
||||
contentsObj,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
},
|
||||
container,
|
||||
parent: {
|
||||
page: { pageNumber },
|
||||
@ -795,7 +805,10 @@ class StampEditor extends AnnotationEditor {
|
||||
isSvg: false,
|
||||
structParent,
|
||||
popupRef,
|
||||
richText,
|
||||
comment: contentsObj?.str || null,
|
||||
creationDate,
|
||||
modificationDate,
|
||||
};
|
||||
}
|
||||
const editor = await super.deserialize(data, parent, uiManager);
|
||||
@ -823,7 +836,7 @@ class StampEditor extends AnnotationEditor {
|
||||
}
|
||||
editor._initialData = initialData;
|
||||
if (data.comment) {
|
||||
editor.setCommentData(data.comment);
|
||||
editor.setCommentData(data);
|
||||
}
|
||||
// No need to be add in the undo stack if the editor is created from an
|
||||
// existing one.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user