ep_table_of_contents 0.3.132 → 0.3.133
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.
|
@@ -26,7 +26,7 @@ jobs:
|
|
|
26
26
|
with:
|
|
27
27
|
repository: ether/etherpad-lite
|
|
28
28
|
path: etherpad-lite
|
|
29
|
-
- uses: pnpm/action-setup@
|
|
29
|
+
- uses: pnpm/action-setup@v6
|
|
30
30
|
name: Install pnpm
|
|
31
31
|
with:
|
|
32
32
|
version: 10
|
|
@@ -35,7 +35,7 @@ jobs:
|
|
|
35
35
|
shell: bash
|
|
36
36
|
run: |
|
|
37
37
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
38
|
-
- uses: actions/cache@
|
|
38
|
+
- uses: actions/cache@v5
|
|
39
39
|
name: Setup pnpm cache
|
|
40
40
|
with:
|
|
41
41
|
path: ${{ env.STORE_PATH }}
|
|
@@ -15,7 +15,7 @@ jobs:
|
|
|
15
15
|
uses: actions/checkout@v6
|
|
16
16
|
with:
|
|
17
17
|
repository: ether/etherpad-lite
|
|
18
|
-
- uses: pnpm/action-setup@
|
|
18
|
+
- uses: pnpm/action-setup@v6
|
|
19
19
|
name: Install pnpm
|
|
20
20
|
with:
|
|
21
21
|
version: 10
|
|
@@ -24,7 +24,7 @@ jobs:
|
|
|
24
24
|
shell: bash
|
|
25
25
|
run: |
|
|
26
26
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
27
|
-
- uses: actions/cache@
|
|
27
|
+
- uses: actions/cache@v5
|
|
28
28
|
name: Setup pnpm cache
|
|
29
29
|
with:
|
|
30
30
|
path: ${{ env.STORE_PATH }}
|
|
@@ -31,7 +31,7 @@ jobs:
|
|
|
31
31
|
uses: actions/checkout@v6
|
|
32
32
|
with:
|
|
33
33
|
repository: ether/etherpad-lite
|
|
34
|
-
- uses: pnpm/action-setup@
|
|
34
|
+
- uses: pnpm/action-setup@v6
|
|
35
35
|
name: Install pnpm
|
|
36
36
|
with:
|
|
37
37
|
version: 10
|
|
@@ -59,12 +59,20 @@ jobs:
|
|
|
59
59
|
[ "${NEW_COMMITS}" -gt 0 ] || exit 0
|
|
60
60
|
git config user.name 'github-actions[bot]'
|
|
61
61
|
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
|
62
|
-
pnpm i
|
|
62
|
+
pnpm i --frozen-lockfile
|
|
63
63
|
# `pnpm version patch` bumps package.json, makes a commit, and creates
|
|
64
64
|
# a `v<new-version>` tag. Capture the new tag name from package.json
|
|
65
65
|
# rather than parsing pnpm's output, which has historically varied.
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
# Bump the patch component directly with Node. pnpm/action-setup@v6
|
|
67
|
+
# sometimes installs pnpm 11 pre-releases even when version: 10.x is
|
|
68
|
+
# requested (pnpm/action-setup#225); those pre-releases either skip
|
|
69
|
+
# the git commit/tag or reject --no-git-tag-version as unknown.
|
|
70
|
+
# Doing the bump in Node sidesteps both failure modes.
|
|
71
|
+
NEW_VERSION=$(node -e "const fs=require('fs');const p=require('./package.json');const v=p.version.split('.');v[2]=String(Number(v[2])+1);p.version=v.join('.');fs.writeFileSync('./package.json',JSON.stringify(p,null,2)+'\n');console.log(p.version);")
|
|
72
|
+
NEW_TAG="v${NEW_VERSION}"
|
|
73
|
+
git add package.json
|
|
74
|
+
git commit -m "${NEW_TAG}"
|
|
75
|
+
git tag -a "${NEW_TAG}" -m "${NEW_TAG}"
|
|
68
76
|
# CRITICAL: use --atomic so the branch update and the tag update
|
|
69
77
|
# succeed (or fail) as a single transaction on the server. The old
|
|
70
78
|
# `git push --follow-tags` was non-atomic per ref: if a concurrent
|
package/README.md
CHANGED
|
@@ -25,6 +25,23 @@ If you want to have a button in the toolbar to toggle the TOC, add following sni
|
|
|
25
25
|
},
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
Install from the Etherpad admin UI (**Admin → Manage Plugins**,
|
|
31
|
+
search for `ep_table_of_contents` and click *Install*), or from the Etherpad
|
|
32
|
+
root directory:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
pnpm run plugins install ep_table_of_contents
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> ⚠️ Don't run `npm i` / `npm install` yourself from the Etherpad
|
|
39
|
+
> source tree — Etherpad tracks installed plugins through its own
|
|
40
|
+
> plugin-manager, and hand-editing `package.json` can leave the
|
|
41
|
+
> server unable to start.
|
|
42
|
+
|
|
43
|
+
After installing, restart Etherpad.
|
|
44
|
+
|
|
28
45
|
## License
|
|
29
46
|
Copyright 2014, John McLear
|
|
30
47
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ep_table_of_contents",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.133",
|
|
4
4
|
"description": "View a table of contents for your pad",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "John McLear",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"eslint": "^8.57.1",
|
|
30
|
-
"eslint-config-etherpad": "^4.0.
|
|
31
|
-
"typescript": "^6.0.
|
|
30
|
+
"eslint-config-etherpad": "^4.0.5",
|
|
31
|
+
"typescript": "^6.0.3"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"test": "node --test tests/*.test.js",
|
package/static/js/toc.js
CHANGED
|
@@ -159,11 +159,34 @@ const tableOfContents = {
|
|
|
159
159
|
$(`.tocItem[data-toc-index="${activeTocIndex}"]`).addClass('activeTOC');
|
|
160
160
|
},
|
|
161
161
|
|
|
162
|
+
// findTags() walks every heading and rebuilds the entire ToC DOM. On
|
|
163
|
+
// pads with hundreds of headings this blocked the main thread on
|
|
164
|
+
// every keystroke and produced the 1-char-per-second typing seen in
|
|
165
|
+
// #51. Debounce the expensive scan — still fast enough to feel
|
|
166
|
+
// responsive, but no longer fires per keystroke.
|
|
167
|
+
_findTagsTimer: null,
|
|
168
|
+
_findTagsPending: false,
|
|
169
|
+
scheduleFindTags: (rep) => {
|
|
170
|
+
if (tableOfContents._findTagsTimer != null) {
|
|
171
|
+
tableOfContents._findTagsPending = true;
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
tableOfContents._findTagsTimer = setTimeout(() => {
|
|
175
|
+
tableOfContents._findTagsTimer = null;
|
|
176
|
+
tableOfContents.findTags();
|
|
177
|
+
if (tableOfContents._findTagsPending) {
|
|
178
|
+
tableOfContents._findTagsPending = false;
|
|
179
|
+
tableOfContents.scheduleFindTags();
|
|
180
|
+
}
|
|
181
|
+
}, 300);
|
|
182
|
+
},
|
|
183
|
+
|
|
162
184
|
update: (rep) => {
|
|
163
185
|
if (rep) {
|
|
164
186
|
tableOfContents.showPosition(rep);
|
|
165
187
|
}
|
|
166
|
-
|
|
188
|
+
if (!$('#options-toc').is(':checked')) return;
|
|
189
|
+
tableOfContents.scheduleFindTags(rep);
|
|
167
190
|
},
|
|
168
191
|
|
|
169
192
|
scroll: (newY) => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert').strict;
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const tocPath = path.resolve(__dirname, '..', '..', '..', '..', 'static', 'js', 'toc.js');
|
|
8
|
+
|
|
9
|
+
describe(__filename, function () {
|
|
10
|
+
let src;
|
|
11
|
+
before(function () { src = fs.readFileSync(tocPath, 'utf8'); });
|
|
12
|
+
|
|
13
|
+
it('update() debounces findTags() via setTimeout (#51)', function () {
|
|
14
|
+
// findTags walks every heading and rebuilds the #tocItems list. On pads
|
|
15
|
+
// with hundreds of headings, firing it on every keystroke was the
|
|
16
|
+
// source of the 1-char-per-second typing seen in #51. The update path
|
|
17
|
+
// must now schedule findTags via setTimeout instead of calling it
|
|
18
|
+
// synchronously.
|
|
19
|
+
const updateBlock = src.match(/update:\s*\([^)]*\)\s*=>\s*\{[\s\S]*?\n\s*\},/);
|
|
20
|
+
assert(updateBlock, 'expected update() in tableOfContents');
|
|
21
|
+
assert(!/tableOfContents\.findTags\s*\(\s*\)/.test(updateBlock[0]),
|
|
22
|
+
'update() must not call findTags() synchronously on every edit');
|
|
23
|
+
assert(/scheduleFindTags|setTimeout/.test(updateBlock[0]),
|
|
24
|
+
'update() should defer the heading scan (via scheduleFindTags / setTimeout)');
|
|
25
|
+
// And the scheduler itself should actually use setTimeout.
|
|
26
|
+
assert(/scheduleFindTags[\s\S]*?setTimeout/.test(src),
|
|
27
|
+
'scheduleFindTags should wrap findTags() in setTimeout');
|
|
28
|
+
});
|
|
29
|
+
});
|