ep_headings2 0.2.119 → 0.2.120

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/static/js/index.js +10 -13
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.119",
4
+ "version": "0.2.120",
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.5.2"
37
+ "ep_plugin_helpers": "^0.6.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "eslint": "^8.57.1",
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {lineAttribute} = require('ep_plugin_helpers/attributes');
4
+ const {toolbarSelect} = require('ep_plugin_helpers/toolbar-select');
4
5
 
5
6
  const cssFiles = ['ep_headings2/static/css/editor.css'];
6
7
  const tags = ['h1', 'h2', 'h3', 'h4', 'code'];
@@ -15,20 +16,16 @@ exports.aceRegisterBlockElements = headings.aceRegisterBlockElements;
15
16
  exports.aceAttribsToClasses = headings.aceAttribsToClasses;
16
17
  exports.aceDomLineProcessLineAttributes = headings.aceDomLineProcessLineAttributes;
17
18
 
18
- // Bind the event handler to the toolbar buttons
19
+ // Bind the event handler to the toolbar buttons. The helper guarantees
20
+ // focus is returned to the editor after every change — including
21
+ // invalid picks — preserving the behavior of the original handler that
22
+ // fixed #130.
19
23
  exports.postAceInit = (hookName, context) => {
20
- const hs = $('#heading-selection');
21
- hs.on('change', function () {
22
- const value = $(this).val();
23
- const intValue = parseInt(value, 10);
24
- if (!isNaN(intValue)) {
25
- context.ace.callWithAce((ace) => {
26
- ace.ace_doInsertHeading(intValue);
27
- }, 'insertheading', true);
28
- hs.val('dummy');
29
- }
30
- // Return focus to the editor after heading selection (fixes #130)
31
- context.ace.focus();
24
+ toolbarSelect({
25
+ selector: '#heading-selection',
26
+ context,
27
+ invoke: (ace, value) => ace.ace_doInsertHeading(value),
28
+ op: 'insertheading',
32
29
  });
33
30
  };
34
31