ep_author_hover 11.0.26 → 11.0.27
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.
- package/ep.json +13 -8
- package/index.js +26 -9
- package/package.json +2 -2
- package/static/js/index.js +31 -25
- package/templates/settings.ejs +0 -6
package/ep.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"parts": [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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.
|
|
9
|
+
"version": "11.0.27",
|
|
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.
|
|
31
|
+
"ep_plugin_helpers": "^0.5.2"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/static/js/index.js
CHANGED
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|