ep_clear_formatting 0.0.67 → 0.0.69

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.
@@ -9,3 +9,7 @@ updates:
9
9
  schedule:
10
10
  interval: "daily"
11
11
  versioning-strategy: "increase"
12
+ ignore:
13
+ # typescript-eslint has no release that supports TypeScript 7 yet.
14
+ - dependency-name: "typescript"
15
+ versions: [">=7"]
@@ -11,8 +11,23 @@ jobs:
11
11
  if: |
12
12
  (github.event_name != 'pull_request')
13
13
  || (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id)
14
- name: with Plugins
14
+ name: with Plugins (Node ${{ matrix.node }} / core ${{ matrix.core_ref || 'develop' }})
15
15
  runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ # Plugin floor is engines.node >=22 but current Etherpad core
19
+ # requires >=24 (engineStrict). Each cell pairs a Node version
20
+ # with a core ref that actually allows it: Node 22 against the
21
+ # last tag whose core floor was 22 (v2.7.3); Node 24 / 26 against
22
+ # current develop.
23
+ matrix:
24
+ include:
25
+ - node: '22'
26
+ core_ref: 'v2.7.3'
27
+ - node: '24'
28
+ core_ref: ''
29
+ - node: '26'
30
+ core_ref: ''
16
31
  steps:
17
32
  -
18
33
  name: Install libreoffice
@@ -25,12 +40,13 @@ jobs:
25
40
  uses: actions/checkout@v7
26
41
  with:
27
42
  repository: ether/etherpad-lite
43
+ ref: ${{ matrix.core_ref }}
28
44
  path: etherpad-lite
29
- - uses: actions/setup-node@v6
45
+ - uses: actions/setup-node@v7
30
46
  name: Install Node.js
31
47
  with:
32
- node-version: 25
33
- - uses: pnpm/action-setup@v6
48
+ node-version: ${{ matrix.node }}
49
+ - uses: pnpm/action-setup@v6.1.1
34
50
  name: Install pnpm
35
51
  with:
36
52
  package_json_file: ./etherpad-lite/package.json
@@ -7,7 +7,26 @@ on:
7
7
 
8
8
  jobs:
9
9
  test-frontend:
10
- runs-on: ubuntu-latest
10
+ runs-on: ${{ matrix.os || 'ubuntu-latest' }}
11
+ name: Playwright (Node ${{ matrix.node }} / core ${{ matrix.core_ref || 'develop' }})
12
+ strategy:
13
+ fail-fast: false
14
+ # Plugin floor is engines.node >=22 but current Etherpad core
15
+ # requires >=24 (engineStrict). Each cell pairs a Node version
16
+ # with a core ref that actually allows it: Node 22 against the
17
+ # last tag whose core floor was 22 (v2.7.3); Node 24 / 26 against
18
+ # current develop.
19
+ matrix:
20
+ include:
21
+ - node: '22'
22
+ core_ref: 'v2.7.3'
23
+ # ubuntu-latest is now 26.04, and the Playwright pinned by core
24
+ # v2.7.3 refuses to install chromium there.
25
+ os: ubuntu-24.04
26
+ - node: '24'
27
+ core_ref: ''
28
+ - node: '26'
29
+ core_ref: ''
11
30
 
12
31
  steps:
13
32
  -
@@ -15,12 +34,13 @@ jobs:
15
34
  uses: actions/checkout@v7
16
35
  with:
17
36
  repository: ether/etherpad-lite
37
+ ref: ${{ matrix.core_ref }}
18
38
  path: etherpad-lite
19
- - uses: actions/setup-node@v6
39
+ - uses: actions/setup-node@v7
20
40
  name: Install Node.js
21
41
  with:
22
- node-version: 25
23
- - uses: pnpm/action-setup@v6
42
+ node-version: ${{ matrix.node }}
43
+ - uses: pnpm/action-setup@v6.1.1
24
44
  name: Install pnpm
25
45
  with:
26
46
  package_json_file: ./etherpad-lite/package.json
@@ -52,6 +72,17 @@ jobs:
52
72
  - name: Create settings.json
53
73
  working-directory: ./etherpad-lite
54
74
  run: cp ./src/tests/settings.json settings.json
75
+ # Etherpad v2.7.x added a "severely outdated" version-badge that polls
76
+ # GitHub for the latest release and renders an absolutely-positioned
77
+ # banner at top-right when the running core is a full major behind.
78
+ # On the core v2.7.3 matrix cell that banner intercepts pointer
79
+ # events (e.g. #chaticon) and Playwright clicks time out. Set
80
+ # updates.tier=off so the badge stays hidden. Harmless no-op on cores
81
+ # without the updater or with the tier already off.
82
+ - name: Disable updater poll in test settings
83
+ working-directory: ./etherpad-lite
84
+ run: |
85
+ node -e 'const fs=require("fs");const s=JSON.parse(fs.readFileSync("settings.json","utf8"));s.updates={...(s.updates||{}),tier:"off"};fs.writeFileSync("settings.json",JSON.stringify(s,null,2));'
55
86
  - name: Run the frontend tests
56
87
  working-directory: ./etherpad-lite
57
88
  shell: bash
@@ -69,4 +100,8 @@ jobs:
69
100
  done
70
101
  cd src
71
102
  pnpm exec playwright install chromium --with-deps
72
- pnpm run test-ui --project=chromium
103
+ # On the core v2.7.3 cell run only this plugin's own specs. Core
104
+ # v2.7.3's specs predate fixes that let them coexist with plugins
105
+ # that change the pad layout (enter.spec, a11y_dialogs.spec), and
106
+ # the develop cells already run the full core suite with the plugin.
107
+ pnpm run test-ui --project=chromium ${{ matrix.core_ref && 'plugin_packages/ --pass-with-no-tests' || '' }}
@@ -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 eslint.config.mjs 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: 26
21
+ - uses: pnpm/action-setup@v6.1.1
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@v6
21
+ - uses: actions/setup-node@v7
22
22
  with:
23
- # OIDC trusted publishing needs npm >= 11.5.1, which requires
24
- # Node >= 20.17.0. setup-node's `20` resolves to the latest
25
- # 20.x, which satisfies that.
26
- node-version: 25
23
+ # OIDC trusted publishing needs npm >= 11.5.1. Node 26 is the
24
+ # Active LTS line and bundles npm 11.x, so the pinned upgrade below
25
+ # stays on the same npm major. Avoid odd non-LTS lines (Node 25):
26
+ # npm 12 requires ^22.22.2 || ^24.15.0 || >=26.0.0 and the upgrade
27
+ # step dies there with EBADENGINE.
28
+ node-version: 26
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@latest
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.1
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/ep.json CHANGED
@@ -3,10 +3,11 @@
3
3
  {
4
4
  "name": "clear_formatting",
5
5
  "client_hooks": {
6
- "postAceInit" : "ep_clear_formatting/static/js/clear_formatting"
6
+ "postAceInit": "ep_clear_formatting/static/js/clear_formatting",
7
+ "aceInitialized": "ep_clear_formatting/static/js/clear_formatting"
7
8
  },
8
9
  "hooks": {
9
- "eejsBlock_dd_format" : "ep_clear_formatting/clear_formatting"
10
+ "eejsBlock_dd_format": "ep_clear_formatting/clear_formatting"
10
11
  }
11
12
  }
12
13
  ]
@@ -0,0 +1,3 @@
1
+ import etherpad from 'eslint-config-etherpad/flat/plugin.js';
2
+
3
+ export default etherpad;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ep_clear_formatting",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "keywords": [
5
5
  "clear",
6
6
  "formatting"
@@ -18,16 +18,16 @@
18
18
  "url": "https://github.com/ether/ep_clear_formatting.git"
19
19
  },
20
20
  "engines": {
21
- "node": ">=18.0.0"
21
+ "node": ">=22.0.0"
22
22
  },
23
23
  "funding": {
24
24
  "type": "individual",
25
25
  "url": "https://etherpad.org/"
26
26
  },
27
27
  "devDependencies": {
28
- "eslint": "^8.57.1",
29
- "eslint-config-etherpad": "^4.0.5",
30
- "typescript": "^6.0.3"
28
+ "eslint": "^9.39.5",
29
+ "eslint-config-etherpad": "^5.0.4",
30
+ "typescript": "~6.0.3"
31
31
  },
32
32
  "scripts": {
33
33
  "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: '^4.3.2'
10
+ brace-expansion@1: '^1.1.16'
@@ -1,7 +1,42 @@
1
1
  'use strict';
2
2
 
3
+ // Attributes Etherpad keeps on the line marker for bookkeeping rather than as
4
+ // formatting. Everything else on a line (align, heading, line spacing, list,
5
+ // …) is formatting and has to go. Mirrors core's
6
+ // AttributeManager.DEFAULT_LINE_ATTRIBUTES.
7
+ const DEFAULT_LINE_ATTRIBUTES = ['author', 'lmkr', 'insertorder', 'start'];
8
+
9
+ // `ace_setAttributeOnSelection()` only touches character attributes, so line
10
+ // attributes such as ep_align's `align` survived "Clear Formatting"
11
+ // (ether/ether-plugins#40). documentAttributeManager is only handed out by
12
+ // aceInitialized, so expose a helper on editorInfo for postAceInit to call
13
+ // from inside callWithAce.
14
+ exports.aceInitialized = (hook, context) => {
15
+ const clearLineFormatting = function () {
16
+ const rep = this.rep;
17
+ const documentAttributeManager = this.documentAttributeManager;
18
+ if (!rep || !rep.selStart || !rep.selEnd) return;
19
+
20
+ const firstLine = rep.selStart[0];
21
+ // A selection that ends at column 0 does not really include that line.
22
+ const lastLine = Math.max(firstLine, rep.selEnd[0] - ((rep.selEnd[1] === 0) ? 1 : 0));
23
+
24
+ for (let line = firstLine; line <= lastLine; line++) {
25
+ const keys = documentAttributeManager.getAttributesOnLine(line).map((attr) => attr[0]);
26
+ for (const key of keys) {
27
+ if (DEFAULT_LINE_ATTRIBUTES.indexOf(key) !== -1) continue;
28
+ documentAttributeManager.removeAttributeOnLine(line, key);
29
+ }
30
+ }
31
+ };
32
+
33
+ context.editorInfo.ace_clearLineFormatting = clearLineFormatting.bind(context);
34
+ };
35
+
3
36
  exports.postAceInit = (hook, context) => {
4
- $('#clearFormatting').click(() => {
37
+ // Delegated: the Format menu this entry lives in is rendered by
38
+ // ep_file_menu_toolbar and may not exist yet when postAceInit runs.
39
+ $('body').on('click', '#clearFormatting', () => {
5
40
  context.ace.callWithAce((ace) => {
6
41
  const rep = ace.ace_getRep(); // get the current user selection
7
42
  const isSelection = (rep.selStart[0] !== rep.selEnd[0] || rep.selStart[1] !== rep.selEnd[1]);
@@ -11,9 +46,16 @@ exports.postAceInit = (hook, context) => {
11
46
  $.each(attrs, (k, v) => { // for each attribute
12
47
  const attr = k.split(',')[0]; // get the name of the attribute
13
48
  if (attr !== 'author') { // if its not an author attribute
14
- ace.ace_setAttributeOnSelection(attr, false); // set the attribute to false
49
+ // An empty value removes the attribute. Passing `false` used to
50
+ // *apply* it instead: the value is stringified into the attribute
51
+ // pool, and "false" is a non-empty — therefore set — value, so
52
+ // "Clear Formatting" turned plain text bold/italic/underlined.
53
+ ace.ace_setAttributeOnSelection(attr, '');
15
54
  }
16
55
  });
56
+
57
+ // Character attributes are gone; now drop the line attributes.
58
+ ace.ace_clearLineFormatting();
17
59
  }, 'clearFormatting', true);
18
60
  });
19
61
  };
@@ -0,0 +1,103 @@
1
+ import {expect, test} from '@playwright/test';
2
+ import {
3
+ clearPadContent,
4
+ getPadBody,
5
+ goToNewPad,
6
+ selectAllText,
7
+ writeToPad,
8
+ } from 'ep_etherpad-lite/tests/frontend-new/helper/padHelper';
9
+
10
+ // The "Clear Formatting" entry lives in the Format menu contributed by
11
+ // ep_file_menu_toolbar, which is not installed alongside this plugin in CI.
12
+ // The click handler is delegated from the pad page's <body>, so adding the
13
+ // element to that document is enough to drive it.
14
+ const addClearFormattingEntry = async (page) => {
15
+ await page.evaluate(() => {
16
+ if (document.getElementById('clearFormatting')) return;
17
+ const a = document.createElement('a');
18
+ a.id = 'clearFormatting';
19
+ a.textContent = 'Clear Formatting';
20
+ document.body.appendChild(a);
21
+ });
22
+ };
23
+
24
+ const clearFormatting = async (page) => {
25
+ await selectAllText(page);
26
+ await page.locator('#clearFormatting').click();
27
+ };
28
+
29
+ // ether/ether-plugins#42: clearing formatting on a line that carries a line
30
+ // attribute used to throw an uncaught RangeError out of
31
+ // AttributeManager.setAttributesOnRange. Fail the test on any page error.
32
+ let pageErrors: string[];
33
+
34
+ test.beforeEach(async ({page}) => {
35
+ pageErrors = [];
36
+ page.on('pageerror', (e) => pageErrors.push(e.message));
37
+ await goToNewPad(page);
38
+ // A new pad starts with the multi-line `defaultPadText` from settings, and
39
+ // these tests count formatting elements over the whole document.
40
+ await clearPadContent(page);
41
+ });
42
+
43
+ test.describe('ep_clear_formatting', () => {
44
+ test('clears character formatting without applying any', async ({page}) => {
45
+ const padBody = await getPadBody(page);
46
+ await writeToPad(page, 'formatted text');
47
+ await selectAllText(page);
48
+ await page.locator('.buttonicon-bold').first().click({force: true});
49
+ await expect(padBody.locator('b')).toHaveCount(1);
50
+
51
+ await addClearFormattingEntry(page);
52
+ await clearFormatting(page);
53
+
54
+ await expect(padBody.locator('b')).toHaveCount(0);
55
+ // Passing `false` instead of '' used to *set* every attribute in the pad's
56
+ // pool, so clearing formatting made the text italic/underlined/struck.
57
+ await expect(padBody.locator('i')).toHaveCount(0);
58
+ await expect(padBody.locator('u')).toHaveCount(0);
59
+ await expect(padBody.locator('s')).toHaveCount(0);
60
+ await expect(padBody).toContainText('formatted text');
61
+ expect(pageErrors).toEqual([]);
62
+ });
63
+
64
+ test('clears line attributes too', async ({page}) => {
65
+ // Regression test for ether/ether-plugins#40: ace_setAttributeOnSelection
66
+ // only clears character attributes, so line attributes (ep_align's
67
+ // `align`, headings, line spacing, lists, …) used to survive. A list is
68
+ // the one line attribute core provides on its own, so it is what this
69
+ // test can exercise without installing another plugin — it goes through
70
+ // the identical removeAttributeOnLine path as `align`.
71
+ const padBody = await getPadBody(page);
72
+ await writeToPad(page, 'a list item');
73
+ await selectAllText(page);
74
+ await page.locator('.buttonicon-insertunorderedlist').first().click({force: true});
75
+ await expect(padBody.locator('ul li')).toHaveCount(1);
76
+
77
+ await addClearFormattingEntry(page);
78
+ await clearFormatting(page);
79
+
80
+ await expect(padBody.locator('ul')).toHaveCount(0);
81
+ await expect(padBody).toContainText('a list item');
82
+ expect(pageErrors).toEqual([]);
83
+ });
84
+
85
+ test('clears a bold list item without throwing (ether-plugins#42)', async ({page}) => {
86
+ const padBody = await getPadBody(page);
87
+ await writeToPad(page, 'bold list item');
88
+ await selectAllText(page);
89
+ await page.locator('.buttonicon-insertunorderedlist').first().click({force: true});
90
+ await expect(padBody.locator('ul li')).toHaveCount(1);
91
+ await selectAllText(page);
92
+ await page.locator('.buttonicon-bold').first().click({force: true});
93
+ await expect(padBody.locator('b')).toHaveCount(1);
94
+
95
+ await addClearFormattingEntry(page);
96
+ await clearFormatting(page);
97
+
98
+ await expect(padBody.locator('ul')).toHaveCount(0);
99
+ await expect(padBody.locator('b')).toHaveCount(0);
100
+ await expect(padBody).toContainText('bold list item');
101
+ expect(pageErrors).toEqual([]);
102
+ });
103
+ });
package/.eslintrc.cjs DELETED
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- // This is a workaround for https://github.com/eslint/eslint/issues/3458
4
- require('eslint-config-etherpad/patch/modern-module-resolution');
5
-
6
- module.exports = {
7
- root: true,
8
- extends: 'etherpad/plugin',
9
- };