@textbus/platform-browser 3.0.0-alpha.41 → 3.0.0-alpha.43
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/bundles/dom-support/parser.d.ts +0 -1
- package/bundles/index.esm.js +17 -30
- package/bundles/index.js +17 -30
- package/package.json +2 -2
package/bundles/index.esm.js
CHANGED
@@ -1250,11 +1250,9 @@ let Parser = Parser_1 = class Parser {
|
|
1250
1250
|
}
|
1251
1251
|
parse(html, rootSlot) {
|
1252
1252
|
const element = Parser_1.parseHTML(html);
|
1253
|
-
|
1254
|
-
this.applyFormats(rootSlot, formatItems);
|
1255
|
-
return rootSlot;
|
1253
|
+
return this.readFormats(element, rootSlot);
|
1256
1254
|
}
|
1257
|
-
readComponent(el, slot
|
1255
|
+
readComponent(el, slot) {
|
1258
1256
|
if (el.nodeType === Node.ELEMENT_NODE) {
|
1259
1257
|
if (el.tagName === 'BR') {
|
1260
1258
|
slot.insert('\n');
|
@@ -1273,7 +1271,7 @@ let Parser = Parser_1 = class Parser {
|
|
1273
1271
|
return;
|
1274
1272
|
}
|
1275
1273
|
}
|
1276
|
-
this.readFormats(el, slot
|
1274
|
+
this.readFormats(el, slot);
|
1277
1275
|
}
|
1278
1276
|
else if (el.nodeType === Node.TEXT_NODE) {
|
1279
1277
|
const textContent = el.textContent;
|
@@ -1283,26 +1281,23 @@ let Parser = Parser_1 = class Parser {
|
|
1283
1281
|
slot.insert(textContent);
|
1284
1282
|
}
|
1285
1283
|
}
|
1286
|
-
readFormats(el, slot
|
1287
|
-
const
|
1284
|
+
readFormats(el, slot) {
|
1285
|
+
const index = slot.index;
|
1286
|
+
this.formatLoaders.filter(f => {
|
1288
1287
|
return f.match(el);
|
1289
|
-
}).
|
1290
|
-
|
1288
|
+
}).forEach(f => {
|
1289
|
+
const v = f.read(el);
|
1290
|
+
slot.applyFormat(v.formatter, {
|
1291
|
+
startIndex: 0,
|
1292
|
+
endIndex: slot.length,
|
1293
|
+
value: v.value
|
1294
|
+
});
|
1291
1295
|
});
|
1292
|
-
|
1296
|
+
slot.retain(index);
|
1293
1297
|
Array.from(el.childNodes).forEach(child => {
|
1294
|
-
this.readComponent(child, slot
|
1298
|
+
this.readComponent(child, slot);
|
1295
1299
|
});
|
1296
|
-
|
1297
|
-
formatItems.unshift(...formats.map(i => {
|
1298
|
-
return {
|
1299
|
-
formatter: i.formatter,
|
1300
|
-
value: i.value,
|
1301
|
-
startIndex,
|
1302
|
-
endIndex
|
1303
|
-
};
|
1304
|
-
}));
|
1305
|
-
return formatItems;
|
1300
|
+
return slot;
|
1306
1301
|
}
|
1307
1302
|
readSlot(childSlot, slotRootElement, slotContentElement) {
|
1308
1303
|
this.attributeLoaders.filter(a => {
|
@@ -1311,15 +1306,7 @@ let Parser = Parser_1 = class Parser {
|
|
1311
1306
|
const r = a.read(slotRootElement);
|
1312
1307
|
childSlot.setAttribute(r.attribute, r.value);
|
1313
1308
|
});
|
1314
|
-
|
1315
|
-
this.applyFormats(childSlot, childFormatItems);
|
1316
|
-
return childSlot;
|
1317
|
-
}
|
1318
|
-
applyFormats(slot, formatItems) {
|
1319
|
-
formatItems.forEach(i => {
|
1320
|
-
slot.retain(i.startIndex);
|
1321
|
-
slot.retain(i.endIndex - i.startIndex, i.formatter, i.value);
|
1322
|
-
});
|
1309
|
+
return this.readFormats(slotContentElement, childSlot);
|
1323
1310
|
}
|
1324
1311
|
};
|
1325
1312
|
Parser = Parser_1 = __decorate([
|
package/bundles/index.js
CHANGED
@@ -1252,11 +1252,9 @@ exports.Parser = Parser_1 = class Parser {
|
|
1252
1252
|
}
|
1253
1253
|
parse(html, rootSlot) {
|
1254
1254
|
const element = Parser_1.parseHTML(html);
|
1255
|
-
|
1256
|
-
this.applyFormats(rootSlot, formatItems);
|
1257
|
-
return rootSlot;
|
1255
|
+
return this.readFormats(element, rootSlot);
|
1258
1256
|
}
|
1259
|
-
readComponent(el, slot
|
1257
|
+
readComponent(el, slot) {
|
1260
1258
|
if (el.nodeType === Node.ELEMENT_NODE) {
|
1261
1259
|
if (el.tagName === 'BR') {
|
1262
1260
|
slot.insert('\n');
|
@@ -1275,7 +1273,7 @@ exports.Parser = Parser_1 = class Parser {
|
|
1275
1273
|
return;
|
1276
1274
|
}
|
1277
1275
|
}
|
1278
|
-
this.readFormats(el, slot
|
1276
|
+
this.readFormats(el, slot);
|
1279
1277
|
}
|
1280
1278
|
else if (el.nodeType === Node.TEXT_NODE) {
|
1281
1279
|
const textContent = el.textContent;
|
@@ -1285,26 +1283,23 @@ exports.Parser = Parser_1 = class Parser {
|
|
1285
1283
|
slot.insert(textContent);
|
1286
1284
|
}
|
1287
1285
|
}
|
1288
|
-
readFormats(el, slot
|
1289
|
-
const
|
1286
|
+
readFormats(el, slot) {
|
1287
|
+
const index = slot.index;
|
1288
|
+
this.formatLoaders.filter(f => {
|
1290
1289
|
return f.match(el);
|
1291
|
-
}).
|
1292
|
-
|
1290
|
+
}).forEach(f => {
|
1291
|
+
const v = f.read(el);
|
1292
|
+
slot.applyFormat(v.formatter, {
|
1293
|
+
startIndex: 0,
|
1294
|
+
endIndex: slot.length,
|
1295
|
+
value: v.value
|
1296
|
+
});
|
1293
1297
|
});
|
1294
|
-
|
1298
|
+
slot.retain(index);
|
1295
1299
|
Array.from(el.childNodes).forEach(child => {
|
1296
|
-
this.readComponent(child, slot
|
1300
|
+
this.readComponent(child, slot);
|
1297
1301
|
});
|
1298
|
-
|
1299
|
-
formatItems.unshift(...formats.map(i => {
|
1300
|
-
return {
|
1301
|
-
formatter: i.formatter,
|
1302
|
-
value: i.value,
|
1303
|
-
startIndex,
|
1304
|
-
endIndex
|
1305
|
-
};
|
1306
|
-
}));
|
1307
|
-
return formatItems;
|
1302
|
+
return slot;
|
1308
1303
|
}
|
1309
1304
|
readSlot(childSlot, slotRootElement, slotContentElement) {
|
1310
1305
|
this.attributeLoaders.filter(a => {
|
@@ -1313,15 +1308,7 @@ exports.Parser = Parser_1 = class Parser {
|
|
1313
1308
|
const r = a.read(slotRootElement);
|
1314
1309
|
childSlot.setAttribute(r.attribute, r.value);
|
1315
1310
|
});
|
1316
|
-
|
1317
|
-
this.applyFormats(childSlot, childFormatItems);
|
1318
|
-
return childSlot;
|
1319
|
-
}
|
1320
|
-
applyFormats(slot, formatItems) {
|
1321
|
-
formatItems.forEach(i => {
|
1322
|
-
slot.retain(i.startIndex);
|
1323
|
-
slot.retain(i.endIndex - i.startIndex, i.formatter, i.value);
|
1324
|
-
});
|
1311
|
+
return this.readFormats(slotContentElement, childSlot);
|
1325
1312
|
}
|
1326
1313
|
};
|
1327
1314
|
exports.Parser = Parser_1 = __decorate([
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/platform-browser",
|
3
|
-
"version": "3.0.0-alpha.
|
3
|
+
"version": "3.0.0-alpha.43",
|
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": "
|
51
|
+
"gitHead": "75fc95d17093c576420d66b9d3bc320db9bc3443"
|
52
52
|
}
|