@textbus/platform-browser 4.0.1 → 4.0.3
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/browser-module.d.ts +1 -1
- package/bundles/collaborate-cursor.d.ts +12 -8
- package/bundles/index.esm.js +4 -20
- package/bundles/index.js +4 -20
- package/package.json +4 -5
@@ -1,11 +1,9 @@
|
|
1
|
-
import { Selection, AbstractSelection, Scheduler, Textbus } from '@textbus/core';
|
2
|
-
import { UserActivity } from '@textbus/collaborate';
|
1
|
+
import { Selection, AbstractSelection, Scheduler, Textbus, SelectionPaths } from '@textbus/core';
|
3
2
|
import { SelectionBridge } from './selection-bridge';
|
4
3
|
import { Rect } from './_utils/uikit';
|
5
4
|
export interface SelectionRect extends Rect {
|
6
5
|
color: string;
|
7
6
|
username: string;
|
8
|
-
id: string;
|
9
7
|
}
|
10
8
|
export interface RemoteSelectionCursor {
|
11
9
|
cursor: HTMLElement;
|
@@ -18,6 +16,14 @@ export interface RemoteSelectionCursor {
|
|
18
16
|
export declare abstract class CollaborateSelectionAwarenessDelegate {
|
19
17
|
abstract getRects(abstractSelection: AbstractSelection, nativeRange: Range): false | Rect[];
|
20
18
|
}
|
19
|
+
/**
|
20
|
+
* 协作用户虚拟光标信息
|
21
|
+
*/
|
22
|
+
export interface UserSelectionCursor {
|
23
|
+
username: string;
|
24
|
+
color: string;
|
25
|
+
selection: SelectionPaths;
|
26
|
+
}
|
21
27
|
/**
|
22
28
|
* 协作光标绘制类
|
23
29
|
*/
|
@@ -25,7 +31,6 @@ export declare class CollaborateCursor {
|
|
25
31
|
private nativeSelection;
|
26
32
|
private scheduler;
|
27
33
|
private selection;
|
28
|
-
private userActivity;
|
29
34
|
private awarenessDelegate?;
|
30
35
|
private host;
|
31
36
|
private canvasContainer;
|
@@ -34,11 +39,10 @@ export declare class CollaborateCursor {
|
|
34
39
|
private tooltips;
|
35
40
|
private onRectsChange;
|
36
41
|
private subscription;
|
37
|
-
private
|
42
|
+
private selectionCursors;
|
38
43
|
private container;
|
39
44
|
private ratio;
|
40
|
-
constructor(textbus: Textbus, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection,
|
41
|
-
init(): void;
|
45
|
+
constructor(textbus: Textbus, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection, awarenessDelegate?: CollaborateSelectionAwarenessDelegate | undefined);
|
42
46
|
/**
|
43
47
|
* 刷新协作光标,由于 Textbus 只会绘制可视区域的光标,当可视区域发生变化时,需要重新绘制
|
44
48
|
*/
|
@@ -48,7 +52,7 @@ export declare class CollaborateCursor {
|
|
48
52
|
* 根据远程用户光标位置,绘制协作光标
|
49
53
|
* @param paths
|
50
54
|
*/
|
51
|
-
|
55
|
+
draw(paths: UserSelectionCursor[]): void;
|
52
56
|
protected drawUserCursor(rects: SelectionRect[]): void;
|
53
57
|
private getUserCursor;
|
54
58
|
}
|
package/bundles/index.esm.js
CHANGED
@@ -2,7 +2,6 @@ import 'reflect-metadata';
|
|
2
2
|
import { Slot, Textbus, Adapter, Controller, Selection, RootComponentRef, ContentType, Event, invokeListener, Keyboard, Commander, Scheduler, makeError, NativeSelectionBridge, FocusManager, Component, Registry } from '@textbus/core';
|
3
3
|
import { Subject, filter, fromEvent, Subscription, distinctUntilChanged, merge, map, Observable } from '@tanbo/stream';
|
4
4
|
import { InjectionToken, Injectable, Inject, Optional } from '@viewfly/core';
|
5
|
-
import { UserActivity } from '@textbus/collaborate';
|
6
5
|
|
7
6
|
function createElement(tagName, options = {}) {
|
8
7
|
const el = document.createElement(tagName);
|
@@ -1480,11 +1479,10 @@ class CollaborateSelectionAwarenessDelegate {
|
|
1480
1479
|
* 协作光标绘制类
|
1481
1480
|
*/
|
1482
1481
|
let CollaborateCursor = class CollaborateCursor {
|
1483
|
-
constructor(textbus, nativeSelection, scheduler, selection,
|
1482
|
+
constructor(textbus, nativeSelection, scheduler, selection, awarenessDelegate) {
|
1484
1483
|
this.nativeSelection = nativeSelection;
|
1485
1484
|
this.scheduler = scheduler;
|
1486
1485
|
this.selection = selection;
|
1487
|
-
this.userActivity = userActivity;
|
1488
1486
|
this.awarenessDelegate = awarenessDelegate;
|
1489
1487
|
this.host = createElement('div', {
|
1490
1488
|
styles: {
|
@@ -1533,7 +1531,7 @@ let CollaborateCursor = class CollaborateCursor {
|
|
1533
1531
|
});
|
1534
1532
|
this.onRectsChange = new Subject();
|
1535
1533
|
this.subscription = new Subscription();
|
1536
|
-
this.
|
1534
|
+
this.selectionCursors = [];
|
1537
1535
|
this.ratio = window.devicePixelRatio || 1;
|
1538
1536
|
this.container = textbus.get(VIEW_CONTAINER);
|
1539
1537
|
this.canvasContainer.append(this.canvas);
|
@@ -1554,18 +1552,11 @@ let CollaborateCursor = class CollaborateCursor {
|
|
1554
1552
|
this.refresh();
|
1555
1553
|
}));
|
1556
1554
|
}
|
1557
|
-
init() {
|
1558
|
-
if (this.userActivity) {
|
1559
|
-
this.subscription.add(this.userActivity.onStateChange.subscribe(v => {
|
1560
|
-
this.draw(v);
|
1561
|
-
}));
|
1562
|
-
}
|
1563
|
-
}
|
1564
1555
|
/**
|
1565
1556
|
* 刷新协作光标,由于 Textbus 只会绘制可视区域的光标,当可视区域发生变化时,需要重新绘制
|
1566
1557
|
*/
|
1567
1558
|
refresh() {
|
1568
|
-
this.draw(this.
|
1559
|
+
this.draw(this.selectionCursors);
|
1569
1560
|
}
|
1570
1561
|
destroy() {
|
1571
1562
|
this.subscription.unsubscribe();
|
@@ -1575,7 +1566,7 @@ let CollaborateCursor = class CollaborateCursor {
|
|
1575
1566
|
* @param paths
|
1576
1567
|
*/
|
1577
1568
|
draw(paths) {
|
1578
|
-
this.
|
1569
|
+
this.selectionCursors = paths;
|
1579
1570
|
const containerRect = this.container.getBoundingClientRect();
|
1580
1571
|
this.canvas.style.top = containerRect.top * -1 + 'px';
|
1581
1572
|
this.canvas.width = this.canvas.offsetWidth * this.ratio;
|
@@ -1632,7 +1623,6 @@ let CollaborateCursor = class CollaborateCursor {
|
|
1632
1623
|
for (let i = rects.length - 1; i >= 0; i--) {
|
1633
1624
|
const rect = rects[i];
|
1634
1625
|
selectionRects.push({
|
1635
|
-
id: item.id,
|
1636
1626
|
color: item.color,
|
1637
1627
|
username: item.username,
|
1638
1628
|
left: rect.left - containerRect.left,
|
@@ -1647,7 +1637,6 @@ let CollaborateCursor = class CollaborateCursor {
|
|
1647
1637
|
cursorRange.collapse(true);
|
1648
1638
|
const cursorRect = getLayoutRectByRange(cursorRange);
|
1649
1639
|
const rect = {
|
1650
|
-
id: item.id,
|
1651
1640
|
username: item.username,
|
1652
1641
|
color: item.color,
|
1653
1642
|
left: cursorRect.left - containerRect.left,
|
@@ -1740,12 +1729,10 @@ let CollaborateCursor = class CollaborateCursor {
|
|
1740
1729
|
CollaborateCursor = __decorate([
|
1741
1730
|
Injectable(),
|
1742
1731
|
__param(4, Optional()),
|
1743
|
-
__param(5, Optional()),
|
1744
1732
|
__metadata("design:paramtypes", [Textbus,
|
1745
1733
|
SelectionBridge,
|
1746
1734
|
Scheduler,
|
1747
1735
|
Selection,
|
1748
|
-
UserActivity,
|
1749
1736
|
CollaborateSelectionAwarenessDelegate])
|
1750
1737
|
], CollaborateCursor);
|
1751
1738
|
|
@@ -2251,11 +2238,8 @@ class BrowserModule {
|
|
2251
2238
|
if (!(host instanceof HTMLElement)) {
|
2252
2239
|
throw browserErrorFn('view container is not a HTMLElement');
|
2253
2240
|
}
|
2254
|
-
const cursor = textbus.get(CollaborateCursor);
|
2255
|
-
cursor.init();
|
2256
2241
|
host.append(this.workbench);
|
2257
2242
|
return () => {
|
2258
|
-
cursor.destroy();
|
2259
2243
|
this.workbench.remove();
|
2260
2244
|
};
|
2261
2245
|
}
|
package/bundles/index.js
CHANGED
@@ -4,7 +4,6 @@ require('reflect-metadata');
|
|
4
4
|
var core$1 = require('@textbus/core');
|
5
5
|
var stream = require('@tanbo/stream');
|
6
6
|
var core = require('@viewfly/core');
|
7
|
-
var collaborate = require('@textbus/collaborate');
|
8
7
|
|
9
8
|
function createElement(tagName, options = {}) {
|
10
9
|
const el = document.createElement(tagName);
|
@@ -1482,11 +1481,10 @@ class CollaborateSelectionAwarenessDelegate {
|
|
1482
1481
|
* 协作光标绘制类
|
1483
1482
|
*/
|
1484
1483
|
exports.CollaborateCursor = class CollaborateCursor {
|
1485
|
-
constructor(textbus, nativeSelection, scheduler, selection,
|
1484
|
+
constructor(textbus, nativeSelection, scheduler, selection, awarenessDelegate) {
|
1486
1485
|
this.nativeSelection = nativeSelection;
|
1487
1486
|
this.scheduler = scheduler;
|
1488
1487
|
this.selection = selection;
|
1489
|
-
this.userActivity = userActivity;
|
1490
1488
|
this.awarenessDelegate = awarenessDelegate;
|
1491
1489
|
this.host = createElement('div', {
|
1492
1490
|
styles: {
|
@@ -1535,7 +1533,7 @@ exports.CollaborateCursor = class CollaborateCursor {
|
|
1535
1533
|
});
|
1536
1534
|
this.onRectsChange = new stream.Subject();
|
1537
1535
|
this.subscription = new stream.Subscription();
|
1538
|
-
this.
|
1536
|
+
this.selectionCursors = [];
|
1539
1537
|
this.ratio = window.devicePixelRatio || 1;
|
1540
1538
|
this.container = textbus.get(VIEW_CONTAINER);
|
1541
1539
|
this.canvasContainer.append(this.canvas);
|
@@ -1556,18 +1554,11 @@ exports.CollaborateCursor = class CollaborateCursor {
|
|
1556
1554
|
this.refresh();
|
1557
1555
|
}));
|
1558
1556
|
}
|
1559
|
-
init() {
|
1560
|
-
if (this.userActivity) {
|
1561
|
-
this.subscription.add(this.userActivity.onStateChange.subscribe(v => {
|
1562
|
-
this.draw(v);
|
1563
|
-
}));
|
1564
|
-
}
|
1565
|
-
}
|
1566
1557
|
/**
|
1567
1558
|
* 刷新协作光标,由于 Textbus 只会绘制可视区域的光标,当可视区域发生变化时,需要重新绘制
|
1568
1559
|
*/
|
1569
1560
|
refresh() {
|
1570
|
-
this.draw(this.
|
1561
|
+
this.draw(this.selectionCursors);
|
1571
1562
|
}
|
1572
1563
|
destroy() {
|
1573
1564
|
this.subscription.unsubscribe();
|
@@ -1577,7 +1568,7 @@ exports.CollaborateCursor = class CollaborateCursor {
|
|
1577
1568
|
* @param paths
|
1578
1569
|
*/
|
1579
1570
|
draw(paths) {
|
1580
|
-
this.
|
1571
|
+
this.selectionCursors = paths;
|
1581
1572
|
const containerRect = this.container.getBoundingClientRect();
|
1582
1573
|
this.canvas.style.top = containerRect.top * -1 + 'px';
|
1583
1574
|
this.canvas.width = this.canvas.offsetWidth * this.ratio;
|
@@ -1634,7 +1625,6 @@ exports.CollaborateCursor = class CollaborateCursor {
|
|
1634
1625
|
for (let i = rects.length - 1; i >= 0; i--) {
|
1635
1626
|
const rect = rects[i];
|
1636
1627
|
selectionRects.push({
|
1637
|
-
id: item.id,
|
1638
1628
|
color: item.color,
|
1639
1629
|
username: item.username,
|
1640
1630
|
left: rect.left - containerRect.left,
|
@@ -1649,7 +1639,6 @@ exports.CollaborateCursor = class CollaborateCursor {
|
|
1649
1639
|
cursorRange.collapse(true);
|
1650
1640
|
const cursorRect = getLayoutRectByRange(cursorRange);
|
1651
1641
|
const rect = {
|
1652
|
-
id: item.id,
|
1653
1642
|
username: item.username,
|
1654
1643
|
color: item.color,
|
1655
1644
|
left: cursorRect.left - containerRect.left,
|
@@ -1742,12 +1731,10 @@ exports.CollaborateCursor = class CollaborateCursor {
|
|
1742
1731
|
exports.CollaborateCursor = __decorate([
|
1743
1732
|
core.Injectable(),
|
1744
1733
|
__param(4, core.Optional()),
|
1745
|
-
__param(5, core.Optional()),
|
1746
1734
|
__metadata("design:paramtypes", [core$1.Textbus,
|
1747
1735
|
exports.SelectionBridge,
|
1748
1736
|
core$1.Scheduler,
|
1749
1737
|
core$1.Selection,
|
1750
|
-
collaborate.UserActivity,
|
1751
1738
|
CollaborateSelectionAwarenessDelegate])
|
1752
1739
|
], exports.CollaborateCursor);
|
1753
1740
|
|
@@ -2253,11 +2240,8 @@ class BrowserModule {
|
|
2253
2240
|
if (!(host instanceof HTMLElement)) {
|
2254
2241
|
throw browserErrorFn('view container is not a HTMLElement');
|
2255
2242
|
}
|
2256
|
-
const cursor = textbus.get(exports.CollaborateCursor);
|
2257
|
-
cursor.init();
|
2258
2243
|
host.append(this.workbench);
|
2259
2244
|
return () => {
|
2260
|
-
cursor.destroy();
|
2261
2245
|
this.workbench.remove();
|
2262
2246
|
};
|
2263
2247
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/platform-browser",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.3",
|
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",
|
@@ -26,9 +26,8 @@
|
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
28
|
"@tanbo/stream": "^1.2.5",
|
29
|
-
"@textbus/
|
30
|
-
"@
|
31
|
-
"@viewfly/core": "^1.0.0-alpha.22"
|
29
|
+
"@textbus/core": "^4.0.3",
|
30
|
+
"@viewfly/core": "^1.0.2"
|
32
31
|
},
|
33
32
|
"devDependencies": {
|
34
33
|
"@rollup/plugin-commonjs": "^23.0.2",
|
@@ -48,5 +47,5 @@
|
|
48
47
|
"bugs": {
|
49
48
|
"url": "https://github.com/textbus/textbus.git/issues"
|
50
49
|
},
|
51
|
-
"gitHead": "
|
50
|
+
"gitHead": "cf4fd289b73bc777124a32fe42bb58eba05a34f1"
|
52
51
|
}
|