@mediafly/js-ui 51.2.1 → 51.2.2-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.
@@ -5,6 +5,12 @@ export default class RichTextService {
5
5
  constructor($sanitize: sanitize.ISanitizeService);
6
6
  /** Older versions of Quill rendered some things differently. Patch those up. */
7
7
  backwardsCompatibleHtml(html: string): string;
8
+ /**
9
+ * Transform <ul><li> into <ol><li data-list="bullet">,
10
+ * and <ol><li> into <ol><li data-list="ordered">
11
+ * accounting for any pattern of nested <ul> and <ol> tags.
12
+ */
13
+ fixBulletPoints(html: string): string;
8
14
  /**
9
15
  * Transform <font> tags from the old Quill editor into <span> tags, as used by the new editor.
10
16
  * Quill used to set fonts using <font color="#000000" face="Open Sans">
@@ -29,12 +29,120 @@ let RichTextService = class RichTextService {
29
29
  }
30
30
  /** Older versions of Quill rendered some things differently. Patch those up. */
31
31
  backwardsCompatibleHtml(html) {
32
+ console.log(`-----> backwardsCompatibleHtml (${html.length}) ${html}`);
32
33
  html = this.removeZeroWidthNoBreakSpaces(html);
34
+ console.log(`-----> after removeZeroWidthNoBreakSpaces (${html.length}) ${html}`);
33
35
  html = this.removeCursor(html);
36
+ console.log(`-----> after removeCursor (${html.length}) ${html}`);
34
37
  html = this.fixWrappingCursor(html);
38
+ console.log(`-----> after fixWrappingCursor (${html.length}) ${html}`);
35
39
  html = this.fixFontTags(html);
40
+ console.log(`-----> after fixFontTags (${html.length}) ${html}`);
41
+ html = this.fixBulletPoints(html);
36
42
  return html;
37
43
  }
44
+ /**
45
+ * Transform <ul><li> into <ol><li data-list="bullet">,
46
+ * and <ol><li> into <ol><li data-list="ordered">
47
+ * accounting for any pattern of nested <ul> and <ol> tags.
48
+ */
49
+ fixBulletPoints(html) {
50
+ console.log(`-----> fixBulletPoints`, html);
51
+ if (!html) {
52
+ return html;
53
+ }
54
+ let newHtml = '';
55
+ const olStartTag = `<ol`;
56
+ const olEndTag = `</ol>`;
57
+ const ulStartTag = `<ul`;
58
+ const ulEndTag = `</ul>`;
59
+ const liStartTag = `<li`;
60
+ const listStack = []; // Stack of <ol> and <ul> tags
61
+ let parsedLength = 0;
62
+ let currentListType;
63
+ while (parsedLength < html.length) {
64
+ console.log(`-----> parsedLength ${parsedLength}`);
65
+ // Find the start of the next <ol>, <ul> or <li> tag
66
+ const olStart = html.indexOf(olStartTag, parsedLength);
67
+ const ulStart = html.indexOf(ulStartTag, parsedLength);
68
+ const liStart = html.indexOf(liStartTag, parsedLength);
69
+ // Find what might be the end of the current list (or might be the end of a nested list)
70
+ let nextListEnd;
71
+ switch (currentListType) {
72
+ case 'ol':
73
+ nextListEnd = html.indexOf(olEndTag, parsedLength);
74
+ break;
75
+ case 'ul':
76
+ nextListEnd = html.indexOf(ulEndTag, parsedLength);
77
+ break;
78
+ default:
79
+ nextListEnd = -1;
80
+ break;
81
+ }
82
+ // Find which tag comes next
83
+ const nextItemPos = Math.min(olStart === -1 ? html.length : olStart, ulStart === -1 ? html.length : ulStart, liStart === -1 ? html.length : liStart, nextListEnd === -1 ? html.length : nextListEnd);
84
+ newHtml += html.substring(parsedLength, nextItemPos);
85
+ parsedLength = nextItemPos;
86
+ switch (nextItemPos) {
87
+ case olStart:
88
+ case ulStart:
89
+ // We've found the start of a list
90
+ newHtml += `<ol>`;
91
+ const listTagEnd = html.indexOf('>', nextItemPos);
92
+ console.log(`-----> listTagEnd ${listTagEnd}`);
93
+ if (listTagEnd === -1) {
94
+ // Invalid HTML. Dump the lot.
95
+ return '';
96
+ }
97
+ parsedLength = listTagEnd + 1;
98
+ if (nextItemPos === olStart) {
99
+ listStack.push('ol');
100
+ currentListType = 'ol';
101
+ console.log(`-----> push ol`);
102
+ }
103
+ else {
104
+ listStack.push('ul');
105
+ currentListType = 'ul';
106
+ console.log(`-----> push ul`);
107
+ }
108
+ break;
109
+ case liStart:
110
+ // We've found a list item
111
+ if (!currentListType) {
112
+ // Invalid HTML. Dump the lot.
113
+ return '';
114
+ }
115
+ const liTagEnd = html.indexOf('>', liStart + 1);
116
+ if (liTagEnd === -1) {
117
+ // Invalid HTML. Dump the lot.
118
+ return '';
119
+ }
120
+ let liTag = html.substring(liStart, liTagEnd + 1);
121
+ if (liTag.indexOf('data-list') === -1) {
122
+ const dataAttr = ` data-list="${currentListType === 'ol' ? 'ordered' : 'bullet'}"`;
123
+ liTag = `<li${dataAttr}` + liTag.substring(3);
124
+ }
125
+ newHtml += liTag;
126
+ parsedLength = liTagEnd + 1;
127
+ break;
128
+ case nextListEnd:
129
+ // We've reached the end of the current list. Write out the closing tag and pop the stack
130
+ newHtml += olEndTag;
131
+ parsedLength = nextListEnd + olEndTag.length;
132
+ console.log(`-----> pop ${listStack[listStack.length - 1]}`);
133
+ listStack.pop();
134
+ currentListType = listStack[listStack.length - 1];
135
+ console.log(`-----> (now in ${currentListType})`);
136
+ break;
137
+ }
138
+ }
139
+ if (listStack.length > 0) {
140
+ // We didn't close the last list. Invalid HTML. Dump the lot.
141
+ return '';
142
+ }
143
+ console.log(`-----> newHtml`, newHtml);
144
+ return newHtml;
145
+ }
38
146
  /**
39
147
  * Transform <font> tags from the old Quill editor into <span> tags, as used by the new editor.
40
148
  * Quill used to set fonts using <font color="#000000" face="Open Sans">
@@ -135,9 +243,14 @@ let RichTextService = class RichTextService {
135
243
  }
136
244
  /** Clean up the HTML, ready for save */
137
245
  sanitizeHtml(html) {
246
+ console.log(`-----> -------------`);
247
+ console.log(`-----> html initial (${html.length}) ${html}`);
138
248
  html = this.removeZeroWidthNoBreakSpaces(html);
249
+ console.log(`-----> after removeZeroWidthNoBreakSpaces (${html.length}) ${html}`);
139
250
  html = this.removeCursor(html);
251
+ console.log(`-----> after removeCursor (${html.length}) ${html}`);
140
252
  html = this.$sanitize(html);
253
+ console.log(`-----> after $sanitize (${html.length}) ${html}`);
141
254
  return html;
142
255
  }
143
256
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text.service.js","sourceRoot":"","sources":["../../src/components/rich-text/rich-text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,EAAE;YACV,OAAO,IAAI,CAAA;SACX;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,yCAAyC,EAAE,EAAE,CAAC,CAAA;IACnE,CAAC;IAED,uDAAuD;IACvD,4BAA4B,CAAC,IAAY;QAExC,IAAI,CAAC,IAAI,EAAE;YACV,OAAO,IAAI,CAAA;SACX;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAED,wCAAwC;IACxC,YAAY,CAAC,IAAY;QAExB,IAAI,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAA;QAC9C,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QAC9B,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAE3B,OAAO,IAAI,CAAA;IACZ,CAAC;CAED,CAAA;AAjJoB,eAAe;IADnC,uBAAU,CAAC,iBAAiB,CAAC;IAI3B,WAAA,mBAAM,CAAC,WAAW,CAAC,CAAA;;GAHD,eAAe,CAiJnC;kBAjJoB,eAAe"}
1
+ {"version":3,"file":"rich-text.service.js","sourceRoot":"","sources":["../../src/components/rich-text/rich-text.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sDAA2C;AAC3C,8CAAkD;AAElD,8GAA8G;AAC9G,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,mBAAmB,EAAE,CAAC,iBAAgD,EAAE,EAAE;QACvG,iBAAiB,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;QAE1C,0GAA0G;QAC1G,iBAAiB,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;IAC/C,CAAC,CAAC,CAAC,CAAA;AAGH,IAAqB,eAAe,GAApC,MAAqB,eAAe;IAEnC,YAC8B,SAAoC;QAApC,cAAS,GAAT,SAAS,CAA2B;IAC9D,CAAC;IAEL,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eAAe"}
@@ -1297,8 +1297,8 @@
1297
1297
  "affectsGlobalScope": false
1298
1298
  },
1299
1299
  "../node_modules/quill/core/module.d.ts": {
1300
- "version": "1fa363695d7a5633ca82cce91c93cc9e7b4972a751a9983b0660c3cd0265787d",
1301
- "signature": "1fa363695d7a5633ca82cce91c93cc9e7b4972a751a9983b0660c3cd0265787d",
1300
+ "version": "d63b8f8ee9d8be8da2b7c8320b6238687d5c6b4c2fff451656a76675ce02b0fa",
1301
+ "signature": "d63b8f8ee9d8be8da2b7c8320b6238687d5c6b4c2fff451656a76675ce02b0fa",
1302
1302
  "affectsGlobalScope": false
1303
1303
  },
1304
1304
  "../node_modules/quill/blots/embed.d.ts": {
@@ -1352,8 +1352,8 @@
1352
1352
  "affectsGlobalScope": false
1353
1353
  },
1354
1354
  "../node_modules/quill/modules/toolbar.d.ts": {
1355
- "version": "2589c2de539ffb71312229513d47d63843bc72213c4174af4c543cf99b8fdede",
1356
- "signature": "2589c2de539ffb71312229513d47d63843bc72213c4174af4c543cf99b8fdede",
1355
+ "version": "41531d66ecc0d7b8b6511b013597170807bb3862dd94a4a6c32dd831d83a26a2",
1356
+ "signature": "41531d66ecc0d7b8b6511b013597170807bb3862dd94a4a6c32dd831d83a26a2",
1357
1357
  "affectsGlobalScope": false
1358
1358
  },
1359
1359
  "../node_modules/quill/core/theme.d.ts": {
@@ -1367,23 +1367,23 @@
1367
1367
  "affectsGlobalScope": false
1368
1368
  },
1369
1369
  "../node_modules/quill/core/quill.d.ts": {
1370
- "version": "f532b3b3df9d5c950b8c952a350df4361b9acac8ea552172f56387b3a067b1bd",
1371
- "signature": "f532b3b3df9d5c950b8c952a350df4361b9acac8ea552172f56387b3a067b1bd",
1370
+ "version": "27805c27fe815e9311d06d4b489965662d197ce055be3224e0890d0511ffbefc",
1371
+ "signature": "27805c27fe815e9311d06d4b489965662d197ce055be3224e0890d0511ffbefc",
1372
1372
  "affectsGlobalScope": false
1373
1373
  },
1374
1374
  "../node_modules/quill/core.d.ts": {
1375
- "version": "0a258caef8e04ec13e4bdbc3daad6f3457088a97ab34564488dc304cba8c1395",
1376
- "signature": "0a258caef8e04ec13e4bdbc3daad6f3457088a97ab34564488dc304cba8c1395",
1375
+ "version": "3668fab5115de694079d3c99f07dcee9ec461910d5c2710aa6e41684a37f494f",
1376
+ "signature": "3668fab5115de694079d3c99f07dcee9ec461910d5c2710aa6e41684a37f494f",
1377
1377
  "affectsGlobalScope": false
1378
1378
  },
1379
1379
  "../node_modules/quill/quill.d.ts": {
1380
- "version": "caffa9bae19fb2e9a234363be7bd665c4fd4db699a3f5d1f68f11494682269af",
1381
- "signature": "caffa9bae19fb2e9a234363be7bd665c4fd4db699a3f5d1f68f11494682269af",
1380
+ "version": "4abcf2cd22461f6a1a47f413a39b36a72ec2ae701ceaadb88fa76e923f720152",
1381
+ "signature": "4abcf2cd22461f6a1a47f413a39b36a72ec2ae701ceaadb88fa76e923f720152",
1382
1382
  "affectsGlobalScope": false
1383
1383
  },
1384
1384
  "../src/components/rich-text/rich-text.service.ts": {
1385
- "version": "0bc07cb7ed1ba52cafd0c0b1b45345d84ee18386d13f0517fe8905966f7e4746",
1386
- "signature": "90e3c7c57ec4c9dcbe75bc82118788f36ca4266ed86ce71fea4239435bffc687",
1385
+ "version": "d2f18d62b9f7f3e9d60bc2f511cc18d822acb4741b57eaf1e2644c1c4251bd2e",
1386
+ "signature": "058d8cb2e2cfdc94bd15180d80ef5d04ed10d3f1d2e1b12fb3ddcc81b6f9f35c",
1387
1387
  "affectsGlobalScope": false
1388
1388
  },
1389
1389
  "../src/components/rich-text/rich-text.component.ts": {
@@ -3332,6 +3332,7 @@
3332
3332
  ],
3333
3333
  "../node_modules/quill/core.d.ts": [
3334
3334
  "../node_modules/quill-delta/dist/delta.d.ts",
3335
+ "../node_modules/quill/core/module.d.ts",
3335
3336
  "../node_modules/quill/core/quill.d.ts"
3336
3337
  ],
3337
3338
  "../node_modules/quill/core/composition.d.ts": [
@@ -5186,6 +5187,7 @@
5186
5187
  ],
5187
5188
  "../node_modules/quill/core.d.ts": [
5188
5189
  "../node_modules/quill-delta/dist/delta.d.ts",
5190
+ "../node_modules/quill/core/module.d.ts",
5189
5191
  "../node_modules/quill/core/quill.d.ts"
5190
5192
  ],
5191
5193
  "../node_modules/quill/core/composition.d.ts": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediafly/js-ui",
3
- "version": "51.2.1",
3
+ "version": "51.2.2-0",
4
4
  "license": "UNLICENSED",
5
5
  "description": "UI components for Mediafly Angular applications",
6
6
  "repository": {
@@ -19,14 +19,146 @@ export default class RichTextService {
19
19
  /** Older versions of Quill rendered some things differently. Patch those up. */
20
20
  backwardsCompatibleHtml(html: string): string {
21
21
 
22
+ console.log(`-----> backwardsCompatibleHtml (${html.length}) ${html}`)
22
23
  html = this.removeZeroWidthNoBreakSpaces(html)
24
+ console.log(`-----> after removeZeroWidthNoBreakSpaces (${html.length}) ${html}`)
23
25
  html = this.removeCursor(html)
26
+ console.log(`-----> after removeCursor (${html.length}) ${html}`)
24
27
  html = this.fixWrappingCursor(html)
28
+ console.log(`-----> after fixWrappingCursor (${html.length}) ${html}`)
25
29
  html = this.fixFontTags(html)
30
+ console.log(`-----> after fixFontTags (${html.length}) ${html}`)
31
+ html = this.fixBulletPoints(html)
26
32
 
27
33
  return html
28
34
  }
29
35
 
36
+ /**
37
+ * Transform <ul><li> into <ol><li data-list="bullet">,
38
+ * and <ol><li> into <ol><li data-list="ordered">
39
+ * accounting for any pattern of nested <ul> and <ol> tags.
40
+ */
41
+ fixBulletPoints(html: string): string {
42
+
43
+ console.log(`-----> fixBulletPoints`, html)
44
+
45
+ if (!html) {
46
+ return html
47
+ }
48
+
49
+ let newHtml: string = ''
50
+
51
+ const olStartTag = `<ol`
52
+ const olEndTag = `</ol>`
53
+ const ulStartTag = `<ul`
54
+ const ulEndTag = `</ul>`
55
+ const liStartTag = `<li`
56
+
57
+ const listStack: string[] = [] // Stack of <ol> and <ul> tags
58
+
59
+ let parsedLength = 0
60
+ let currentListType: string | undefined
61
+ while (parsedLength < html.length) {
62
+ console.log(`-----> parsedLength ${parsedLength}`)
63
+
64
+ // Find the start of the next <ol>, <ul> or <li> tag
65
+ const olStart = html.indexOf(olStartTag, parsedLength)
66
+ const ulStart = html.indexOf(ulStartTag, parsedLength)
67
+ const liStart = html.indexOf(liStartTag, parsedLength)
68
+
69
+ // Find what might be the end of the current list (or might be the end of a nested list)
70
+ let nextListEnd: number
71
+ switch (currentListType) {
72
+ case 'ol':
73
+ nextListEnd = html.indexOf(olEndTag, parsedLength)
74
+ break
75
+ case 'ul':
76
+ nextListEnd = html.indexOf(ulEndTag, parsedLength)
77
+ break
78
+ default:
79
+ nextListEnd = -1
80
+ break
81
+ }
82
+
83
+ // Find which tag comes next
84
+ const nextItemPos = Math.min(
85
+ olStart === -1 ? html.length : olStart,
86
+ ulStart === -1 ? html.length : ulStart,
87
+ liStart === -1 ? html.length : liStart,
88
+ nextListEnd === -1 ? html.length : nextListEnd)
89
+
90
+ newHtml += html.substring(parsedLength, nextItemPos)
91
+ parsedLength = nextItemPos
92
+
93
+ switch (nextItemPos) {
94
+ case olStart:
95
+ case ulStart:
96
+ // We've found the start of a list
97
+ newHtml += `<ol>`
98
+
99
+ const listTagEnd = html.indexOf('>', nextItemPos)
100
+ console.log(`-----> listTagEnd ${listTagEnd}`)
101
+ if (listTagEnd === -1) {
102
+ // Invalid HTML. Dump the lot.
103
+ return ''
104
+ }
105
+ parsedLength = listTagEnd + 1
106
+
107
+ if (nextItemPos === olStart) {
108
+ listStack.push('ol')
109
+ currentListType = 'ol'
110
+ console.log(`-----> push ol`)
111
+ } else {
112
+ listStack.push('ul')
113
+ currentListType = 'ul'
114
+ console.log(`-----> push ul`)
115
+ }
116
+ break
117
+
118
+ case liStart:
119
+ // We've found a list item
120
+ if (!currentListType) {
121
+ // Invalid HTML. Dump the lot.
122
+ return ''
123
+ }
124
+
125
+ const liTagEnd = html.indexOf('>', liStart + 1)
126
+ if (liTagEnd === -1) {
127
+ // Invalid HTML. Dump the lot.
128
+ return ''
129
+ }
130
+ let liTag = html.substring(liStart, liTagEnd + 1)
131
+
132
+ if (liTag.indexOf('data-list') === -1) {
133
+ const dataAttr = ` data-list="${currentListType === 'ol' ? 'ordered' : 'bullet'}"`
134
+ liTag = `<li${dataAttr}` + liTag.substring(3)
135
+ }
136
+
137
+ newHtml += liTag
138
+ parsedLength = liTagEnd + 1
139
+ break
140
+
141
+ case nextListEnd:
142
+ // We've reached the end of the current list. Write out the closing tag and pop the stack
143
+ newHtml += olEndTag
144
+ parsedLength = nextListEnd + olEndTag.length
145
+ console.log(`-----> pop ${listStack[listStack.length - 1]}`)
146
+ listStack.pop()
147
+ currentListType = listStack[listStack.length - 1]
148
+ console.log(`-----> (now in ${currentListType})`)
149
+ break
150
+ }
151
+ }
152
+
153
+ if (listStack.length > 0) {
154
+ // We didn't close the last list. Invalid HTML. Dump the lot.
155
+ return ''
156
+ }
157
+
158
+ console.log(`-----> newHtml`, newHtml)
159
+ return newHtml
160
+ }
161
+
30
162
  /**
31
163
  * Transform <font> tags from the old Quill editor into <span> tags, as used by the new editor.
32
164
  * Quill used to set fonts using <font color="#000000" face="Open Sans">
@@ -148,9 +280,14 @@ export default class RichTextService {
148
280
  /** Clean up the HTML, ready for save */
149
281
  sanitizeHtml(html: string): string {
150
282
 
283
+ console.log(`-----> -------------`)
284
+ console.log(`-----> html initial (${html.length}) ${html}`)
151
285
  html = this.removeZeroWidthNoBreakSpaces(html)
286
+ console.log(`-----> after removeZeroWidthNoBreakSpaces (${html.length}) ${html}`)
152
287
  html = this.removeCursor(html)
288
+ console.log(`-----> after removeCursor (${html.length}) ${html}`)
153
289
  html = this.$sanitize(html)
290
+ console.log(`-----> after $sanitize (${html.length}) ${html}`)
154
291
 
155
292
  return html
156
293
  }