ep_file_menu_toolbar 0.2.59 → 0.2.60
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/.github/workflows/backend-tests.yml +2 -2
- package/.github/workflows/frontend-tests.yml +2 -2
- package/.github/workflows/lint.yml +39 -0
- package/.github/workflows/npmpublish.yml +12 -8
- package/.github/workflows/test-and-release.yml +4 -0
- package/README.md +38 -0
- package/locales/en.json +24 -0
- package/package.json +4 -4
- package/pnpm-workspace.yaml +10 -0
- package/static/js/index.js +1 -1
- package/static/tests/backend/specs/menu_blocks.js +82 -0
- package/static/tests/frontend-new/specs/format_menu.spec.ts +81 -0
- package/static/tests/frontend-new/specs/i18n.spec.ts +86 -0
- package/templates/toolbar.ejs +42 -25
|
@@ -26,11 +26,11 @@ jobs:
|
|
|
26
26
|
with:
|
|
27
27
|
repository: ether/etherpad-lite
|
|
28
28
|
path: etherpad-lite
|
|
29
|
-
- uses: actions/setup-node@
|
|
29
|
+
- uses: actions/setup-node@v7
|
|
30
30
|
name: Install Node.js
|
|
31
31
|
with:
|
|
32
32
|
node-version: 25
|
|
33
|
-
- uses: pnpm/action-setup@v6
|
|
33
|
+
- uses: pnpm/action-setup@v6.1.0
|
|
34
34
|
name: Install pnpm
|
|
35
35
|
with:
|
|
36
36
|
package_json_file: ./etherpad-lite/package.json
|
|
@@ -16,11 +16,11 @@ jobs:
|
|
|
16
16
|
with:
|
|
17
17
|
repository: ether/etherpad-lite
|
|
18
18
|
path: etherpad-lite
|
|
19
|
-
- uses: actions/setup-node@
|
|
19
|
+
- uses: actions/setup-node@v7
|
|
20
20
|
name: Install Node.js
|
|
21
21
|
with:
|
|
22
22
|
node-version: 25
|
|
23
|
-
- uses: pnpm/action-setup@v6
|
|
23
|
+
- uses: pnpm/action-setup@v6.1.0
|
|
24
24
|
name: Install pnpm
|
|
25
25
|
with:
|
|
26
26
|
package_json_file: ./etherpad-lite/package.json
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: Lint
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_call:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
lint:
|
|
8
|
+
name: ESLint
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
# `eslint .` executes .eslintrc.cjs and every installed ESLint plugin, so
|
|
11
|
+
# don't hand it the caller's contents:write / id-token:write token.
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
steps:
|
|
15
|
+
- name: Check out plugin repository
|
|
16
|
+
uses: actions/checkout@v7
|
|
17
|
+
- uses: actions/setup-node@v7
|
|
18
|
+
name: Install Node.js
|
|
19
|
+
with:
|
|
20
|
+
node-version: 25
|
|
21
|
+
- uses: pnpm/action-setup@v6.1.0
|
|
22
|
+
name: Install pnpm
|
|
23
|
+
with:
|
|
24
|
+
version: 10
|
|
25
|
+
run_install: false
|
|
26
|
+
- name: Get pnpm store directory
|
|
27
|
+
shell: bash
|
|
28
|
+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
29
|
+
- uses: actions/cache@v6
|
|
30
|
+
name: Setup pnpm cache
|
|
31
|
+
with:
|
|
32
|
+
path: ${{ env.STORE_PATH }}
|
|
33
|
+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
34
|
+
restore-keys: |
|
|
35
|
+
${{ runner.os }}-pnpm-store-
|
|
36
|
+
- name: Install dependencies
|
|
37
|
+
run: pnpm install --ignore-scripts
|
|
38
|
+
- name: Run ESLint
|
|
39
|
+
run: pnpm run lint
|
|
@@ -18,20 +18,24 @@ jobs:
|
|
|
18
18
|
contents: write # for the atomic version-bump push (branch + tag)
|
|
19
19
|
id-token: write # for npm OIDC trusted publishing
|
|
20
20
|
steps:
|
|
21
|
-
- uses: actions/setup-node@
|
|
21
|
+
- uses: actions/setup-node@v7
|
|
22
22
|
with:
|
|
23
|
-
# OIDC trusted publishing needs npm >= 11.5.1
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
|
|
23
|
+
# OIDC trusted publishing needs npm >= 11.5.1. Node 24 is an LTS
|
|
24
|
+
# line that every npm 11.x and 12.x supports; Node 25 is not —
|
|
25
|
+
# npm 12 requires ^22.22.2 || ^24.15.0 || >=26.0.0, so on Node 25
|
|
26
|
+
# the upgrade step below died with EBADENGINE and no plugin could
|
|
27
|
+
# publish.
|
|
28
|
+
node-version: 24
|
|
27
29
|
registry-url: https://registry.npmjs.org/
|
|
30
|
+
# Pinned to a range rather than @latest: the next npm major dropping
|
|
31
|
+
# this Node line would silently break publishing fleet-wide again.
|
|
28
32
|
- name: Upgrade npm to >=11.5.1 (required for trusted publishing)
|
|
29
|
-
run: npm install -g npm
|
|
33
|
+
run: npm install -g npm@^11.5.1
|
|
30
34
|
- name: Check out Etherpad core
|
|
31
35
|
uses: actions/checkout@v7
|
|
32
36
|
with:
|
|
33
37
|
repository: ether/etherpad-lite
|
|
34
|
-
- uses: pnpm/action-setup@v6
|
|
38
|
+
- uses: pnpm/action-setup@v6.1.0
|
|
35
39
|
name: Install pnpm
|
|
36
40
|
with:
|
|
37
41
|
run_install: false
|
|
@@ -73,7 +77,7 @@ jobs:
|
|
|
73
77
|
# `pnpm version patch` bumps package.json, makes a commit, and creates
|
|
74
78
|
# a `v<new-version>` tag. Capture the new tag name from package.json
|
|
75
79
|
# rather than parsing pnpm's output, which has historically varied.
|
|
76
|
-
# Bump the patch component directly with Node. pnpm/action-setup@v6
|
|
80
|
+
# Bump the patch component directly with Node. pnpm/action-setup@v6.0.10
|
|
77
81
|
# sometimes installs pnpm 11 pre-releases even when version: 10.x is
|
|
78
82
|
# requested (pnpm/action-setup#225); those pre-releases either skip
|
|
79
83
|
# the git commit/tag or reject --no-git-tag-version as unknown.
|
|
@@ -14,6 +14,9 @@ permissions:
|
|
|
14
14
|
id-token: write
|
|
15
15
|
|
|
16
16
|
jobs:
|
|
17
|
+
lint:
|
|
18
|
+
uses: ./.github/workflows/lint.yml
|
|
19
|
+
secrets: inherit
|
|
17
20
|
backend:
|
|
18
21
|
uses: ./.github/workflows/backend-tests.yml
|
|
19
22
|
secrets: inherit
|
|
@@ -23,6 +26,7 @@ jobs:
|
|
|
23
26
|
release:
|
|
24
27
|
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
|
|
25
28
|
needs:
|
|
29
|
+
- lint
|
|
26
30
|
- backend
|
|
27
31
|
- frontend
|
|
28
32
|
permissions:
|
package/README.md
CHANGED
|
@@ -9,6 +9,44 @@ Install using /admin/plugins
|
|
|
9
9
|
OR
|
|
10
10
|
``git clone git@github.com:ether/ep_file_menu_toolbar.git``
|
|
11
11
|
|
|
12
|
+
## Adding your plugin to the menus
|
|
13
|
+
|
|
14
|
+
Every menu is an [eejs block](https://etherpad.org/doc/latest/#index_eejsblock_name),
|
|
15
|
+
so a plugin puts itself in the file menu by rendering a template into the
|
|
16
|
+
block it belongs in — no change is needed in `ep_file_menu_toolbar`:
|
|
17
|
+
|
|
18
|
+
| Block | Menu | Use it for |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| `dd_file` | File | pad-level actions |
|
|
21
|
+
| `dd_edit` | Edit | undo/redo style actions |
|
|
22
|
+
| `dd_format_text` | Format, first group | formatting applied to a **selection** (subscript, superscript, ...) |
|
|
23
|
+
| `dd_format_block` | Format, second group | formatting applied to whole **lines** (headings, alignment, ...) |
|
|
24
|
+
| `dd_format` | Format, third group | anything else in Format (font pickers, clear formatting, ...) |
|
|
25
|
+
| `dd_insert` | Insert | inserting content |
|
|
26
|
+
| `dd_view` | View | display toggles |
|
|
27
|
+
| `dd_help` | Help | links and about entries |
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
// index.js
|
|
31
|
+
const {template} = require('ep_plugin_helpers');
|
|
32
|
+
exports.eejsBlock_dd_format_block = template('ep_myplugin/templates/fileMenu.ejs');
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
// ep.json
|
|
37
|
+
{"parts": [{"name": "main", "hooks": {
|
|
38
|
+
"eejsBlock_dd_format_block": "ep_myplugin/index"
|
|
39
|
+
}}]}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The menu entry is plain HTML. Reuse the handler your editbar button already
|
|
43
|
+
has (most plugins bind by class, e.g. `$('body').on('click', '.ep_myplugin', ...)`)
|
|
44
|
+
and localize the label with `data-l10n-id`:
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<li><a href="#" class="ep_myplugin" data-l10n-id="ep_myplugin.title">My thing</a></li>
|
|
48
|
+
```
|
|
49
|
+
|
|
12
50
|
## TODO
|
|
13
51
|
* i18n support
|
|
14
52
|
* Test against weird wrap/pad scrolling edge cases
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ep_file_menu_toolbar.file": "File",
|
|
3
|
+
"ep_file_menu_toolbar.edit": "Edit",
|
|
4
|
+
"ep_file_menu_toolbar.format": "Format",
|
|
5
|
+
"ep_file_menu_toolbar.insert": "Insert",
|
|
6
|
+
"ep_file_menu_toolbar.view": "View",
|
|
7
|
+
"ep_file_menu_toolbar.help": "Help",
|
|
8
|
+
"ep_file_menu_toolbar.save": "Save Revision",
|
|
9
|
+
"ep_file_menu_toolbar.print": "Print",
|
|
10
|
+
"ep_file_menu_toolbar.embed": "Share & Embed",
|
|
11
|
+
"ep_file_menu_toolbar.timeslider": "Timeslider",
|
|
12
|
+
"ep_file_menu_toolbar.undo": "Undo (Ctrl+Z)",
|
|
13
|
+
"ep_file_menu_toolbar.redo": "Redo (Ctrl+Y)",
|
|
14
|
+
"ep_file_menu_toolbar.bold": "Bold (Ctrl+B)",
|
|
15
|
+
"ep_file_menu_toolbar.italic": "Italic (Ctrl+I)",
|
|
16
|
+
"ep_file_menu_toolbar.underline": "Underline (Ctrl+U)",
|
|
17
|
+
"ep_file_menu_toolbar.strikethrough": "Strikethrough (Ctrl+5)",
|
|
18
|
+
"ep_file_menu_toolbar.orderedList": "Ordered list (Ctrl+Shift+N)",
|
|
19
|
+
"ep_file_menu_toolbar.unorderedList": "Unordered list (Ctrl+Shift+L)",
|
|
20
|
+
"ep_file_menu_toolbar.indent": "Indent (TAB)",
|
|
21
|
+
"ep_file_menu_toolbar.outdent": "Outdent (Shift+TAB)",
|
|
22
|
+
"ep_file_menu_toolbar.clearAuthorship": "Clear Authorship Colors (Ctrl+Shift+C)",
|
|
23
|
+
"ep_file_menu_toolbar.about": "File Menu Toolbar plugin by John McLear"
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ep_file_menu_toolbar",
|
|
3
3
|
"description": "File / Menu style toolbar",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.60",
|
|
5
5
|
"author": "johnyma22 (John McLear) <john@mclear.co.uk>",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=22.0.0"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"eslint": "^8.57.1",
|
|
19
|
-
"eslint-config-etherpad": "^
|
|
20
|
-
"typescript": "
|
|
19
|
+
"eslint-config-etherpad": "^5.0.0",
|
|
20
|
+
"typescript": "~6.0.3"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"lint": "eslint .",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# js-yaml and brace-expansion arrive only as transitive dev dependencies (via
|
|
2
|
+
# eslint and minimatch@3), so `pnpm update` cannot move them. The selectors are
|
|
3
|
+
# scoped to the affected major line: an unbounded range would drag minimatch@3
|
|
4
|
+
# onto brace-expansion 5.x and eslint onto js-yaml 5.x.
|
|
5
|
+
#
|
|
6
|
+
# pnpm 11 no longer reads `pnpm.overrides` from package.json — these must live
|
|
7
|
+
# here or the lockfile and the install disagree (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH).
|
|
8
|
+
overrides:
|
|
9
|
+
js-yaml: '^4.3.2'
|
|
10
|
+
brace-expansion@1: '^1.1.16'
|
package/static/js/index.js
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert').strict;
|
|
4
|
+
const pluginDefs = require('ep_etherpad-lite/static/js/pluginfw/plugin_defs');
|
|
5
|
+
|
|
6
|
+
const BLOCKS = ['dd_format_text', 'dd_format_block', 'dd_format'];
|
|
7
|
+
|
|
8
|
+
// Render the toolbar with a fake plugin hooked into every Format block, so the
|
|
9
|
+
// test can see where a plugin's menu entries actually end up.
|
|
10
|
+
const renderToolbar = () => {
|
|
11
|
+
const saved = new Map();
|
|
12
|
+
for (const block of BLOCKS) {
|
|
13
|
+
const name = `eejsBlock_${block}`;
|
|
14
|
+
saved.set(name, pluginDefs.hooks[name]);
|
|
15
|
+
pluginDefs.hooks[name] = [{
|
|
16
|
+
hook_name: name,
|
|
17
|
+
hook_fn: (hookName, args, cb) => {
|
|
18
|
+
args.content += `<li id="from-${block}"></li>`;
|
|
19
|
+
return cb();
|
|
20
|
+
},
|
|
21
|
+
hook_fn_name: `menu_blocks.js:${block}`,
|
|
22
|
+
part: {plugin: 'ep_file_menu_toolbar_test'},
|
|
23
|
+
}];
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const args = {content: ''};
|
|
27
|
+
require('../../../../eejs').eejsBlock_body('eejsBlock_body', args, () => {});
|
|
28
|
+
return args.content;
|
|
29
|
+
} finally {
|
|
30
|
+
for (const [name, hooks] of saved) {
|
|
31
|
+
if (hooks === undefined) delete pluginDefs.hooks[name];
|
|
32
|
+
else pluginDefs.hooks[name] = hooks;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe(__filename, function () {
|
|
38
|
+
let html;
|
|
39
|
+
let at;
|
|
40
|
+
|
|
41
|
+
before(async function () {
|
|
42
|
+
html = renderToolbar();
|
|
43
|
+
at = (needle) => {
|
|
44
|
+
const i = html.indexOf(needle);
|
|
45
|
+
assert.notEqual(i, -1, `${needle} is missing from the rendered toolbar`);
|
|
46
|
+
return i;
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('puts dd_format_text in the character formatting group', async function () {
|
|
51
|
+
// Right below Strikethrough, where ep_subscript_and_superscript and
|
|
52
|
+
// friends belong — https://github.com/ether/ep_subscript_and_superscript/issues/17
|
|
53
|
+
assert(at('data-key="strikethrough"') < at('id="from-dd_format_text"'));
|
|
54
|
+
assert(at('id="from-dd_format_text"') < at('data-key="insertorderedlist"'));
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('puts dd_format_block in the paragraph formatting group', async function () {
|
|
58
|
+
// Below Outdent: headings and alignment are line level formatting.
|
|
59
|
+
assert(at('data-key="outdent"') < at('id="from-dd_format_block"'));
|
|
60
|
+
assert(at('id="from-dd_format_block"') < at('id="from-dd_format"'));
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('keeps the legacy dd_format block after the built in entries', async function () {
|
|
64
|
+
assert(at('data-key="outdent"') < at('id="from-dd_format"'));
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// https://github.com/ether/ep_file_menu_toolbar/issues/21
|
|
68
|
+
it('renders Clear Authorship Colors after everything plugins add', async function () {
|
|
69
|
+
for (const block of BLOCKS) {
|
|
70
|
+
assert(at(`id="from-${block}"`) < at('data-key="clearauthorship"'),
|
|
71
|
+
`${block} content should render before Clear Authorship Colors`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('closes every menu entry it opens', async function () {
|
|
76
|
+
// An unclosed <li> used to leave an extra, label-less menu in the menu bar.
|
|
77
|
+
const opened = html.match(/<li[\s>]/g) || [];
|
|
78
|
+
const closed = html.match(/<\/li>/g) || [];
|
|
79
|
+
assert.equal(opened.length - closed.length, 0,
|
|
80
|
+
`${opened.length} <li> tags but ${closed.length} </li> tags`);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {expect, test} from '@playwright/test';
|
|
2
|
+
import {clearPadContent, getPadBody, goToNewPad, writeToPad}
|
|
3
|
+
from 'ep_etherpad-lite/tests/frontend-new/helper/padHelper';
|
|
4
|
+
|
|
5
|
+
// The dropdown plugin flattens the menu markup, so the entries of a menu end
|
|
6
|
+
// up as direct children of its <ul>. Describe each child by the data-key of
|
|
7
|
+
// its link (or HR for a separator) to get a readable signature of the menu.
|
|
8
|
+
const menuSignature = async (page: import('@playwright/test').Page, title: string) =>
|
|
9
|
+
await page.locator(`.dropdown-menu > li:has(> a:text-is("${title}")) > ul`)
|
|
10
|
+
.evaluate((ul) => [...ul.children]
|
|
11
|
+
.filter((el) => el.tagName === 'HR' || el.querySelector(':scope > a'))
|
|
12
|
+
.map((el) => el.tagName === 'HR'
|
|
13
|
+
? 'HR'
|
|
14
|
+
: (el.querySelector(':scope > a')!.getAttribute('data-key') || el.id || 'li')));
|
|
15
|
+
|
|
16
|
+
test.beforeEach(async ({page}) => {
|
|
17
|
+
await goToNewPad(page);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test.describe('ep_file_menu_toolbar format menu', () => {
|
|
21
|
+
// https://github.com/ether/ep_file_menu_toolbar/issues/21
|
|
22
|
+
test('Clear Authorship Colors sits alone in the last group of Format', async ({page}) => {
|
|
23
|
+
const entries = await menuSignature(page, 'Format');
|
|
24
|
+
|
|
25
|
+
// It is the last entry of the menu, and a separator puts it in a group of
|
|
26
|
+
// its own — it used to sit between the formatting commands and everything
|
|
27
|
+
// plugins add to the Format menu.
|
|
28
|
+
expect(entries[entries.length - 1]).toBe('clearauthorship');
|
|
29
|
+
expect(entries[entries.length - 2]).toBe('HR');
|
|
30
|
+
expect(entries.filter((e) => e === 'clearauthorship')).toHaveLength(1);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('Format keeps character formatting, then paragraph formatting', async ({page}) => {
|
|
34
|
+
const entries = await menuSignature(page, 'Format');
|
|
35
|
+
// The first group is the character formatting one, and the paragraph
|
|
36
|
+
// formatting commands come after it, each behind a separator. Plugins are
|
|
37
|
+
// appended to the end of the group they belong in, so only the relative
|
|
38
|
+
// order of the built in entries is pinned here.
|
|
39
|
+
expect(entries.slice(0, 4))
|
|
40
|
+
.toEqual(['bold', 'italic', 'underline', 'strikethrough']);
|
|
41
|
+
expect(entries.indexOf('insertorderedlist'))
|
|
42
|
+
.toBeLessThan(entries.indexOf('outdent'));
|
|
43
|
+
// Group boundaries: a separator between the character formatting group and
|
|
44
|
+
// the paragraph one, and one before the clear authorship colours group.
|
|
45
|
+
for (const [before, after] of [
|
|
46
|
+
['strikethrough', 'insertorderedlist'],
|
|
47
|
+
['outdent', 'clearauthorship'],
|
|
48
|
+
]) {
|
|
49
|
+
expect(entries.indexOf(before)).toBeLessThan(entries.indexOf(after));
|
|
50
|
+
expect(entries.slice(entries.indexOf(before), entries.indexOf(after)))
|
|
51
|
+
.toContain('HR');
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('menu bar has no empty entries', async ({page}) => {
|
|
56
|
+
const titles = await page.locator('.dropdown-menu > li > a').allTextContents();
|
|
57
|
+
expect(titles.map((t) => t.trim())).toEqual(
|
|
58
|
+
['File', 'Edit', 'Format', 'Insert', 'View', 'Help']);
|
|
59
|
+
// An unclosed <li> used to leave an extra, label-less menu between Edit
|
|
60
|
+
// and Format, so count the menus too and not just the labels.
|
|
61
|
+
await expect(page.locator('.dropdown-menu > li')).toHaveCount(titles.length);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('Edit menu undoes and redoes', async ({page}) => {
|
|
65
|
+
const padBody = await getPadBody(page);
|
|
66
|
+
await padBody.click();
|
|
67
|
+
await clearPadContent(page);
|
|
68
|
+
await writeToPad(page, 'hello world');
|
|
69
|
+
const firstLine = padBody.locator('div').first();
|
|
70
|
+
await expect(firstLine).toHaveText('hello world');
|
|
71
|
+
|
|
72
|
+
// The entries live inside the collapsed "Edit" submenu, which the
|
|
73
|
+
// jquery-css dropdown plugin only expands on hover. dispatchEvent fires
|
|
74
|
+
// the click straight at the element regardless of visibility.
|
|
75
|
+
await page.locator(".dropdown-menu a[data-key='undo']").dispatchEvent('click');
|
|
76
|
+
await expect(firstLine).not.toHaveText('hello world');
|
|
77
|
+
|
|
78
|
+
await page.locator(".dropdown-menu a[data-key='redo']").dispatchEvent('click');
|
|
79
|
+
await expect(firstLine).toHaveText('hello world');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {expect, test} from '@playwright/test';
|
|
2
|
+
import {goToNewPad} from 'ep_etherpad-lite/tests/frontend-new/helper/padHelper';
|
|
3
|
+
|
|
4
|
+
// Every label in the menu, with the key it must be translated through. The
|
|
5
|
+
// plugin's own keys live in locales/en.json; the rest are core keys that
|
|
6
|
+
// already carry translations for every language Etherpad ships.
|
|
7
|
+
const LABELS: [string, string][] = [
|
|
8
|
+
['File', 'ep_file_menu_toolbar.file'],
|
|
9
|
+
['New Pad', 'index.newPad'],
|
|
10
|
+
['Save Revision', 'ep_file_menu_toolbar.save'],
|
|
11
|
+
['Import Now', 'pad.impexp.importbutton'],
|
|
12
|
+
['Export current pad as:', 'pad.importExport.export'],
|
|
13
|
+
['Timeslider', 'ep_file_menu_toolbar.timeslider'],
|
|
14
|
+
['Pad-wide Settings', 'pad.settings.padSettings'],
|
|
15
|
+
['Print', 'ep_file_menu_toolbar.print'],
|
|
16
|
+
['Share & Embed', 'ep_file_menu_toolbar.embed'],
|
|
17
|
+
['Edit', 'ep_file_menu_toolbar.edit'],
|
|
18
|
+
['Undo (Ctrl+Z)', 'ep_file_menu_toolbar.undo'],
|
|
19
|
+
['Redo (Ctrl+Y)', 'ep_file_menu_toolbar.redo'],
|
|
20
|
+
['Format', 'ep_file_menu_toolbar.format'],
|
|
21
|
+
['Bold (Ctrl+B)', 'ep_file_menu_toolbar.bold'],
|
|
22
|
+
['Italic (Ctrl+I)', 'ep_file_menu_toolbar.italic'],
|
|
23
|
+
['Underline (Ctrl+U)', 'ep_file_menu_toolbar.underline'],
|
|
24
|
+
['Strikethrough (Ctrl+5)', 'ep_file_menu_toolbar.strikethrough'],
|
|
25
|
+
['Ordered list (Ctrl+Shift+N)', 'ep_file_menu_toolbar.orderedList'],
|
|
26
|
+
['Unordered list (Ctrl+Shift+L)', 'ep_file_menu_toolbar.unorderedList'],
|
|
27
|
+
['Indent (TAB)', 'ep_file_menu_toolbar.indent'],
|
|
28
|
+
['Outdent (Shift+TAB)', 'ep_file_menu_toolbar.outdent'],
|
|
29
|
+
['Clear Authorship Colors (Ctrl+Shift+C)', 'ep_file_menu_toolbar.clearAuthorship'],
|
|
30
|
+
['Insert', 'ep_file_menu_toolbar.insert'],
|
|
31
|
+
['View', 'ep_file_menu_toolbar.view'],
|
|
32
|
+
['Authorship colors', 'pad.settings.colorcheck'],
|
|
33
|
+
['Line numbers', 'pad.settings.linenocheck'],
|
|
34
|
+
['Chat always on screen', 'pad.settings.stickychat'],
|
|
35
|
+
['Read content from right to left?', 'pad.settings.rtlcheck'],
|
|
36
|
+
['Help', 'ep_file_menu_toolbar.help'],
|
|
37
|
+
['File Menu Toolbar plugin by John McLear', 'ep_file_menu_toolbar.about'],
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
// The export submenu is cloned from core's export links at runtime, so those
|
|
41
|
+
// entries are already translated by core and carry no key of their own.
|
|
42
|
+
const menuLinks = async (page: import('@playwright/test').Page) =>
|
|
43
|
+
await page.locator('.dropdown-menu a').evaluateAll((links) => links
|
|
44
|
+
.filter((a) => !a.classList.contains('exportlink'))
|
|
45
|
+
.map((a) => ({text: a.textContent!.trim(), key: a.getAttribute('data-l10n-id')})));
|
|
46
|
+
|
|
47
|
+
test.beforeEach(async ({page}) => {
|
|
48
|
+
await goToNewPad(page);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test.describe('ep_file_menu_toolbar i18n', () => {
|
|
52
|
+
test('every menu entry is translated through a key', async ({page}) => {
|
|
53
|
+
// Other plugins may add entries of their own to the menu, so check that
|
|
54
|
+
// the plugin's own entries are all there rather than pinning the list.
|
|
55
|
+
const links = await menuLinks(page);
|
|
56
|
+
for (const [label, key] of LABELS) {
|
|
57
|
+
expect(links, `no entry "${label}" with key ${key}`)
|
|
58
|
+
.toContainEqual({text: label, key});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('the displayed label is what the key resolves to', async ({page}) => {
|
|
63
|
+
// A key core cannot resolve leaves the hardcoded English from the template
|
|
64
|
+
// on screen. Two ways that used to happen here: a key ending in `.title`
|
|
65
|
+
// only ever sets the title attribute (html10n treats the last segment as
|
|
66
|
+
// an attribute name), and a label wrapped in markup such as
|
|
67
|
+
// `<u>B</u>old` gets the translation appended to the leftover `B`.
|
|
68
|
+
for (const [label, key] of LABELS) {
|
|
69
|
+
const resolved = await page.evaluate((k) => (window as any).html10n.get(k), key);
|
|
70
|
+
expect(resolved, `${key} does not resolve`).toBe(label);
|
|
71
|
+
}
|
|
72
|
+
const links = await menuLinks(page);
|
|
73
|
+
for (const [, key] of LABELS) {
|
|
74
|
+
const link = links.find((l) => l.key === key)!;
|
|
75
|
+
const resolved = await page.evaluate((k) => (window as any).html10n.get(k), key);
|
|
76
|
+
expect(link.text, `${key} is not applied to the label`).toBe(resolved);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('the plugin locales file is served by core', async ({page}) => {
|
|
81
|
+
const locales = await page.evaluate(async () =>
|
|
82
|
+
await (await fetch('/locales/en')).json());
|
|
83
|
+
expect(Object.keys(locales.en).filter((k) => k.startsWith('ep_file_menu_toolbar.')))
|
|
84
|
+
.toHaveLength(22);
|
|
85
|
+
});
|
|
86
|
+
});
|
package/templates/toolbar.ejs
CHANGED
|
@@ -1,55 +1,67 @@
|
|
|
1
1
|
<ul class="dropdown-menu">
|
|
2
2
|
<% e.begin_block("dd_dropdownMenu"); %>
|
|
3
3
|
<li>
|
|
4
|
-
<a href="#">File</a>
|
|
4
|
+
<a href="#" data-l10n-id="ep_file_menu_toolbar.file">File</a>
|
|
5
5
|
<ul>
|
|
6
6
|
<li>
|
|
7
7
|
<% e.begin_block("dd_file"); %>
|
|
8
8
|
<li><a href target="_blank" id="newPad" data-l10n-id="index.newPad">New</a></li>
|
|
9
|
-
<li><a href="#" data-key="save" id="revisionlink" data-type="button" data-l10n-id="
|
|
9
|
+
<li><a href="#" data-key="save" id="revisionlink" data-type="button" data-l10n-id="ep_file_menu_toolbar.save">Save Revision</a></li>
|
|
10
10
|
<li><a href="#" id="importexportlink" data-key="import_export" class="acl-write" data-type="button" data-l10n-id="pad.impexp.importbutton">Import</a></li>
|
|
11
11
|
<li id="file_menu_exports"><a href="#" data-key="export" data-type="button" data-l10n-id="pad.importExport.export">Export</a>
|
|
12
12
|
<ul class="submenu">
|
|
13
13
|
</ul>
|
|
14
14
|
</li>
|
|
15
15
|
<hr></hr>
|
|
16
|
-
<li onclick="document.location = document.location.pathname+ '/timeslider'"><a data-l10n-id="
|
|
16
|
+
<li onclick="document.location = document.location.pathname+ '/timeslider'"><a data-l10n-id="ep_file_menu_toolbar.timeslider" href="#" id="timesliderlink">Timeslider</a></li>
|
|
17
17
|
<hr></hr>
|
|
18
18
|
<li><a href="#" id="filemenutoolbarsettings" data-key="settings" data-type="button" data-l10n-id="pad.settings.padSettings">Pad Settings</a></li>
|
|
19
|
-
<li><a href="#" data-key="print" onClick="printPad()" data-type="button" data-l10n-id="">Print</a></li>
|
|
20
|
-
<li><a href="#" id="filemenutoolbarembed" data-key="embed" id="embedlink" data-type="button" data-l10n-id="
|
|
19
|
+
<li><a href="#" data-key="print" onClick="printPad()" data-type="button" data-l10n-id="ep_file_menu_toolbar.print">Print</a></li>
|
|
20
|
+
<li><a href="#" id="filemenutoolbarembed" data-key="embed" id="embedlink" data-type="button" data-l10n-id="ep_file_menu_toolbar.embed">Share & Embed</a></li>
|
|
21
21
|
<% e.end_block(); %>
|
|
22
22
|
</li>
|
|
23
23
|
</ul>
|
|
24
24
|
</li>
|
|
25
25
|
<li class="acl-write">
|
|
26
|
-
<a href="#" data-l10n-id="">Edit</a>
|
|
26
|
+
<a href="#" data-l10n-id="ep_file_menu_toolbar.edit">Edit</a>
|
|
27
27
|
<ul>
|
|
28
28
|
<li>
|
|
29
29
|
<% e.begin_block("dd_edit"); %>
|
|
30
|
-
<li><a href="#" data-key="undo" data-l10n-id="
|
|
31
|
-
<li><a href="#" data-key="redo" data-l10n-id="
|
|
30
|
+
<li><a href="#" data-key="undo" data-l10n-id="ep_file_menu_toolbar.undo">Undo</a></li>
|
|
31
|
+
<li><a href="#" data-key="redo" data-l10n-id="ep_file_menu_toolbar.redo">Redo</a></li>
|
|
32
32
|
<% e.end_block(); %>
|
|
33
33
|
</li>
|
|
34
34
|
</ul>
|
|
35
|
-
|
|
35
|
+
</li>
|
|
36
36
|
<li class="acl-write">
|
|
37
|
-
<a href="#">Format</a>
|
|
37
|
+
<a href="#" data-l10n-id="ep_file_menu_toolbar.format">Format</a>
|
|
38
38
|
<ul>
|
|
39
39
|
<li>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<li id="
|
|
44
|
-
<li id="
|
|
40
|
+
<!-- Character formatting. Plugins that style a *selection*
|
|
41
|
+
(subscript, superscript, ...) append themselves here. -->
|
|
42
|
+
<% e.begin_block("dd_format_text"); %>
|
|
43
|
+
<li id="bold"><a href="#" data-key="bold" data-type="button" onClick="$('.buttonicon-bold').click();" data-l10n-id="ep_file_menu_toolbar.bold">Bold</a></li>
|
|
44
|
+
<li id="italic"><a href="#" data-key="italic" data-type="button" onClick="$('.buttonicon-italic').click();" data-l10n-id="ep_file_menu_toolbar.italic">Italic</a></li>
|
|
45
|
+
<li id="underline"><a href="#" data-key="underline" data-type="button" onClick="$('.buttonicon-underline').click();" data-l10n-id="ep_file_menu_toolbar.underline">Underline</a></li>
|
|
46
|
+
<li id="strikethrough"><a href="#" data-key="strikethrough" data-type="button" onClick="$('.buttonicon-strikethrough').click();" data-l10n-id="ep_file_menu_toolbar.strikethrough">Strikethrough</a></li>
|
|
47
|
+
<% e.end_block(); %>
|
|
45
48
|
<hr></hr>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<li><a href="#" data-l10n-id="
|
|
49
|
+
<!-- Paragraph formatting. Plugins that style whole *lines*
|
|
50
|
+
(headings, alignment, ...) append themselves here. -->
|
|
51
|
+
<% e.begin_block("dd_format_block"); %>
|
|
52
|
+
<li><a href="#" data-l10n-id="ep_file_menu_toolbar.orderedList" data-key="insertorderedlist" data-type="button" onClick="$('.buttonicon-insertorderedlist').click();">Ordered List</a></li>
|
|
53
|
+
<li><a href="#" data-l10n-id="ep_file_menu_toolbar.unorderedList" data-key="insertunorderedlist" data-type="button" onClick="$('.buttonicon-insertunorderedlist').click();">Unordered list</a></li>
|
|
54
|
+
<li><a href="#" data-l10n-id="ep_file_menu_toolbar.indent" data-key="indent" data-type="button" onClick="$('.buttonicon-indent').click();">Indent</a></li>
|
|
55
|
+
<li><a href="#" data-l10n-id="ep_file_menu_toolbar.outdent" data-key="outdent" data-type="button" onClick="$('.buttonicon-outdent').click();">Outdent</a></li>
|
|
56
|
+
<% e.end_block(); %>
|
|
50
57
|
<hr></hr>
|
|
51
|
-
|
|
58
|
+
<!-- Everything else a plugin wants in Format (font pickers,
|
|
59
|
+
clear formatting, ...). Kept for backwards compatibility:
|
|
60
|
+
this is the block plugins have always hooked. -->
|
|
61
|
+
<% e.begin_block("dd_format"); %>
|
|
52
62
|
<% e.end_block(); %>
|
|
63
|
+
<hr></hr>
|
|
64
|
+
<li><a href="#" data-l10n-id="ep_file_menu_toolbar.clearAuthorship" data-key="clearauthorship" data-type="button" onClick="$('.buttonicon-clearauthorship').click();">Clear Authorship Colors</a></li>
|
|
53
65
|
|
|
54
66
|
</li>
|
|
55
67
|
</ul>
|
|
@@ -57,7 +69,7 @@
|
|
|
57
69
|
|
|
58
70
|
|
|
59
71
|
<li class="acl-write">
|
|
60
|
-
<a href="#">Insert</a>
|
|
72
|
+
<a href="#" data-l10n-id="ep_file_menu_toolbar.insert">Insert</a>
|
|
61
73
|
<ul>
|
|
62
74
|
<li>
|
|
63
75
|
<% e.begin_block("dd_insert"); %>
|
|
@@ -68,14 +80,14 @@
|
|
|
68
80
|
|
|
69
81
|
|
|
70
82
|
<li>
|
|
71
|
-
<a href="#">View</a>
|
|
83
|
+
<a href="#" data-l10n-id="ep_file_menu_toolbar.view">View</a>
|
|
72
84
|
<ul>
|
|
73
85
|
<li>
|
|
74
86
|
<% e.begin_block("dd_view"); %>
|
|
75
87
|
<li><a href="#" data-l10n-id="pad.settings.colorcheck" onClick="$('#options-colorscheck').click();">Authorship colors</a></li>
|
|
76
88
|
<li><a href="#" data-l10n-id="pad.settings.linenocheck" onClick="$('#options-linenoscheck').click();">Line Numbers</a></li>
|
|
77
89
|
<li><a href="#" data-l10n-id="pad.settings.stickychat" onClick="chat.stickToScreen();">Chat Always Visible</a></li>
|
|
78
|
-
<li><a href="#" onClick="$('#timesliderlink').click();" data-l10n-id="
|
|
90
|
+
<li><a href="#" onClick="$('#timesliderlink').click();" data-l10n-id="ep_file_menu_toolbar.timeslider">Timeslider</a></li>
|
|
79
91
|
<li><a href="#" data-l10n-id="pad.settings.rtlcheck" onClick="$('#options-rtlcheck').click();">Text Right to Left</a></li>
|
|
80
92
|
<% e.end_block(); %>
|
|
81
93
|
</li>
|
|
@@ -83,11 +95,11 @@
|
|
|
83
95
|
|
|
84
96
|
</li>
|
|
85
97
|
<li>
|
|
86
|
-
<a href="#" class='dropdown-help'>Help</a>
|
|
98
|
+
<a href="#" class='dropdown-help' data-l10n-id="ep_file_menu_toolbar.help">Help</a>
|
|
87
99
|
<ul>
|
|
88
100
|
<li>
|
|
89
101
|
<% e.begin_block("dd_help"); %>
|
|
90
|
-
<li><a href="http://mclear.co.uk" target="_blank">File Menu Toolbar plugin by John McLear</a></li>
|
|
102
|
+
<li><a href="http://mclear.co.uk" target="_blank" data-l10n-id="ep_file_menu_toolbar.about">File Menu Toolbar plugin by John McLear</a></li>
|
|
91
103
|
<% e.end_block(); %>
|
|
92
104
|
</li>
|
|
93
105
|
</ul>
|
|
@@ -112,6 +124,11 @@
|
|
|
112
124
|
.dropdown-menu-sub-indicator > ul > hr{
|
|
113
125
|
margin:10px 0px 10px 0px;
|
|
114
126
|
}
|
|
127
|
+
/* An extension block that no plugin filled in leaves two separators next to
|
|
128
|
+
each other. Collapse them so the menu never shows an empty group. */
|
|
129
|
+
.dropdown-menu-sub-indicator > ul > hr + hr{
|
|
130
|
+
display:none;
|
|
131
|
+
}
|
|
115
132
|
@media all and (max-width: 400px){
|
|
116
133
|
.dropdown-menu{
|
|
117
134
|
display:none;
|