mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Implement the new alt text flow (bug 1909604)
For the Firefox pdf viewer, we want to use AI to guess an alt-text when adding an image to a pdf. For now the telemtry stuff is not implemented and will come soon. In order to test it locally: - set enableAltText, enableFakeMLManager and enableUpdatedAddImage to true. or in Firefox: - set browser.ml.enable, pdfjs.enableAltText and pdfjs.enableUpdatedAddImage to true.
This commit is contained in:
parent
8378c40f4c
commit
ed22d934e5
22 changed files with 1366 additions and 91 deletions
|
@ -46,6 +46,8 @@
|
|||
--editorFreeHighlight-editing-cursor: url(images/cursor-editorFreeHighlight.svg)
|
||||
1 18,
|
||||
pointer;
|
||||
|
||||
--new-alt-text-warning-image: url(images/altText_warning.svg);
|
||||
}
|
||||
|
||||
/* The following class is used to hide an element but keep it available to
|
||||
|
@ -76,6 +78,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
#viewerContainer.pdfPresentationMode:fullscreen {
|
||||
.noAltTextBadge {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-resolution: 1.1dppx) {
|
||||
:root {
|
||||
--editorFreeText-editing-cursor: url(images/cursor-editorFreeText.svg) 0 16,
|
||||
|
@ -222,12 +230,18 @@
|
|||
--editor-toolbar-vert-offset: 6px;
|
||||
--editor-toolbar-height: 28px;
|
||||
--editor-toolbar-padding: 2px;
|
||||
--alt-text-done-color: #2ac3a2;
|
||||
--alt-text-warning-color: #0090ed;
|
||||
--alt-text-hover-done-color: var(--alt-text-done-color);
|
||||
--alt-text-hover-warning-color: var(--alt-text-warning-color);
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
--editor-toolbar-bg-color: #2b2a33;
|
||||
--editor-toolbar-fg-color: #fbfbfe;
|
||||
--editor-toolbar-hover-bg-color: #52525e;
|
||||
--editor-toolbar-focus-outline-color: #0df;
|
||||
--alt-text-done-color: #54ffbd;
|
||||
--alt-text-warning-color: #80ebff;
|
||||
}
|
||||
|
||||
@media screen and (forced-colors: active) {
|
||||
|
@ -241,6 +255,10 @@
|
|||
var(--editor-toolbar-hover-border-color);
|
||||
--editor-toolbar-focus-outline-color: ButtonBorder;
|
||||
--editor-toolbar-shadow: none;
|
||||
--alt-text-done-color: var(--editor-toolbar-fg-color);
|
||||
--alt-text-warning-color: var(--editor-toolbar-fg-color);
|
||||
--alt-text-hover-done-color: var(--editor-toolbar-hover-fg-color);
|
||||
--alt-text-hover-warning-color: var(--editor-toolbar-hover-fg-color);
|
||||
}
|
||||
|
||||
display: flex;
|
||||
|
@ -400,6 +418,31 @@
|
|||
mask-image: var(--alt-text-done-image);
|
||||
}
|
||||
|
||||
&.new {
|
||||
&::before {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
mask-image: var(--new-alt-text-warning-image);
|
||||
background-color: var(--alt-text-warning-color);
|
||||
mask-size: cover;
|
||||
}
|
||||
|
||||
&:hover::before {
|
||||
background-color: var(--alt-text-hover-warning-color);
|
||||
}
|
||||
|
||||
&.done {
|
||||
&::before {
|
||||
mask-image: var(--alt-text-done-image);
|
||||
background-color: var(--alt-text-done-color);
|
||||
}
|
||||
|
||||
&:hover::before {
|
||||
background-color: var(--alt-text-hover-done-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
display: none;
|
||||
|
||||
|
@ -519,6 +562,50 @@
|
|||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.noAltTextBadge {
|
||||
--no-alt-text-badge-border-color: #f0f0f4;
|
||||
--no-alt-text-badge-bg-color: #cfcfd8;
|
||||
--no-alt-text-badge-fg-color: #5b5b66;
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
--no-alt-text-badge-border-color: #52525e;
|
||||
--no-alt-text-badge-bg-color: #fbfbfe;
|
||||
--no-alt-text-badge-fg-color: #15141a;
|
||||
}
|
||||
|
||||
@media screen and (forced-colors: active) {
|
||||
--no-alt-text-badge-border-color: ButtonText;
|
||||
--no-alt-text-badge-bg-color: ButtonFace;
|
||||
--no-alt-text-badge-fg-color: ButtonText;
|
||||
}
|
||||
|
||||
position: absolute;
|
||||
inset-inline-end: 5px;
|
||||
inset-block-end: 5px;
|
||||
display: inline-flex;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding: 3px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
|
||||
border-radius: 2px;
|
||||
border: 1px solid var(--no-alt-text-badge-border-color);
|
||||
background: var(--no-alt-text-badge-bg-color);
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
mask-image: var(--new-alt-text-warning-image);
|
||||
mask-size: cover;
|
||||
background-color: var(--no-alt-text-badge-fg-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.annotationEditorLayer {
|
||||
|
@ -767,6 +854,177 @@
|
|||
}
|
||||
}
|
||||
|
||||
.dialog.newAltText {
|
||||
--new-alt-text-ai-disclaimer-icon: url(images/altText_disclaimer.svg);
|
||||
--new-alt-text-spinner-icon: url(images/altText_spinner.svg);
|
||||
|
||||
width: 80%;
|
||||
max-width: 570px;
|
||||
min-width: 300px;
|
||||
padding: 0;
|
||||
|
||||
&.noAi {
|
||||
#newAltTextDisclaimer,
|
||||
#newAltTextCreateAutomatically {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
&.aiInstalling {
|
||||
#newAltTextCreateAutomatically {
|
||||
display: none !important;
|
||||
}
|
||||
#newAltTextDownloadModel {
|
||||
display: flex !important;
|
||||
}
|
||||
}
|
||||
|
||||
&.error {
|
||||
#newAltTextNotNow {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#newAltTextCancel {
|
||||
display: inline-block !important;
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.error) #newAltTextError {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#newAltTextContainer {
|
||||
display: flex;
|
||||
width: auto;
|
||||
padding: 16px;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
flex: 0 1 auto;
|
||||
|
||||
#mainContent {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
align-self: stretch;
|
||||
flex: 1 1 auto;
|
||||
|
||||
#descriptionAndSettings {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
flex: 1 0 0;
|
||||
align-self: stretch;
|
||||
}
|
||||
|
||||
#descriptionInstruction {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
align-self: stretch;
|
||||
flex: 1 1 auto;
|
||||
|
||||
#newAltTextDescriptionContainer {
|
||||
width: 100%;
|
||||
height: 70px;
|
||||
position: relative;
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 8px;
|
||||
|
||||
&::placeholder {
|
||||
color: var(--text-secondary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.altTextSpinner {
|
||||
display: none;
|
||||
position: absolute;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
inset-inline-start: 8px;
|
||||
inset-block-start: 8px;
|
||||
mask-size: cover;
|
||||
background-color: var(--text-secondary-color);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&.loading {
|
||||
textarea::placeholder {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.altTextSpinner {
|
||||
display: inline-block;
|
||||
mask-image: var(--new-alt-text-spinner-icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#newAltTextDescription {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#newAltTextDisclaimer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
align-self: stretch;
|
||||
flex-wrap: wrap;
|
||||
font-size: 11px;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
mask-image: var(--new-alt-text-ai-disclaimer-icon);
|
||||
mask-size: cover;
|
||||
background-color: var(--text-secondary-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#newAltTextDownloadModel {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
align-self: stretch;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
mask-image: var(--new-alt-text-spinner-icon);
|
||||
mask-size: cover;
|
||||
background-color: var(--text-secondary-color);
|
||||
}
|
||||
}
|
||||
|
||||
#newAltTextImagePreview {
|
||||
width: 180px;
|
||||
aspect-ratio: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex: 0 0 auto;
|
||||
|
||||
> canvas {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.colorPicker {
|
||||
--hover-outline-color: #0250bb;
|
||||
--selected-outline-color: #0060df;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue