@textbus/collaborate 3.0.0-alpha.4 → 3.0.0-alpha.44

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,3 @@
1
- import { Module } from '@textbus/core';
2
- export * from './collaborate';
3
- export * from './collaborate-cursor';
4
- export declare const collaborateModule: Module;
1
+ import { Module } from '@textbus/core';
2
+ export * from './collaborate';
3
+ export declare const collaborateModule: Module;
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@textbus/collaborate",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.44",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
- "main": "./bundles/public-api.js",
6
- "module": "./bundles/public-api.js",
5
+ "main": "./bundles/index.js",
6
+ "module": "./bundles/index.esm.js",
7
7
  "typings": "./bundles/public-api.d.ts",
8
8
  "scripts": {
9
9
  "start": "webpack-dev-server",
10
10
  "test": "cross-env env=test jest",
11
11
  "test-c": "cross-env env=test jest --coverage",
12
- "build:lib": "rimraf bundles && tsc -p tsconfig-build.json",
12
+ "build:lib": "rimraf bundles && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
13
13
  "publish:lib": "npm run build:lib && npm publish --access=public"
14
14
  },
15
15
  "license": "GPL-3.0-only",
@@ -25,14 +25,20 @@
25
25
  "typescript editor"
26
26
  ],
27
27
  "dependencies": {
28
- "@tanbo/di": "^1.1.3",
28
+ "@tanbo/di": "^1.1.4",
29
29
  "@tanbo/stream": "^1.1.8",
30
- "@textbus/browser": "^3.0.0-alpha.4",
31
- "@textbus/core": "^3.0.0-alpha.3",
30
+ "@textbus/core": "^3.0.0-alpha.44",
32
31
  "reflect-metadata": "^0.1.13",
33
32
  "y-protocols": "^1.0.5",
34
33
  "yjs": "^13.5.39"
35
34
  },
35
+ "devDependencies": {
36
+ "@rollup/plugin-commonjs": "^23.0.2",
37
+ "@rollup/plugin-typescript": "^9.0.2",
38
+ "rimraf": "^3.0.2",
39
+ "rollup": "^3.2.5",
40
+ "tslib": "^2.4.1"
41
+ },
36
42
  "author": {
37
43
  "name": "Tanbo",
38
44
  "email": "tanbohb@qq.com"
@@ -44,5 +50,5 @@
44
50
  "bugs": {
45
51
  "url": "https://github.com/textbus/textbus.git/issues"
46
52
  },
47
- "gitHead": "95e61178adaf447e8f55cf6c8b241c02a89f1db3"
53
+ "gitHead": "3abc943158b03b675002df947d95ce14eee9b31d"
48
54
  }
@@ -1,42 +0,0 @@
1
- import { SelectionBridge } from '@textbus/browser';
2
- import { Selection, SelectionPaths, AbstractSelection, Scheduler, Rect } from '@textbus/core';
3
- export interface RemoteSelection {
4
- id: string;
5
- color: string;
6
- username: string;
7
- paths: SelectionPaths;
8
- }
9
- export interface SelectionRect extends Rect {
10
- color: string;
11
- username: string;
12
- id: string;
13
- }
14
- export interface RemoteSelectionCursor {
15
- cursor: HTMLElement;
16
- anchor: HTMLElement;
17
- userTip: HTMLElement;
18
- }
19
- export declare abstract class CollaborateSelectionAwarenessDelegate {
20
- abstract getRects(abstractSelection: AbstractSelection, nativeRange: Range): false | Rect[];
21
- }
22
- export declare class CollaborateCursor {
23
- private container;
24
- private awarenessDelegate;
25
- private nativeSelection;
26
- private scheduler;
27
- private selection;
28
- private host;
29
- private canvasContainer;
30
- private canvas;
31
- private context;
32
- private tooltips;
33
- private onRectsChange;
34
- private subscription;
35
- private currentSelection;
36
- constructor(container: HTMLElement, awarenessDelegate: CollaborateSelectionAwarenessDelegate, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection);
37
- refresh(): void;
38
- destroy(): void;
39
- draw(paths: RemoteSelection[]): void;
40
- protected drawUserCursor(rects: SelectionRect[]): void;
41
- private getUserCursor;
42
- }
@@ -1,273 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- import { Inject, Injectable, Optional } from '@tanbo/di';
14
- import { createElement, VIEW_CONTAINER, getLayoutRectByRange, SelectionBridge } from '@textbus/browser';
15
- import { Selection, Scheduler } from '@textbus/core';
16
- import { fromEvent, Subject, Subscription } from '@tanbo/stream';
17
- export class CollaborateSelectionAwarenessDelegate {
18
- }
19
- let CollaborateCursor = class CollaborateCursor {
20
- constructor(container, awarenessDelegate, nativeSelection, scheduler, selection) {
21
- this.container = container;
22
- this.awarenessDelegate = awarenessDelegate;
23
- this.nativeSelection = nativeSelection;
24
- this.scheduler = scheduler;
25
- this.selection = selection;
26
- this.host = createElement('div', {
27
- styles: {
28
- position: 'absolute',
29
- left: 0,
30
- top: 0,
31
- width: '100%',
32
- height: '100%',
33
- pointerEvents: 'none',
34
- zIndex: 1
35
- }
36
- });
37
- this.canvasContainer = createElement('div', {
38
- styles: {
39
- position: 'absolute',
40
- left: 0,
41
- top: 0,
42
- width: '100%',
43
- height: '100%',
44
- overflow: 'hidden'
45
- }
46
- });
47
- this.canvas = createElement('canvas', {
48
- styles: {
49
- position: 'absolute',
50
- opacity: 0.5,
51
- left: 0,
52
- top: 0,
53
- width: '100%',
54
- height: document.documentElement.clientHeight + 'px',
55
- pointerEvents: 'none',
56
- }
57
- });
58
- this.context = this.canvas.getContext('2d');
59
- this.tooltips = createElement('div', {
60
- styles: {
61
- position: 'absolute',
62
- left: 0,
63
- top: 0,
64
- width: '100%',
65
- height: '100%',
66
- pointerEvents: 'none',
67
- fontSize: '12px',
68
- zIndex: 10
69
- }
70
- });
71
- this.onRectsChange = new Subject();
72
- this.subscription = new Subscription();
73
- this.currentSelection = [];
74
- this.canvasContainer.append(this.canvas);
75
- this.host.append(this.canvasContainer, this.tooltips);
76
- container.prepend(this.host);
77
- this.subscription.add(this.onRectsChange.subscribe(rects => {
78
- for (const rect of rects) {
79
- this.context.fillStyle = rect.color;
80
- this.context.beginPath();
81
- this.context.rect(rect.left, rect.top, rect.width, rect.height);
82
- this.context.fill();
83
- this.context.closePath();
84
- }
85
- }), fromEvent(window, 'resize').subscribe(() => {
86
- this.canvas.style.height = document.documentElement.clientHeight + 'px';
87
- this.refresh();
88
- }), this.scheduler.onDocChanged.subscribe(() => {
89
- this.refresh();
90
- }));
91
- }
92
- refresh() {
93
- this.draw(this.currentSelection);
94
- }
95
- destroy() {
96
- this.subscription.unsubscribe();
97
- }
98
- draw(paths) {
99
- this.currentSelection = paths;
100
- const containerRect = this.container.getBoundingClientRect();
101
- this.canvas.style.top = containerRect.top * -1 + 'px';
102
- this.canvas.width = this.canvas.offsetWidth;
103
- this.canvas.height = this.canvas.offsetHeight;
104
- this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
105
- const users = [];
106
- paths.filter(i => {
107
- return i.paths.anchor.length && i.paths.focus.length;
108
- }).forEach(item => {
109
- const anchorPaths = [...item.paths.anchor];
110
- const focusPaths = [...item.paths.focus];
111
- const anchorOffset = anchorPaths.pop();
112
- const anchorSlot = this.selection.findSlotByPaths(anchorPaths);
113
- const focusOffset = focusPaths.pop();
114
- const focusSlot = this.selection.findSlotByPaths(focusPaths);
115
- if (!anchorSlot || !focusSlot) {
116
- return;
117
- }
118
- const { focus, anchor } = this.nativeSelection.getPositionByRange({
119
- focusOffset,
120
- anchorOffset,
121
- focusSlot,
122
- anchorSlot
123
- });
124
- if (!focus || !anchor) {
125
- return;
126
- }
127
- const nativeRange = document.createRange();
128
- nativeRange.setStart(anchor.node, anchor.offset);
129
- nativeRange.setEnd(focus.node, focus.offset);
130
- if ((anchor.node !== focus.node || anchor.offset !== focus.offset) && nativeRange.collapsed) {
131
- nativeRange.setStart(focus.node, focus.offset);
132
- nativeRange.setEnd(anchor.node, anchor.offset);
133
- }
134
- let rects = false;
135
- if (this.awarenessDelegate) {
136
- rects = this.awarenessDelegate.getRects({
137
- focusOffset,
138
- anchorOffset,
139
- focusSlot,
140
- anchorSlot
141
- }, nativeRange);
142
- }
143
- if (!rects) {
144
- rects = nativeRange.getClientRects();
145
- }
146
- const selectionRects = [];
147
- for (let i = rects.length - 1; i >= 0; i--) {
148
- const rect = rects[i];
149
- selectionRects.push({
150
- id: item.id,
151
- color: item.color,
152
- username: item.username,
153
- left: rect.left - containerRect.left,
154
- top: rect.top,
155
- width: rect.width,
156
- height: rect.height,
157
- });
158
- }
159
- this.onRectsChange.next(selectionRects);
160
- const cursorRange = nativeRange.cloneRange();
161
- cursorRange.setStart(focus.node, focus.offset);
162
- cursorRange.collapse(true);
163
- const cursorRect = getLayoutRectByRange(cursorRange);
164
- const rect = {
165
- id: item.id,
166
- username: item.username,
167
- color: item.color,
168
- left: cursorRect.left - containerRect.left,
169
- top: cursorRect.top - containerRect.top,
170
- width: 2,
171
- height: cursorRect.height
172
- };
173
- if (rect.left < 0 || rect.top < 0 || rect.left > containerRect.width) {
174
- return;
175
- }
176
- users.push(rect);
177
- });
178
- this.drawUserCursor(users);
179
- }
180
- drawUserCursor(rects) {
181
- for (let i = 0; i < rects.length; i++) {
182
- const rect = rects[i];
183
- const { cursor, userTip, anchor } = this.getUserCursor(i);
184
- Object.assign(cursor.style, {
185
- left: rect.left + 'px',
186
- top: rect.top + 'px',
187
- width: rect.width + 'px',
188
- height: rect.height + 'px',
189
- background: rect.color,
190
- display: 'block'
191
- });
192
- anchor.style.background = rect.color;
193
- userTip.innerText = rect.username;
194
- userTip.style.background = rect.color;
195
- }
196
- for (let i = rects.length; i < this.tooltips.children.length; i++) {
197
- this.tooltips.removeChild(this.tooltips.children[i]);
198
- }
199
- }
200
- getUserCursor(index) {
201
- let child = this.tooltips.children[index];
202
- if (child) {
203
- const anchor = child.children[0];
204
- return {
205
- cursor: child,
206
- anchor,
207
- userTip: anchor.children[0]
208
- };
209
- }
210
- const userTip = createElement('span', {
211
- styles: {
212
- position: 'absolute',
213
- display: 'none',
214
- left: '50%',
215
- transform: 'translateX(-50%)',
216
- marginBottom: '2px',
217
- bottom: '100%',
218
- whiteSpace: 'nowrap',
219
- color: '#fff',
220
- boxShadow: '0 1px 2px rgba(0,0,0,.1)',
221
- borderRadius: '3px',
222
- padding: '3px 5px',
223
- pointerEvents: 'none',
224
- }
225
- });
226
- const anchor = createElement('span', {
227
- styles: {
228
- position: 'absolute',
229
- top: '-2px',
230
- left: '-2px',
231
- width: '6px',
232
- height: '6px',
233
- pointerEvents: 'auto',
234
- pointer: 'cursor',
235
- },
236
- children: [userTip],
237
- on: {
238
- mouseenter() {
239
- userTip.style.display = 'block';
240
- },
241
- mouseleave() {
242
- userTip.style.display = 'none';
243
- }
244
- }
245
- });
246
- child = createElement('span', {
247
- styles: {
248
- position: 'absolute',
249
- },
250
- children: [
251
- anchor
252
- ]
253
- });
254
- this.tooltips.append(child);
255
- return {
256
- cursor: child,
257
- anchor,
258
- userTip
259
- };
260
- }
261
- };
262
- CollaborateCursor = __decorate([
263
- Injectable(),
264
- __param(0, Inject(VIEW_CONTAINER)),
265
- __param(1, Optional()),
266
- __metadata("design:paramtypes", [HTMLElement,
267
- CollaborateSelectionAwarenessDelegate,
268
- SelectionBridge,
269
- Scheduler,
270
- Selection])
271
- ], CollaborateCursor);
272
- export { CollaborateCursor };
273
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sbGFib3JhdGUtY3Vyc29yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2NvbGxhYm9yYXRlLWN1cnNvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdz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AgIHBhZGRpbmc6ICczcHggNXB4JyxcbiAgICAgICAgcG9pbnRlckV2ZW50czogJ25vbmUnLFxuICAgICAgfVxuICAgIH0pXG5cbiAgICBjb25zdCBhbmNob3IgPSBjcmVhdGVFbGVtZW50KCdzcGFuJywge1xuICAgICAgc3R5bGVzOiB7XG4gICAgICAgIHBvc2l0aW9uOiAnYWJzb2x1dGUnLFxuICAgICAgICB0b3A6ICctMnB4JyxcbiAgICAgICAgbGVmdDogJy0ycHgnLFxuICAgICAgICB3aWR0aDogJzZweCcsXG4gICAgICAgIGhlaWdodDogJzZweCcsXG4gICAgICAgIHBvaW50ZXJFdmVudHM6ICdhdXRvJyxcbiAgICAgICAgcG9pbnRlcjogJ2N1cnNvcicsXG4gICAgICB9LFxuICAgICAgY2hpbGRyZW46IFt1c2VyVGlwXSxcbiAgICAgIG9uOiB7XG4gICAgICAgIG1vdXNlZW50ZXIoKSB7XG4gICAgICAgICAgdXNlclRpcC5zdHlsZS5kaXNwbGF5ID0gJ2Jsb2NrJ1xuICAgICAgICB9LFxuICAgICAgICBtb3VzZWxlYXZlKCkge1xuICAgICAgICAgIHVzZXJUaXAuc3R5bGUuZGlzcGxheSA9ICdub25lJ1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfSlcbiAgICBjaGlsZCA9IGNyZWF0ZUVsZW1lbnQoJ3NwYW4nLCB7XG4gICAgICBzdHlsZXM6IHtcbiAgICAgICAgcG9zaXRpb246ICdhYnNvbHV0ZScsXG4gICAgICB9LFxuICAgICAgY2hpbGRyZW46IFtcbiAgICAgICAgYW5jaG9yXG4gICAgICBdXG4gICAgfSlcbiAgICB0aGlzLnRvb2x0aXBzLmFwcGVuZChjaGlsZClcbiAgICByZXR1cm4ge1xuICAgICAgY3Vyc29yOiBjaGlsZCxcbiAgICAgIGFuY2hvcixcbiAgICAgIHVzZXJUaXBcbiAgICB9XG4gIH1cbn1cbiJdfQ==