ep_headings2 0.2.117 → 0.2.118
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/AGENTS.md +75 -0
- package/CONTRIBUTING.md +67 -126
- package/ep.json +1 -0
- package/package.json +2 -2
- package/static/js/shared.js +1 -0
- package/static/tests/backend/specs/exportHTML.ts +31 -0
- package/templates/editbarButtons.ejs +1 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Agent Guide — ep_headings2
|
|
2
|
+
|
|
3
|
+
Adds heading support to Etherpad Lite. Includes improved suppot for export, i18n etc.
|
|
4
|
+
|
|
5
|
+
## Tech stack
|
|
6
|
+
|
|
7
|
+
* Etherpad plugin framework (hooks declared in `ep.json`)
|
|
8
|
+
* EJS templates rendered server-side via `eejsBlock_*` hooks
|
|
9
|
+
* html10n for i18n (`locales/<lang>.json`, `data-l10n-id` in templates)
|
|
10
|
+
* `ep_plugin_helpers` for shared boilerplate
|
|
11
|
+
|
|
12
|
+
## Project structure
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
ep_headings2/
|
|
16
|
+
├── AGENTS.md
|
|
17
|
+
├── CONTRIBUTING.md
|
|
18
|
+
├── ep.json
|
|
19
|
+
├── index.js
|
|
20
|
+
├── locales/
|
|
21
|
+
│ ├── ar.json
|
|
22
|
+
│ ├── be-tarask.json
|
|
23
|
+
│ ├── bn.json
|
|
24
|
+
│ ├── ca.json
|
|
25
|
+
│ ├── cs.json
|
|
26
|
+
│ ├── cy.json
|
|
27
|
+
│ └── ...
|
|
28
|
+
├── package.json
|
|
29
|
+
├── static/
|
|
30
|
+
│ ├── css/
|
|
31
|
+
│ ├── js/
|
|
32
|
+
│ ├── tests/
|
|
33
|
+
├── templates/
|
|
34
|
+
│ ├── editbarButtons.ejs
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Helpers used
|
|
38
|
+
|
|
39
|
+
* `attributes` from `ep_plugin_helpers`
|
|
40
|
+
* `attributes-server` from `ep_plugin_helpers`
|
|
41
|
+
* `template` from `ep_plugin_helpers`
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Helpers NOT used
|
|
45
|
+
|
|
46
|
+
_To be audited in the helpers-adoption sweep (Phase 4)._
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## Running tests locally
|
|
50
|
+
|
|
51
|
+
`ep_headings2` runs inside Etherpad's test harness. From an etherpad checkout that has installed this plugin via `pnpm run plugins i --path ../ep_headings2`:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Backend (Mocha) — harness boots its own server
|
|
55
|
+
pnpm --filter ep_etherpad-lite run test
|
|
56
|
+
|
|
57
|
+
# Playwright — needs `pnpm run dev` in a second terminal
|
|
58
|
+
pnpm --filter ep_etherpad-lite run test-ui
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Standing rules for agent edits
|
|
62
|
+
|
|
63
|
+
* PRs target `main`. Linear commits, no merge commits.
|
|
64
|
+
* Every bug fix includes a regression test in the same commit.
|
|
65
|
+
* All user-facing strings in `locales/`. No hardcoded English in templates.
|
|
66
|
+
* No hardcoded `aria-label` on icon-only controls — etherpad's html10n auto-populates `aria-label` from the localized string when (a) the element has a `data-l10n-id` and (b) no author-supplied `aria-label` is present. Adding a hardcoded English `aria-label` blocks that and leaves it untranslated. (See `etherpad-lite/src/static/js/vendors/html10n.ts:665-678`.)
|
|
67
|
+
* No nested interactive elements (no `<button>` inside `<a>`).
|
|
68
|
+
* LLM/Agent contributions are explicitly welcomed by maintainers.
|
|
69
|
+
|
|
70
|
+
## Quick reference: hooks declared in `ep.json`
|
|
71
|
+
|
|
72
|
+
* Server: `eejsBlock_editbarMenuLeft`, `collectContentPre`, `collectContentPost`, `ccRegisterBlockElements`, `getLineHTMLForExport`, `stylesForExport`
|
|
73
|
+
* Client: `aceEditorCSS`, `aceEditEvent`, `aceDomLineProcessLineAttributes`, `postAceInit`, `aceInitialized`, `aceAttribsToClasses`, `collectContentPre`, `aceRegisterBlockElements`
|
|
74
|
+
|
|
75
|
+
When adding a hook, register it in both `ep.json` *and* the matching `exports.<hook> = ...` in the JS file.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,133 +1,74 @@
|
|
|
1
|
-
#
|
|
2
|
-
(Please talk to people on the mailing list before you change this page, see our section on [how to get in touch](https://github.com/ether/etherpad-lite#get-in-touch))
|
|
3
|
-
|
|
4
|
-
## Pull requests
|
|
5
|
-
|
|
6
|
-
* the commit series in the PR should be _linear_ (it **should not contain merge commits**). This is necessary because we want to be able to [bisect](https://en.wikipedia.org/wiki/Bisection_(software_engineering)) bugs easily. Rewrite history/perform a rebase if necessary
|
|
7
|
-
* PRs should be issued against the **develop** branch: we never pull directly into **master**
|
|
8
|
-
* PRs **should not have conflicts** with develop. If there are, please resolve them rebasing and force-pushing
|
|
9
|
-
* when preparing your PR, please make sure that you have included the relevant **changes to the documentation** (preferably with usage examples)
|
|
10
|
-
* contain meaningful and detailed **commit messages** in the form:
|
|
11
|
-
```
|
|
12
|
-
submodule: description
|
|
13
|
-
|
|
14
|
-
longer description of the change you have made, eventually mentioning the
|
|
15
|
-
number of the issue that is being fixed, in the form: Fixes #someIssueNumber
|
|
16
|
-
```
|
|
17
|
-
* if the PR is a **bug fix**:
|
|
18
|
-
* the first commit in the series must be a test that shows the failure
|
|
19
|
-
* subsequent commits will fix the bug and make the test pass
|
|
20
|
-
* the final commit message should include the text `Fixes: #xxx` to link it to its bug report
|
|
21
|
-
* think about stability: code has to be backwards compatible as much as possible. Always **assume your code will be run with an older version of the DB/config file**
|
|
22
|
-
* if you want to remove a feature, **deprecate it instead**:
|
|
23
|
-
* write an issue with your deprecation plan
|
|
24
|
-
* output a `WARN` in the log informing that the feature is going to be removed
|
|
25
|
-
* remove the feature in the next version
|
|
26
|
-
* if you want to add a new feature, put it under a **feature flag**:
|
|
27
|
-
* once the new feature has reached a minimal level of stability, do a PR for it, so it can be integrated early
|
|
28
|
-
* expose a mechanism for enabling/disabling the feature
|
|
29
|
-
* the new feature should be **disabled** by default. With the feature disabled, the code path should be exactly the same as before your contribution. This is a __necessary condition__ for early integration
|
|
30
|
-
* think of the PR not as something that __you wrote__, but as something that __someone else is going to read__. The commit series in the PR should tell a novice developer the story of your thoughts when developing it
|
|
31
|
-
|
|
32
|
-
## How to write a bug report
|
|
33
|
-
|
|
34
|
-
* Please be polite, we all are humans and problems can occur.
|
|
35
|
-
* Please add as much information as possible, for example
|
|
36
|
-
* client os(s) and version(s)
|
|
37
|
-
* browser(s) and version(s), is the problem reproducible on different clients
|
|
38
|
-
* special environments like firewalls or antivirus
|
|
39
|
-
* host os and version
|
|
40
|
-
* npm and nodejs version
|
|
41
|
-
* Logfiles if available
|
|
42
|
-
* steps to reproduce
|
|
43
|
-
* what you expected to happen
|
|
44
|
-
* what actually happened
|
|
45
|
-
* Please format logfiles and code examples with markdown see github Markdown help below the issue textarea for more information.
|
|
46
|
-
|
|
47
|
-
If you send logfiles, please set the loglevel switch DEBUG in your settings.json file:
|
|
1
|
+
# Contributing to ep_headings2
|
|
48
2
|
|
|
3
|
+
Thanks for helping improve `ep_headings2` — a plugin for [Etherpad](https://etherpad.org/). LLM/Agent contributions are explicitly welcome, provided they follow the rules below.
|
|
4
|
+
|
|
5
|
+
For shared rules that apply to all Etherpad code (linear commits, deprecation policy, feature flags, stability guarantees), please read [ether/etherpad's CONTRIBUTING.md](https://github.com/ether/etherpad/blob/develop/CONTRIBUTING.md). This document only covers what's specific to plugin work.
|
|
6
|
+
|
|
7
|
+
## Plugin-specific rules
|
|
8
|
+
|
|
9
|
+
* **Target branch:** PRs go to `main` on this repo. Plugin repos do not use git-flow's `develop` branch.
|
|
10
|
+
* **Linear commits, no merge commits.** Rebase if needed.
|
|
11
|
+
* **Every bug fix must include a regression test in the same commit.**
|
|
12
|
+
* **Internationalization (i18n):** every user-facing string lives in `locales/<lang>.json` and is referenced via `data-l10n-id` in templates or `html10n.get(key)` in code. No hardcoded English in markup.
|
|
13
|
+
* **Accessibility (a11y):** no nested interactive elements (no `<button>` inside `<a>`); every interactive control has an accessible name; keyboard focus order matches visual order. Note that on icon-only controls you should rely on Etherpad's html10n to populate `aria-label` from the `data-l10n-id` translation — adding a hardcoded English `aria-label` blocks that and leaves the control untranslated.
|
|
14
|
+
|
|
15
|
+
## Local development
|
|
16
|
+
|
|
17
|
+
`ep_headings2` is a plugin, so you develop it inside a checkout of [ether/etherpad](https://github.com/ether/etherpad).
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Once: clone etherpad alongside this repo
|
|
21
|
+
git clone https://github.com/ether/etherpad.git
|
|
22
|
+
cd etherpad
|
|
23
|
+
pnpm install
|
|
24
|
+
|
|
25
|
+
# Install ep_headings2 from your local clone
|
|
26
|
+
pnpm run plugins i --path ../ep_headings2
|
|
27
|
+
|
|
28
|
+
# Start the dev server (port 9001)
|
|
29
|
+
pnpm --filter ep_etherpad-lite run dev
|
|
49
30
|
```
|
|
50
|
-
|
|
51
|
-
|
|
31
|
+
|
|
32
|
+
Edits in `../ep_headings2/` are picked up after a server restart.
|
|
33
|
+
|
|
34
|
+
## Tests
|
|
35
|
+
|
|
36
|
+
Tests live inside this repo and are executed by Etherpad's test harness:
|
|
37
|
+
|
|
38
|
+
* Backend (Mocha): `static/tests/backend/specs/`
|
|
39
|
+
* Playwright (frontend E2E): `static/tests/frontend-new/specs/`
|
|
40
|
+
|
|
41
|
+
Run them from the etherpad checkout:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Backend (no separate server needed, harness boots one)
|
|
45
|
+
pnpm --filter ep_etherpad-lite run test
|
|
46
|
+
|
|
47
|
+
# Playwright (requires `pnpm run dev` in another terminal)
|
|
48
|
+
pnpm --filter ep_etherpad-lite run test-ui
|
|
52
49
|
```
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* easy to integrate into other apps, but also usable as standalone
|
|
60
|
-
* lightweight and scalable
|
|
61
|
-
* extensible, as much functionality should be extendable with plugins so changes don't have to be done in core.
|
|
62
|
-
Also, keep it maintainable. We don't wanna end up as the monster Etherpad was!
|
|
63
|
-
|
|
64
|
-
## How to work with git?
|
|
65
|
-
* Don't work in your master branch.
|
|
66
|
-
* Make a new branch for every feature you're working on. (This ensures that you can work you can do lots of small, independent pull requests instead of one big one with complete different features)
|
|
67
|
-
* Don't use the online edit function of github (this only creates ugly and not working commits!)
|
|
68
|
-
* Try to make clean commits that are easy readable (including descriptive commit messages!)
|
|
69
|
-
* Test before you push. Sounds easy, it isn't!
|
|
70
|
-
* Don't check in stuff that gets generated during build or runtime
|
|
71
|
-
* Make small pull requests that are easy to review but make sure they do add value by themselves / individually
|
|
51
|
+
Lint locally before pushing:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pnpm run lint
|
|
55
|
+
```
|
|
72
56
|
|
|
73
57
|
## Coding style
|
|
74
|
-
* Do write comments. (You don't have to comment every line, but if you come up with something that's a bit complex/weird, just leave a comment. Bear in mind that you will probably leave the project at some point and that other people will read your code. Undocumented huge amounts of code are worthless!)
|
|
75
|
-
* Never ever use tabs
|
|
76
|
-
* Indentation: JS/CSS: 2 spaces; HTML: 4 spaces
|
|
77
|
-
* Don't overengineer. Don't try to solve any possible problem in one step, but try to solve problems as easy as possible and improve the solution over time!
|
|
78
|
-
* Do generalize sooner or later! (if an old solution, quickly hacked together, poses more problems than it solves today, refactor it!)
|
|
79
|
-
* Keep it compatible. Do not introduce changes to the public API, db schema or configurations too lightly. Don't make incompatible changes without good reasons!
|
|
80
|
-
* If you do make changes, document them! (see below)
|
|
81
|
-
* Use protocol independent urls "//"
|
|
82
|
-
|
|
83
|
-
## Branching model / git workflow
|
|
84
|
-
see git flow http://nvie.com/posts/a-successful-git-branching-model/
|
|
85
|
-
|
|
86
|
-
### `master` branch
|
|
87
|
-
* the stable
|
|
88
|
-
* This is the branch everyone should use for production stuff
|
|
89
|
-
|
|
90
|
-
### `develop`branch
|
|
91
|
-
* everything that is READY to go into master at some point in time
|
|
92
|
-
* This stuff is tested and ready to go out
|
|
93
|
-
|
|
94
|
-
### release branches
|
|
95
|
-
* stuff that should go into master very soon
|
|
96
|
-
* only bugfixes go into these (see http://nvie.com/posts/a-successful-git-branching-model/ for why)
|
|
97
|
-
* we should not be blocking new features to develop, just because we feel that we should be releasing it to master soon. This is the situation that release branches solve/handle.
|
|
98
|
-
|
|
99
|
-
### hotfix branches
|
|
100
|
-
* fixes for bugs in master
|
|
101
|
-
|
|
102
|
-
### feature branches (in your own repos)
|
|
103
|
-
* these are the branches where you develop your features in
|
|
104
|
-
* If it's ready to go out, it will be merged into develop
|
|
105
|
-
|
|
106
|
-
Over the time we pull features from feature branches into the develop branch. Every month we pull from develop into master. Bugs in master get fixed in hotfix branches. These branches will get merged into master AND develop. There should never be commits in master that aren't in develop
|
|
107
|
-
|
|
108
|
-
## Documentation
|
|
109
|
-
The docs are in the `doc/` folder in the git repository, so people can easily find the suitable docs for the current git revision.
|
|
110
|
-
|
|
111
|
-
Documentation should be kept up-to-date. This means, whenever you add a new API method, add a new hook or change the database model, pack the relevant changes to the docs in the same pull request.
|
|
112
|
-
|
|
113
|
-
You can build the docs e.g. produce html, using `make docs`. At some point in the future we will provide an online documentation. The current documentation in the github wiki should always reflect the state of `master` (!), since there are no docs in master, yet.
|
|
114
|
-
|
|
115
|
-
## Testing
|
|
116
|
-
Front-end tests are found in the `tests/frontend/` folder in the repository. Run them by pointing your browser to `<yourdomainhere>/tests/frontend`.
|
|
117
|
-
|
|
118
|
-
Back-end tests can be run from the `src` directory, via `npm test`.
|
|
119
|
-
|
|
120
|
-
## Things you can help with
|
|
121
|
-
Etherpad is much more than software. So if you aren't a developer then worry not, there is still a LOT you can do! A big part of what we do is community engagement. You can help in the following ways
|
|
122
|
-
* Triage bugs (applying labels) and confirming their existence
|
|
123
|
-
* Testing fixes (simply applying them and seeing if it fixes your issue or not) - Some git experience required
|
|
124
|
-
* Notifying large site admins of new releases
|
|
125
|
-
* Writing Changelogs for releases
|
|
126
|
-
* Creating Windows packages
|
|
127
|
-
* Creating releases
|
|
128
|
-
* Bumping dependencies periodically and checking they don't break anything
|
|
129
|
-
* Write proposals for grants
|
|
130
|
-
* Co-Author and Publish CVEs
|
|
131
|
-
* Work with SFC to maintain legal side of project
|
|
132
|
-
* Maintain TODO page - https://github.com/ether/etherpad-lite/wiki/TODO#IMPORTANT_TODOS
|
|
133
58
|
|
|
59
|
+
* JS/CSS/HTML: 2 spaces, no tabs.
|
|
60
|
+
* `pnpm run lint` must pass (configured via `eslint-config-etherpad`).
|
|
61
|
+
* Avoid breaking changes to public hooks, the line-attribute storage shape, or HTML export output. The backend export spec enforces a stable shape.
|
|
62
|
+
|
|
63
|
+
## Bug reports
|
|
64
|
+
|
|
65
|
+
Please include:
|
|
66
|
+
|
|
67
|
+
* Etherpad version, ep_headings2 version, browser + OS
|
|
68
|
+
* Steps to reproduce
|
|
69
|
+
* What you expected, what actually happened
|
|
70
|
+
* Server log excerpt (set `"loglevel": "DEBUG"` in `settings.json` for verbose output)
|
|
71
|
+
|
|
72
|
+
## AI agents
|
|
73
|
+
|
|
74
|
+
If you are an LLM/agent contributor, also read [`AGENTS.md`](AGENTS.md) — it documents the file layout, helper usage, and standing rules for autonomous edits.
|
package/ep.json
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"eejsBlock_editbarMenuLeft": "ep_headings2/index",
|
|
17
17
|
"collectContentPre": "ep_headings2/static/js/shared",
|
|
18
18
|
"collectContentPost": "ep_headings2/static/js/shared",
|
|
19
|
+
"ccRegisterBlockElements": "ep_headings2/static/js/shared",
|
|
19
20
|
"getLineHTMLForExport": "ep_headings2/index",
|
|
20
21
|
"stylesForExport" : "ep_headings2/index"
|
|
21
22
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "Adds heading support to Etherpad Lite. Includes improved suppot for export, i18n etc.",
|
|
3
3
|
"name": "ep_headings2",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.118",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "John McLear",
|
|
7
7
|
"email": "john@mclear.co.uk"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"url": "https://github.com/ether/ep_headings2/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"ep_plugin_helpers": "^0.2
|
|
37
|
+
"ep_plugin_helpers": "^0.5.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"eslint": "^8.57.1",
|
package/static/js/shared.js
CHANGED
|
@@ -121,4 +121,35 @@ describe('ep_headings2 - export headings to HTML', function () {
|
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
|
+
|
|
125
|
+
context('when pad has adjacent <h1> and <h2> with no separator', function () {
|
|
126
|
+
// Regression for ether/etherpad#7568 round-trip. Without server-side
|
|
127
|
+
// ccRegisterBlockElements registered for the heading tags,
|
|
128
|
+
// contentcollector treats <h1>/<h2> as inline and adjacent ones
|
|
129
|
+
// merge into a single pad line.
|
|
130
|
+
before(async function () {
|
|
131
|
+
html = () => buildHTML('<h1>Alpha</h1><h2>Beta</h2>');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('keeps each heading on its own line', function (done) {
|
|
135
|
+
const expected = /<h1>\s*Alpha\s*<\/h1>[\s\S]*<h2>\s*Beta\s*<\/h2>/;
|
|
136
|
+
generateJWTToken().then((token) => {
|
|
137
|
+
agent.get(getHTMLEndPointFor(padID))
|
|
138
|
+
.set('Authorization', token)
|
|
139
|
+
.end((err, res) => {
|
|
140
|
+
if (err) return done(err);
|
|
141
|
+
const out = res.body.data.html;
|
|
142
|
+
if (out.search(expected) === -1) {
|
|
143
|
+
return done(new Error(
|
|
144
|
+
`Adjacent headings merged or missing in: ${out}`));
|
|
145
|
+
}
|
|
146
|
+
if (out.search(/AlphaBeta/) !== -1) {
|
|
147
|
+
return done(new Error(
|
|
148
|
+
`Headings merged into one line: ${out}`));
|
|
149
|
+
}
|
|
150
|
+
done();
|
|
151
|
+
});
|
|
152
|
+
}).catch(done);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
124
155
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<select id="heading-selection"
|
|
4
4
|
aria-label="Text style"
|
|
5
5
|
data-l10n-id="ep_headings.style"
|
|
6
|
-
data-l10n-
|
|
6
|
+
data-l10n-aria-label="true">
|
|
7
7
|
<option value="dummy" selected data-l10n-id="ep_headings.style">Style</option>
|
|
8
8
|
<option value="-1" data-l10n-id="ep_headings.normal">Normal</option>
|
|
9
9
|
<option value="0" data-l10n-id="ep_headings.h1">Heading 1</option>
|