@textbus/platform-browser 3.0.0-alpha.50 → 3.0.0-alpha.52

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.
@@ -21,6 +21,7 @@ declare class ExperimentalCaret implements Caret {
21
21
  elementRef: HTMLElement;
22
22
  compositionState: CompositionState | null;
23
23
  get rect(): DOMRect;
24
+ compositionElement: HTMLElement;
24
25
  private timer;
25
26
  private caret;
26
27
  private oldPosition;
@@ -33,7 +34,6 @@ declare class ExperimentalCaret implements Caret {
33
34
  private styleChangeEvent;
34
35
  private oldRange;
35
36
  private isFixed;
36
- private compositionElement;
37
37
  constructor(scheduler: Scheduler, editorMask: HTMLElement);
38
38
  refresh(isFixedCaret?: boolean): void;
39
39
  show(range: Range, restart: boolean): void;
@@ -1328,24 +1328,24 @@ Parser = Parser_1 = __decorate([
1328
1328
  __metadata("design:paramtypes", [Object, Injector])
1329
1329
  ], Parser);
1330
1330
 
1331
- const iframeHTML = `
1332
- <!DOCTYPE html>
1333
- <html>
1334
- <head>
1335
- <meta charset="UTF-8">
1336
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
1337
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
1338
- <title>Textbus</title>
1339
- <style>
1340
- html {position: fixed; left:0; overflow: hidden}
1341
- html, body{height: 100%;width:100%}
1342
- body{margin:0; overflow: hidden}
1343
- textarea{width: 2000px;height: 100%;opacity: 0; padding: 0; outline: none; border: none; position: absolute; left:0; top:0;}
1344
- </style>
1345
- </head>
1346
- <body>
1347
- </body>
1348
- </html>
1331
+ const iframeHTML = `
1332
+ <!DOCTYPE html>
1333
+ <html>
1334
+ <head>
1335
+ <meta charset="UTF-8">
1336
+ <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
1337
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
1338
+ <title>Textbus</title>
1339
+ <style>
1340
+ html {position: fixed; left:0; overflow: hidden}
1341
+ html, body{height: 100%;width:100%}
1342
+ body{margin:0; overflow: hidden}
1343
+ textarea{width: 2000px;height: 100%;opacity: 0; padding: 0; outline: none; border: none; position: absolute; left:0; top:0;}
1344
+ </style>
1345
+ </head>
1346
+ <body>
1347
+ </body>
1348
+ </html>
1349
1349
  `;
1350
1350
  class ExperimentalCaret {
1351
1351
  get rect() {
@@ -1362,6 +1362,11 @@ class ExperimentalCaret {
1362
1362
  this.scheduler = scheduler;
1363
1363
  this.editorMask = editorMask;
1364
1364
  this.compositionState = null;
1365
+ this.compositionElement = createElement('span', {
1366
+ styles: {
1367
+ textDecoration: 'underline'
1368
+ }
1369
+ });
1365
1370
  this.timer = null;
1366
1371
  this.oldPosition = null;
1367
1372
  this._display = true;
@@ -1371,11 +1376,6 @@ class ExperimentalCaret {
1371
1376
  this.styleChangeEvent = new Subject();
1372
1377
  this.oldRange = null;
1373
1378
  this.isFixed = false;
1374
- this.compositionElement = createElement('span', {
1375
- styles: {
1376
- textDecoration: 'underline'
1377
- }
1378
- });
1379
1379
  this.onPositionChange = this.positionChangeEvent.pipe(distinctUntilChanged());
1380
1380
  this.onStyleChange = this.styleChangeEvent.asObservable();
1381
1381
  this.elementRef = createElement('div', {
@@ -1771,6 +1771,10 @@ let MagicInput = class MagicInput extends Input {
1771
1771
  this.subscription.add(fromEvent(textarea, 'compositionstart').subscribe(() => {
1772
1772
  startIndex = this.selection.startOffset;
1773
1773
  }), fromEvent(textarea, 'compositionupdate').subscribe(ev => {
1774
+ if (ev.data === ' ') {
1775
+ // 处理搜狗五笔不符合 composition 事件预期,会意外跳光标的问题
1776
+ return;
1777
+ }
1774
1778
  this.caret.compositionState = {
1775
1779
  slot: this.selection.startSlot,
1776
1780
  index: startIndex,
@@ -1778,7 +1782,9 @@ let MagicInput = class MagicInput extends Input {
1778
1782
  };
1779
1783
  this.caret.refresh(true);
1780
1784
  }), fromEvent(textarea, 'compositionend').subscribe(() => {
1785
+ var _a;
1781
1786
  this.caret.compositionState = null;
1787
+ (_a = this.caret.compositionElement.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.caret.compositionElement);
1782
1788
  }));
1783
1789
  this.subscription.add(merge(fromEvent(textarea, 'beforeinput').pipe(filter(ev => {
1784
1790
  ev.preventDefault();
package/bundles/index.js CHANGED
@@ -1330,24 +1330,24 @@ exports.Parser = Parser_1 = __decorate([
1330
1330
  __metadata("design:paramtypes", [Object, di.Injector])
1331
1331
  ], exports.Parser);
1332
1332
 
1333
- const iframeHTML = `
1334
- <!DOCTYPE html>
1335
- <html>
1336
- <head>
1337
- <meta charset="UTF-8">
1338
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
1339
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
1340
- <title>Textbus</title>
1341
- <style>
1342
- html {position: fixed; left:0; overflow: hidden}
1343
- html, body{height: 100%;width:100%}
1344
- body{margin:0; overflow: hidden}
1345
- textarea{width: 2000px;height: 100%;opacity: 0; padding: 0; outline: none; border: none; position: absolute; left:0; top:0;}
1346
- </style>
1347
- </head>
1348
- <body>
1349
- </body>
1350
- </html>
1333
+ const iframeHTML = `
1334
+ <!DOCTYPE html>
1335
+ <html>
1336
+ <head>
1337
+ <meta charset="UTF-8">
1338
+ <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
1339
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
1340
+ <title>Textbus</title>
1341
+ <style>
1342
+ html {position: fixed; left:0; overflow: hidden}
1343
+ html, body{height: 100%;width:100%}
1344
+ body{margin:0; overflow: hidden}
1345
+ textarea{width: 2000px;height: 100%;opacity: 0; padding: 0; outline: none; border: none; position: absolute; left:0; top:0;}
1346
+ </style>
1347
+ </head>
1348
+ <body>
1349
+ </body>
1350
+ </html>
1351
1351
  `;
1352
1352
  class ExperimentalCaret {
1353
1353
  get rect() {
@@ -1364,6 +1364,11 @@ class ExperimentalCaret {
1364
1364
  this.scheduler = scheduler;
1365
1365
  this.editorMask = editorMask;
1366
1366
  this.compositionState = null;
1367
+ this.compositionElement = createElement('span', {
1368
+ styles: {
1369
+ textDecoration: 'underline'
1370
+ }
1371
+ });
1367
1372
  this.timer = null;
1368
1373
  this.oldPosition = null;
1369
1374
  this._display = true;
@@ -1373,11 +1378,6 @@ class ExperimentalCaret {
1373
1378
  this.styleChangeEvent = new stream.Subject();
1374
1379
  this.oldRange = null;
1375
1380
  this.isFixed = false;
1376
- this.compositionElement = createElement('span', {
1377
- styles: {
1378
- textDecoration: 'underline'
1379
- }
1380
- });
1381
1381
  this.onPositionChange = this.positionChangeEvent.pipe(stream.distinctUntilChanged());
1382
1382
  this.onStyleChange = this.styleChangeEvent.asObservable();
1383
1383
  this.elementRef = createElement('div', {
@@ -1773,6 +1773,10 @@ exports.MagicInput = class MagicInput extends Input {
1773
1773
  this.subscription.add(stream.fromEvent(textarea, 'compositionstart').subscribe(() => {
1774
1774
  startIndex = this.selection.startOffset;
1775
1775
  }), stream.fromEvent(textarea, 'compositionupdate').subscribe(ev => {
1776
+ if (ev.data === ' ') {
1777
+ // 处理搜狗五笔不符合 composition 事件预期,会意外跳光标的问题
1778
+ return;
1779
+ }
1776
1780
  this.caret.compositionState = {
1777
1781
  slot: this.selection.startSlot,
1778
1782
  index: startIndex,
@@ -1780,7 +1784,9 @@ exports.MagicInput = class MagicInput extends Input {
1780
1784
  };
1781
1785
  this.caret.refresh(true);
1782
1786
  }), stream.fromEvent(textarea, 'compositionend').subscribe(() => {
1787
+ var _a;
1783
1788
  this.caret.compositionState = null;
1789
+ (_a = this.caret.compositionElement.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.caret.compositionElement);
1784
1790
  }));
1785
1791
  this.subscription.add(stream.merge(stream.fromEvent(textarea, 'beforeinput').pipe(stream.filter(ev => {
1786
1792
  ev.preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/platform-browser",
3
- "version": "3.0.0-alpha.50",
3
+ "version": "3.0.0-alpha.52",
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": "ad396a0f17fc18d1eaddd2532f223c1252cf5d6f"
51
+ "gitHead": "4c64b9a00d2a4e87ad7bfdc9502b8a70ed1dc39a"
52
52
  }