@textbus/platform-browser 3.0.0-alpha.41 → 3.0.0-alpha.42
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 +15 -30
- package/bundles/index.js +15 -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,21 @@ let Parser = Parser_1 = class Parser {
|
|
1283
1281
|
slot.insert(textContent);
|
1284
1282
|
}
|
1285
1283
|
}
|
1286
|
-
readFormats(el, slot
|
1287
|
-
|
1284
|
+
readFormats(el, slot) {
|
1285
|
+
this.formatLoaders.filter(f => {
|
1288
1286
|
return f.match(el);
|
1289
|
-
}).
|
1290
|
-
|
1287
|
+
}).forEach(f => {
|
1288
|
+
const v = f.read(el);
|
1289
|
+
slot.applyFormat(v.formatter, {
|
1290
|
+
startIndex: 0,
|
1291
|
+
endIndex: slot.length,
|
1292
|
+
value: v.value
|
1293
|
+
});
|
1291
1294
|
});
|
1292
|
-
const startIndex = slot.index;
|
1293
1295
|
Array.from(el.childNodes).forEach(child => {
|
1294
|
-
this.readComponent(child, slot
|
1296
|
+
this.readComponent(child, slot);
|
1295
1297
|
});
|
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;
|
1298
|
+
return slot;
|
1306
1299
|
}
|
1307
1300
|
readSlot(childSlot, slotRootElement, slotContentElement) {
|
1308
1301
|
this.attributeLoaders.filter(a => {
|
@@ -1311,15 +1304,7 @@ let Parser = Parser_1 = class Parser {
|
|
1311
1304
|
const r = a.read(slotRootElement);
|
1312
1305
|
childSlot.setAttribute(r.attribute, r.value);
|
1313
1306
|
});
|
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
|
-
});
|
1307
|
+
return this.readFormats(slotContentElement, childSlot);
|
1323
1308
|
}
|
1324
1309
|
};
|
1325
1310
|
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,21 @@ exports.Parser = Parser_1 = class Parser {
|
|
1285
1283
|
slot.insert(textContent);
|
1286
1284
|
}
|
1287
1285
|
}
|
1288
|
-
readFormats(el, slot
|
1289
|
-
|
1286
|
+
readFormats(el, slot) {
|
1287
|
+
this.formatLoaders.filter(f => {
|
1290
1288
|
return f.match(el);
|
1291
|
-
}).
|
1292
|
-
|
1289
|
+
}).forEach(f => {
|
1290
|
+
const v = f.read(el);
|
1291
|
+
slot.applyFormat(v.formatter, {
|
1292
|
+
startIndex: 0,
|
1293
|
+
endIndex: slot.length,
|
1294
|
+
value: v.value
|
1295
|
+
});
|
1293
1296
|
});
|
1294
|
-
const startIndex = slot.index;
|
1295
1297
|
Array.from(el.childNodes).forEach(child => {
|
1296
|
-
this.readComponent(child, slot
|
1298
|
+
this.readComponent(child, slot);
|
1297
1299
|
});
|
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;
|
1300
|
+
return slot;
|
1308
1301
|
}
|
1309
1302
|
readSlot(childSlot, slotRootElement, slotContentElement) {
|
1310
1303
|
this.attributeLoaders.filter(a => {
|
@@ -1313,15 +1306,7 @@ exports.Parser = Parser_1 = class Parser {
|
|
1313
1306
|
const r = a.read(slotRootElement);
|
1314
1307
|
childSlot.setAttribute(r.attribute, r.value);
|
1315
1308
|
});
|
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
|
-
});
|
1309
|
+
return this.readFormats(slotContentElement, childSlot);
|
1325
1310
|
}
|
1326
1311
|
};
|
1327
1312
|
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.42",
|
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": "5ac4dfb4ae18393afc93ffac9df4012d68adeffa"
|
52
52
|
}
|