@textbus/collaborate 2.5.4 → 2.5.6

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.
@@ -1,3 +1,4 @@
1
+ import { Injector } from '@tanbo/di';
1
2
  import { SelectionBridge } from '@textbus/browser';
2
3
  import { Selection, SelectionPaths, AbstractSelection, Scheduler, Rect } from '@textbus/core';
3
4
  export interface RemoteSelection {
@@ -20,11 +21,11 @@ export declare abstract class CollaborateSelectionAwarenessDelegate {
20
21
  abstract getRects(abstractSelection: AbstractSelection, nativeRange: Range): false | Rect[];
21
22
  }
22
23
  export declare class CollaborateCursor {
23
- private container;
24
- private awarenessDelegate;
24
+ private injector;
25
25
  private nativeSelection;
26
26
  private scheduler;
27
27
  private selection;
28
+ private awarenessDelegate;
28
29
  private host;
29
30
  private canvasContainer;
30
31
  private canvas;
@@ -33,7 +34,8 @@ export declare class CollaborateCursor {
33
34
  private onRectsChange;
34
35
  private subscription;
35
36
  private currentSelection;
36
- constructor(container: HTMLElement, awarenessDelegate: CollaborateSelectionAwarenessDelegate, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection);
37
+ private container;
38
+ constructor(injector: Injector, nativeSelection: SelectionBridge, scheduler: Scheduler, selection: Selection, awarenessDelegate?: CollaborateSelectionAwarenessDelegate | null);
37
39
  refresh(): void;
38
40
  destroy(): void;
39
41
  draw(paths: RemoteSelection[]): void;
@@ -1,10 +1,10 @@
1
1
  import { Scheduler, Selection, defineComponent, ContentType, VElement, makeError, HISTORY_STACK_SIZE, ChangeOrigin, Slot, FormatType, RootComponentRef, Controller, Translator, Registry, Starter, History } from '@textbus/core';
2
- import { Injectable, Inject, Optional } from '@tanbo/di';
2
+ import { Injectable, Optional, Injector, Inject } from '@tanbo/di';
3
3
  import { Subject, Subscription, fromEvent, delay, map, filter } from '@tanbo/stream';
4
4
  import { Doc, UndoManager, Array, createAbsolutePositionFromRelativePosition, createRelativePositionFromTypeIndex, Map, Text } from 'yjs';
5
- import { VIEW_CONTAINER, createElement, getLayoutRectByRange, SelectionBridge } from '@textbus/browser';
5
+ import { createElement, VIEW_CONTAINER, getLayoutRectByRange, SelectionBridge } from '@textbus/browser';
6
6
 
7
- /*! *****************************************************************************
7
+ /******************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
9
9
 
10
10
  Permission to use, copy, modify, and/or distribute this software for any
@@ -37,12 +37,12 @@ function __metadata(metadataKey, metadataValue) {
37
37
  class CollaborateSelectionAwarenessDelegate {
38
38
  }
39
39
  let CollaborateCursor = class CollaborateCursor {
40
- constructor(container, awarenessDelegate, nativeSelection, scheduler, selection) {
41
- this.container = container;
42
- this.awarenessDelegate = awarenessDelegate;
40
+ constructor(injector, nativeSelection, scheduler, selection, awarenessDelegate = null) {
41
+ this.injector = injector;
43
42
  this.nativeSelection = nativeSelection;
44
43
  this.scheduler = scheduler;
45
44
  this.selection = selection;
45
+ this.awarenessDelegate = awarenessDelegate;
46
46
  this.host = createElement('div', {
47
47
  styles: {
48
48
  position: 'absolute',
@@ -91,9 +91,10 @@ let CollaborateCursor = class CollaborateCursor {
91
91
  this.onRectsChange = new Subject();
92
92
  this.subscription = new Subscription();
93
93
  this.currentSelection = [];
94
+ this.container = injector.get(VIEW_CONTAINER);
94
95
  this.canvasContainer.append(this.canvas);
95
96
  this.host.append(this.canvasContainer, this.tooltips);
96
- container.prepend(this.host);
97
+ this.container.prepend(this.host);
97
98
  this.subscription.add(this.onRectsChange.subscribe(rects => {
98
99
  for (const rect of rects) {
99
100
  this.context.fillStyle = rect.color;
@@ -187,7 +188,7 @@ let CollaborateCursor = class CollaborateCursor {
187
188
  color: item.color,
188
189
  left: cursorRect.left - containerRect.left,
189
190
  top: cursorRect.top - containerRect.top,
190
- width: 2,
191
+ width: 1,
191
192
  height: cursorRect.height
192
193
  };
193
194
  if (rect.left < 0 || rect.top < 0 || rect.left > containerRect.width) {
@@ -230,7 +231,6 @@ let CollaborateCursor = class CollaborateCursor {
230
231
  const userTip = createElement('span', {
231
232
  styles: {
232
233
  position: 'absolute',
233
- display: 'none',
234
234
  left: '50%',
235
235
  transform: 'translateX(-50%)',
236
236
  marginBottom: '2px',
@@ -238,6 +238,7 @@ let CollaborateCursor = class CollaborateCursor {
238
238
  whiteSpace: 'nowrap',
239
239
  color: '#fff',
240
240
  boxShadow: '0 1px 2px rgba(0,0,0,.1)',
241
+ opacity: 0.8,
241
242
  borderRadius: '3px',
242
243
  padding: '3px 5px',
243
244
  pointerEvents: 'none',
@@ -248,20 +249,13 @@ let CollaborateCursor = class CollaborateCursor {
248
249
  position: 'absolute',
249
250
  top: '-2px',
250
251
  left: '-2px',
251
- width: '6px',
252
- height: '6px',
252
+ width: '5px',
253
+ height: '5px',
254
+ borderRadius: '50%',
253
255
  pointerEvents: 'auto',
254
256
  pointer: 'cursor',
255
257
  },
256
- children: [userTip],
257
- on: {
258
- mouseenter() {
259
- userTip.style.display = 'block';
260
- },
261
- mouseleave() {
262
- userTip.style.display = 'none';
263
- }
264
- }
258
+ children: [userTip]
265
259
  });
266
260
  child = createElement('span', {
267
261
  styles: {
@@ -281,13 +275,11 @@ let CollaborateCursor = class CollaborateCursor {
281
275
  };
282
276
  CollaborateCursor = __decorate([
283
277
  Injectable(),
284
- __param(0, Inject(VIEW_CONTAINER)),
285
- __param(1, Optional()),
286
- __metadata("design:paramtypes", [HTMLElement,
287
- CollaborateSelectionAwarenessDelegate,
278
+ __param(4, Optional()),
279
+ __metadata("design:paramtypes", [Injector,
288
280
  SelectionBridge,
289
281
  Scheduler,
290
- Selection])
282
+ Selection, Object])
291
283
  ], CollaborateCursor);
292
284
 
293
285
  function createUnknownComponent(factoryName, canInsertInlineComponent) {
package/bundles/index.js CHANGED
@@ -6,7 +6,7 @@ var stream = require('@tanbo/stream');
6
6
  var yjs = require('yjs');
7
7
  var browser = require('@textbus/browser');
8
8
 
9
- /*! *****************************************************************************
9
+ /******************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
11
11
 
12
12
  Permission to use, copy, modify, and/or distribute this software for any
@@ -39,12 +39,12 @@ function __metadata(metadataKey, metadataValue) {
39
39
  class CollaborateSelectionAwarenessDelegate {
40
40
  }
41
41
  exports.CollaborateCursor = class CollaborateCursor {
42
- constructor(container, awarenessDelegate, nativeSelection, scheduler, selection) {
43
- this.container = container;
44
- this.awarenessDelegate = awarenessDelegate;
42
+ constructor(injector, nativeSelection, scheduler, selection, awarenessDelegate = null) {
43
+ this.injector = injector;
45
44
  this.nativeSelection = nativeSelection;
46
45
  this.scheduler = scheduler;
47
46
  this.selection = selection;
47
+ this.awarenessDelegate = awarenessDelegate;
48
48
  this.host = browser.createElement('div', {
49
49
  styles: {
50
50
  position: 'absolute',
@@ -93,9 +93,10 @@ exports.CollaborateCursor = class CollaborateCursor {
93
93
  this.onRectsChange = new stream.Subject();
94
94
  this.subscription = new stream.Subscription();
95
95
  this.currentSelection = [];
96
+ this.container = injector.get(browser.VIEW_CONTAINER);
96
97
  this.canvasContainer.append(this.canvas);
97
98
  this.host.append(this.canvasContainer, this.tooltips);
98
- container.prepend(this.host);
99
+ this.container.prepend(this.host);
99
100
  this.subscription.add(this.onRectsChange.subscribe(rects => {
100
101
  for (const rect of rects) {
101
102
  this.context.fillStyle = rect.color;
@@ -189,7 +190,7 @@ exports.CollaborateCursor = class CollaborateCursor {
189
190
  color: item.color,
190
191
  left: cursorRect.left - containerRect.left,
191
192
  top: cursorRect.top - containerRect.top,
192
- width: 2,
193
+ width: 1,
193
194
  height: cursorRect.height
194
195
  };
195
196
  if (rect.left < 0 || rect.top < 0 || rect.left > containerRect.width) {
@@ -232,7 +233,6 @@ exports.CollaborateCursor = class CollaborateCursor {
232
233
  const userTip = browser.createElement('span', {
233
234
  styles: {
234
235
  position: 'absolute',
235
- display: 'none',
236
236
  left: '50%',
237
237
  transform: 'translateX(-50%)',
238
238
  marginBottom: '2px',
@@ -240,6 +240,7 @@ exports.CollaborateCursor = class CollaborateCursor {
240
240
  whiteSpace: 'nowrap',
241
241
  color: '#fff',
242
242
  boxShadow: '0 1px 2px rgba(0,0,0,.1)',
243
+ opacity: 0.8,
243
244
  borderRadius: '3px',
244
245
  padding: '3px 5px',
245
246
  pointerEvents: 'none',
@@ -250,20 +251,13 @@ exports.CollaborateCursor = class CollaborateCursor {
250
251
  position: 'absolute',
251
252
  top: '-2px',
252
253
  left: '-2px',
253
- width: '6px',
254
- height: '6px',
254
+ width: '5px',
255
+ height: '5px',
256
+ borderRadius: '50%',
255
257
  pointerEvents: 'auto',
256
258
  pointer: 'cursor',
257
259
  },
258
- children: [userTip],
259
- on: {
260
- mouseenter() {
261
- userTip.style.display = 'block';
262
- },
263
- mouseleave() {
264
- userTip.style.display = 'none';
265
- }
266
- }
260
+ children: [userTip]
267
261
  });
268
262
  child = browser.createElement('span', {
269
263
  styles: {
@@ -283,13 +277,11 @@ exports.CollaborateCursor = class CollaborateCursor {
283
277
  };
284
278
  exports.CollaborateCursor = __decorate([
285
279
  di.Injectable(),
286
- __param(0, di.Inject(browser.VIEW_CONTAINER)),
287
- __param(1, di.Optional()),
288
- __metadata("design:paramtypes", [HTMLElement,
289
- CollaborateSelectionAwarenessDelegate,
280
+ __param(4, di.Optional()),
281
+ __metadata("design:paramtypes", [di.Injector,
290
282
  browser.SelectionBridge,
291
283
  core.Scheduler,
292
- core.Selection])
284
+ core.Selection, Object])
293
285
  ], exports.CollaborateCursor);
294
286
 
295
287
  function createUnknownComponent(factoryName, canInsertInlineComponent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/collaborate",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
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,8 +27,8 @@
27
27
  "dependencies": {
28
28
  "@tanbo/di": "^1.1.3",
29
29
  "@tanbo/stream": "^1.1.8",
30
- "@textbus/browser": "^2.5.4",
31
- "@textbus/core": "^2.5.4",
30
+ "@textbus/browser": "^2.5.5",
31
+ "@textbus/core": "^2.5.5",
32
32
  "reflect-metadata": "^0.1.13",
33
33
  "y-protocols": "^1.0.5",
34
34
  "yjs": "^13.5.39"
@@ -36,7 +36,9 @@
36
36
  "devDependencies": {
37
37
  "@rollup/plugin-commonjs": "^23.0.2",
38
38
  "@rollup/plugin-typescript": "^9.0.2",
39
- "rollup": "^3.2.5"
39
+ "rimraf": "^3.0.2",
40
+ "rollup": "^3.2.5",
41
+ "tslib": "^2.4.1"
40
42
  },
41
43
  "author": {
42
44
  "name": "Tanbo",
@@ -49,5 +51,5 @@
49
51
  "bugs": {
50
52
  "url": "https://github.com/textbus/textbus.git/issues"
51
53
  },
52
- "gitHead": "e735eef19dfb830c5fe186622328f3e7a86086be"
54
+ "gitHead": "cd75d4ae54f0976cbb87c654ab322b5d66f572e5"
53
55
  }