ep_author_hover 11.0.26 → 11.0.28

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.
@@ -29,7 +29,7 @@ jobs:
29
29
  - uses: actions/setup-node@v6
30
30
  name: Install Node.js
31
31
  with:
32
- node-version: 22
32
+ node-version: 25
33
33
  - uses: pnpm/action-setup@v6
34
34
  name: Install pnpm
35
35
  with:
@@ -19,7 +19,7 @@ jobs:
19
19
  - uses: actions/setup-node@v6
20
20
  name: Install Node.js
21
21
  with:
22
- node-version: 22
22
+ node-version: 25
23
23
  - uses: pnpm/action-setup@v6
24
24
  name: Install pnpm
25
25
  with:
@@ -23,7 +23,7 @@ jobs:
23
23
  # OIDC trusted publishing needs npm >= 11.5.1, which requires
24
24
  # Node >= 20.17.0. setup-node's `20` resolves to the latest
25
25
  # 20.x, which satisfies that.
26
- node-version: 20
26
+ node-version: 25
27
27
  registry-url: https://registry.npmjs.org/
28
28
  - name: Upgrade npm to >=11.5.1 (required for trusted publishing)
29
29
  run: npm install -g npm@latest
package/ep.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "parts": [
3
- {
4
- "name": "ep_author_hover",
5
- "hooks" : {
6
- "eejsBlock_mySettings": "ep_author_hover/index"
7
- },
8
- "client_hooks" : {
9
- "postAceInit":"ep_author_hover/static/js/index"
3
+ {
4
+ "name": "ep_author_hover",
5
+ "hooks": {
6
+ "loadSettings": "ep_author_hover/index",
7
+ "clientVars": "ep_author_hover/index",
8
+ "eejsBlock_mySettings": "ep_author_hover/index",
9
+ "eejsBlock_padSettings": "ep_author_hover/index"
10
+ },
11
+ "client_hooks": {
12
+ "postAceInit": "ep_author_hover/static/js/index",
13
+ "handleClientMessage_CLIENT_MESSAGE": "ep_author_hover/static/js/index:handleClientMessage_CLIENT_MESSAGE"
14
+ }
10
15
  }
11
- }]
16
+ ]
12
17
  }
package/index.js CHANGED
@@ -1,12 +1,29 @@
1
1
  'use strict';
2
2
 
3
- const {template} = require('ep_plugin_helpers');
4
- const settings = require('ep_etherpad-lite/node/utils/Settings');
5
-
6
- exports.eejsBlock_mySettings = template('ep_author_hover/templates/settings.ejs', {
7
- vars: () => ({
8
- checked: settings.ep_author_hover &&
9
- settings.ep_author_hover.disabledByDefault === true
10
- ? '' : 'checked',
11
- }),
3
+ const {padToggle} = require('ep_plugin_helpers/pad-toggle-server');
4
+
5
+ // Parallel User Settings + Pad Wide Settings checkboxes for "Show Author on
6
+ // Hover". Helper owns markup, storage, broadcast, enforce, and i18n wiring.
7
+ const authorHoverToggle = padToggle({
8
+ pluginName: 'ep_author_hover',
9
+ settingId: 'author-hover',
10
+ l10nId: 'ep_author_hover.showHoverLabel',
11
+ defaultLabel: 'Show Author on Hover',
12
+ defaultEnabled: true,
12
13
  });
14
+
15
+ // Older settings.json used `ep_author_hover.disabledByDefault: true` to flip
16
+ // the checkbox off. Translate to the helper's `defaultEnabled` so existing
17
+ // installs keep their current behavior after the conversion.
18
+ exports.loadSettings = async (hookName, args) => {
19
+ const ps = args && args.settings && args.settings.ep_author_hover;
20
+ if (ps && typeof ps.defaultEnabled !== 'boolean' &&
21
+ typeof ps.disabledByDefault === 'boolean') {
22
+ ps.defaultEnabled = !ps.disabledByDefault;
23
+ }
24
+ return authorHoverToggle.loadSettings(hookName, args);
25
+ };
26
+
27
+ exports.clientVars = authorHoverToggle.clientVars;
28
+ exports.eejsBlock_mySettings = authorHoverToggle.eejsBlock_mySettings;
29
+ exports.eejsBlock_padSettings = authorHoverToggle.eejsBlock_padSettings;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "ep_author_hover",
8
8
  "description": "Adds author names to span titles (shows on hover), works as authors change their name. Hover includes author color and fast switching between author spans. Hat tip to Martyn York for the initial work on this.",
9
- "version": "11.0.26",
9
+ "version": "11.0.28",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/ether/ep_author_hover.git"
@@ -28,6 +28,6 @@
28
28
  "node": ">=18.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "ep_plugin_helpers": "^0.5.0"
31
+ "ep_plugin_helpers": "^0.5.2"
32
32
  }
33
33
  }
@@ -1,19 +1,35 @@
1
1
  'use strict';
2
2
 
3
- const padcookie = require('ep_etherpad-lite/static/js/pad_cookie').padcookie;
4
- import html10n from 'ep_etherpad-lite/static/js/vendors/html10n'
3
+ // Sub-path import keeps the client bundle clean — the top-level
4
+ // `ep_plugin_helpers` index pulls in server-only modules.
5
+ const {padToggle} = require('ep_plugin_helpers/pad-toggle');
6
+ import html10n from 'ep_etherpad-lite/static/js/vendors/html10n';
7
+
8
+ // Same config as the server-side instance — must agree on pluginName,
9
+ // settingId, l10nId, and defaultLabel so checkbox ids and clientVars line up.
10
+ const authorHoverToggle = padToggle({
11
+ pluginName: 'ep_author_hover',
12
+ settingId: 'author-hover',
13
+ l10nId: 'ep_author_hover.showHoverLabel',
14
+ defaultLabel: 'Show Author on Hover',
15
+ defaultEnabled: true,
16
+ });
17
+
18
+ // Re-export so the helper sees pad-wide broadcasts and refreshes our state
19
+ // when another user toggles the pad-wide checkbox.
20
+ exports.handleClientMessage_CLIENT_MESSAGE = authorHoverToggle.handleClientMessage_CLIENT_MESSAGE;
5
21
 
6
22
  let timer = 0;
7
23
 
8
24
  const showAuthor = {
9
25
  enable: () => {
10
26
  $('iframe[name="ace_outer"]').contents().find('iframe')
11
- .contents().find('#innerdocbody').on('mousemove',exports.showAuthor.hover);
27
+ .contents().find('#innerdocbody').on('mousemove', exports.showAuthor.hover);
12
28
  },
13
29
  disable: (context) => {
14
30
  context.ace.callWithAce((ace) => {
15
31
  const doc = ace.ace_getDocument();
16
- $(doc).find('#innerdocbody').on('mousemove',null.bind(ace));
32
+ $(doc).find('#innerdocbody').on('mousemove', null.bind(ace));
17
33
  }, 'showAuthor', true);
18
34
  },
19
35
  hover: (span) => {
@@ -33,7 +49,7 @@ const showAuthor = {
33
49
  if (!authorId) { return; } // Default text isn't shown
34
50
  showAuthor.destroy(); // Destroy existing
35
51
  const authorNameAndColor =
36
- showAuthor.authorNameAndColorFromAuthorId(authorId); // Get the authorName And Color
52
+ showAuthor.authorNameAndColorFromAuthorId(authorId);
37
53
  showAuthor.draw(span, authorNameAndColor.name, authorNameAndColor.color);
38
54
  }
39
55
  },
@@ -133,27 +149,17 @@ const showAuthor = {
133
149
 
134
150
  exports.postAceInit = (hookName, context) => {
135
151
  showAuthor.enable(context);
136
- clientVars.plugins.plugins.ep_author_hover = {};
137
- /* init */
138
- if (padcookie.getPref('author-hover') === false) {
139
- $('#options-author-hover').val();
140
- $('#options-author-hover').prop('checked', false);
141
- $('#options-author-hover').prop('checked', false);
142
- } else {
143
- $('#options-author-hover').prop('checked', true);
152
+ // Pre-existing public API: showAuthor.show() reads
153
+ // clientVars.plugins.plugins.ep_author_hover.enabled on every hover. Keep
154
+ // the field populated as the toggle changes so external integrations
155
+ // (and our own show() code) see the live state without rewiring.
156
+ if (!clientVars.plugins.plugins.ep_author_hover) {
157
+ clientVars.plugins.plugins.ep_author_hover = {};
144
158
  }
145
-
146
- clientVars.plugins.plugins.ep_author_hover.enabled = !!$('#options-author-hover').is(':checked');
147
-
148
- /* on click */
149
- $('#options-author-hover').on('click', () => {
150
- if ($('#options-author-hover').is(':checked')) {
151
- clientVars.plugins.plugins.ep_author_hover.enabled = true;
152
- padcookie.setPref('author-hover', true);
153
- } else {
154
- padcookie.setPref('author-hover', false);
155
- clientVars.plugins.plugins.ep_author_hover.enabled = false;
156
- }
159
+ authorHoverToggle.init({
160
+ onChange: (enabled) => {
161
+ clientVars.plugins.plugins.ep_author_hover.enabled = enabled;
162
+ },
157
163
  });
158
164
  };
159
165
 
@@ -1,6 +0,0 @@
1
- <p>
2
- <input type="checkbox" id="options-author-hover" checked></input>
3
- <label for="options-author-hover" data-l10n-id="ep_author_hover.showHoverLabel">
4
- Show Author on Hover
5
- </label>
6
- </p>