@samuelbradshaw/highlight-helper-js 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,18 +17,18 @@ jobs:
17
17
  - name: Update package.json
18
18
  run: npm version "${{ steps.get_version.outputs.RELEASE_VERSION }}" --no-git-tag-version
19
19
  - name: Commit package.json changes
20
- uses: stefanzweifel/git-auto-commit-action@v6
20
+ uses: stefanzweifel/git-auto-commit-action@v7
21
21
  with:
22
22
  commit_message: "Update package.json version to ${{ steps.get_version.outputs.RELEASE_VERSION }}"
23
23
  branch: main
24
24
  - name: Set up Node.js
25
- uses: actions/setup-node@v4
25
+ uses: actions/setup-node@v6
26
26
  with:
27
- node-version: '20.x'
27
+ node-version: '24.x'
28
28
  registry-url: 'https://registry.npmjs.org'
29
29
  - name: Install dependencies
30
30
  run: npm ci
31
+ - name: Build
32
+ run: npm run build --if-present
31
33
  - name: Push to npmjs
32
34
  run: npm publish --provenance --access public
33
- env:
34
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
- # Highlight Helper
1
+ # HighlightHelper.js
2
2
 
3
- **Highlight Helper** is a JavaScript tool that enables highlighting or underlining text in an HTML page (such as a digital book or article). Highlighting text in an HTML document can be difficult, especially in cases where a highlight starts in one element but ends in another.
3
+ **HighlightHelper.js** is a JavaScript tool that enables highlighting or underlining text in an HTML page (such as a digital book or article). Highlighting text in an HTML document can be difficult, especially in cases where a highlight starts in one element but ends in another.
4
4
 
5
- Behind the scenes, Highlight Helper supports three different mechanisms for drawing highlights:
5
+ Behind the scenes, HighlightHelper.js supports three different mechanisms for drawing highlights:
6
6
 
7
7
  1. [SVG shapes](https://developer.mozilla.org/en-US/docs/Web/SVG) drawn behind text (default).
8
8
  2. The [CSS Custom Highlight API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API) (experimental*).
9
9
  3. Inserted [HTML mark elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/mark).
10
10
 
11
- An HTML demo page that shows basic functionality can be found here: [Highlight Helper Demo](https://samuelbradshaw.github.io/highlight-helper-js/demo.html). Source code for the demo is in **demo.html**. Highlight Helper itself is in **highlight-helper.js**.
11
+ An HTML demo page that shows basic functionality can be found here: [HighlightHelper.js Demo](https://samuelbradshaw.github.io/highlight-helper-js/demo.html). Source code for the demo is in **demo.html**. HighlightHelper.js itself is in **highlight-helper.js**.
12
12
 
13
- *The Custom Highlight API requires Safari 17.2+ or Chrome 105+, and may hang when rendering a large number of highlights. Additionally, only a few CSS styles are supported (see [Styling Highlights](https://www.w3.org/TR/css-pseudo-4/#highlight-styling)). Browser support and loading speed will hopefully improve in the future. See also the [load test page](https://samuelbradshaw.github.io/highlight-helper-js/test-load.html) for Highlight Helper.
13
+ *The Custom Highlight API requires Safari 17.2+ or Chrome 105+, and may hang when rendering a large number of highlights. Additionally, only a few CSS styles are supported (see [Styling Highlights](https://www.w3.org/TR/css-pseudo-4/#highlight-styling)). Browser support and loading speed will hopefully improve in the future. See also the [load test page](https://samuelbradshaw.github.io/highlight-helper-js/test-load.html) for HighlightHelper.js.
14
14
 
15
15
  ### Documentation:
16
16
  - [Known issues](#known-issues)
@@ -28,7 +28,7 @@ There are a few known issues:
28
28
 
29
29
  - **Chrome on Android** doesn’t set focus (and therefore doesn’t show text selection handles) when text is programmatically selected (such as from a disambiguation panel), unless the selection is initiated directly by a user’s tap. However, if you’re working in a native app with a webview, you may be able to focus the webview from Android (see [StackOverflow](https://stackoverflow.com/a/6372903/1349044) and [GitHub](https://github.com/lawlsausage/save_gfy/pull/1)).
30
30
  - **Safari on iOS** doesn’t respect the text selection color set via CSS, so when a highlight is active for editing it has a blue overlay. However, if you’re working in a native app with a webview, you may be able to set colors natively with [tintColor](https://stackoverflow.com/a/60510743/1349044), [highlightView](https://developer.apple.com/documentation/uikit/uitextselectiondisplayinteraction/4195471-highlightview), and/or [handleViews](https://developer.apple.com/documentation/uikit/uitextselectiondisplayinteraction/4195470-handleviews).
31
- - **Safari on iOS** loses focus and doesn’t send a `visibilitychange` event if the device screen locks after a period of inactivity. This can cause selection handles to not show when unlocking your device and tapping on an existing highlight. Going to another app and back or manually triggering a `visibilitychange` event will allow Highlight Helper to set focus again. Focus will also be set again if the user long-presses to select text.
31
+ - **Safari on iOS** loses focus and doesn’t send a `visibilitychange` event if the device screen locks after a period of inactivity. This can cause selection handles to not show when unlocking your device and tapping on an existing highlight. Going to another app and back or manually triggering a `visibilitychange` event will allow HighlightHelper.js to set focus again. Focus will also be set again if the user long-presses to select text.
32
32
  - **Safari on iOS and macOS** doesn’t allow setting underline thickness on a ::highlight() pseudo-element, so underline highlights drawn by the Custom Highlight API are thin and hard to see (see [StackOverflow](https://stackoverflow.com/q/79060854/1349044) and [WebKit Bugzilla](https://bugs.webkit.org/show_bug.cgi?id=282027)). This will hopefully be fixed in a future version of Safari.
33
33
 
34
34
 
@@ -40,36 +40,51 @@ In the source of demo.html, you’ll see CSS styles, followed by the HTML body,
40
40
  1. Links to highlight-helper.js,
41
41
  2. Initializes a “Highlighter” instance with options,
42
42
  3. Pre-loads and draws a few existing highlights,
43
- 3. Sets up logic to call Highlight Helper methods when buttons on the demo page are tapped, and
44
- 4. Sets up listeners to respond to custom event messages that come back from Highlight Helper.
43
+ 3. Sets up logic to call HighlightHelper.js methods when buttons on the demo page are tapped, and
44
+ 4. Sets up listeners to respond to custom event messages that come back from HighlightHelper.js.
45
45
 
46
46
 
47
47
  ### <a name="installation-options"></a>Installation options
48
48
 
49
- You can download highlight-helper.js from GitHub and reference it from your HTML file:
49
+ HighlightHelper.js is available as classic JavaScript (highlight-helper.js) or as a [JavaScript module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) (highlight-helper.mjs).
50
+
51
+ #### Classic JavaScript
52
+
53
+ Download highlight-helper.js from GitHub and reference it locally in your HTML file:
50
54
  ```html
51
55
  <script src="scripts/highlight-helper.js"></script>
52
56
  ```
53
57
 
54
- Or you can load it from [jsDelivr](https://www.jsdelivr.com/package/gh/samuelbradshaw/highlight-helper-js):
58
+ Or load it from [jsDelivr](https://www.jsdelivr.com/package/gh/samuelbradshaw/highlight-helper-js) CDN:
55
59
  ```html
56
60
  <script src="https://cdn.jsdelivr.net/gh/samuelbradshaw/highlight-helper-js@main/highlight-helper.min.js"></script>
57
61
  ```
58
62
 
59
- Or you can install it using [npm](https://www.npmjs.com/package/@samuelbradshaw/highlight-helper-js):
63
+ #### JavaScript Module
64
+
65
+ Download highlight-helper.js and highlight-helper.mjs from GitHub and import as a JavaScript module:
66
+ ```javascript
67
+ import { Highlighter } from './highlight-helper.mjs';
68
+ ```
69
+
70
+ Or load it from [jsDelivr](https://www.jsdelivr.com/package/gh/samuelbradshaw/highlight-helper-js) CDN:
71
+ ```javascript
72
+ import { Highlighter } from 'https://cdn.jsdelivr.net/gh/samuelbradshaw/highlight-helper-js@main/highlight-helper.min.mjs';
73
+ ```
74
+
75
+ You can also install it using [npm](https://www.npmjs.com/package/@samuelbradshaw/highlight-helper-js):
60
76
  ```bash
61
77
  % cd /your/project/folder
62
78
  % npm i @samuelbradshaw/highlight-helper-js
63
79
  ```
64
80
 
65
-
66
81
  ## <a name="methods-options-and-custom-events"></a>Methods, options, and custom events
67
82
 
68
83
  ### <a name="methods"></a>Methods
69
84
 
70
- - **loadHighlights(highlights)** – Load an array of existing highlights into Highlight Helper. Each highlight should have one or more of the properties described under “Highlight attributes” below. Omitted or invalid properties will fall back to previous or default values. If highlights are already loaded, this method will replace the loaded highlights by diffing for changes, then adding, removing, or updating individual highlights as needed.
85
+ - **loadHighlights(highlights)** – Load an array of existing highlights into HighlightHelper.js. Each highlight should have one or more of the properties described under “Highlight attributes” below. Omitted or invalid properties will fall back to previous or default values. If highlights are already loaded, this method will replace the loaded highlights by diffing for changes, then adding, removing, or updating individual highlights as needed.
71
86
  - **createOrUpdateHighlight(attributes, triggeredByUserAction)** – Create or update an individual highlight. `attributes` is an object with one or more of the properties described under “Highlight attributes” below. If a highlight ID isn’t passed in, the currently-active highlight will be updated, if there is one, otherwise a new highlight will be created. If it’s a new highlight and start and end bounds aren’t passed in, the highlight will be created based on selected text. `triggeredByUserAction` is an optional boolean (default: `true`). If this is set to false, the highlight won’t be activated after editing, and the color and style won’t be saved as the default for the next highlight.
72
- - **drawHighlights(highlightIds)** – Draw or redraw highlights on the page, given an array of highlight IDs. If no highlight IDs are passed, all highlights will be drawn. This shouldn’t need to be called frequently (Highlight Helper will usually draw or redraw highlights automatically).
87
+ - **drawHighlights(highlightIds)** – Draw or redraw highlights on the page, given an array of highlight IDs. If no highlight IDs are passed, all highlights will be drawn. This shouldn’t need to be called frequently (HighlightHelper.js will usually draw or redraw highlights automatically).
73
88
  - **activateHighlight(highlightId)** – Activate a highlight for editing, given its `highlightId`. Only one highlight can be active at a time (because it’s tied to text selection, and there can only be one text selection on a page). Normally, a highlight activates automatically when the user taps it; however, if there are overlapping highlights or if `autoTapToActivate` is set to `false`, this will need to be called manually.
74
89
  - **activateHyperlink(position)** – Activate the specified hyperlink (i.e. open the link). `position` is the 0-based position of the link in the annotatable area of the page, relative to other links. Normally, a link opens automatically when the user taps it; however, if a highlight overlaps the hyperlink or if `autoTapToActivate` is set to `false`, this will need to be called manually.
75
90
  - **deactivateHighlights()** – Clear the text selection and deactivate any active highlights. Normally, highlights are deactivated automatically when the user taps away.
@@ -83,24 +98,24 @@ Or you can install it using [npm](https://www.npmjs.com/package/@samuelbradshaw/
83
98
 
84
99
  ### <a name="options"></a>Options
85
100
 
86
- Options can be provided when Highlight Helper is initialized. They can also be set on demand using `setOption(key, value)` (described above). All of these settings are optional. If not specified, the default value for each option will be used.
101
+ Options can be provided when HighlightHelper.js is initialized. They can also be set on demand using `setOption(key, value)` (described above). All of these settings are optional. If not specified, the default value for each option will be used.
87
102
 
88
103
  - **containerSelector** – CSS selector for the section of the page that should be annotatable. Default: `body`.
89
104
  - **paragraphSelector** – CSS selector for the paragraphs (or other block elements) on the page that should be annotatable. Each paragraph is expected to have an ID attribute in the HTML, which is used to keep track of where a highlight starts and ends. Default: `h1[id], h2[id], h3[id], h4[id], h5[id], h6[id], p[id], ol[id], ul[id], dl[id], tr[id]`.
90
105
  - **colors** – Object that describes available highlight colors. Keys are color names, and values are [CSS color values](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). Default: red, orange, yellow, green, blue (see full default values at the bottom of highlight-helper.js).
91
106
  - **styles** – Object that describes available highlight styles. Keys are style names, and there are four properties for each style: `css`, `svg`, `css-active` (optional), and `svg-active` (optional). `css` is a CSS string used for styling highlights in `highlight-api` and `mark-elements` drawing modes, as well as for read-only highlights. `svg` is an SVG string (one or more SVG shapes) to represent the highlight in `svg` drawing mode. `css-active` and `svg-active` are alternative styles to be used when a highlight is active. The CSS custom property `var(--hh-color)` can be used to reference the highlight color value. For SVG highlights, the following variables (if present) will be replaced with relevant values from the highlight’s DOMRect: `{x}`, `{y}`, `{width}`, `{height}`, `{top}`, `{bottom}`, `{left}`, `{right}`. Default: fill, single-underline, double-underline, colored-text, redacted (see full default values at the bottom of highlight-helper.js).
92
- - **wrappers** – Object that describes available highlight wrappers. Keys are wrapper names, and values are objects with two optional properties: `start` (HTML string to be inserted at the beginning of the highlight), and `end` (HTML string to be inserted at the end of the highlight). Only read-only highlights support wrappers. To avoid problems when calculating ranges and offsets, all [text nodes](https://developer.mozilla.org/en-US/docs/Web/API/Text) in the start and end wrappers will be removed (if text is needed, it should be rendered with CSS). `var(--hh-color)` can be used to reference the highlight color value. Variables surrounded by curly brackets will be replaced with variables stored in the `wrapperVariables` attribute of the highlight, if applicable. See default values at the bottom of highlight-helper.js.
107
+ - **wrappers** – Object that describes available highlight wrappers. Keys are wrapper names, and values are objects with two optional properties: `start` (HTML string to be inserted at the beginning of the highlight), and `end` (HTML string to be inserted at the end of the highlight). Only read-only highlights support wrappers. `var(--hh-color)` can be used to reference the highlight color value. Variables surrounded by curly brackets will be replaced with variables stored in the `wrapperVariables` attribute of the highlight, if applicable. See default values at the bottom of highlight-helper.js.
93
108
  - **selectionHandles** – Object that describes custom selection handles that a user can drag to resize a selection or highlight. Because most touch devices have built-in selection handles, custom selection handles will only show when using a mouse or trackpad. There are two properties: `left` (HTML string to be used for the left selection handle) and `right` (HTML string to be used for the right selection handle). `var(--hh-color)` can be used to reference the highlight color value. See default values at the bottom of highlight-helper.js.
94
109
  - **rememberStyle** – Whether the most recent color, style, and wrapper should be remembered and used by default the next time the user creates a highlight. Boolean. Default: `true`.
95
110
  - **snapToWord** – Whether highlights should snap to the nearest word boundary. Spaces and dashes are considered word boundaries (this option may not work correctly in all languages). Boolean. Default: `false`.
96
- - **autoTapToActivate** – Whether Highlight Helper should automatically activate highlights and hyperlinks when they’re tapped. If set to false, you’ll need to listen for the `hh:tap` event and call `activateHighlight()` or `activateHyperlink()` manually when needed. Boolean. Default: `true`.
97
- - **longPressTimeout** – Duration in milliseconds before a tap turns into a long-press. On long-press, Highlight Helper will send an `hh:tap` event with `isLongPress: true`. If this option is set to 0, Highlight Helper will treat long-presses the same as regular taps, sending the `hh:tap` event after the user lifts their finger. If you have access to system APIs (such as in a mobile app), you may be able to get the system long-press duration to use for this value (which may vary based on accessibility settings). For example, Android has a [getLongPressTimeout()](https://developer.android.com/reference/kotlin/android/view/ViewConfiguration#getlongpresstimeout) method and iOS has a [minimumPressDuration](https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer/minimumpressduration) property. Default: `500`.
111
+ - **autoTapToActivate** – Whether HighlightHelper.js should automatically activate highlights and hyperlinks when they’re tapped. If set to false, you’ll need to listen for the `hh:tap` event and call `activateHighlight()` or `activateHyperlink()` manually when needed. Boolean. Default: `true`.
112
+ - **longPressTimeout** – Duration in milliseconds before a tap turns into a long-press. On long-press, HighlightHelper.js will send an `hh:tap` event with `isLongPress: true`. If this option is set to 0, HighlightHelper.js will treat long-presses the same as regular taps, sending the `hh:tap` event after the user lifts their finger. If you have access to system APIs (such as in a mobile app), you may be able to get the system long-press duration to use for this value (which may vary based on accessibility settings). For example, Android has a [getLongPressTimeout()](https://developer.android.com/reference/kotlin/android/view/ViewConfiguration#getlongpresstimeout) method and iOS has a [minimumPressDuration](https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer/minimumpressduration) property. Default: `500`.
98
113
  - **pointerMode** – Mode for responding to pointer events. Options are `simple` (create highlights by selecting text, then tapping a color or style); `live` (create highlights immediately when selecting text, without needing to tap a button); and `auto` (`simple` for touch and mouse input, but `live` when a stylus or Apple Pencil is detected). Default: `auto`.
99
114
  - **drawingMode** – Mode for drawing highlights on the page. Options are `svg` (SVG shapes), `highlight-api` (Custom Highlight API), and `mark-elements` (inserted HTML mark elements). For faster performance, read-only highlights will always be drawn as mark elements, even if a different drawing mode is set. Default: `svg`.
100
115
  - **defaultColor** – Key of the default highlight color. Default: `yellow`.
101
116
  - **defaultStyle** – Key of the default highlight style. Default: `fill`.
102
117
  - **defaultWrapper** – Key of the default highlight wrapper. Default: `none`.
103
- - **highlightIdFunction** – Identifier of a function that provides unique IDs for new highlights. Default: `hhGetNewHighlightId`.
118
+ - **highlightIdFunction** – Identifier of a function that provides unique IDs for new highlights. Default: `_getNewHighlightId`.
104
119
  - **showCustomSelectionHandlesForActiveHighlights** – Whether custom selection handles should show for active highlights. Default: `true`.
105
120
  - **showCustomSelectionHandlesForTextSelection** – Whether custom selection handles should show for text selection. Default: `false`.
106
121
  - **showCustomSelectionHandlesOnTouch** – Whether custom selection handles should show on touch devices. Default: `false`.
@@ -108,7 +123,7 @@ Options can be provided when Highlight Helper is initialized. They can also be s
108
123
 
109
124
  ### <a name="custom-events"></a>Custom events
110
125
 
111
- Highlight Helper sends [custom events](https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events) to the container element (defined in the `containerSelector` option) that can be listened for and responded to:
126
+ HighlightHelper.js sends [custom events](https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events) to the container element (defined in the `containerSelector` option) that can be listened for and responded to:
112
127
 
113
128
  - **hh:highlightsload** – Sent when an array of highlights loads. Includes the number of highlights added, removed, or updated, the total number of loaded highlights, and the time they took to load (in milliseconds).
114
129
  - **hh:highlightcreate** – Sent when a new highlight is created. Includes information about the highlight.
@@ -119,12 +134,12 @@ Highlight Helper sends [custom events](https://developer.mozilla.org/en-US/docs/
119
134
  - **hh:highlightactivate** – Sent when a highlight is activated. Includes information about the activated highlight.
120
135
  - **hh:highlightdeactivate** – Sent when a highlight is deactivated. Includes the ID of the deactivated highlight.
121
136
  - **hh:ambiguousaction** – Sent when a user taps on overlapping highlights or an overlapping highlight and link. Includes the location of the tap, the highlight(s) that were tapped, and the hyperlink(s) that were tapped. This event will not be sent if `autoTapToActivate` is set to `false`.
122
- - **selectionchange** – This is a [standard JavaScript event](https://developer.mozilla.org/en-US/docs/Web/API/Document/selectionchange_event) (not specific to Highlight Helper), but it’s worth mentioning here because it can be useful for adding custom selection UI around the selected text (such as a floating annotation menu). When this sends, you can call `window.getSelection()` to get the current [Selection object](https://developer.mozilla.org/en-US/docs/Web/API/Selection).
137
+ - **selectionchange** – This is a [standard JavaScript event](https://developer.mozilla.org/en-US/docs/Web/API/Document/selectionchange_event) (not specific to HighlightHelper.js), but it’s worth mentioning here because it can be useful for adding custom selection UI around the selected text (such as a floating annotation menu). When this sends, you can call `window.getSelection()` to get the current [Selection object](https://developer.mozilla.org/en-US/docs/Web/API/Selection).
123
138
 
124
139
 
125
140
  ## <a name="highlight-attributes"></a>Highlight attributes
126
141
 
127
- These are the attributes that Highlight Helper stores for each highlight. You can update a highlight by calling `createOrUpdateHighlight(attributes)`, where `attributes` is an object that includes the keys to be updated.
142
+ These are the attributes that HighlightHelper.js stores for each highlight. You can update a highlight by calling `createOrUpdateHighlight(attributes)`, where `attributes` is an object that includes the keys to be updated.
128
143
 
129
144
  - **highlightId** (read-only after creation) – The ID of the highlight.
130
145
  - **color** – The color of the highlight (key from the `colors` object in the initialized options). Example: `red`.
@@ -133,11 +148,13 @@ These are the attributes that Highlight Helper stores for each highlight. You ca
133
148
  - **wrapperVariables** – Variables used in wrappers. Example: `{ marker: 'a', }`.
134
149
  - **readOnly** – Whether the highlight should be read-only (prevents a user from changing its color, bounds, or other attributes). Boolean. Example: `true`.
135
150
  - **startParagraphId** – ID of the paragraph where the highlight starts. Example: `p1`.
136
- - **startParagraphOffset** – Character offset where the highlight starts, relative to the beginning of the paragraph. Example: 12.
151
+ - **startParagraphOffset** – Character offset where the highlight starts, relative to the beginning of the paragraph.* Example: 12.
137
152
  - **endParagraphId** – ID of the paragraph where the highlight ends. Example: `p1`.
138
- - **endParagraphOffset** – Character offset where the highlight ends, relative to the beginning of the paragraph. Example: 14.
139
- - **escapedHighlightId** (read-only) – Escaped highlight ID used as a CSS identifier (this is used internally by Highlight Helper).
153
+ - **endParagraphOffset** – Character offset where the highlight ends, relative to the beginning of the paragraph.* Example: 14.
154
+ - **escapedHighlightId** (read-only) – Escaped highlight ID used as a CSS identifier (this is used internally by HighlightHelper.js).
140
155
  - **rangeText** (read-only) – Text content in the highlighted range.
141
156
  - **rangeHtml** (read-only) – HTML content in the highlighted range.
142
157
  - **rangeParagraphIds** (read-only) – IDs of paragraphs in the highlighted range.
143
158
  - **rangeObj** (read-only) – The [Range](https://developer.mozilla.org/en-US/docs/Web/API/Range) object that represents where the highlight is drawn.
159
+
160
+ *If you have dynamic elements that need to be inserted into an annotatable paragraph temporarily, you can mark them with the `data-hh-ignore` attribute. HighlightHelper.js will skip over elements with this attribute when calculating character offsets and drawing highlights.
package/demo.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <html lang="en" translate="no">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>Text Selection Demo</title>
5
+ <title>HighlightHelper.js Demo</title>
6
6
  <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
7
7
  <meta name="google" content="notranslate">
8
8
  <style>
@@ -25,7 +25,7 @@
25
25
  color: var(--text-color);
26
26
  line-height: 1.4;
27
27
  }
28
- img { width: 120px; height: 120px; float: right; }
28
+ img { width: 120px; float: right; }
29
29
  a { color: var(--gray-50); }
30
30
  button {
31
31
  cursor: pointer;
@@ -105,9 +105,9 @@
105
105
  </head>
106
106
  <body>
107
107
  <main>
108
- <h1 id="title1">Highlight Helper Demo</h1>
109
- <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/CMYK_color_model.svg/180px-CMYK_color_model.svg.png">
110
- <p id="p1"><b>Highlight Helper</b> enables highlighting or underlining text in an HTML page. Highlights are drawn via <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/SVG">SVG shapes</a>, the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API">Custom Highlight API</a>, or <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/mark">HTML mark elements</a>. Highlights can be drawn across multiple paragraphs or <b>inline <i>style</i></b> elements—they can even overlap!</p>
108
+ <h1 id="title1">HighlightHelper.js Demo</h1>
109
+ <img src="https://upload.wikimedia.org/wikipedia/commons/d/db/CMYK-color_model.png">
110
+ <p id="p1"><b>HighlightHelper.js</b> enables highlighting or underlining text in an HTML page. Highlights are drawn via <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/SVG">SVG shapes</a>, the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API">Custom Highlight API</a>, or <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/mark">HTML mark elements</a>. Highlights can be drawn across multiple paragraphs or <b>inline <i>style</i></b> elements—they can even overlap!</p>
111
111
  <p id="p2">Select text, then choose a color and style. Tap away when you’re done. Tap to activate it again for editing. Secondary elements like images (right) and Japanese ruby/furigana (below) are highlighted around.</p>
112
112
  <p id="p3">わたしニーファイは<ruby><rb>善</rb><rt>よ</rt></ruby>い<ruby><rb>両</rb><rt>りょう</rt></ruby><ruby><rb>親</rb><rt>しん</rt></ruby>から<ruby><rb>生</rb><rt>う</rt></ruby>まれたので,<ruby><rb>父</rb><rt>ちち</rt></ruby>が<ruby><rb>学</rb><rt>まな</rt></ruby>んだすべてのことの<ruby><rb>中</rb><rt>なか</rt></ruby>から<ruby><rb>幾</rb><rt>いく</rt></ruby>らかの<ruby><rb>教</rb><rt>おし</rt></ruby>えを<ruby><rb>受</rb><rt>う</rt></ruby>けた。</p>
113
113
  <p id="p4" style="direction: rtl;">فِي الْبَدْءِ خَلَقَ اللهُ السَّمَاوَاتِ وَالأَرْضَ. وَكَانَتِ الأَرْضُ خَرِبَةً وَخَالِيَةً، وَعَلَى وَجْهِ الْغَمْرِ ظُلْمَةٌ، وَرُوحُ اللهِ يَرِفُّ عَلَى وَجْهِ الْمِيَاهِ. وَقَالَ اللهُ: «لِيَكُنْ نُورٌ»، فَكَانَ نُورٌ.</p>
@@ -164,8 +164,11 @@
164
164
  <div id="disambiguation-buttons"></div>
165
165
  <button id="disambiguation-cancel">Cancel</button>
166
166
  </dialog>
167
+ <p>
168
+ ← <a href="https://github.com/samuelbradshaw/highlight-helper-js">Back to GitHub</a>
169
+ </p>
167
170
 
168
- <!-- Link to the Highlight Helper JavaScript file -->
171
+ <!-- Link to the HighlightHelper.js JavaScript file -->
169
172
  <script src="highlight-helper.js"></script>
170
173
  <script>
171
174
  // Example highlights
@@ -173,8 +176,8 @@
173
176
  {
174
177
  highlightId: 'hh-1729991847207',
175
178
  color: 'green', style: 'fill',
176
- startParagraphId: 'p1', startParagraphOffset: 25,
177
- endParagraphId: 'p1', endParagraphOffset: 57,
179
+ startParagraphId: 'p1', startParagraphOffset: 27,
180
+ endParagraphId: 'p1', endParagraphOffset: 59,
178
181
  },
179
182
  {
180
183
  highlightId: 'hh-1729991847300',
@@ -199,14 +202,14 @@
199
202
  {
200
203
  highlightId: 'hh-1735379727958',
201
204
  color: 'yellow', style: 'fill',
202
- startParagraphId: 'p1', startParagraphOffset: 246,
203
- endParagraphId: 'p1', endParagraphOffset: 259,
205
+ startParagraphId: 'p1', startParagraphOffset: 248,
206
+ endParagraphId: 'p1', endParagraphOffset: 261,
204
207
  },
205
208
  {
206
209
  highlightId: 'hh-1735379721523',
207
210
  color: 'red', style: 'fill',
208
- startParagraphId: 'p1', startParagraphOffset: 237,
209
- endParagraphId: 'p1', endParagraphOffset: 250,
211
+ startParagraphId: 'p1', startParagraphOffset: 239,
212
+ endParagraphId: 'p1', endParagraphOffset: 252,
210
213
  },
211
214
  {
212
215
  highlightId: 'hh-1735479727958',
@@ -226,7 +229,7 @@
226
229
  });
227
230
  highlighter.loadHighlights(highlights);
228
231
 
229
- // Call Highlight Helper methods when color, style, wrapper, or remove buttons on this demo page are tapped
232
+ // Call HighlightHelper.js methods when color, style, wrapper, or remove buttons on this demo page are tapped
230
233
  const colorButtons = document.getElementsByName('hh-color');
231
234
  for (const colorButton of colorButtons) {
232
235
  colorButton.addEventListener('click', () => { highlighter.createOrUpdateHighlight({ color: colorButton.value }); });
@@ -246,7 +249,7 @@
246
249
  if (event.key === 'Backspace') highlighter.removeHighlights([highlighter.getActiveHighlightId()]);
247
250
  }
248
251
 
249
- // Call Highlight Helper methods when options are changed
252
+ // Call HighlightHelper.js methods when options are changed
250
253
  const rememberStyleCheckbox = document.getElementById('hh-remember-style');
251
254
  const snapToWordCheckbox = document.getElementById('hh-snap-to-word');
252
255
  const pointerModeRadioButtons = document.getElementsByName('hh-pointer-mode');