Skip to content

Commit

Permalink
With the symbols plugin you can use the Shift key to select multiple …
Browse files Browse the repository at this point in the history
…symbols.

special character #1194
Issue: #1194)
  • Loading branch information
xdan committed Nov 18, 2024
1 parent f5a73a7 commit 5fbc8bc
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

## 4.2.42

### :rocket: New Feature

- With the symbols plugin you can use the Shift key to select multiple symbols.
[special character #1194](https://github.com/xdan/jodit/issues/1194)

### :bug: Bug Fix

- Fixed a bug in the logic of the ControlType.popup method; if the method did not return anything,
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/symbols/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Insert special symbol

Added button and dialog for inserting special symbols.
If you want to select multiple characters, you can hold down the `Shift`
key and click on the characters you want to insert.
44 changes: 43 additions & 1 deletion src/plugins/symbols/symbols.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ describe('Symbols plugin', () => {
});

describe('Press Enter or mousedown on element', () => {
it('Should insert character', () => {
it('Should insert character and close dialog', () => {
const area = appendTestArea();
const editor = new Jodit(area, {
toolbarAdaptive: false,
Expand Down Expand Up @@ -267,6 +267,48 @@ describe('Symbols plugin', () => {

expect(editor.value).equals('<p>test&amp;½</p>');
});

describe('with shift', () => {
it('Should not close dialog', () => {
const editor = getJodit({
toolbarAdaptive: false,
buttons: 'symbols'
});

editor.value = '<p>test|</p>';
setCursorToChar(editor);

const btn = getButton('symbols', editor);

simulateEvent('click', btn);
let dialog = getOpenedDialog(editor);

const currentActive = dialog.getElementsByTagName('a')[5];

simulateEvent('mousedown', currentActive, function (data) {
data.shiftKey = true;
});

expect(editor.value).equals('<p>test&amp;</p>');

expect(getOpenedDialog(editor)).equals(dialog);

const currentActive2 =
dialog.getElementsByTagName('a')[125];

for (let i = 0; i < 3; i++) {
simulateEvent(
'mousedown',
currentActive2,
function (data) {
data.shiftKey = true;
}
);
}

expect(editor.value).equals('<p>test&amp;½½½</p>');
});
});
});
});

Expand Down
4 changes: 3 additions & 1 deletion src/plugins/symbols/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export class symbols extends Plugin {
if (Dom.isTag(this, 'a')) {
jodit.s.focus();
jodit.s.insertHTML(this.innerHTML);
jodit.e.fire(this, 'close_dialog');
if (!e?.shiftKey) {
jodit.e.fire(this, 'close_dialog');
}
e && e.preventDefault();
e && e.stopImmediatePropagation();
}
Expand Down

0 comments on commit 5fbc8bc

Please sign in to comment.