2014-06-18 07:43:33 +09:00
|
|
|
/* Copyright 2014 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2019-08-31 23:40:39 +09:00
|
|
|
/* eslint no-var: error */
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-04-02 21:25:33 +09:00
|
|
|
import {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
addLinkAttributes,
|
|
|
|
DOMSVGFactory,
|
|
|
|
getFilenameFromUrl,
|
|
|
|
LinkTarget,
|
|
|
|
PDFDateString,
|
2020-01-02 20:00:16 +09:00
|
|
|
} from "./display_utils.js";
|
2017-04-02 21:25:33 +09:00
|
|
|
import {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
AnnotationBorderStyleType,
|
|
|
|
AnnotationType,
|
|
|
|
stringToPDFString,
|
|
|
|
unreachable,
|
|
|
|
Util,
|
|
|
|
warn,
|
2020-01-02 20:00:16 +09:00
|
|
|
} from "../shared/util.js";
|
[api-minor] Fix the `AnnotationStorage` usage properly in the viewer/tests (PR 12107 and 12143 follow-up)
*The [api-minor] label probably ought to have been added to the original PR, given the changes to the `createAnnotationLayerBuilder` signature (if nothing else).*
This patch fixes the following things:
- Let the `AnnotationLayer.render` method create an `AnnotationStorage`-instance if none was provided, thus making the parameter *properly* optional. This not only fixes the reference tests, it also prevents issues when the viewer components are used.
- Stop exporting `AnnotationStorage` in the official API, i.e. the `src/pdf.js` file, since it's no longer necessary given the change above. Generally speaking, unless absolutely necessary we probably shouldn't export unused things in the API.
- Fix a number of JSDocs `typedef`s, in `src/display/` and `web/` code, to actually account for the new `annotationStorage` parameter.
- Update `web/interfaces.js` to account for the changes in `createAnnotationLayerBuilder`.
- Initialize the storage, in `AnnotationStorage`, using `Object.create(null)` rather than `{}` (which is the PDF.js default).
2020-07-31 23:13:26 +09:00
|
|
|
import { AnnotationStorage } from "./annotation_storage.js";
|
2015-11-22 01:32:47 +09:00
|
|
|
|
2015-12-17 23:55:11 +09:00
|
|
|
/**
|
|
|
|
* @typedef {Object} AnnotationElementParameters
|
|
|
|
* @property {Object} data
|
2015-12-23 05:31:56 +09:00
|
|
|
* @property {HTMLDivElement} layer
|
2015-12-17 23:55:11 +09:00
|
|
|
* @property {PDFPage} page
|
|
|
|
* @property {PageViewport} viewport
|
|
|
|
* @property {IPDFLinkService} linkService
|
2016-02-15 04:44:00 +09:00
|
|
|
* @property {DownloadManager} downloadManager
|
[api-minor] Fix the `AnnotationStorage` usage properly in the viewer/tests (PR 12107 and 12143 follow-up)
*The [api-minor] label probably ought to have been added to the original PR, given the changes to the `createAnnotationLayerBuilder` signature (if nothing else).*
This patch fixes the following things:
- Let the `AnnotationLayer.render` method create an `AnnotationStorage`-instance if none was provided, thus making the parameter *properly* optional. This not only fixes the reference tests, it also prevents issues when the viewer components are used.
- Stop exporting `AnnotationStorage` in the official API, i.e. the `src/pdf.js` file, since it's no longer necessary given the change above. Generally speaking, unless absolutely necessary we probably shouldn't export unused things in the API.
- Fix a number of JSDocs `typedef`s, in `src/display/` and `web/` code, to actually account for the new `annotationStorage` parameter.
- Update `web/interfaces.js` to account for the changes in `createAnnotationLayerBuilder`.
- Initialize the storage, in `AnnotationStorage`, using `Object.create(null)` rather than `{}` (which is the PDF.js default).
2020-07-31 23:13:26 +09:00
|
|
|
* @property {AnnotationStorage} [annotationStorage]
|
2019-10-12 23:30:32 +09:00
|
|
|
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
|
|
|
* for annotation icons. Include trailing slash.
|
2016-09-07 05:26:57 +09:00
|
|
|
* @property {boolean} renderInteractiveForms
|
2017-07-24 07:09:18 +09:00
|
|
|
* @property {Object} svgFactory
|
2015-12-17 23:55:11 +09:00
|
|
|
*/
|
2014-12-26 04:44:16 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class AnnotationElementFactory {
|
2015-12-17 23:55:11 +09:00
|
|
|
/**
|
|
|
|
* @param {AnnotationElementParameters} parameters
|
|
|
|
* @returns {AnnotationElement}
|
|
|
|
*/
|
2017-08-27 07:30:00 +09:00
|
|
|
static create(parameters) {
|
2019-08-31 23:40:39 +09:00
|
|
|
const subtype = parameters.data.annotationType;
|
2015-12-17 23:55:11 +09:00
|
|
|
|
|
|
|
switch (subtype) {
|
|
|
|
case AnnotationType.LINK:
|
|
|
|
return new LinkAnnotationElement(parameters);
|
2014-12-26 04:44:16 +09:00
|
|
|
|
2015-12-17 23:55:11 +09:00
|
|
|
case AnnotationType.TEXT:
|
|
|
|
return new TextAnnotationElement(parameters);
|
2014-12-26 04:44:16 +09:00
|
|
|
|
2015-12-17 23:55:11 +09:00
|
|
|
case AnnotationType.WIDGET:
|
2019-08-31 23:40:39 +09:00
|
|
|
const fieldType = parameters.data.fieldType;
|
2016-09-06 06:46:52 +09:00
|
|
|
|
|
|
|
switch (fieldType) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "Tx":
|
2016-09-06 06:46:52 +09:00
|
|
|
return new TextWidgetAnnotationElement(parameters);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "Btn":
|
2016-12-16 07:49:46 +09:00
|
|
|
if (parameters.data.radioButton) {
|
|
|
|
return new RadioButtonWidgetAnnotationElement(parameters);
|
|
|
|
} else if (parameters.data.checkBox) {
|
|
|
|
return new CheckboxWidgetAnnotationElement(parameters);
|
2016-11-04 21:01:42 +09:00
|
|
|
}
|
2017-11-21 07:00:19 +09:00
|
|
|
return new PushButtonWidgetAnnotationElement(parameters);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
case "Ch":
|
2016-09-25 08:45:49 +09:00
|
|
|
return new ChoiceWidgetAnnotationElement(parameters);
|
2016-09-06 06:46:52 +09:00
|
|
|
}
|
2015-12-17 23:55:11 +09:00
|
|
|
return new WidgetAnnotationElement(parameters);
|
2014-12-26 04:44:16 +09:00
|
|
|
|
2015-12-23 05:31:56 +09:00
|
|
|
case AnnotationType.POPUP:
|
|
|
|
return new PopupAnnotationElement(parameters);
|
|
|
|
|
2019-04-14 01:45:22 +09:00
|
|
|
case AnnotationType.FREETEXT:
|
|
|
|
return new FreeTextAnnotationElement(parameters);
|
|
|
|
|
2017-04-03 03:50:17 +09:00
|
|
|
case AnnotationType.LINE:
|
|
|
|
return new LineAnnotationElement(parameters);
|
|
|
|
|
2017-07-24 07:11:27 +09:00
|
|
|
case AnnotationType.SQUARE:
|
|
|
|
return new SquareAnnotationElement(parameters);
|
|
|
|
|
2017-07-24 07:30:58 +09:00
|
|
|
case AnnotationType.CIRCLE:
|
|
|
|
return new CircleAnnotationElement(parameters);
|
|
|
|
|
2017-09-18 03:18:22 +09:00
|
|
|
case AnnotationType.POLYLINE:
|
|
|
|
return new PolylineAnnotationElement(parameters);
|
|
|
|
|
2019-04-10 06:35:32 +09:00
|
|
|
case AnnotationType.CARET:
|
|
|
|
return new CaretAnnotationElement(parameters);
|
|
|
|
|
2018-09-30 23:29:16 +09:00
|
|
|
case AnnotationType.INK:
|
|
|
|
return new InkAnnotationElement(parameters);
|
|
|
|
|
2017-09-23 23:50:49 +09:00
|
|
|
case AnnotationType.POLYGON:
|
|
|
|
return new PolygonAnnotationElement(parameters);
|
|
|
|
|
2016-01-01 23:31:46 +09:00
|
|
|
case AnnotationType.HIGHLIGHT:
|
|
|
|
return new HighlightAnnotationElement(parameters);
|
|
|
|
|
2015-12-28 08:33:41 +09:00
|
|
|
case AnnotationType.UNDERLINE:
|
|
|
|
return new UnderlineAnnotationElement(parameters);
|
|
|
|
|
2015-12-30 23:28:26 +09:00
|
|
|
case AnnotationType.SQUIGGLY:
|
|
|
|
return new SquigglyAnnotationElement(parameters);
|
|
|
|
|
2015-12-29 23:09:28 +09:00
|
|
|
case AnnotationType.STRIKEOUT:
|
|
|
|
return new StrikeOutAnnotationElement(parameters);
|
|
|
|
|
2017-09-16 23:37:50 +09:00
|
|
|
case AnnotationType.STAMP:
|
|
|
|
return new StampAnnotationElement(parameters);
|
|
|
|
|
2016-02-15 04:44:00 +09:00
|
|
|
case AnnotationType.FILEATTACHMENT:
|
|
|
|
return new FileAttachmentAnnotationElement(parameters);
|
|
|
|
|
2015-12-17 23:55:11 +09:00
|
|
|
default:
|
2016-01-12 12:44:44 +09:00
|
|
|
return new AnnotationElement(parameters);
|
2015-12-17 23:55:11 +09:00
|
|
|
}
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
}
|
2014-12-26 04:44:16 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class AnnotationElement {
|
2017-08-31 15:18:53 +09:00
|
|
|
constructor(parameters, isRenderable = false, ignoreBorder = false) {
|
2017-08-27 07:24:27 +09:00
|
|
|
this.isRenderable = isRenderable;
|
2015-12-17 23:55:11 +09:00
|
|
|
this.data = parameters.data;
|
2015-12-23 05:31:56 +09:00
|
|
|
this.layer = parameters.layer;
|
2015-12-17 23:55:11 +09:00
|
|
|
this.page = parameters.page;
|
|
|
|
this.viewport = parameters.viewport;
|
|
|
|
this.linkService = parameters.linkService;
|
2016-02-15 04:44:00 +09:00
|
|
|
this.downloadManager = parameters.downloadManager;
|
2016-03-29 04:49:22 +09:00
|
|
|
this.imageResourcesPath = parameters.imageResourcesPath;
|
2016-09-07 05:26:57 +09:00
|
|
|
this.renderInteractiveForms = parameters.renderInteractiveForms;
|
2017-07-24 07:09:18 +09:00
|
|
|
this.svgFactory = parameters.svgFactory;
|
2020-07-22 20:55:52 +09:00
|
|
|
this.annotationStorage = parameters.annotationStorage;
|
2015-12-17 23:55:11 +09:00
|
|
|
|
2016-01-12 12:44:44 +09:00
|
|
|
if (isRenderable) {
|
2017-04-03 03:31:21 +09:00
|
|
|
this.container = this._createContainer(ignoreBorder);
|
2016-01-12 12:44:44 +09:00
|
|
|
}
|
2015-12-17 23:55:11 +09:00
|
|
|
}
|
2014-12-26 04:44:16 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Create an empty container for the annotation's HTML element.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {boolean} ignoreBorder
|
|
|
|
* @memberof AnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
_createContainer(ignoreBorder = false) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const data = this.data,
|
|
|
|
page = this.page,
|
|
|
|
viewport = this.viewport;
|
|
|
|
const container = document.createElement("section");
|
2017-08-27 07:24:27 +09:00
|
|
|
let width = data.rect[2] - data.rect[0];
|
|
|
|
let height = data.rect[3] - data.rect[1];
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
container.setAttribute("data-annotation-id", data.id);
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
// Do *not* modify `data.rect`, since that will corrupt the annotation
|
|
|
|
// position on subsequent calls to `_createContainer` (see issue 6804).
|
2019-08-31 23:40:39 +09:00
|
|
|
const rect = Util.normalizeRect([
|
2017-08-27 07:24:27 +09:00
|
|
|
data.rect[0],
|
|
|
|
page.view[3] - data.rect[1] + page.view[1],
|
|
|
|
data.rect[2],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
page.view[3] - data.rect[3] + page.view[1],
|
2017-08-27 07:24:27 +09:00
|
|
|
]);
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
container.style.transform = `matrix(${viewport.transform.join(",")})`;
|
2019-08-31 23:40:39 +09:00
|
|
|
container.style.transformOrigin = `-${rect[0]}px -${rect[1]}px`;
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
if (!ignoreBorder && data.borderStyle.width > 0) {
|
2019-08-31 23:40:39 +09:00
|
|
|
container.style.borderWidth = `${data.borderStyle.width}px`;
|
2017-08-27 07:24:27 +09:00
|
|
|
if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
|
|
|
|
// Underline styles only have a bottom border, so we do not need
|
|
|
|
// to adjust for all borders. This yields a similar result as
|
|
|
|
// Adobe Acrobat/Reader.
|
|
|
|
width = width - 2 * data.borderStyle.width;
|
|
|
|
height = height - 2 * data.borderStyle.width;
|
|
|
|
}
|
2014-12-26 04:44:16 +09:00
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
const horizontalRadius = data.borderStyle.horizontalCornerRadius;
|
|
|
|
const verticalRadius = data.borderStyle.verticalCornerRadius;
|
2017-08-27 07:24:27 +09:00
|
|
|
if (horizontalRadius > 0 || verticalRadius > 0) {
|
2019-08-31 23:40:39 +09:00
|
|
|
const radius = `${horizontalRadius}px / ${verticalRadius}px`;
|
2017-12-31 21:51:51 +09:00
|
|
|
container.style.borderRadius = radius;
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
2014-12-26 04:44:16 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
switch (data.borderStyle.style) {
|
|
|
|
case AnnotationBorderStyleType.SOLID:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
container.style.borderStyle = "solid";
|
2017-08-27 07:24:27 +09:00
|
|
|
break;
|
2015-12-03 08:20:18 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
case AnnotationBorderStyleType.DASHED:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
container.style.borderStyle = "dashed";
|
2017-08-27 07:24:27 +09:00
|
|
|
break;
|
2015-12-03 08:20:18 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
case AnnotationBorderStyleType.BEVELED:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
warn("Unimplemented border style: beveled");
|
2017-08-27 07:24:27 +09:00
|
|
|
break;
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
case AnnotationBorderStyleType.INSET:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
warn("Unimplemented border style: inset");
|
2017-08-27 07:24:27 +09:00
|
|
|
break;
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
case AnnotationBorderStyleType.UNDERLINE:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
container.style.borderBottomStyle = "solid";
|
2017-08-27 07:24:27 +09:00
|
|
|
break;
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
default:
|
|
|
|
break;
|
2015-12-17 23:55:11 +09:00
|
|
|
}
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (data.color) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
container.style.borderColor = Util.makeCssRgb(
|
|
|
|
data.color[0] | 0,
|
|
|
|
data.color[1] | 0,
|
|
|
|
data.color[2] | 0
|
|
|
|
);
|
2017-08-27 07:24:27 +09:00
|
|
|
} else {
|
|
|
|
// Transparent (invisible) border, so do not draw it at all.
|
|
|
|
container.style.borderWidth = 0;
|
2016-02-23 08:21:28 +09:00
|
|
|
}
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
2016-02-23 08:21:28 +09:00
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
container.style.left = `${rect[0]}px`;
|
|
|
|
container.style.top = `${rect[1]}px`;
|
|
|
|
container.style.width = `${width}px`;
|
|
|
|
container.style.height = `${height}px`;
|
2017-08-27 07:24:27 +09:00
|
|
|
return container;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a popup for the annotation's HTML element. This is used for
|
|
|
|
* annotations that do not have a Popup entry in the dictionary, but
|
|
|
|
* are of a type that works with popups (such as Highlight annotations).
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {HTMLSectionElement} container
|
|
|
|
* @param {HTMLDivElement|HTMLImageElement|null} trigger
|
|
|
|
* @param {Object} data
|
|
|
|
* @memberof AnnotationElement
|
|
|
|
*/
|
|
|
|
_createPopup(container, trigger, data) {
|
|
|
|
// If no trigger element is specified, create it.
|
|
|
|
if (!trigger) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
trigger = document.createElement("div");
|
2017-08-27 07:24:27 +09:00
|
|
|
trigger.style.height = container.style.height;
|
|
|
|
trigger.style.width = container.style.width;
|
|
|
|
container.appendChild(trigger);
|
|
|
|
}
|
2016-02-23 08:21:28 +09:00
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
const popupElement = new PopupElement({
|
2017-08-27 07:24:27 +09:00
|
|
|
container,
|
|
|
|
trigger,
|
|
|
|
color: data.color,
|
|
|
|
title: data.title,
|
2019-04-22 04:21:01 +09:00
|
|
|
modificationDate: data.modificationDate,
|
2017-08-27 07:24:27 +09:00
|
|
|
contents: data.contents,
|
|
|
|
hideWrapper: true,
|
|
|
|
});
|
2019-08-31 23:40:39 +09:00
|
|
|
const popup = popupElement.render();
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
// Position the popup next to the annotation's container.
|
|
|
|
popup.style.left = container.style.width;
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
container.appendChild(popup);
|
2015-12-17 23:55:11 +09:00
|
|
|
}
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof AnnotationElement
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
unreachable("Abstract method `AnnotationElement.render` called");
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
}
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class LinkAnnotationElement extends AnnotationElement {
|
2017-08-31 15:18:53 +09:00
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.url ||
|
|
|
|
parameters.data.dest ||
|
|
|
|
parameters.data.action
|
|
|
|
);
|
2017-09-02 17:06:44 +09:00
|
|
|
super(parameters, isRenderable);
|
2017-08-31 15:18:53 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the link annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof LinkAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "linkAnnotation";
|
2017-08-27 07:24:27 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const { data, linkService } = this;
|
|
|
|
const link = document.createElement("a");
|
2018-02-13 22:03:52 +09:00
|
|
|
|
2019-09-11 20:17:41 +09:00
|
|
|
if (data.url) {
|
|
|
|
addLinkAttributes(link, {
|
|
|
|
url: data.url,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
target: data.newWindow
|
|
|
|
? LinkTarget.BLANK
|
|
|
|
: linkService.externalLinkTarget,
|
2019-09-11 20:17:41 +09:00
|
|
|
rel: linkService.externalLinkRel,
|
|
|
|
enabled: linkService.externalLinkEnabled,
|
|
|
|
});
|
|
|
|
} else if (data.action) {
|
|
|
|
this._bindNamedAction(link, data.action);
|
|
|
|
} else {
|
|
|
|
this._bindLink(link, data.dest);
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
2014-06-18 07:43:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
this.container.appendChild(link);
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bind internal links to the link element.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {Object} link
|
|
|
|
* @param {Object} destination
|
|
|
|
* @memberof LinkAnnotationElement
|
|
|
|
*/
|
|
|
|
_bindLink(link, destination) {
|
|
|
|
link.href = this.linkService.getDestinationHash(destination);
|
|
|
|
link.onclick = () => {
|
2015-12-17 23:55:11 +09:00
|
|
|
if (destination) {
|
2017-08-27 07:24:27 +09:00
|
|
|
this.linkService.navigateTo(destination);
|
2015-12-09 07:38:32 +09:00
|
|
|
}
|
2017-08-27 07:24:27 +09:00
|
|
|
return false;
|
|
|
|
};
|
|
|
|
if (destination) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
link.className = "internalLink";
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
}
|
2015-12-09 07:38:32 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Bind named actions to the link element.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {Object} link
|
|
|
|
* @param {Object} action
|
|
|
|
* @memberof LinkAnnotationElement
|
|
|
|
*/
|
|
|
|
_bindNamedAction(link, action) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
link.href = this.linkService.getAnchorUrl("");
|
2017-08-27 07:24:27 +09:00
|
|
|
link.onclick = () => {
|
|
|
|
this.linkService.executeNamedAction(action);
|
|
|
|
return false;
|
|
|
|
};
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
link.className = "internalLink";
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
}
|
2015-04-19 19:27:51 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class TextAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-08-27 07:24:27 +09:00
|
|
|
super(parameters, isRenderable);
|
2015-12-17 23:55:11 +09:00
|
|
|
}
|
2015-12-17 10:26:03 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the text annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof TextAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "textAnnotation";
|
2017-08-27 07:24:27 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const image = document.createElement("img");
|
2017-08-27 07:24:27 +09:00
|
|
|
image.style.height = this.container.style.height;
|
|
|
|
image.style.width = this.container.style.width;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
image.src =
|
|
|
|
this.imageResourcesPath +
|
|
|
|
"annotation-" +
|
|
|
|
this.data.name.toLowerCase() +
|
|
|
|
".svg";
|
|
|
|
image.alt = "[{{type}} Annotation]";
|
|
|
|
image.dataset.l10nId = "text_annotation_type";
|
|
|
|
image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
if (!this.data.hasPopup) {
|
|
|
|
this._createPopup(this.container, image, this.data);
|
|
|
|
}
|
2015-12-17 23:55:11 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
this.container.appendChild(image);
|
|
|
|
return this.container;
|
2015-12-16 00:48:55 +09:00
|
|
|
}
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
2015-12-16 00:48:55 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class WidgetAnnotationElement extends AnnotationElement {
|
|
|
|
/**
|
|
|
|
* Render the widget annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof WidgetAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
// Show only the container for unsupported field types.
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
2016-09-12 00:04:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable =
|
|
|
|
parameters.renderInteractiveForms ||
|
2016-09-25 08:45:49 +09:00
|
|
|
(!parameters.data.hasAppearance && !!parameters.data.fieldValue);
|
2017-08-27 07:24:27 +09:00
|
|
|
super(parameters, isRenderable);
|
2016-09-06 06:46:52 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the text widget annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof TextWidgetAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const TEXT_ALIGNMENT = ["left", "center", "right"];
|
2020-08-05 21:40:31 +09:00
|
|
|
const storage = this.annotationStorage;
|
|
|
|
const id = this.data.id;
|
2017-08-27 07:24:27 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "textWidgetAnnotation";
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
let element = null;
|
|
|
|
if (this.renderInteractiveForms) {
|
|
|
|
// NOTE: We cannot set the values using `element.value` below, since it
|
|
|
|
// prevents the AnnotationLayer rasterizer in `test/driver.js`
|
|
|
|
// from parsing the elements correctly for the reference tests.
|
2020-08-05 21:40:31 +09:00
|
|
|
const textContent = storage.getOrCreateValue(id, this.data.fieldValue);
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (this.data.multiLine) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element = document.createElement("textarea");
|
2020-08-05 21:40:31 +09:00
|
|
|
element.textContent = textContent;
|
2017-08-27 07:24:27 +09:00
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element = document.createElement("input");
|
|
|
|
element.type = "text";
|
2020-08-05 21:40:31 +09:00
|
|
|
element.setAttribute("value", textContent);
|
2016-09-07 05:26:57 +09:00
|
|
|
}
|
2016-09-12 00:04:33 +09:00
|
|
|
|
2020-08-06 23:07:13 +09:00
|
|
|
element.addEventListener("input", function (event) {
|
2020-08-05 21:40:31 +09:00
|
|
|
storage.setValue(id, event.target.value);
|
|
|
|
});
|
|
|
|
|
2020-09-10 17:37:13 +09:00
|
|
|
element.addEventListener("blur", function (event) {
|
|
|
|
event.target.setSelectionRange(0, 0);
|
|
|
|
});
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
element.disabled = this.data.readOnly;
|
2020-04-27 23:51:18 +09:00
|
|
|
element.name = this.data.fieldName;
|
2016-09-12 00:04:33 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (this.data.maxLen !== null) {
|
|
|
|
element.maxLength = this.data.maxLen;
|
2015-12-16 00:48:55 +09:00
|
|
|
}
|
2015-12-17 23:55:11 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (this.data.comb) {
|
2019-08-31 23:40:39 +09:00
|
|
|
const fieldWidth = this.data.rect[2] - this.data.rect[0];
|
|
|
|
const combWidth = fieldWidth / this.data.maxLen;
|
2015-12-17 23:55:11 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element.classList.add("comb");
|
2019-08-31 23:40:39 +09:00
|
|
|
element.style.letterSpacing = `calc(${combWidth}px - 1ch)`;
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element = document.createElement("div");
|
2017-08-27 07:24:27 +09:00
|
|
|
element.textContent = this.data.fieldValue;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element.style.verticalAlign = "middle";
|
|
|
|
element.style.display = "table-cell";
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
let font = null;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
this.data.fontRefName &&
|
|
|
|
this.page.commonObjs.has(this.data.fontRefName)
|
|
|
|
) {
|
2018-11-07 22:36:29 +09:00
|
|
|
font = this.page.commonObjs.get(this.data.fontRefName);
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
this._setTextStyle(element, font);
|
|
|
|
}
|
2015-12-16 00:48:55 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (this.data.textAlignment !== null) {
|
|
|
|
element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
|
|
|
|
}
|
2015-12-17 23:55:11 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
this.container.appendChild(element);
|
|
|
|
return this.container;
|
2016-11-04 21:01:42 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Apply text styles to the text in the element.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {HTMLDivElement} element
|
|
|
|
* @param {Object} font
|
|
|
|
* @memberof TextWidgetAnnotationElement
|
|
|
|
*/
|
|
|
|
_setTextStyle(element, font) {
|
|
|
|
// TODO: This duplicates some of the logic in CanvasGraphics.setFont().
|
2019-08-31 23:40:39 +09:00
|
|
|
const style = element.style;
|
|
|
|
style.fontSize = `${this.data.fontSize}px`;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
style.direction = this.data.fontDirection < 0 ? "rtl" : "ltr";
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
if (!font) {
|
|
|
|
return;
|
|
|
|
}
|
2016-11-04 21:01:42 +09:00
|
|
|
|
2020-01-13 03:47:13 +09:00
|
|
|
let bold = "normal";
|
|
|
|
if (font.black) {
|
|
|
|
bold = "900";
|
|
|
|
} else if (font.bold) {
|
|
|
|
bold = "bold";
|
|
|
|
}
|
|
|
|
style.fontWeight = bold;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
style.fontStyle = font.italic ? "italic" : "normal";
|
2016-11-04 21:01:42 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
// Use a reasonable default font if the font doesn't specify a fallback.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const fontFamily = font.loadedName ? `"${font.loadedName}", ` : "";
|
|
|
|
const fallbackName = font.fallbackName || "Helvetica, sans-serif";
|
2017-08-27 07:24:27 +09:00
|
|
|
style.fontFamily = fontFamily + fallbackName;
|
|
|
|
}
|
|
|
|
}
|
2016-11-04 21:01:42 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
|
|
constructor(parameters) {
|
|
|
|
super(parameters, parameters.renderInteractiveForms);
|
2016-11-04 21:01:42 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the checkbox widget annotation's HTML element
|
|
|
|
* in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof CheckboxWidgetAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2020-07-23 00:10:59 +09:00
|
|
|
const storage = this.annotationStorage;
|
|
|
|
const data = this.data;
|
|
|
|
const id = data.id;
|
|
|
|
const value = storage.getOrCreateValue(
|
|
|
|
id,
|
|
|
|
data.fieldValue && data.fieldValue !== "Off"
|
|
|
|
);
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "buttonWidgetAnnotation checkBox";
|
2017-08-27 07:24:27 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const element = document.createElement("input");
|
2020-07-23 00:10:59 +09:00
|
|
|
element.disabled = data.readOnly;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element.type = "checkbox";
|
2020-04-27 23:51:18 +09:00
|
|
|
element.name = this.data.fieldName;
|
2020-07-23 00:10:59 +09:00
|
|
|
if (value) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element.setAttribute("checked", true);
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
2016-11-04 21:01:42 +09:00
|
|
|
|
2020-07-23 00:10:59 +09:00
|
|
|
element.addEventListener("change", function (event) {
|
|
|
|
storage.setValue(id, event.target.checked);
|
|
|
|
});
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
this.container.appendChild(element);
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
2016-11-04 21:01:42 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
|
|
constructor(parameters) {
|
|
|
|
super(parameters, parameters.renderInteractiveForms);
|
|
|
|
}
|
2016-11-04 21:01:42 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the radio button widget annotation's HTML element
|
|
|
|
* in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof RadioButtonWidgetAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "buttonWidgetAnnotation radioButton";
|
2020-07-23 00:29:35 +09:00
|
|
|
const storage = this.annotationStorage;
|
|
|
|
const data = this.data;
|
|
|
|
const id = data.id;
|
|
|
|
const value = storage.getOrCreateValue(
|
|
|
|
id,
|
|
|
|
data.fieldValue === data.buttonValue
|
|
|
|
);
|
2017-08-27 07:24:27 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const element = document.createElement("input");
|
2020-07-23 00:29:35 +09:00
|
|
|
element.disabled = data.readOnly;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element.type = "radio";
|
2020-07-23 00:29:35 +09:00
|
|
|
element.name = data.fieldName;
|
|
|
|
if (value) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element.setAttribute("checked", true);
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
|
2020-07-23 00:29:35 +09:00
|
|
|
element.addEventListener("change", function (event) {
|
|
|
|
const name = event.target.name;
|
|
|
|
for (const radio of document.getElementsByName(name)) {
|
|
|
|
if (radio !== event.target) {
|
|
|
|
storage.setValue(
|
|
|
|
radio.parentNode.getAttribute("data-annotation-id"),
|
|
|
|
false
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
storage.setValue(id, event.target.checked);
|
|
|
|
});
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
this.container.appendChild(element);
|
|
|
|
return this.container;
|
2016-09-25 08:45:49 +09:00
|
|
|
}
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
2016-09-25 08:45:49 +09:00
|
|
|
|
2017-11-21 07:00:19 +09:00
|
|
|
class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
|
|
|
|
/**
|
|
|
|
* Render the push button widget annotation's HTML element
|
|
|
|
* in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof PushButtonWidgetAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
// The rendering and functionality of a push button widget annotation is
|
|
|
|
// equal to that of a link annotation, but may have more functionality, such
|
|
|
|
// as performing actions on form fields (resetting, submitting, et cetera).
|
2019-08-31 23:40:39 +09:00
|
|
|
const container = super.render();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
container.className = "buttonWidgetAnnotation pushButton";
|
2017-11-21 07:00:19 +09:00
|
|
|
return container;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
|
|
constructor(parameters) {
|
|
|
|
super(parameters, parameters.renderInteractiveForms);
|
|
|
|
}
|
2016-09-25 08:45:49 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the choice widget annotation's HTML element in the empty
|
|
|
|
* container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof ChoiceWidgetAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "choiceWidgetAnnotation";
|
2020-08-05 21:40:31 +09:00
|
|
|
const storage = this.annotationStorage;
|
|
|
|
const id = this.data.id;
|
2016-09-25 08:45:49 +09:00
|
|
|
|
2020-08-22 21:29:00 +09:00
|
|
|
// For printing/saving we currently only support choice widgets with one
|
|
|
|
// option selection. Therefore, listboxes (#12189) and comboboxes (#12224)
|
|
|
|
// are not properly printed/saved yet, so we only store the first item in
|
|
|
|
// the field value array instead of the entire array. Once support for those
|
|
|
|
// two field types is implemented, we should use the same pattern as the
|
|
|
|
// other interactive widgets where the return value of `getOrCreateValue` is
|
|
|
|
// used and the full array of field values is stored.
|
|
|
|
storage.getOrCreateValue(
|
|
|
|
id,
|
|
|
|
this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : null
|
|
|
|
);
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const selectElement = document.createElement("select");
|
2017-08-27 07:24:27 +09:00
|
|
|
selectElement.disabled = this.data.readOnly;
|
2020-04-27 23:51:18 +09:00
|
|
|
selectElement.name = this.data.fieldName;
|
2016-09-25 08:45:49 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (!this.data.combo) {
|
|
|
|
// List boxes have a size and (optionally) multiple selection.
|
|
|
|
selectElement.size = this.data.options.length;
|
|
|
|
if (this.data.multiSelect) {
|
|
|
|
selectElement.multiple = true;
|
2016-09-25 08:45:49 +09:00
|
|
|
}
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
2016-09-25 08:45:49 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
// Insert the options into the choice field.
|
2019-08-31 23:40:39 +09:00
|
|
|
for (const option of this.data.options) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const optionElement = document.createElement("option");
|
2017-08-27 07:24:27 +09:00
|
|
|
optionElement.textContent = option.displayValue;
|
|
|
|
optionElement.value = option.exportValue;
|
2020-08-22 20:57:12 +09:00
|
|
|
if (this.data.fieldValue.includes(option.exportValue)) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
optionElement.setAttribute("selected", true);
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
selectElement.appendChild(optionElement);
|
|
|
|
}
|
|
|
|
|
2020-08-06 23:07:13 +09:00
|
|
|
selectElement.addEventListener("input", function (event) {
|
2020-08-05 21:40:31 +09:00
|
|
|
const options = event.target.options;
|
2020-08-22 20:57:12 +09:00
|
|
|
const value = options[options.selectedIndex].value;
|
2020-08-05 21:40:31 +09:00
|
|
|
storage.setValue(id, value);
|
|
|
|
});
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
this.container.appendChild(selectElement);
|
|
|
|
return this.container;
|
2015-12-23 05:31:56 +09:00
|
|
|
}
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class PopupAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
2019-08-31 23:40:39 +09:00
|
|
|
const isRenderable = !!(parameters.data.title || parameters.data.contents);
|
2017-08-27 07:24:27 +09:00
|
|
|
super(parameters, isRenderable);
|
|
|
|
}
|
2017-04-03 03:50:17 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the popup annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof PopupAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
// Do not render popup annotations for parent elements with these types as
|
|
|
|
// they create the popups themselves (because of custom trigger divs).
|
2018-09-30 23:29:16 +09:00
|
|
|
const IGNORE_TYPES = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
"Line",
|
|
|
|
"Square",
|
|
|
|
"Circle",
|
|
|
|
"PolyLine",
|
|
|
|
"Polygon",
|
|
|
|
"Ink",
|
2018-09-30 23:29:16 +09:00
|
|
|
];
|
2015-12-23 05:31:56 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "popupAnnotation";
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2018-02-04 22:50:58 +09:00
|
|
|
if (IGNORE_TYPES.includes(this.data.parentType)) {
|
2017-08-27 07:24:27 +09:00
|
|
|
return this.container;
|
|
|
|
}
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
const selector = `[data-annotation-id="${this.data.parentId}"]`;
|
|
|
|
const parentElement = this.layer.querySelector(selector);
|
2017-08-27 07:24:27 +09:00
|
|
|
if (!parentElement) {
|
2015-12-23 05:31:56 +09:00
|
|
|
return this.container;
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
const popup = new PopupElement({
|
2017-08-27 07:24:27 +09:00
|
|
|
container: this.container,
|
|
|
|
trigger: parentElement,
|
|
|
|
color: this.data.color,
|
|
|
|
title: this.data.title,
|
2019-04-22 04:21:01 +09:00
|
|
|
modificationDate: this.data.modificationDate,
|
2017-08-27 07:24:27 +09:00
|
|
|
contents: this.data.contents,
|
|
|
|
});
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
// Position the popup next to the parent annotation's container.
|
|
|
|
// PDF viewers ignore a popup annotation's rectangle.
|
2019-08-31 23:40:39 +09:00
|
|
|
const parentLeft = parseFloat(parentElement.style.left);
|
|
|
|
const parentWidth = parseFloat(parentElement.style.width);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.style.transformOrigin = `-${parentLeft + parentWidth}px -${
|
|
|
|
parentElement.style.top
|
|
|
|
}`;
|
2019-08-31 23:40:39 +09:00
|
|
|
this.container.style.left = `${parentLeft + parentWidth}px`;
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
this.container.appendChild(popup.render());
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class PopupElement {
|
|
|
|
constructor(parameters) {
|
2015-12-27 23:07:18 +09:00
|
|
|
this.container = parameters.container;
|
|
|
|
this.trigger = parameters.trigger;
|
2015-12-23 05:31:56 +09:00
|
|
|
this.color = parameters.color;
|
|
|
|
this.title = parameters.title;
|
2019-04-22 04:21:01 +09:00
|
|
|
this.modificationDate = parameters.modificationDate;
|
2015-12-23 05:31:56 +09:00
|
|
|
this.contents = parameters.contents;
|
2015-12-27 23:07:18 +09:00
|
|
|
this.hideWrapper = parameters.hideWrapper || false;
|
2015-12-23 05:31:56 +09:00
|
|
|
|
|
|
|
this.pinned = false;
|
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the popup's HTML element.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof PopupElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const BACKGROUND_ENLIGHT = 0.7;
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const wrapper = document.createElement("div");
|
|
|
|
wrapper.className = "popupWrapper";
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
// For Popup annotations we hide the entire section because it contains
|
|
|
|
// only the popup. However, for Text annotations without a separate Popup
|
|
|
|
// annotation, we cannot hide the entire container as the image would
|
|
|
|
// disappear too. In that special case, hiding the wrapper suffices.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.hideElement = this.hideWrapper ? wrapper : this.container;
|
|
|
|
this.hideElement.setAttribute("hidden", true);
|
2017-08-27 07:24:27 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const popup = document.createElement("div");
|
|
|
|
popup.className = "popup";
|
2017-08-27 07:24:27 +09:00
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
const color = this.color;
|
2017-08-27 07:24:27 +09:00
|
|
|
if (color) {
|
|
|
|
// Enlighten the color.
|
2019-08-31 23:40:39 +09:00
|
|
|
const r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
|
|
|
|
const g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
|
|
|
|
const b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
|
2017-08-27 07:24:27 +09:00
|
|
|
popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
|
|
|
|
}
|
2015-12-27 23:07:18 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const title = document.createElement("h1");
|
2017-08-27 07:24:27 +09:00
|
|
|
title.textContent = this.title;
|
2019-04-22 04:21:01 +09:00
|
|
|
popup.appendChild(title);
|
|
|
|
|
|
|
|
// The modification date is shown in the popup instead of the creation
|
|
|
|
// date if it is available and can be parsed correctly, which is
|
|
|
|
// consistent with other viewers such as Adobe Acrobat.
|
|
|
|
const dateObject = PDFDateString.toDateObject(this.modificationDate);
|
|
|
|
if (dateObject) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const modificationDate = document.createElement("span");
|
|
|
|
modificationDate.textContent = "{{date}}, {{time}}";
|
|
|
|
modificationDate.dataset.l10nId = "annotation_date_string";
|
2019-04-22 04:21:01 +09:00
|
|
|
modificationDate.dataset.l10nArgs = JSON.stringify({
|
|
|
|
date: dateObject.toLocaleDateString(),
|
|
|
|
time: dateObject.toLocaleTimeString(),
|
|
|
|
});
|
|
|
|
popup.appendChild(modificationDate);
|
|
|
|
}
|
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
const contents = this._formatContents(this.contents);
|
2019-04-22 04:21:01 +09:00
|
|
|
popup.appendChild(contents);
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
// Attach the event listeners to the trigger element.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.trigger.addEventListener("click", this._toggle.bind(this));
|
|
|
|
this.trigger.addEventListener("mouseover", this._show.bind(this, false));
|
|
|
|
this.trigger.addEventListener("mouseout", this._hide.bind(this, false));
|
|
|
|
popup.addEventListener("click", this._hide.bind(this, true));
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
wrapper.appendChild(popup);
|
|
|
|
return wrapper;
|
|
|
|
}
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Format the contents of the popup by adding newlines where necessary.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {string} contents
|
|
|
|
* @memberof PopupElement
|
|
|
|
* @returns {HTMLParagraphElement}
|
|
|
|
*/
|
|
|
|
_formatContents(contents) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const p = document.createElement("p");
|
2019-08-31 23:40:39 +09:00
|
|
|
const lines = contents.split(/(?:\r\n?|\n)/);
|
2017-08-27 07:24:27 +09:00
|
|
|
for (let i = 0, ii = lines.length; i < ii; ++i) {
|
2019-08-31 23:40:39 +09:00
|
|
|
const line = lines[i];
|
2017-08-27 07:24:27 +09:00
|
|
|
p.appendChild(document.createTextNode(line));
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (i < ii - 1) {
|
|
|
|
p.appendChild(document.createElement("br"));
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
2015-12-23 05:31:56 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Toggle the visibility of the popup.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @memberof PopupElement
|
|
|
|
*/
|
|
|
|
_toggle() {
|
|
|
|
if (this.pinned) {
|
|
|
|
this._hide(true);
|
|
|
|
} else {
|
|
|
|
this._show(true);
|
|
|
|
}
|
|
|
|
}
|
2017-04-03 03:50:17 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Show the popup.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {boolean} pin
|
|
|
|
* @memberof PopupElement
|
|
|
|
*/
|
|
|
|
_show(pin = false) {
|
|
|
|
if (pin) {
|
|
|
|
this.pinned = true;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (this.hideElement.hasAttribute("hidden")) {
|
|
|
|
this.hideElement.removeAttribute("hidden");
|
2017-08-27 07:24:27 +09:00
|
|
|
this.container.style.zIndex += 1;
|
|
|
|
}
|
2017-04-03 03:50:17 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Hide the popup.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {boolean} unpin
|
|
|
|
* @memberof PopupElement
|
|
|
|
*/
|
|
|
|
_hide(unpin = true) {
|
|
|
|
if (unpin) {
|
|
|
|
this.pinned = false;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (!this.hideElement.hasAttribute("hidden") && !this.pinned) {
|
|
|
|
this.hideElement.setAttribute("hidden", true);
|
2017-08-27 07:24:27 +09:00
|
|
|
this.container.style.zIndex -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-03 03:50:17 +09:00
|
|
|
|
2019-04-14 01:45:22 +09:00
|
|
|
class FreeTextAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2019-04-14 01:45:22 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the free text annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof FreeTextAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "freeTextAnnotation";
|
2019-04-14 01:45:22 +09:00
|
|
|
|
|
|
|
if (!this.data.hasPopup) {
|
|
|
|
this._createPopup(this.container, null, this.data);
|
|
|
|
}
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class LineAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-08-27 07:24:27 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
|
|
|
}
|
2017-04-03 03:50:17 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the line annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof LineAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "lineAnnotation";
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
// Create an invisible line with the same starting and ending coordinates
|
|
|
|
// that acts as the trigger for the popup. Only the line itself should
|
|
|
|
// trigger the popup, not the entire container.
|
2019-08-31 23:40:39 +09:00
|
|
|
const data = this.data;
|
|
|
|
const width = data.rect[2] - data.rect[0];
|
|
|
|
const height = data.rect[3] - data.rect[1];
|
|
|
|
const svg = this.svgFactory.create(width, height);
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
// PDF coordinates are calculated from a bottom left origin, so transform
|
|
|
|
// the line coordinates to a top left origin for the SVG element.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const line = this.svgFactory.createElement("svg:line");
|
|
|
|
line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
|
|
|
|
line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
|
|
|
|
line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
|
|
|
|
line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
|
2019-11-09 21:29:09 +09:00
|
|
|
// Ensure that the 'stroke-width' is always non-zero, since otherwise it
|
|
|
|
// won't be possible to open/close the popup (note e.g. issue 11122).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
line.setAttribute("stroke-width", data.borderStyle.width || 1);
|
|
|
|
line.setAttribute("stroke", "transparent");
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
svg.appendChild(line);
|
|
|
|
this.container.append(svg);
|
|
|
|
|
|
|
|
// Create the popup ourselves so that we can bind it to the line instead
|
|
|
|
// of to the entire container (which is the default).
|
2017-07-24 07:09:18 +09:00
|
|
|
this._createPopup(this.container, line, data);
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
2017-04-03 03:50:17 +09:00
|
|
|
|
2017-07-24 07:11:27 +09:00
|
|
|
class SquareAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-07-24 07:11:27 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the square annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof SquareAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "squareAnnotation";
|
2017-07-24 07:11:27 +09:00
|
|
|
|
|
|
|
// Create an invisible square with the same rectangle that acts as the
|
|
|
|
// trigger for the popup. Only the square itself should trigger the
|
|
|
|
// popup, not the entire container.
|
2019-08-31 23:40:39 +09:00
|
|
|
const data = this.data;
|
|
|
|
const width = data.rect[2] - data.rect[0];
|
|
|
|
const height = data.rect[3] - data.rect[1];
|
|
|
|
const svg = this.svgFactory.create(width, height);
|
2017-07-24 07:11:27 +09:00
|
|
|
|
|
|
|
// The browser draws half of the borders inside the square and half of
|
|
|
|
// the borders outside the square by default. This behavior cannot be
|
|
|
|
// changed programmatically, so correct for that here.
|
2019-08-31 23:40:39 +09:00
|
|
|
const borderWidth = data.borderStyle.width;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const square = this.svgFactory.createElement("svg:rect");
|
|
|
|
square.setAttribute("x", borderWidth / 2);
|
|
|
|
square.setAttribute("y", borderWidth / 2);
|
|
|
|
square.setAttribute("width", width - borderWidth);
|
|
|
|
square.setAttribute("height", height - borderWidth);
|
2019-11-09 21:29:09 +09:00
|
|
|
// Ensure that the 'stroke-width' is always non-zero, since otherwise it
|
|
|
|
// won't be possible to open/close the popup (note e.g. issue 11122).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
square.setAttribute("stroke-width", borderWidth || 1);
|
|
|
|
square.setAttribute("stroke", "transparent");
|
|
|
|
square.setAttribute("fill", "none");
|
2017-07-24 07:11:27 +09:00
|
|
|
|
|
|
|
svg.appendChild(square);
|
|
|
|
this.container.append(svg);
|
|
|
|
|
|
|
|
// Create the popup ourselves so that we can bind it to the square instead
|
|
|
|
// of to the entire container (which is the default).
|
|
|
|
this._createPopup(this.container, square, data);
|
|
|
|
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-24 07:30:58 +09:00
|
|
|
class CircleAnnotationElement extends AnnotationElement {
|
2017-08-27 07:24:27 +09:00
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-07-24 07:30:58 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the circle annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof CircleAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "circleAnnotation";
|
2017-07-24 07:11:27 +09:00
|
|
|
|
2017-07-24 07:30:58 +09:00
|
|
|
// Create an invisible circle with the same ellipse that acts as the
|
|
|
|
// trigger for the popup. Only the circle itself should trigger the
|
|
|
|
// popup, not the entire container.
|
2019-08-31 23:40:39 +09:00
|
|
|
const data = this.data;
|
|
|
|
const width = data.rect[2] - data.rect[0];
|
|
|
|
const height = data.rect[3] - data.rect[1];
|
|
|
|
const svg = this.svgFactory.create(width, height);
|
2017-07-24 07:30:58 +09:00
|
|
|
|
|
|
|
// The browser draws half of the borders inside the circle and half of
|
|
|
|
// the borders outside the circle by default. This behavior cannot be
|
|
|
|
// changed programmatically, so correct for that here.
|
2019-08-31 23:40:39 +09:00
|
|
|
const borderWidth = data.borderStyle.width;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const circle = this.svgFactory.createElement("svg:ellipse");
|
|
|
|
circle.setAttribute("cx", width / 2);
|
|
|
|
circle.setAttribute("cy", height / 2);
|
|
|
|
circle.setAttribute("rx", width / 2 - borderWidth / 2);
|
|
|
|
circle.setAttribute("ry", height / 2 - borderWidth / 2);
|
2019-11-09 21:29:09 +09:00
|
|
|
// Ensure that the 'stroke-width' is always non-zero, since otherwise it
|
|
|
|
// won't be possible to open/close the popup (note e.g. issue 11122).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
circle.setAttribute("stroke-width", borderWidth || 1);
|
|
|
|
circle.setAttribute("stroke", "transparent");
|
|
|
|
circle.setAttribute("fill", "none");
|
2017-07-24 07:30:58 +09:00
|
|
|
|
|
|
|
svg.appendChild(circle);
|
|
|
|
this.container.append(svg);
|
|
|
|
|
|
|
|
// Create the popup ourselves so that we can bind it to the circle instead
|
|
|
|
// of to the entire container (which is the default).
|
|
|
|
this._createPopup(this.container, circle, data);
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
2017-04-03 03:50:17 +09:00
|
|
|
|
2017-09-18 03:18:22 +09:00
|
|
|
class PolylineAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-09-18 03:18:22 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
2017-09-23 23:50:49 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.containerClassName = "polylineAnnotation";
|
|
|
|
this.svgElementName = "svg:polyline";
|
2017-09-18 03:18:22 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the polyline annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof PolylineAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2017-09-23 23:50:49 +09:00
|
|
|
this.container.className = this.containerClassName;
|
2017-09-18 03:18:22 +09:00
|
|
|
|
|
|
|
// Create an invisible polyline with the same points that acts as the
|
|
|
|
// trigger for the popup. Only the polyline itself should trigger the
|
|
|
|
// popup, not the entire container.
|
2019-08-31 23:40:39 +09:00
|
|
|
const data = this.data;
|
|
|
|
const width = data.rect[2] - data.rect[0];
|
|
|
|
const height = data.rect[3] - data.rect[1];
|
|
|
|
const svg = this.svgFactory.create(width, height);
|
2017-09-18 03:18:22 +09:00
|
|
|
|
|
|
|
// Convert the vertices array to a single points string that the SVG
|
|
|
|
// polyline element expects ("x1,y1 x2,y2 ..."). PDF coordinates are
|
|
|
|
// calculated from a bottom left origin, so transform the polyline
|
|
|
|
// coordinates to a top left origin for the SVG element.
|
|
|
|
let points = [];
|
2019-08-31 23:40:39 +09:00
|
|
|
for (const coordinate of data.vertices) {
|
|
|
|
const x = coordinate.x - data.rect[0];
|
|
|
|
const y = data.rect[3] - coordinate.y;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
points.push(x + "," + y);
|
2017-09-18 03:18:22 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
points = points.join(" ");
|
2017-09-18 03:18:22 +09:00
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
const polyline = this.svgFactory.createElement(this.svgElementName);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
polyline.setAttribute("points", points);
|
2019-11-09 21:29:09 +09:00
|
|
|
// Ensure that the 'stroke-width' is always non-zero, since otherwise it
|
|
|
|
// won't be possible to open/close the popup (note e.g. issue 11122).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
|
|
|
|
polyline.setAttribute("stroke", "transparent");
|
|
|
|
polyline.setAttribute("fill", "none");
|
2017-09-18 03:18:22 +09:00
|
|
|
|
|
|
|
svg.appendChild(polyline);
|
|
|
|
this.container.append(svg);
|
|
|
|
|
|
|
|
// Create the popup ourselves so that we can bind it to the polyline
|
|
|
|
// instead of to the entire container (which is the default).
|
|
|
|
this._createPopup(this.container, polyline, data);
|
|
|
|
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-23 23:50:49 +09:00
|
|
|
class PolygonAnnotationElement extends PolylineAnnotationElement {
|
|
|
|
constructor(parameters) {
|
|
|
|
// Polygons are specific forms of polylines, so reuse their logic.
|
|
|
|
super(parameters);
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.containerClassName = "polygonAnnotation";
|
|
|
|
this.svgElementName = "svg:polygon";
|
2017-09-23 23:50:49 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 06:35:32 +09:00
|
|
|
class CaretAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2019-04-10 06:35:32 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the caret annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof CaretAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "caretAnnotation";
|
2019-04-10 06:35:32 +09:00
|
|
|
|
|
|
|
if (!this.data.hasPopup) {
|
|
|
|
this._createPopup(this.container, null, this.data);
|
|
|
|
}
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-30 23:29:16 +09:00
|
|
|
class InkAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2018-09-30 23:29:16 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.containerClassName = "inkAnnotation";
|
2018-09-30 23:29:16 +09:00
|
|
|
|
|
|
|
// Use the polyline SVG element since it allows us to use coordinates
|
|
|
|
// directly and to draw both straight lines and curves.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.svgElementName = "svg:polyline";
|
2018-09-30 23:29:16 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the ink annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof InkAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
this.container.className = this.containerClassName;
|
|
|
|
|
|
|
|
// Create an invisible polyline with the same points that acts as the
|
|
|
|
// trigger for the popup.
|
2019-08-31 23:40:39 +09:00
|
|
|
const data = this.data;
|
|
|
|
const width = data.rect[2] - data.rect[0];
|
|
|
|
const height = data.rect[3] - data.rect[1];
|
|
|
|
const svg = this.svgFactory.create(width, height);
|
2018-09-30 23:29:16 +09:00
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
for (const inkList of data.inkLists) {
|
2018-09-30 23:29:16 +09:00
|
|
|
// Convert the ink list to a single points string that the SVG
|
|
|
|
// polyline element expects ("x1,y1 x2,y2 ..."). PDF coordinates are
|
|
|
|
// calculated from a bottom left origin, so transform the polyline
|
|
|
|
// coordinates to a top left origin for the SVG element.
|
2019-08-31 23:40:39 +09:00
|
|
|
let points = [];
|
|
|
|
for (const coordinate of inkList) {
|
|
|
|
const x = coordinate.x - data.rect[0];
|
|
|
|
const y = data.rect[3] - coordinate.y;
|
|
|
|
points.push(`${x},${y}`);
|
2018-09-30 23:29:16 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
points = points.join(" ");
|
2018-09-30 23:29:16 +09:00
|
|
|
|
2019-08-31 23:40:39 +09:00
|
|
|
const polyline = this.svgFactory.createElement(this.svgElementName);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
polyline.setAttribute("points", points);
|
2019-11-09 21:29:09 +09:00
|
|
|
// Ensure that the 'stroke-width' is always non-zero, since otherwise it
|
|
|
|
// won't be possible to open/close the popup (note e.g. issue 11122).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
|
|
|
|
polyline.setAttribute("stroke", "transparent");
|
|
|
|
polyline.setAttribute("fill", "none");
|
2018-09-30 23:29:16 +09:00
|
|
|
|
|
|
|
// Create the popup ourselves so that we can bind it to the polyline
|
|
|
|
// instead of to the entire container (which is the default).
|
|
|
|
this._createPopup(this.container, polyline, data);
|
|
|
|
|
|
|
|
svg.appendChild(polyline);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.container.append(svg);
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class HighlightAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-08-27 07:24:27 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
2016-01-01 23:31:46 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the highlight annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof HighlightAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "highlightAnnotation";
|
2016-01-01 23:31:46 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (!this.data.hasPopup) {
|
|
|
|
this._createPopup(this.container, null, this.data);
|
|
|
|
}
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
2016-01-01 23:31:46 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class UnderlineAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-08-27 07:24:27 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
2015-12-28 08:33:41 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the underline annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof UnderlineAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "underlineAnnotation";
|
2015-12-28 08:33:41 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (!this.data.hasPopup) {
|
|
|
|
this._createPopup(this.container, null, this.data);
|
|
|
|
}
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
2015-12-28 08:33:41 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class SquigglyAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-08-27 07:24:27 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
2015-12-30 23:28:26 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the squiggly annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof SquigglyAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "squigglyAnnotation";
|
2015-12-30 23:28:26 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (!this.data.hasPopup) {
|
|
|
|
this._createPopup(this.container, null, this.data);
|
|
|
|
}
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
2015-12-30 23:28:26 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class StrikeOutAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-08-27 07:24:27 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
2015-12-29 23:09:28 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the strikeout annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof StrikeOutAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "strikeoutAnnotation";
|
2015-12-29 23:09:28 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
if (!this.data.hasPopup) {
|
|
|
|
this._createPopup(this.container, null, this.data);
|
|
|
|
}
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
2015-12-29 23:09:28 +09:00
|
|
|
|
2017-09-16 23:37:50 +09:00
|
|
|
class StampAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const isRenderable = !!(
|
|
|
|
parameters.data.hasPopup ||
|
|
|
|
parameters.data.title ||
|
|
|
|
parameters.data.contents
|
|
|
|
);
|
2017-09-16 23:37:50 +09:00
|
|
|
super(parameters, isRenderable, /* ignoreBorder = */ true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the stamp annotation's HTML element in the empty container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof StampAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "stampAnnotation";
|
2017-09-16 23:37:50 +09:00
|
|
|
|
|
|
|
if (!this.data.hasPopup) {
|
|
|
|
this._createPopup(this.container, null, this.data);
|
|
|
|
}
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class FileAttachmentAnnotationElement extends AnnotationElement {
|
|
|
|
constructor(parameters) {
|
2017-08-31 15:18:53 +09:00
|
|
|
super(parameters, /* isRenderable = */ true);
|
2016-02-15 04:44:00 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const { filename, content } = this.data.file;
|
2018-10-01 18:55:25 +09:00
|
|
|
this.filename = getFilenameFromUrl(filename);
|
|
|
|
this.content = content;
|
|
|
|
|
|
|
|
if (this.linkService.eventBus) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.linkService.eventBus.dispatch("fileattachmentannotation", {
|
2018-10-01 18:55:25 +09:00
|
|
|
source: this,
|
|
|
|
id: stringToPDFString(filename),
|
|
|
|
filename,
|
|
|
|
content,
|
|
|
|
});
|
|
|
|
}
|
2016-02-15 04:44:00 +09:00
|
|
|
}
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
/**
|
|
|
|
* Render the file attachment annotation's HTML element in the empty
|
|
|
|
* container.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @memberof FileAttachmentAnnotationElement
|
|
|
|
* @returns {HTMLSectionElement}
|
|
|
|
*/
|
|
|
|
render() {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.container.className = "fileAttachmentAnnotation";
|
2016-02-15 04:44:00 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const trigger = document.createElement("div");
|
2017-08-27 07:24:27 +09:00
|
|
|
trigger.style.height = this.container.style.height;
|
|
|
|
trigger.style.width = this.container.style.width;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
trigger.addEventListener("dblclick", this._download.bind(this));
|
2017-08-27 07:24:27 +09:00
|
|
|
|
|
|
|
if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
|
|
|
|
this._createPopup(this.container, trigger, this.data);
|
|
|
|
}
|
2016-02-15 04:44:00 +09:00
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
this.container.appendChild(trigger);
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Download the file attachment associated with this annotation.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @memberof FileAttachmentAnnotationElement
|
|
|
|
*/
|
|
|
|
_download() {
|
|
|
|
if (!this.downloadManager) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
warn("Download cannot be started due to unavailable download manager");
|
2017-08-27 07:24:27 +09:00
|
|
|
return;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.downloadManager.downloadData(this.content, this.filename, "");
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
}
|
2016-02-15 04:44:00 +09:00
|
|
|
|
2015-12-17 23:55:11 +09:00
|
|
|
/**
|
|
|
|
* @typedef {Object} AnnotationLayerParameters
|
|
|
|
* @property {PageViewport} viewport
|
|
|
|
* @property {HTMLDivElement} div
|
|
|
|
* @property {Array} annotations
|
|
|
|
* @property {PDFPage} page
|
|
|
|
* @property {IPDFLinkService} linkService
|
2018-02-13 21:17:11 +09:00
|
|
|
* @property {DownloadManager} downloadManager
|
2019-10-12 23:30:32 +09:00
|
|
|
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
|
|
|
* for annotation icons. Include trailing slash.
|
2016-09-07 05:26:57 +09:00
|
|
|
* @property {boolean} renderInteractiveForms
|
2015-12-17 23:55:11 +09:00
|
|
|
*/
|
|
|
|
|
2017-08-27 07:24:27 +09:00
|
|
|
class AnnotationLayer {
|
|
|
|
/**
|
|
|
|
* Render a new annotation layer with all annotation elements.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @param {AnnotationLayerParameters} parameters
|
|
|
|
* @memberof AnnotationLayer
|
|
|
|
*/
|
|
|
|
static render(parameters) {
|
2020-01-26 00:53:34 +09:00
|
|
|
const sortedAnnotations = [],
|
|
|
|
popupAnnotations = [];
|
|
|
|
// Ensure that Popup annotations are handled last, since they're dependant
|
|
|
|
// upon the parent annotation having already been rendered (please refer to
|
|
|
|
// the `PopupAnnotationElement.render` method); fixes issue 11362.
|
2019-08-31 23:40:39 +09:00
|
|
|
for (const data of parameters.annotations) {
|
2017-08-27 07:24:27 +09:00
|
|
|
if (!data) {
|
|
|
|
continue;
|
2015-12-17 23:55:11 +09:00
|
|
|
}
|
2020-01-26 00:53:34 +09:00
|
|
|
if (data.annotationType === AnnotationType.POPUP) {
|
|
|
|
popupAnnotations.push(data);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sortedAnnotations.push(data);
|
|
|
|
}
|
|
|
|
if (popupAnnotations.length) {
|
|
|
|
sortedAnnotations.push(...popupAnnotations);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const data of sortedAnnotations) {
|
2019-08-31 23:40:39 +09:00
|
|
|
const element = AnnotationElementFactory.create({
|
2017-08-27 07:24:27 +09:00
|
|
|
data,
|
|
|
|
layer: parameters.div,
|
|
|
|
page: parameters.page,
|
|
|
|
viewport: parameters.viewport,
|
|
|
|
linkService: parameters.linkService,
|
|
|
|
downloadManager: parameters.downloadManager,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
imageResourcesPath: parameters.imageResourcesPath || "",
|
2020-08-22 20:58:33 +09:00
|
|
|
renderInteractiveForms:
|
|
|
|
typeof parameters.renderInteractiveForms === "boolean"
|
|
|
|
? parameters.renderInteractiveForms
|
|
|
|
: true,
|
2017-07-24 07:09:18 +09:00
|
|
|
svgFactory: new DOMSVGFactory(),
|
[api-minor] Fix the `AnnotationStorage` usage properly in the viewer/tests (PR 12107 and 12143 follow-up)
*The [api-minor] label probably ought to have been added to the original PR, given the changes to the `createAnnotationLayerBuilder` signature (if nothing else).*
This patch fixes the following things:
- Let the `AnnotationLayer.render` method create an `AnnotationStorage`-instance if none was provided, thus making the parameter *properly* optional. This not only fixes the reference tests, it also prevents issues when the viewer components are used.
- Stop exporting `AnnotationStorage` in the official API, i.e. the `src/pdf.js` file, since it's no longer necessary given the change above. Generally speaking, unless absolutely necessary we probably shouldn't export unused things in the API.
- Fix a number of JSDocs `typedef`s, in `src/display/` and `web/` code, to actually account for the new `annotationStorage` parameter.
- Update `web/interfaces.js` to account for the changes in `createAnnotationLayerBuilder`.
- Initialize the storage, in `AnnotationStorage`, using `Object.create(null)` rather than `{}` (which is the PDF.js default).
2020-07-31 23:13:26 +09:00
|
|
|
annotationStorage:
|
|
|
|
parameters.annotationStorage || new AnnotationStorage(),
|
2017-08-27 07:24:27 +09:00
|
|
|
});
|
|
|
|
if (element.isRenderable) {
|
|
|
|
parameters.div.appendChild(element.render());
|
2015-12-17 23:55:11 +09:00
|
|
|
}
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the annotation elements on existing annotation layer.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
* @param {AnnotationLayerParameters} parameters
|
|
|
|
* @memberof AnnotationLayer
|
|
|
|
*/
|
|
|
|
static update(parameters) {
|
2019-08-31 23:40:39 +09:00
|
|
|
for (const data of parameters.annotations) {
|
|
|
|
const element = parameters.div.querySelector(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
`[data-annotation-id="${data.id}"]`
|
|
|
|
);
|
2017-08-27 07:24:27 +09:00
|
|
|
if (element) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
element.style.transform = `matrix(${parameters.viewport.transform.join(
|
|
|
|
","
|
|
|
|
)})`;
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
parameters.div.removeAttribute("hidden");
|
2017-08-27 07:24:27 +09:00
|
|
|
}
|
|
|
|
}
|
2015-12-17 23:55:11 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
export { AnnotationLayer };
|