Skip to content

Commit

Permalink
Merge pull request #911 from xdan/commit-styles
Browse files Browse the repository at this point in the history
Commit styles
  • Loading branch information
xdan authored Dec 17, 2022
2 parents b9ac6f3 + fce84e2 commit 789974a
Show file tree
Hide file tree
Showing 66 changed files with 2,307 additions and 923 deletions.
70 changes: 65 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,66 @@
> - :house: [Internal]
> - :nail_care: [Polish]
## 3.24.1

#### :boom: Breaking Change

- Constant array `MAY_BE_REMOVED_WITH_KEY` was replaced on set `INSEPARABLE_TAGS`

#### :rocket: New Feature

- Method `Select.applyStyle` marked as deprecated. Use `Select.commitStyle` instead.

Before:

```js
jodit.select.applyStyle(
{ color: red },
{
element: 'strong'
}
);
```

Now:

```js
jodit.s.commitStyle({
element: 'strong',
attributes: {
style: {
color: 'red'
}
}
});
```

- In the options of the `Select`.`commitStyle` method, the `attributes` property has been added, which allows you to
also set attributes when applying a style.

```js
jodit.s.commitStyle({
element: 'a',
attributes: {
href: 'https://stename.ru'
}
});
```

Wraps the selected text into a link with the specified address.

- When inserting a url, if the text is selected, it will automatically be replaced with a link

- In Tab plugin allow use shift+tab for lists

#### :bug: Bug Fix

- [Safari custom color picker errors out on browser check #906](https://github.com/xdan/jodit/issues/906)

#### :house: Internal

- Fixed deletion of the asserts function from the production code, instead of regular expressions, transformers are used\*\*\*\*

## 3.23.3

#### :rocket: New Feature
Expand Down Expand Up @@ -1824,11 +1884,11 @@ Related with https://github.com/xdan/jodit/issues/574. In some cases need to lim
- @property {IUIOption[]} link.selectOptionsClassName=[] The list of the option for the select (to use with
modeClassName="select")
- ex: [
- { value: "", text: "" },
- { value: "val1", text: "text1" },
- { value: "val2", text: "text2" },
- { value: "val3", text: "text3" }
- ]
- { value: "", text: "" },
- { value: "val1", text: "text1" },
- { value: "val2", text: "text2" },
- { value: "val3", text: "text3" }
- ]
PR: https://github.com/xdan/jodit/pull/577 Thanks @s-renier-taonix-fr
##### New option `statusbar: boolean = true`
Expand Down
9 changes: 0 additions & 9 deletions build-system/loaders/change-asserts.js

This file was deleted.

8 changes: 6 additions & 2 deletions build-system/rules/extra-typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
*/

const path = require('path');
const { removeAsserts } = require('../utils/remove-asserts');

module.exports = ({ ES, superDirname }) => {
module.exports = ({ ES, superDirname, isProd, isTest }) => {
return {
test: /\.(js|ts)$/,
loader: 'ts-loader',
Expand All @@ -15,7 +16,10 @@ module.exports = ({ ES, superDirname }) => {
allowTsInNodeModules: true,
compilerOptions: {
target: ES
}
},
getCustomTransformers: () => ({
before: isProd && !isTest ? [removeAsserts()] : []
})
},
include: [path.resolve(superDirname, './node_modules')]
};
Expand Down
19 changes: 6 additions & 13 deletions build-system/rules/internal-typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

const path = require('path');
const { removeAsserts } = require('../utils/remove-asserts');

module.exports = ({ superDirname, uglify, ES, isProd, isTest }) => {
return {
Expand All @@ -17,21 +18,13 @@ module.exports = ({ superDirname, uglify, ES, isProd, isTest }) => {
allowTsInNodeModules: true,
compilerOptions: {
target: ES
}
},
getCustomTransformers: () => ({
before: isProd && !isTest ? [removeAsserts()] : []
})
}
}
].concat(
isProd && !isTest
? [
{
loader: path.resolve(
__dirname,
'../loaders/change-asserts.js'
)
}
]
: []
),
],
include: [path.resolve(superDirname, './src/')],
exclude: [/langs\/[a-z]{2}\.ts/, /langs\/[a-z]{2}_[a-z]{2}\.ts/]
};
Expand Down
3 changes: 2 additions & 1 deletion build-system/utils/find-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const glob = require('glob');
const path = require('path');
const fs = require('fs');

const dir = path.resolve(__dirname, '../../') + '/';
const dir = path.resolve(process.cwd()) + '/';
console.log('Find directory:', dir);

const list = [];
// options is optional
Expand Down
26 changes: 26 additions & 0 deletions build-system/utils/remove-asserts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/

const ts = require('typescript');

module.exports.removeAsserts = function removeAsserts(
names = new Set(['assert'])
) {
return ctx => {
const visitor = node => {
if (
ts.isCallExpression(node) &&
names.has(node.expression.getText())
) {
return ts.factory.createVoidZero();
}

return ts.visitEachChild(node, visitor, ctx);
};

return file => ts.visitEachChild(file, visitor, ctx);
};
};
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": "3.23.3",
"version": "3.24.0",
"description": "Jodit is awesome and usefully wysiwyg editor with filebrowser",
"main": "build/jodit.min.js",
"types": "./types/index.d.ts",
Expand Down
18 changes: 10 additions & 8 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @module constants
*/

import type { IDictionary } from 'jodit/types';
import type { HTMLTagNames, IDictionary } from 'jodit/types';

export const INVISIBLE_SPACE = '\uFEFF';
export const NBSP_SPACE = '\u00A0';
Expand All @@ -25,24 +25,26 @@ export const IS_BLOCK =

export const IS_INLINE = /^(STRONG|SPAN|I|EM|B|SUP|SUB|A|U)$/i;

export const INSEPARABLE_TAGS: Array<keyof HTMLElementTagNameMap> = [
const __UNSEPARABLE_TAGS: HTMLTagNames[] = [
'img',
'br',
'video',
'svg',
'iframe',
'script',
'input',
'textarea',
'hr',
'link',
'jodit',
'jodit-media'
];

export const MAY_BE_REMOVED_WITH_KEY = RegExp(
`^${INSEPARABLE_TAGS.join('|')}$`,
'i'
);
export const INSEPARABLE_TAGS: Set<HTMLTagNames> = new Set([
...__UNSEPARABLE_TAGS,
'br',
'hr'
]);

export const NO_EMPTY_TAGS: Set<HTMLTagNames> = new Set(__UNSEPARABLE_TAGS);

export const KEY_META = 'Meta';
export const KEY_BACKSPACE = 'Backspace';
Expand Down
25 changes: 25 additions & 0 deletions src/core/dom/dom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,21 @@ describe('Test Dom module', function () {
});
});

describe('Method isTag', () => {
it('Should return true then element is same tag', () => {
for (const tag of ['div', 'span', 'p', 'img']) {
const div = document.createElement(tag);
expect(Dom.isTag(div, new Set([tag]))).is.true;
expect(Dom.isTag(div, new Set([tag.toUpperCase()]))).is.true;
expect(Dom.isTag(div, [tag])).is.true;
expect(Dom.isTag(div, tag)).is.true;
expect(Dom.isTag(div, tag.toUpperCase())).is.true;
expect(Dom.isTag(div, 'br')).is.false;
expect(Dom.isTag(div, ['br'])).is.false;
}
});
});

describe('Method isEmpty', function () {
it('Should return true then element is empty', function () {
expect(true).equals(Dom.isEmpty(document.createElement('div')));
Expand All @@ -236,6 +251,7 @@ describe('Test Dom module', function () {

expect(true).equals(Dom.isEmpty(node));
});

it('Should return false then element is not empty', function () {
expect(false).equals(Dom.isEmpty(document.documentElement));
expect(false).equals(Dom.isEmpty(document.createTextNode('test')));
Expand All @@ -250,6 +266,15 @@ describe('Test Dom module', function () {

expect(false).equals(Dom.isEmpty(node));
});

describe('Own second argument', function () {
it('Should return true then element is empty', () => {
const node = document.createElement('div');
node.innerHTML = '<ul>' + '<li><img></li>' + '</ul>';

expect(Dom.isEmpty(node, new Set([]))).is.true;
});
});
});

describe('Method isOrContains', function () {
Expand Down
Loading

0 comments on commit 789974a

Please sign in to comment.