leksy-editor 2.3.1 → 2.4.0

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.
package/constant.js CHANGED
@@ -1,5 +1,43 @@
1
1
  const WHILE_LISTED_TAG = "br|p|div|pre|blockquote|h|h1|h2|h3|h4|h5|h6|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|source|table|thead|tbody|tr|th|td|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code|svg|path|details|summary|font|article|section|main|header|footer|aside|mark|cite|abbr|dfn|nav|caption|picture|dl|dt|dd|time|label|kbd|samp|wbr";
2
2
  const WHILE_LISTED_ATTRIBUTES = "align|alt|bgcolor|border|cellpadding|cellspacing|color|colspan|contenteditable|dir|download|face|height|href|lang|name|rowspan|size|src|style|target|title|valign|width|background|media|sizes|srcset|spellcheck";
3
+ const BLOCKED_STYLES = [
4
+ "position",
5
+ "inset",
6
+ "top",
7
+ "right",
8
+ "bottom",
9
+ "left",
10
+ "z-index",
11
+ "float",
12
+ "clear",
13
+ "overflow",
14
+ "overflow-x",
15
+ "overflow-y",
16
+ "transform",
17
+ "transform-origin",
18
+ "perspective",
19
+ "transition",
20
+ "transition-property",
21
+ "transition-duration",
22
+ "transition-timing-function",
23
+ "transition-delay",
24
+ "animation",
25
+ "animation-name",
26
+ "animation-duration",
27
+ "animation-timing-function",
28
+ "animation-delay",
29
+ "animation-iteration-count",
30
+ "animation-direction",
31
+ "animation-fill-mode",
32
+ "animation-play-state",
33
+ "flex-basis",
34
+ "flex-grow",
35
+ "flex-shrink",
36
+ "order",
37
+ "place-self",
38
+ "grid-column",
39
+ "grid-row",
40
+ ].join("|")
3
41
 
4
42
  const REGEX = {
5
43
  TEXT_URL: /(https?:\/\/[^\s]+|www\.[^\s]+)$/i,
@@ -10,6 +48,7 @@ const REGEX = {
10
48
  MOBILE: /^\+?[0-9\s()-]+$/,
11
49
  WHILE_LISTED_TAG: new RegExp('^(' + WHILE_LISTED_TAG.replace(/\|/g, '\\b|\\b') + ')$', 'i'),
12
50
  WHILE_LISTED_ATTRIBUTES: new RegExp('^(' + WHILE_LISTED_ATTRIBUTES.replace(/\|/g, '\\b|\\b') + ')$', 'i'),
51
+ BLOCKED_STYLES: new RegExp('^(' + BLOCKED_STYLES.replace(/\|/g, '\\b|\\b') + ')$', 'i'),
13
52
  }
14
53
 
15
54
  const ERRORS = {
@@ -923,4 +962,4 @@ export {
923
962
  UNORDERED_LIST_STYLES_BY_LEVEL,
924
963
  UNORDERED_LIST_OPTIONS,
925
964
  ORDERED_LIST_OPTIONS,
926
- }
965
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leksy-editor",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "Leksy Editor is an alternative to traditional WYSIWYG editors, designed primarily for creating mail templates, blogs, and documents without any content manipulation.",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -21,6 +21,6 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "diff-dom": "5.2.0",
24
- "uuid": "13.0.0"
24
+ "uuid": "13.0.2"
25
25
  }
26
26
  }
package/utilities.js CHANGED
@@ -6,6 +6,21 @@ import { findTab } from "./tab";
6
6
 
7
7
  const dd = new DiffDOM();
8
8
 
9
+ const removeBlockedStyles = (node) => {
10
+ if (!node?.style) return;
11
+ const styleProperties = Array.from(node.style);
12
+
13
+ styleProperties.forEach((propertyName) => {
14
+ if (REGEX.BLOCKED_STYLES.test(propertyName)) {
15
+ node.style.removeProperty(propertyName);
16
+ }
17
+ });
18
+
19
+ if (!node.getAttribute('style')?.trim()) {
20
+ node.removeAttribute('style');
21
+ }
22
+ }
23
+
9
24
  const traverseAndClean = (element, options, core) => {
10
25
  if (!element?.childNodes) return;
11
26
 
@@ -51,6 +66,7 @@ const traverseAndClean = (element, options, core) => {
51
66
  node.style.removeProperty('background-color');
52
67
  node.style.removeProperty('color');
53
68
  }
69
+ removeBlockedStyles(node);
54
70
  attributesToRemove.forEach(attr => node.removeAttribute(attr));
55
71
 
56
72
  // Process child nodes
@@ -4070,4 +4086,4 @@ export {
4070
4086
  highlightActiveOutline,
4071
4087
  findAndReplace,
4072
4088
  handleBackspaceInList,
4073
- }
4089
+ }