@zipify/wysiwyg 1.0.0-dev.96 → 1.0.0-dev.97

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/dist/wysiwyg.css CHANGED
@@ -851,17 +851,17 @@ to {
851
851
  position: relative;
852
852
  }
853
853
  .zw-margin-bottom--xxs {
854
- margin-bottom: var(--zw-offset-xxs);
854
+ margin-bottom: var(--zw-offset-xxs) !important;
855
855
  }
856
856
  .zw-margin-bottom--xs {
857
- margin-bottom: var(--zw-offset-xs);
857
+ margin-bottom: var(--zw-offset-xs) !important;
858
858
  }
859
859
  .zw-margin-bottom--sm {
860
- margin-bottom: var(--zw-offset-sm);
860
+ margin-bottom: var(--zw-offset-sm) !important;
861
861
  }
862
862
  .zw-margin-bottom--md {
863
- margin-bottom: var(--zw-offset-md);
863
+ margin-bottom: var(--zw-offset-md) !important;
864
864
  }
865
865
  .zw-margin-right--xs {
866
- margin-right: var(--zw-offset-xs);
866
+ margin-right: var(--zw-offset-xs) !important;
867
867
  }
package/dist/wysiwyg.mjs CHANGED
@@ -19455,6 +19455,7 @@ const _ContentNormalizer = class {
19455
19455
  }
19456
19456
  _normalizeTextContent() {
19457
19457
  this._dom = this._parser.parseFromString(this._content.replace(/(\r)?\n/g, ""), "text/html");
19458
+ this._removeComments();
19458
19459
  this._iterateNodes(this._normalizeBreakLines, (node) => node.tagName === "BR");
19459
19460
  this._iterateNodes(this._removeEmptyNodes, this._isBlockNode);
19460
19461
  this._iterateNodes(this._normalizeListItems, (node) => node.tagName === "LI");
@@ -19462,10 +19463,17 @@ const _ContentNormalizer = class {
19462
19463
  this._iterateNodes(this._normalizeStyles, (node) => node.tagName !== "SPAN");
19463
19464
  return this._dom.body.innerHTML;
19464
19465
  }
19466
+ _removeComments() {
19467
+ const iterator = this._dom.createNodeIterator(this._dom.body, NodeFilter.SHOW_COMMENT);
19468
+ this._runIterator(iterator, (node) => node.remove());
19469
+ }
19465
19470
  _iterateNodes(handler, condition = () => true) {
19466
19471
  const iterator = this._dom.createNodeIterator(this._dom.body, NodeFilter.SHOW_ELEMENT, {
19467
19472
  acceptNode: (node) => condition.call(this, node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
19468
19473
  });
19474
+ this._runIterator(iterator, handler);
19475
+ }
19476
+ _runIterator(iterator, handler) {
19469
19477
  let currentNode = iterator.nextNode();
19470
19478
  while (currentNode) {
19471
19479
  handler.call(this, currentNode);
@@ -40,6 +40,7 @@ export class ContentNormalizer {
40
40
  _normalizeTextContent() {
41
41
  this._dom = this._parser.parseFromString(this._content.replace(/(\r)?\n/g, ''), 'text/html');
42
42
 
43
+ this._removeComments();
43
44
  this._iterateNodes(this._normalizeBreakLines, (node) => node.tagName === 'BR');
44
45
  this._iterateNodes(this._removeEmptyNodes, this._isBlockNode);
45
46
  this._iterateNodes(this._normalizeListItems, (node) => node.tagName === 'LI');
@@ -49,10 +50,21 @@ export class ContentNormalizer {
49
50
  return this._dom.body.innerHTML;
50
51
  }
51
52
 
53
+ _removeComments() {
54
+ const iterator = this._dom.createNodeIterator(this._dom.body, NodeFilter.SHOW_COMMENT);
55
+
56
+ this._runIterator(iterator, (node) => node.remove());
57
+ }
58
+
52
59
  _iterateNodes(handler, condition = () => true) {
53
60
  const iterator = this._dom.createNodeIterator(this._dom.body, NodeFilter.SHOW_ELEMENT, {
54
61
  acceptNode: (node) => condition.call(this, node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
55
62
  });
63
+
64
+ this._runIterator(iterator, handler);
65
+ }
66
+
67
+ _runIterator(iterator, handler) {
56
68
  let currentNode = iterator.nextNode();
57
69
 
58
70
  while (currentNode) {
@@ -161,4 +161,11 @@ describe('normalize text content', () => {
161
161
 
162
162
  expect(ContentNormalizer.normalize(input)).toBe(output);
163
163
  });
164
+
165
+ test('should remove comments', () => {
166
+ const input = '<p>lorem ipsum</p><p style="color: red;">Hello <!-- world --></p>';
167
+ const output = '<p>lorem ipsum</p><p><span style="color: red;">Hello </span></p>';
168
+
169
+ expect(ContentNormalizer.normalize(input)).toBe(output);
170
+ });
164
171
  });
@@ -1,19 +1,19 @@
1
1
  .zw-margin-bottom--xxs {
2
- margin-bottom: var(--zw-offset-xxs);
2
+ margin-bottom: var(--zw-offset-xxs) !important;
3
3
  }
4
4
 
5
5
  .zw-margin-bottom--xs {
6
- margin-bottom: var(--zw-offset-xs);
6
+ margin-bottom: var(--zw-offset-xs) !important;
7
7
  }
8
8
 
9
9
  .zw-margin-bottom--sm {
10
- margin-bottom: var(--zw-offset-sm);
10
+ margin-bottom: var(--zw-offset-sm) !important;
11
11
  }
12
12
 
13
13
  .zw-margin-bottom--md {
14
- margin-bottom: var(--zw-offset-md);
14
+ margin-bottom: var(--zw-offset-md) !important;
15
15
  }
16
16
 
17
17
  .zw-margin-right--xs {
18
- margin-right: var(--zw-offset-xs);
18
+ margin-right: var(--zw-offset-xs) !important;
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "1.0.0-dev.96",
3
+ "version": "1.0.0-dev.97",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "repository": {