ep_set_title_on_pad 0.7.5 → 0.7.7
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/handleMessage.js +4 -7
- package/index.js +31 -27
- package/package.json +2 -2
- package/templates/title.ejs +21 -5
package/handleMessage.js
CHANGED
|
@@ -8,13 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
const authorManager = require('ep_etherpad-lite/node/db/AuthorManager');
|
|
10
10
|
const padMessageHandler = require('ep_etherpad-lite/node/handler/PadMessageHandler');
|
|
11
|
-
const db = require('ep_etherpad-lite/node/db/DB')
|
|
11
|
+
const db = require('ep_etherpad-lite/node/db/DB');
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
db.
|
|
15
|
-
|
|
16
|
-
const saveRoomTitle = (padId, message) => {
|
|
17
|
-
db.set(`title:${padId}`, message);
|
|
13
|
+
const saveRoomTitle = async (padId, message) => {
|
|
14
|
+
await db.set(`title:${padId}`, message);
|
|
18
15
|
};
|
|
19
16
|
|
|
20
17
|
const sendToRoom = (message, msg) => {
|
|
@@ -66,7 +63,7 @@ exports.handleMessage = async (hookName, context, cb) => {
|
|
|
66
63
|
},
|
|
67
64
|
};
|
|
68
65
|
sendToRoom(message, msg);
|
|
69
|
-
saveRoomTitle(message.padId, message.message);
|
|
66
|
+
await saveRoomTitle(message.padId, message.message);
|
|
70
67
|
return null; // handled by plugin
|
|
71
68
|
}
|
|
72
69
|
};
|
package/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const db = require('ep_etherpad-lite/node/db/DB')
|
|
3
|
+
const db = require('ep_etherpad-lite/node/db/DB');
|
|
4
4
|
const padMessageHandler = require('ep_etherpad-lite/node/handler/PadMessageHandler');
|
|
5
5
|
const {padToggle} = require('ep_plugin_helpers/pad-toggle-server');
|
|
6
6
|
|
|
7
|
-
// Remove cache for this procedure
|
|
8
|
-
db.dbSettings.cache = 0;
|
|
9
|
-
|
|
10
7
|
// Parallel User Settings + Pad Wide Settings checkboxes for "Show Title".
|
|
11
8
|
// Helper owns the storage, broadcast, enforce, and i18n wiring. The pad
|
|
12
9
|
// creator can enforce the pad-wide value to lock the title bar visible (or
|
|
@@ -31,35 +28,42 @@ exports.eejsBlock_padSettings = titleToggle.eejsBlock_padSettings;
|
|
|
31
28
|
exports.clientVars = async (hookName, context) => {
|
|
32
29
|
const padId = context.pad.id;
|
|
33
30
|
// Fire the saved-title broadcast (legacy behavior — kept verbatim).
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
let value;
|
|
32
|
+
try {
|
|
33
|
+
value = await db.get(`title:${padId}`);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
console.error('ep_set_title_on_pad clientVars db.get failed:', err);
|
|
36
|
+
}
|
|
37
|
+
const msg = {
|
|
38
|
+
type: 'COLLABROOM',
|
|
39
|
+
data: {
|
|
40
|
+
type: 'CUSTOM',
|
|
41
|
+
payload: {
|
|
42
|
+
action: 'recieveTitleMessage',
|
|
43
|
+
padId,
|
|
44
|
+
message: value,
|
|
44
45
|
},
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
padMessageHandler.handleCustomObjectMessage(msg, false, () => {});
|
|
50
|
+
}, 100);
|
|
50
51
|
// Return the padToggle's clientVars contribution so the helper picks up
|
|
51
52
|
// pad-wide state on the client.
|
|
52
53
|
return await titleToggle.clientVars(hookName, context);
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
exports.exportFileName = (hook, padId
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
56
|
+
exports.exportFileName = async (hook, padId) => {
|
|
57
|
+
// ueberdb2 v6 is promise-only; the legacy db.get(key, cb) callback never
|
|
58
|
+
// fires, which previously hung the export pipeline when the export hook's
|
|
59
|
+
// callback was placed inside it.
|
|
60
|
+
try {
|
|
61
|
+
const value = await db.get(`title:${padId}`);
|
|
62
|
+
if (value) return value;
|
|
63
|
+
} catch (err) {
|
|
64
|
+
console.error('ep_set_title_on_pad exportFileName db.get failed:', err);
|
|
65
|
+
}
|
|
66
|
+
return padId;
|
|
63
67
|
};
|
|
64
68
|
|
|
65
69
|
exports.padRemove = async (hookName, {pad}) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ep_set_title_on_pad",
|
|
3
3
|
"description": "Set the title on a pad in Etherpad, also includes real time updates to the UI",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.7",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "johnyma22 (John McLear) <john@mclear.co.uk>",
|
|
7
7
|
"keywords": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://etherpad.org/"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"ep_plugin_helpers": "^0.
|
|
28
|
+
"ep_plugin_helpers": "^0.6.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"eslint": "^8.57.1",
|
package/templates/title.ejs
CHANGED
|
@@ -6,20 +6,30 @@
|
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
8
|
<style type="text/css">
|
|
9
|
+
/* Bar height kept tight so the body-level title doesn't eat enough of the
|
|
10
|
+
editor viewport to break etherpad's auto-scroll on Enter (the bar pushes
|
|
11
|
+
the iframe down without the editor's scroll calculation accounting for
|
|
12
|
+
it — see ep_set_title_on_pad CI history vs etherpad-lite #7611). */
|
|
9
13
|
#pad_title {
|
|
10
14
|
flex-direction: row;
|
|
11
15
|
align-items: center;
|
|
12
16
|
border-bottom: 1px solid #ccc;
|
|
13
17
|
margin: 0 !important;
|
|
14
|
-
padding:
|
|
18
|
+
padding: 0 10px;
|
|
19
|
+
height: 16px;
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
line-height: 15px;
|
|
15
22
|
}
|
|
16
23
|
#input_title{
|
|
17
24
|
display:none;
|
|
18
25
|
flex: 1 auto;
|
|
19
|
-
padding: 8px
|
|
26
|
+
padding: 0 8px !important;
|
|
27
|
+
height: 14px;
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
font-size: 11px;
|
|
20
30
|
}
|
|
21
31
|
#title{
|
|
22
|
-
line-height:
|
|
32
|
+
line-height: 15px;
|
|
23
33
|
max-width: calc(100% - 30px);
|
|
24
34
|
white-space: nowrap;
|
|
25
35
|
overflow: hidden;
|
|
@@ -29,18 +39,24 @@
|
|
|
29
39
|
text-decoration:none;
|
|
30
40
|
}
|
|
31
41
|
#title h1{
|
|
32
|
-
|
|
42
|
+
margin: 0;
|
|
43
|
+
padding: 0;
|
|
44
|
+
font-size: 11px;
|
|
45
|
+
line-height: 15px;
|
|
46
|
+
font-weight: 600;
|
|
33
47
|
}
|
|
34
48
|
#edit_title{
|
|
35
|
-
padding
|
|
49
|
+
padding: 0;
|
|
36
50
|
margin-left: 10px;
|
|
37
51
|
cursor:pointer;
|
|
38
52
|
display:none;
|
|
53
|
+
line-height: 15px;
|
|
39
54
|
}
|
|
40
55
|
#save_title{
|
|
41
56
|
display:none;
|
|
42
57
|
cursor:pointer;
|
|
43
58
|
margin-left:8px;
|
|
59
|
+
line-height: 15px;
|
|
44
60
|
}
|
|
45
61
|
#save_title button{
|
|
46
62
|
margin-right: 0 !important;
|