Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[editor] Add some UI elements in order to set font size & color, and ink thickness & color #15039

Merged
merged 1 commit into from
Jun 28, 2022

Conversation

calixteman
Copy link
Contributor

No description provided.

@marco-c marco-c linked an issue Jun 13, 2022 that may be closed by this pull request
Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not really had time to test this yet, but I've added a few comments based on an initial look at the code.
While this seems mostly reasonable, there's a couple of things (e.g. related to the Toolbar-positions of the buttons) that we need to fix here.

src/display/editor/tools.js Outdated Show resolved Hide resolved
src/display/editor/tools.js Outdated Show resolved Hide resolved
web/annotation_editor_params.js Outdated Show resolved Hide resolved
web/annotation_editor_params.js Outdated Show resolved Hide resolved
web/base_viewer.js Outdated Show resolved Hide resolved
web/viewer.css Outdated Show resolved Hide resolved
web/viewer.html Outdated Show resolved Hide resolved
web/viewer.css Outdated
Comment on lines 528 to 543
#editorParamsToolbarContainer .editorParamsSlider::-moz-range-progress {
background-color: black;
}
#editorParamsToolbarContainer .editorParamsSlider::-moz-range-track {
background-color: black;
}
#editorParamsToolbarContainer .editorParamsSlider::-moz-range-thumb {
background-color: white;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these not available as standard CSS features instead (since it won't work in the GENERIC viewer)?

Copy link
Collaborator

@Snuffleupagus Snuffleupagus Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to leave these enabled everywhere though, such that the GENERIC viewer works better when used standalone in Firefox.

I was mostly wondering if there's anything similar for other browsers; sorry if that wasn't clear.

web/viewer.css Outdated Show resolved Hide resolved
src/shared/util.js Outdated Show resolved Hide resolved
web/viewer.css Outdated Show resolved Hide resolved
src/display/editor/freetext.js Outdated Show resolved Hide resolved
src/display/editor/ink.js Outdated Show resolved Hide resolved
src/display/editor/freetext.js Outdated Show resolved Hide resolved
src/display/editor/freetext.js Outdated Show resolved Hide resolved
src/display/editor/ink.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
web/toolbar.js Outdated Show resolved Hide resolved
web/viewer.html Outdated Show resolved Hide resolved
web/viewer.html Outdated Show resolved Hide resolved
@Snuffleupagus
Copy link
Collaborator

I'll try to review this PR during the weekend, since the size/scope of the changes means that it takes a little time to try and understand everything here; sorry about the delay!

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to create a preview to play with this a little bit, and to see how the new CSS-rules behave, however it needs a rebase first for that to work.

src/display/display_utils.js Outdated Show resolved Hide resolved
@@ -89,6 +95,94 @@ class FreeTextEditor extends AnnotationEditor {
return editor;
}

static updateDefaultParams(type, value) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to update the default values, and not just the values for the current instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure either it's a good idea: we need to know what UX thinks about that.
Anyway it works like this in Acrobat.

src/display/editor/freetext.js Outdated Show resolved Hide resolved
src/display/editor/ink.js Show resolved Hide resolved
src/display/editor/ink.js Outdated Show resolved Hide resolved
web/annotation_editor_params.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
web/viewer.css Outdated Show resolved Hide resolved
web/viewer.css Outdated Show resolved Hide resolved
@Snuffleupagus
Copy link
Collaborator

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/486fa915e784836/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/486fa915e784836/output.txt

Total script time: 2.76 mins

Published

web/viewer.css Outdated
padding-inline: 12px;
}

#editorParamsToolbarContainer .editorParamsLabel {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These labels are almost invisible in the "light"-CSS viewer mode.
Similar to the regular toolbarLabel-class, you'll definitely need to add the following rule here as well:

color: var(--main-color);

web/viewer.html Outdated
@@ -147,6 +147,32 @@
</div>
</div> <!-- findbar -->

<div class="editorParamsToolbar hidden doorHangerRight" id="editorFreeTextParamsToolbar">
<div id="editorParamsToolbarContainer">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're adding the same id for two different elements here, which feels strange.
What you probably want, here and below, is to use a class-name instead:

Suggested change
<div id="editorParamsToolbarContainer">
<div class="editorParamsToolbarContainer">

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remember to make the same changes throughout the CSS-code as well.

web/viewer.html Outdated
</div>

<div class="editorParamsToolbar hidden doorHangerRight" id="editorInkParamsToolbar">
<div id="editorParamsToolbarContainer">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div id="editorParamsToolbarContainer">
<div class="editorParamsToolbarContainer">

web/viewer.css Outdated
padding: 6px 0 10px;
inset-inline-end: 4px;
height: auto;
z-index: 30000;
background-color: var(--doorhanger-bg-color);
}

#editorParamsToolbarContainer > .editorParamsSetter {
max-width: 220px;
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finding it slightly inconsistent that the width of the two new toolbars aren't consistent.
So, can we perhaps remove this line, and instead add the following just above?

.editorParamsToolbarContainer {
  width: 220px;
  margin-bottom: -4px;
}

(The second line again follows the secondaryToolbar code, to get consitent top/bottom margins.)

web/viewer.html Outdated
<input type="color" id="editorFreeTextColor" name="fontColor" class="editorParamsColor" tabindex="100">
<label for="fontColor" class="editorParamsLabel" data-l10n-id="editor_free_text_font_color">Font Color</label>
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it, perhaps, look better with the order of the labels/inputs flipped?

web/viewer.css Outdated
display: flex;
align-items: center;
justify-content: space-between;
padding-inline: 12px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we perhaps want to reduce this a little bit (e.g. to 10px)?

@Snuffleupagus
Copy link
Collaborator

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/fd81324e58f9554/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/fd81324e58f9554/output.txt

Total script time: 2.63 mins

Published

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, with the last round of comments addressed; thank you!

web/viewer.html Outdated
Comment on lines 166 to 167
<input type="color" id="editorInkColor" name="inkColor" class="editorParamsColor" tabindex="102">
<label for="color" class="editorParamsLabel" data-l10n-id="editor_ink_line_color">Line Color</label>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's flip the order of these elements as well, for consistency with the FreeText-toolbar.

Copy link
Contributor Author

@calixteman calixteman Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for your information, I copied/pasted this code from:

pdf.js/web/viewer.html

Lines 131 to 136 in 4e025e1

<div id="findbarOptionsOneContainer">
<input type="checkbox" id="findHighlightAll" class="toolbarField" tabindex="94">
<label for="findHighlightAll" class="toolbarLabel" data-l10n-id="find_highlight">Highlight All</label>
<input type="checkbox" id="findMatchCase" class="toolbarField" tabindex="95">
<label for="findMatchCase" class="toolbarLabel" data-l10n-id="find_match_case_label">Match Case</label>
</div>

where it's input, label.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that, however please note that in those cases only the label is actually visible; hence it's a slightly different situation :-)

web/viewer.html Outdated
Comment on lines 170 to 171
<input type="range" id="editorInkThickness" class="editorParamsSlider" name="lineThickness" value="1" min="1" max="20" step="1" tabindex="103">
<label for="lineThickness" class="editorParamsLabel" data-l10n-id="editor_ink_line_thickness">Line Thickness</label>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's flip the order of these elements as well, for consistency with the FreeText-toolbar.

web/viewer.html Outdated
Comment on lines 153 to 154
<label for="fontColor" class="editorParamsLabel" data-l10n-id="editor_free_text_font_color">Font Color</label>
<input type="color" id="editorFreeTextColor" name="fontColor" class="editorParamsColor" tabindex="100">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the for-attribute reference the input-id in order to work correctly?

Basically, I believe that you want the following (with similar changes for the new elements below):

Suggested change
<label for="fontColor" class="editorParamsLabel" data-l10n-id="editor_free_text_font_color">Font Color</label>
<input type="color" id="editorFreeTextColor" name="fontColor" class="editorParamsColor" tabindex="100">
<label for="editorFreeTextColor" class="editorParamsLabel" data-l10n-id="editor_free_text_font_color">Font Color</label>
<input type="color" id="editorFreeTextColor" class="editorParamsColor" tabindex="100">

web/viewer.css Outdated
}

.editorParamsToolbarContainer .editorParamsLabel {
padding-inline-start: 10px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be changed to padding-inline-end now?

@calixteman
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/88fd07bb59f7dad/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/534c35c559dca77/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/88fd07bb59f7dad/output.txt

Total script time: 26.53 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 27

Image differences available at: http://54.241.84.105:8877/88fd07bb59f7dad/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/534c35c559dca77/output.txt

Total script time: 28.41 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 2

Image differences available at: http://54.193.163.58:8877/534c35c559dca77/reftest-analyzer.html#web=eq.log

@calixteman
Copy link
Contributor Author

The "regressions" in ref tests are because I changed the linecap, hence they're acceptable.

@Snuffleupagus Snuffleupagus merged commit f1d4015 into mozilla:master Jun 28, 2022
@Snuffleupagus
Copy link
Collaborator

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_makeref from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/7919825f1ca22cc/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_makeref from @Snuffleupagus received. Current queue size: 1

Live output at: http://54.193.163.58:8877/b17a0e005f4040b/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/7919825f1ca22cc/output.txt

Total script time: 22.64 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/b17a0e005f4040b/output.txt

Total script time: 22.50 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants