[Editor] Make possible to change the highlight color from the main panel
It's consistent with the way to change colors for FreeText or Ink annotations.
This commit is contained in:
parent
9f645fb9a6
commit
5162209b27
@ -43,8 +43,6 @@ class ColorPicker {
|
|||||||
|
|
||||||
#uiManager = null;
|
#uiManager = null;
|
||||||
|
|
||||||
#type;
|
|
||||||
|
|
||||||
static #l10nColor = null;
|
static #l10nColor = null;
|
||||||
|
|
||||||
static get _keyboardManager() {
|
static get _keyboardManager() {
|
||||||
@ -74,11 +72,9 @@ class ColorPicker {
|
|||||||
constructor({ editor = null, uiManager = null }) {
|
constructor({ editor = null, uiManager = null }) {
|
||||||
if (editor) {
|
if (editor) {
|
||||||
this.#isMainColorPicker = false;
|
this.#isMainColorPicker = false;
|
||||||
this.#type = AnnotationEditorParamsType.HIGHLIGHT_COLOR;
|
|
||||||
this.#editor = editor;
|
this.#editor = editor;
|
||||||
} else {
|
} else {
|
||||||
this.#isMainColorPicker = true;
|
this.#isMainColorPicker = true;
|
||||||
this.#type = AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR;
|
|
||||||
}
|
}
|
||||||
this.#uiManager = editor?._uiManager || uiManager;
|
this.#uiManager = editor?._uiManager || uiManager;
|
||||||
this.#eventBus = this.#uiManager._eventBus;
|
this.#eventBus = this.#uiManager._eventBus;
|
||||||
@ -163,9 +159,10 @@ class ColorPicker {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.#eventBus.dispatch("switchannotationeditorparams", {
|
this.#eventBus.dispatch("switchannotationeditorparams", {
|
||||||
source: this,
|
source: this,
|
||||||
type: this.#type,
|
type: AnnotationEditorParamsType.HIGHLIGHT_COLOR,
|
||||||
value: color,
|
value: color,
|
||||||
});
|
});
|
||||||
|
this.updateColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
_colorSelectFromKeyboard(event) {
|
_colorSelectFromKeyboard(event) {
|
||||||
|
|||||||
@ -278,7 +278,7 @@ class HighlightEditor extends AnnotationEditor {
|
|||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
static updateDefaultParams(type, value) {
|
static updateDefaultParams(type, value) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:
|
case AnnotationEditorParamsType.HIGHLIGHT_COLOR:
|
||||||
HighlightEditor._defaultColor = value;
|
HighlightEditor._defaultColor = value;
|
||||||
break;
|
break;
|
||||||
case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
|
case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
|
||||||
@ -310,7 +310,7 @@ class HighlightEditor extends AnnotationEditor {
|
|||||||
static get defaultPropertiesToUpdate() {
|
static get defaultPropertiesToUpdate() {
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR,
|
AnnotationEditorParamsType.HIGHLIGHT_COLOR,
|
||||||
HighlightEditor._defaultColor,
|
HighlightEditor._defaultColor,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
@ -1786,9 +1786,6 @@ class AnnotationEditorUIManager {
|
|||||||
case AnnotationEditorParamsType.CREATE:
|
case AnnotationEditorParamsType.CREATE:
|
||||||
this.currentLayer.addNewEditor(value);
|
this.currentLayer.addNewEditor(value);
|
||||||
return;
|
return;
|
||||||
case AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:
|
|
||||||
this.#mainHighlightColorPicker?.updateColor(value);
|
|
||||||
break;
|
|
||||||
case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
|
case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
|
||||||
this._eventBus.dispatch("reporttelemetry", {
|
this._eventBus.dispatch("reporttelemetry", {
|
||||||
source: this,
|
source: this,
|
||||||
|
|||||||
@ -88,10 +88,9 @@ const AnnotationEditorParamsType = {
|
|||||||
INK_THICKNESS: 22,
|
INK_THICKNESS: 22,
|
||||||
INK_OPACITY: 23,
|
INK_OPACITY: 23,
|
||||||
HIGHLIGHT_COLOR: 31,
|
HIGHLIGHT_COLOR: 31,
|
||||||
HIGHLIGHT_DEFAULT_COLOR: 32,
|
HIGHLIGHT_THICKNESS: 32,
|
||||||
HIGHLIGHT_THICKNESS: 33,
|
HIGHLIGHT_FREE: 33,
|
||||||
HIGHLIGHT_FREE: 34,
|
HIGHLIGHT_SHOW_ALL: 34,
|
||||||
HIGHLIGHT_SHOW_ALL: 35,
|
|
||||||
DRAW_STEP: 41,
|
DRAW_STEP: 41,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2710,4 +2710,43 @@ describe("Highlight Editor", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Highlight must change their color when selected", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
pages = await loadAndWait(
|
||||||
|
"tracemonkey.pdf",
|
||||||
|
".annotationEditorLayer",
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
{ highlightEditorColors: "red=#AB0000,blue=#0000AB" }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must check that the color is correctly updated", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await switchToHighlight(page);
|
||||||
|
|
||||||
|
const rect = await getSpanRectFromText(page, 1, "Abstract");
|
||||||
|
const x = rect.x + rect.width / 2;
|
||||||
|
const y = rect.y + rect.height / 2;
|
||||||
|
await page.mouse.click(x, y, { count: 2, delay: 100 });
|
||||||
|
const highlightSelector = `.page[data-page-number = "1"] .canvasWrapper > svg.highlight`;
|
||||||
|
await page.waitForSelector(`${highlightSelector}[fill = "#AB0000"]`);
|
||||||
|
|
||||||
|
await page.click(
|
||||||
|
"#editorHighlightColorPicker button[title = 'Blue']"
|
||||||
|
);
|
||||||
|
|
||||||
|
await page.waitForSelector(`${highlightSelector}[fill = "#0000AB"]`);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -118,7 +118,7 @@ class AnnotationEditorParams {
|
|||||||
case AnnotationEditorParamsType.INK_OPACITY:
|
case AnnotationEditorParamsType.INK_OPACITY:
|
||||||
editorInkOpacity.value = value;
|
editorInkOpacity.value = value;
|
||||||
break;
|
break;
|
||||||
case AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:
|
case AnnotationEditorParamsType.HIGHLIGHT_COLOR:
|
||||||
eventBus.dispatch("mainhighlightcolorpickerupdatecolor", {
|
eventBus.dispatch("mainhighlightcolorpickerupdatecolor", {
|
||||||
source: this,
|
source: this,
|
||||||
value,
|
value,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user