@textbus/platform-browser 3.4.5 → 3.4.8

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.
@@ -98,6 +98,7 @@ export declare class Parser {
98
98
  */
99
99
  parse(html: string, rootSlot: Slot): Slot<any>;
100
100
  private readComponent;
101
+ private readText;
101
102
  private readFormats;
102
103
  private readSlot;
103
104
  private applyFormats;
@@ -1280,12 +1280,15 @@ let Parser = Parser_1 = class Parser {
1280
1280
  this.readFormats(el, slot);
1281
1281
  }
1282
1282
  else if (el.nodeType === Node.TEXT_NODE) {
1283
- const textContent = el.textContent;
1284
- if (/^\s*[\r\n\u200b]+\s*$/.test(textContent)) {
1285
- return;
1286
- }
1287
- slot.insert(textContent);
1283
+ this.readText(slot, el);
1284
+ }
1285
+ }
1286
+ readText(slot, el) {
1287
+ const textContent = el.textContent;
1288
+ if (/^\s*[\r\n\u200b]+\s*$/.test(textContent)) {
1289
+ return;
1288
1290
  }
1291
+ slot.insert(textContent);
1289
1292
  }
1290
1293
  readFormats(el, slot) {
1291
1294
  const formats = this.formatLoaders.filter(f => {
@@ -1312,13 +1315,20 @@ let Parser = Parser_1 = class Parser {
1312
1315
  return slot;
1313
1316
  }
1314
1317
  readSlot(childSlot, slotRootElement, slotContentElement) {
1315
- this.attributeLoaders.filter(a => {
1316
- return a.match(slotRootElement);
1317
- }).forEach(a => {
1318
- const r = a.read(slotRootElement);
1319
- childSlot.setAttribute(r.attribute, r.value);
1320
- });
1321
- this.readFormats(slotContentElement, childSlot);
1318
+ if (slotRootElement.nodeType === Node.ELEMENT_NODE) {
1319
+ this.attributeLoaders.filter(a => {
1320
+ return a.match(slotRootElement);
1321
+ }).forEach(a => {
1322
+ const r = a.read(slotRootElement);
1323
+ childSlot.setAttribute(r.attribute, r.value);
1324
+ });
1325
+ }
1326
+ if (slotContentElement.nodeType === Node.ELEMENT_NODE) {
1327
+ this.readFormats(slotContentElement, childSlot);
1328
+ }
1329
+ else {
1330
+ this.readText(childSlot, slotContentElement);
1331
+ }
1322
1332
  return childSlot;
1323
1333
  }
1324
1334
  applyFormats(slot, formatItems) {
package/bundles/index.js CHANGED
@@ -1282,12 +1282,15 @@ exports.Parser = Parser_1 = class Parser {
1282
1282
  this.readFormats(el, slot);
1283
1283
  }
1284
1284
  else if (el.nodeType === Node.TEXT_NODE) {
1285
- const textContent = el.textContent;
1286
- if (/^\s*[\r\n\u200b]+\s*$/.test(textContent)) {
1287
- return;
1288
- }
1289
- slot.insert(textContent);
1285
+ this.readText(slot, el);
1286
+ }
1287
+ }
1288
+ readText(slot, el) {
1289
+ const textContent = el.textContent;
1290
+ if (/^\s*[\r\n\u200b]+\s*$/.test(textContent)) {
1291
+ return;
1290
1292
  }
1293
+ slot.insert(textContent);
1291
1294
  }
1292
1295
  readFormats(el, slot) {
1293
1296
  const formats = this.formatLoaders.filter(f => {
@@ -1314,13 +1317,20 @@ exports.Parser = Parser_1 = class Parser {
1314
1317
  return slot;
1315
1318
  }
1316
1319
  readSlot(childSlot, slotRootElement, slotContentElement) {
1317
- this.attributeLoaders.filter(a => {
1318
- return a.match(slotRootElement);
1319
- }).forEach(a => {
1320
- const r = a.read(slotRootElement);
1321
- childSlot.setAttribute(r.attribute, r.value);
1322
- });
1323
- this.readFormats(slotContentElement, childSlot);
1320
+ if (slotRootElement.nodeType === Node.ELEMENT_NODE) {
1321
+ this.attributeLoaders.filter(a => {
1322
+ return a.match(slotRootElement);
1323
+ }).forEach(a => {
1324
+ const r = a.read(slotRootElement);
1325
+ childSlot.setAttribute(r.attribute, r.value);
1326
+ });
1327
+ }
1328
+ if (slotContentElement.nodeType === Node.ELEMENT_NODE) {
1329
+ this.readFormats(slotContentElement, childSlot);
1330
+ }
1331
+ else {
1332
+ this.readText(childSlot, slotContentElement);
1333
+ }
1324
1334
  return childSlot;
1325
1335
  }
1326
1336
  applyFormats(slot, formatItems) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "3.4.5",
3
+ "version": "3.4.8",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -48,5 +48,5 @@
48
48
  "bugs": {
49
49
  "url": "https://github.com/textbus/textbus.git/issues"
50
50
  },
51
- "gitHead": "81634d5c7c1439e514895dba49a4d1c73f2fd7ff"
51
+ "gitHead": "3fc9163650adf5e6a8279b874b1869e9d810c9b7"
52
52
  }