@textbus/platform-browser 3.0.0-y.0 → 3.0.1
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/README.md +1 -1
- package/bundles/core/dom-renderer.d.ts +1 -1
- package/bundles/core/magic-input.d.ts +1 -0
- package/bundles/index.esm.js +15 -9
- package/bundles/index.js +15 -9
- package/package.json +3 -3
package/README.md
CHANGED
@@ -48,5 +48,5 @@ export declare class DomRenderer implements NativeRenderer {
|
|
48
48
|
removeXlinkAttribute(target: NativeNode, key: string): void;
|
49
49
|
replace(newChild: NativeNode, oldChild: NativeNode): void;
|
50
50
|
copy(): void;
|
51
|
-
static replaceEmpty(s: string
|
51
|
+
static replaceEmpty(s: string): string;
|
52
52
|
}
|
package/bundles/index.esm.js
CHANGED
@@ -1134,7 +1134,7 @@ let DomRenderer = DomRenderer_1 = class DomRenderer {
|
|
1134
1134
|
node.removeEventListener(type, callback);
|
1135
1135
|
}
|
1136
1136
|
createTextNode(textContent) {
|
1137
|
-
return document.createTextNode(DomRenderer_1.replaceEmpty(textContent
|
1137
|
+
return document.createTextNode(DomRenderer_1.replaceEmpty(textContent));
|
1138
1138
|
}
|
1139
1139
|
createElement(name) {
|
1140
1140
|
if (this.isSVG.test(name)) {
|
@@ -1165,8 +1165,9 @@ let DomRenderer = DomRenderer_1 = class DomRenderer {
|
|
1165
1165
|
target.style[key] = value !== null && value !== void 0 ? value : '';
|
1166
1166
|
}
|
1167
1167
|
syncTextContent(target, content) {
|
1168
|
-
|
1169
|
-
|
1168
|
+
const c = DomRenderer_1.replaceEmpty(content);
|
1169
|
+
if (target.textContent !== c) {
|
1170
|
+
target.textContent = c;
|
1170
1171
|
}
|
1171
1172
|
}
|
1172
1173
|
removeStyle(target, key) {
|
@@ -1205,12 +1206,13 @@ let DomRenderer = DomRenderer_1 = class DomRenderer {
|
|
1205
1206
|
copy() {
|
1206
1207
|
document.execCommand('copy');
|
1207
1208
|
}
|
1208
|
-
static replaceEmpty(s
|
1209
|
+
static replaceEmpty(s) {
|
1210
|
+
const empty = '\u00a0';
|
1209
1211
|
return s.replace(/\s\s+/g, str => {
|
1210
1212
|
return ' ' + Array.from({
|
1211
1213
|
length: str.length - 1
|
1212
|
-
}).fill(
|
1213
|
-
}).replace(/^\s|\s$/g,
|
1214
|
+
}).fill(empty).join('');
|
1215
|
+
}).replace(/^\s|\s$/g, empty);
|
1214
1216
|
}
|
1215
1217
|
};
|
1216
1218
|
DomRenderer = DomRenderer_1 = __decorate([
|
@@ -1373,6 +1375,7 @@ class ExperimentalCaret {
|
|
1373
1375
|
this._display = true;
|
1374
1376
|
this.flashing = true;
|
1375
1377
|
this.subs = [];
|
1378
|
+
this.subscription = new Subscription();
|
1376
1379
|
this.positionChangeEvent = new Subject();
|
1377
1380
|
this.styleChangeEvent = new Subject();
|
1378
1381
|
this.oldRange = null;
|
@@ -1397,7 +1400,7 @@ class ExperimentalCaret {
|
|
1397
1400
|
})
|
1398
1401
|
]
|
1399
1402
|
});
|
1400
|
-
this.
|
1403
|
+
this.subscription.add(fromEvent(document, 'mousedown').subscribe(() => {
|
1401
1404
|
this.flashing = false;
|
1402
1405
|
}), fromEvent(document, 'mouseup').subscribe(() => {
|
1403
1406
|
this.flashing = true;
|
@@ -1446,6 +1449,7 @@ class ExperimentalCaret {
|
|
1446
1449
|
}
|
1447
1450
|
destroy() {
|
1448
1451
|
clearTimeout(this.timer);
|
1452
|
+
this.subscription.unsubscribe();
|
1449
1453
|
this.subs.forEach(i => i.unsubscribe());
|
1450
1454
|
}
|
1451
1455
|
correctScrollTop(scroller) {
|
@@ -1755,9 +1759,11 @@ let MagicInput = class MagicInput extends Input {
|
|
1755
1759
|
return !isWriting; // || !this.textarea.value
|
1756
1760
|
})).subscribe(ev => {
|
1757
1761
|
let key = ev.key;
|
1758
|
-
const
|
1762
|
+
const keys = ')!@#$%^Z&*(';
|
1763
|
+
const b = key === 'Process' && /Digit\d/.test(ev.code) && ev.shiftKey;
|
1759
1764
|
if (b) {
|
1760
|
-
|
1765
|
+
// 大小写锁定为大写 + 全角 + shift + 数字键,还存在问题
|
1766
|
+
key = keys.charAt(+ev.code.substring(5));
|
1761
1767
|
this.isSougouPinYin = true;
|
1762
1768
|
ev.preventDefault();
|
1763
1769
|
}
|
package/bundles/index.js
CHANGED
@@ -1136,7 +1136,7 @@ exports.DomRenderer = DomRenderer_1 = class DomRenderer {
|
|
1136
1136
|
node.removeEventListener(type, callback);
|
1137
1137
|
}
|
1138
1138
|
createTextNode(textContent) {
|
1139
|
-
return document.createTextNode(DomRenderer_1.replaceEmpty(textContent
|
1139
|
+
return document.createTextNode(DomRenderer_1.replaceEmpty(textContent));
|
1140
1140
|
}
|
1141
1141
|
createElement(name) {
|
1142
1142
|
if (this.isSVG.test(name)) {
|
@@ -1167,8 +1167,9 @@ exports.DomRenderer = DomRenderer_1 = class DomRenderer {
|
|
1167
1167
|
target.style[key] = value !== null && value !== void 0 ? value : '';
|
1168
1168
|
}
|
1169
1169
|
syncTextContent(target, content) {
|
1170
|
-
|
1171
|
-
|
1170
|
+
const c = DomRenderer_1.replaceEmpty(content);
|
1171
|
+
if (target.textContent !== c) {
|
1172
|
+
target.textContent = c;
|
1172
1173
|
}
|
1173
1174
|
}
|
1174
1175
|
removeStyle(target, key) {
|
@@ -1207,12 +1208,13 @@ exports.DomRenderer = DomRenderer_1 = class DomRenderer {
|
|
1207
1208
|
copy() {
|
1208
1209
|
document.execCommand('copy');
|
1209
1210
|
}
|
1210
|
-
static replaceEmpty(s
|
1211
|
+
static replaceEmpty(s) {
|
1212
|
+
const empty = '\u00a0';
|
1211
1213
|
return s.replace(/\s\s+/g, str => {
|
1212
1214
|
return ' ' + Array.from({
|
1213
1215
|
length: str.length - 1
|
1214
|
-
}).fill(
|
1215
|
-
}).replace(/^\s|\s$/g,
|
1216
|
+
}).fill(empty).join('');
|
1217
|
+
}).replace(/^\s|\s$/g, empty);
|
1216
1218
|
}
|
1217
1219
|
};
|
1218
1220
|
exports.DomRenderer = DomRenderer_1 = __decorate([
|
@@ -1375,6 +1377,7 @@ class ExperimentalCaret {
|
|
1375
1377
|
this._display = true;
|
1376
1378
|
this.flashing = true;
|
1377
1379
|
this.subs = [];
|
1380
|
+
this.subscription = new stream.Subscription();
|
1378
1381
|
this.positionChangeEvent = new stream.Subject();
|
1379
1382
|
this.styleChangeEvent = new stream.Subject();
|
1380
1383
|
this.oldRange = null;
|
@@ -1399,7 +1402,7 @@ class ExperimentalCaret {
|
|
1399
1402
|
})
|
1400
1403
|
]
|
1401
1404
|
});
|
1402
|
-
this.
|
1405
|
+
this.subscription.add(stream.fromEvent(document, 'mousedown').subscribe(() => {
|
1403
1406
|
this.flashing = false;
|
1404
1407
|
}), stream.fromEvent(document, 'mouseup').subscribe(() => {
|
1405
1408
|
this.flashing = true;
|
@@ -1448,6 +1451,7 @@ class ExperimentalCaret {
|
|
1448
1451
|
}
|
1449
1452
|
destroy() {
|
1450
1453
|
clearTimeout(this.timer);
|
1454
|
+
this.subscription.unsubscribe();
|
1451
1455
|
this.subs.forEach(i => i.unsubscribe());
|
1452
1456
|
}
|
1453
1457
|
correctScrollTop(scroller) {
|
@@ -1757,9 +1761,11 @@ exports.MagicInput = class MagicInput extends Input {
|
|
1757
1761
|
return !isWriting; // || !this.textarea.value
|
1758
1762
|
})).subscribe(ev => {
|
1759
1763
|
let key = ev.key;
|
1760
|
-
const
|
1764
|
+
const keys = ')!@#$%^Z&*(';
|
1765
|
+
const b = key === 'Process' && /Digit\d/.test(ev.code) && ev.shiftKey;
|
1761
1766
|
if (b) {
|
1762
|
-
|
1767
|
+
// 大小写锁定为大写 + 全角 + shift + 数字键,还存在问题
|
1768
|
+
key = keys.charAt(+ev.code.substring(5));
|
1763
1769
|
this.isSougouPinYin = true;
|
1764
1770
|
ev.preventDefault();
|
1765
1771
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/platform-browser",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.1",
|
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",
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"dependencies": {
|
28
28
|
"@tanbo/di": "^1.1.4",
|
29
29
|
"@tanbo/stream": "^1.1.9",
|
30
|
-
"@textbus/core": "^3.0.0
|
30
|
+
"@textbus/core": "^3.0.0",
|
31
31
|
"reflect-metadata": "^0.1.13"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
@@ -48,5 +48,5 @@
|
|
48
48
|
"bugs": {
|
49
49
|
"url": "https://github.com/textbus/textbus.git/issues"
|
50
50
|
},
|
51
|
-
"gitHead": "
|
51
|
+
"gitHead": "a74f952c6e72e51005208e0b79921007e11bb6b0"
|
52
52
|
}
|