Skip to content

Commit

Permalink
New version 4.0.6 Read more https://github.com/xdan/jodit/blob/main/C…
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Jan 17, 2024
1 parent 62e8841 commit b8864b9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jodit",
"version": "4.0.5",
"version": "4.0.6",
"description": "Jodit is awesome and usefully wysiwyg editor with filebrowser",
"main": "build/jodit.min.js",
"types": "./types/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/core/selection/selection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,9 @@ describe('Selection Module Tests', function () {
setCursorToChar(jodit);
jodit.s.expandSelection();
replaceCursorToChar(jodit);
expect(sortAttributes(jodit.value)).eq(result);
expect(sortAttributes(jodit.value, ['contenteditable'])).eq(
sortAttributes(result, ['contenteditable'])
);
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/delete/delete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ describe('Delete plugin', () => {
editor.editor
);

expect(sortAttributes(editor.value)).equals(
sortAttributes(result)
);
expect(
sortAttributes(editor.value, ['contenteditable'])
).equals(sortAttributes(result, ['contenteditable']));
});
});
});
Expand Down
15 changes: 11 additions & 4 deletions test/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ function sortStyles(matches) {
return styles.join(';');
}

function sortAttributes(html) {
function sortAttributes(html, excludeAttr = []) {
const tag = /<([^>]+)>/g;
const reg = /([a-z_-]+)[\s]*=[\s]*"([^"]*)"/i,
tags = [];
Expand All @@ -663,13 +663,20 @@ function sortAttributes(html) {
break;
}

if (matches[1].toLowerCase() === 'style') {
const attributeName = matches[1].toLowerCase();

if (excludeAttr.includes(attributeName)) {
newTag = newTag.replace(matches[0], '');
continue;
}

if (attributeName === 'style') {
matches[2] = sortStyles(matches[2]);
}

if (matches[1].toLowerCase() !== 'unselectable') {
if (attributeName !== 'unselectable') {
attrs.push({
name: matches[1].toLowerCase(),
name: attributeName,
value: matches[2]
});

Expand Down

0 comments on commit b8864b9

Please sign in to comment.