@textbus/collaborate 3.0.0-alpha.61 → 3.0.0-alpha.62
Sign up to get free protection for your applications and to get access to all the features.
- package/bundles/collaborate.d.ts +6 -2
- package/bundles/index.esm.js +16 -5
- package/bundles/index.js +15 -3
- package/package.json +2 -2
package/bundles/collaborate.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Observable, Subject, Subscription } from '@tanbo/stream';
|
2
2
|
import { AbstractSelection, ComponentInstance, Controller, Registry, History, RootComponentRef, Scheduler, Selection, SelectionPaths, Slot, Starter } from '@textbus/core';
|
3
|
-
import { Array as YArray, Doc as YDoc, Map as YMap, RelativePosition, Text as YText, Transaction, UndoManager } from 'yjs';
|
3
|
+
import { Array as YArray, Doc as YDoc, Map as YMap, RelativePosition, Text as YText, Transaction, UndoManager, Item } from 'yjs';
|
4
4
|
interface CursorPosition {
|
5
5
|
anchor: RelativePosition;
|
6
6
|
focus: RelativePosition;
|
@@ -18,6 +18,9 @@ interface UpdateItem {
|
|
18
18
|
record: boolean;
|
19
19
|
action(): void;
|
20
20
|
}
|
21
|
+
export declare abstract class CustomUndoManagerConfig {
|
22
|
+
abstract deleteFilter(item: Item): boolean;
|
23
|
+
}
|
21
24
|
export declare class Collaborate implements History {
|
22
25
|
protected stackSize: number;
|
23
26
|
protected rootComponentRef: RootComponentRef;
|
@@ -26,6 +29,7 @@ export declare class Collaborate implements History {
|
|
26
29
|
protected registry: Registry;
|
27
30
|
protected selection: Selection;
|
28
31
|
protected starter: Starter;
|
32
|
+
protected undoManagerConfig: CustomUndoManagerConfig;
|
29
33
|
onLocalChangesApplied: Observable<void>;
|
30
34
|
yDoc: YDoc;
|
31
35
|
onBack: Observable<void>;
|
@@ -52,7 +56,7 @@ export declare class Collaborate implements History {
|
|
52
56
|
protected noRecord: {};
|
53
57
|
protected historyItems: Array<CursorPosition | null>;
|
54
58
|
protected index: number;
|
55
|
-
constructor(stackSize: number, rootComponentRef: RootComponentRef, controller: Controller, scheduler: Scheduler, registry: Registry, selection: Selection, starter: Starter);
|
59
|
+
constructor(stackSize: number, rootComponentRef: RootComponentRef, controller: Controller, scheduler: Scheduler, registry: Registry, selection: Selection, starter: Starter, undoManagerConfig: CustomUndoManagerConfig);
|
56
60
|
listen(): void;
|
57
61
|
back(): void;
|
58
62
|
forward(): void;
|
package/bundles/index.esm.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { makeError, HISTORY_STACK_SIZE, ChangeOrigin, Slot, RootComponentRef, Controller, Scheduler, Registry, Selection, Starter, History } from '@textbus/core';
|
2
|
-
import { Injectable, Inject } from '@tanbo/di';
|
2
|
+
import { Injectable, Inject, Optional } from '@tanbo/di';
|
3
3
|
import { Subject, map, filter } from '@tanbo/stream';
|
4
4
|
import { Doc, UndoManager, Array, createAbsolutePositionFromRelativePosition, createRelativePositionFromTypeIndex, Map, Text } from 'yjs';
|
5
5
|
|
@@ -72,6 +72,8 @@ class ContentMap {
|
|
72
72
|
}
|
73
73
|
}
|
74
74
|
}
|
75
|
+
class CustomUndoManagerConfig {
|
76
|
+
}
|
75
77
|
let Collaborate = class Collaborate {
|
76
78
|
get canBack() {
|
77
79
|
var _a;
|
@@ -81,7 +83,7 @@ let Collaborate = class Collaborate {
|
|
81
83
|
var _a;
|
82
84
|
return ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.canRedo()) || false;
|
83
85
|
}
|
84
|
-
constructor(stackSize, rootComponentRef, controller, scheduler, registry, selection, starter) {
|
86
|
+
constructor(stackSize, rootComponentRef, controller, scheduler, registry, selection, starter, undoManagerConfig) {
|
85
87
|
this.stackSize = stackSize;
|
86
88
|
this.rootComponentRef = rootComponentRef;
|
87
89
|
this.controller = controller;
|
@@ -89,6 +91,7 @@ let Collaborate = class Collaborate {
|
|
89
91
|
this.registry = registry;
|
90
92
|
this.selection = selection;
|
91
93
|
this.starter = starter;
|
94
|
+
this.undoManagerConfig = undoManagerConfig;
|
92
95
|
this.yDoc = new Doc();
|
93
96
|
this.backEvent = new Subject();
|
94
97
|
this.forwardEvent = new Subject();
|
@@ -118,7 +121,13 @@ let Collaborate = class Collaborate {
|
|
118
121
|
const root = this.yDoc.getMap('RootComponent');
|
119
122
|
const rootComponent = this.rootComponentRef.component;
|
120
123
|
const manager = new UndoManager(root, {
|
121
|
-
trackedOrigins: new Set([this.yDoc])
|
124
|
+
trackedOrigins: new Set([this.yDoc]),
|
125
|
+
deleteFilter: (item) => {
|
126
|
+
if (this.undoManagerConfig) {
|
127
|
+
return this.undoManagerConfig.deleteFilter(item);
|
128
|
+
}
|
129
|
+
return true;
|
130
|
+
}
|
122
131
|
});
|
123
132
|
this.manager = manager;
|
124
133
|
manager.on('stack-item-added', event => {
|
@@ -724,12 +733,14 @@ let Collaborate = class Collaborate {
|
|
724
733
|
Collaborate = __decorate([
|
725
734
|
Injectable(),
|
726
735
|
__param(0, Inject(HISTORY_STACK_SIZE)),
|
736
|
+
__param(7, Optional()),
|
727
737
|
__metadata("design:paramtypes", [Number, RootComponentRef,
|
728
738
|
Controller,
|
729
739
|
Scheduler,
|
730
740
|
Registry,
|
731
741
|
Selection,
|
732
|
-
Starter
|
742
|
+
Starter,
|
743
|
+
CustomUndoManagerConfig])
|
733
744
|
], Collaborate);
|
734
745
|
function remoteFormatsToLocal(registry, attrs) {
|
735
746
|
const formats = [];
|
@@ -754,4 +765,4 @@ const collaborateModule = {
|
|
754
765
|
]
|
755
766
|
};
|
756
767
|
|
757
|
-
export { Collaborate, collaborateModule };
|
768
|
+
export { Collaborate, CustomUndoManagerConfig, collaborateModule };
|
package/bundles/index.js
CHANGED
@@ -74,6 +74,8 @@ class ContentMap {
|
|
74
74
|
}
|
75
75
|
}
|
76
76
|
}
|
77
|
+
class CustomUndoManagerConfig {
|
78
|
+
}
|
77
79
|
exports.Collaborate = class Collaborate {
|
78
80
|
get canBack() {
|
79
81
|
var _a;
|
@@ -83,7 +85,7 @@ exports.Collaborate = class Collaborate {
|
|
83
85
|
var _a;
|
84
86
|
return ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.canRedo()) || false;
|
85
87
|
}
|
86
|
-
constructor(stackSize, rootComponentRef, controller, scheduler, registry, selection, starter) {
|
88
|
+
constructor(stackSize, rootComponentRef, controller, scheduler, registry, selection, starter, undoManagerConfig) {
|
87
89
|
this.stackSize = stackSize;
|
88
90
|
this.rootComponentRef = rootComponentRef;
|
89
91
|
this.controller = controller;
|
@@ -91,6 +93,7 @@ exports.Collaborate = class Collaborate {
|
|
91
93
|
this.registry = registry;
|
92
94
|
this.selection = selection;
|
93
95
|
this.starter = starter;
|
96
|
+
this.undoManagerConfig = undoManagerConfig;
|
94
97
|
this.yDoc = new yjs.Doc();
|
95
98
|
this.backEvent = new stream.Subject();
|
96
99
|
this.forwardEvent = new stream.Subject();
|
@@ -120,7 +123,13 @@ exports.Collaborate = class Collaborate {
|
|
120
123
|
const root = this.yDoc.getMap('RootComponent');
|
121
124
|
const rootComponent = this.rootComponentRef.component;
|
122
125
|
const manager = new yjs.UndoManager(root, {
|
123
|
-
trackedOrigins: new Set([this.yDoc])
|
126
|
+
trackedOrigins: new Set([this.yDoc]),
|
127
|
+
deleteFilter: (item) => {
|
128
|
+
if (this.undoManagerConfig) {
|
129
|
+
return this.undoManagerConfig.deleteFilter(item);
|
130
|
+
}
|
131
|
+
return true;
|
132
|
+
}
|
124
133
|
});
|
125
134
|
this.manager = manager;
|
126
135
|
manager.on('stack-item-added', event => {
|
@@ -726,12 +735,14 @@ exports.Collaborate = class Collaborate {
|
|
726
735
|
exports.Collaborate = __decorate([
|
727
736
|
di.Injectable(),
|
728
737
|
__param(0, di.Inject(core.HISTORY_STACK_SIZE)),
|
738
|
+
__param(7, di.Optional()),
|
729
739
|
__metadata("design:paramtypes", [Number, core.RootComponentRef,
|
730
740
|
core.Controller,
|
731
741
|
core.Scheduler,
|
732
742
|
core.Registry,
|
733
743
|
core.Selection,
|
734
|
-
core.Starter
|
744
|
+
core.Starter,
|
745
|
+
CustomUndoManagerConfig])
|
735
746
|
], exports.Collaborate);
|
736
747
|
function remoteFormatsToLocal(registry, attrs) {
|
737
748
|
const formats = [];
|
@@ -756,4 +767,5 @@ const collaborateModule = {
|
|
756
767
|
]
|
757
768
|
};
|
758
769
|
|
770
|
+
exports.CustomUndoManagerConfig = CustomUndoManagerConfig;
|
759
771
|
exports.collaborateModule = collaborateModule;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@textbus/collaborate",
|
3
|
-
"version": "3.0.0-alpha.
|
3
|
+
"version": "3.0.0-alpha.62",
|
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",
|
@@ -50,5 +50,5 @@
|
|
50
50
|
"bugs": {
|
51
51
|
"url": "https://github.com/textbus/textbus.git/issues"
|
52
52
|
},
|
53
|
-
"gitHead": "
|
53
|
+
"gitHead": "19e52671c05d0701d3c748452bcb7bbede65ac81"
|
54
54
|
}
|