etherpad-webcomponents 0.0.5 → 0.0.7
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/dist/EpDropdown.d.ts +3 -0
- package/dist/EpDropdown.d.ts.map +1 -1
- package/dist/EpDropdown.js +30 -4
- package/dist/EpDropdown.js.map +1 -1
- package/dist/EpEditor.d.ts +108 -0
- package/dist/EpEditor.d.ts.map +1 -0
- package/dist/EpEditor.js +288 -0
- package/dist/EpEditor.js.map +1 -0
- package/dist/editor/AceEditor.d.ts +204 -0
- package/dist/editor/AceEditor.d.ts.map +1 -0
- package/dist/editor/AceEditor.js +2847 -0
- package/dist/editor/AceEditor.js.map +1 -0
- package/dist/editor/AttributeManager.d.ts +25 -0
- package/dist/editor/AttributeManager.d.ts.map +1 -0
- package/dist/editor/AttributeManager.js +236 -0
- package/dist/editor/AttributeManager.js.map +1 -0
- package/dist/editor/AttributeMap.d.ts +13 -0
- package/dist/editor/AttributeMap.d.ts.map +1 -0
- package/dist/editor/AttributeMap.js +37 -0
- package/dist/editor/AttributeMap.js.map +1 -0
- package/dist/editor/AttributePool.d.ts +22 -0
- package/dist/editor/AttributePool.d.ts.map +1 -0
- package/dist/editor/AttributePool.js +101 -0
- package/dist/editor/AttributePool.js.map +1 -0
- package/dist/editor/Builder.d.ts +15 -0
- package/dist/editor/Builder.d.ts.map +1 -0
- package/dist/editor/Builder.js +47 -0
- package/dist/editor/Builder.js.map +1 -0
- package/dist/editor/Changeset.d.ts +61 -0
- package/dist/editor/Changeset.d.ts.map +1 -0
- package/dist/editor/Changeset.js +942 -0
- package/dist/editor/Changeset.js.map +1 -0
- package/dist/editor/ChangesetUtils.d.ts +11 -0
- package/dist/editor/ChangesetUtils.d.ts.map +1 -0
- package/dist/editor/ChangesetUtils.js +30 -0
- package/dist/editor/ChangesetUtils.js.map +1 -0
- package/dist/editor/MergingOpAssembler.d.ts +13 -0
- package/dist/editor/MergingOpAssembler.d.ts.map +1 -0
- package/dist/editor/MergingOpAssembler.js +60 -0
- package/dist/editor/MergingOpAssembler.js.map +1 -0
- package/dist/editor/Op.d.ts +10 -0
- package/dist/editor/Op.d.ts.map +1 -0
- package/dist/editor/Op.js +18 -0
- package/dist/editor/Op.js.map +1 -0
- package/dist/editor/OpAssembler.d.ts +9 -0
- package/dist/editor/OpAssembler.d.ts.map +1 -0
- package/dist/editor/OpAssembler.js +16 -0
- package/dist/editor/OpAssembler.js.map +1 -0
- package/dist/editor/OpIter.d.ts +9 -0
- package/dist/editor/OpIter.d.ts.map +1 -0
- package/dist/editor/OpIter.js +22 -0
- package/dist/editor/OpIter.js.map +1 -0
- package/dist/editor/SmartOpAssembler.d.ts +21 -0
- package/dist/editor/SmartOpAssembler.d.ts.map +1 -0
- package/dist/editor/SmartOpAssembler.js +71 -0
- package/dist/editor/SmartOpAssembler.js.map +1 -0
- package/dist/editor/StringAssembler.d.ts +7 -0
- package/dist/editor/StringAssembler.d.ts.map +1 -0
- package/dist/editor/StringAssembler.js +15 -0
- package/dist/editor/StringAssembler.js.map +1 -0
- package/dist/editor/StringIterator.d.ts +13 -0
- package/dist/editor/StringIterator.d.ts.map +1 -0
- package/dist/editor/StringIterator.js +29 -0
- package/dist/editor/StringIterator.js.map +1 -0
- package/dist/editor/TextLinesMutator.d.ts +31 -0
- package/dist/editor/TextLinesMutator.d.ts.map +1 -0
- package/dist/editor/TextLinesMutator.js +198 -0
- package/dist/editor/TextLinesMutator.js.map +1 -0
- package/dist/editor/ace2_common.d.ts +9 -0
- package/dist/editor/ace2_common.d.ts.map +1 -0
- package/dist/editor/ace2_common.js +31 -0
- package/dist/editor/ace2_common.js.map +1 -0
- package/dist/editor/attributes.d.ts +20 -0
- package/dist/editor/attributes.d.ts.map +1 -0
- package/dist/editor/attributes.js +54 -0
- package/dist/editor/attributes.js.map +1 -0
- package/dist/editor/browser_flags.d.ts +7 -0
- package/dist/editor/browser_flags.d.ts.map +1 -0
- package/dist/editor/browser_flags.js +8 -0
- package/dist/editor/browser_flags.js.map +1 -0
- package/dist/editor/changesettracker.d.ts +54 -0
- package/dist/editor/changesettracker.d.ts.map +1 -0
- package/dist/editor/changesettracker.js +193 -0
- package/dist/editor/changesettracker.js.map +1 -0
- package/dist/editor/colorutils.d.ts +22 -0
- package/dist/editor/colorutils.d.ts.map +1 -0
- package/dist/editor/colorutils.js +81 -0
- package/dist/editor/colorutils.js.map +1 -0
- package/dist/editor/contentcollector.d.ts +52 -0
- package/dist/editor/contentcollector.d.ts.map +1 -0
- package/dist/editor/contentcollector.js +692 -0
- package/dist/editor/contentcollector.js.map +1 -0
- package/dist/editor/core/EventBus.d.ts +187 -0
- package/dist/editor/core/EventBus.d.ts.map +1 -0
- package/dist/editor/core/EventBus.js +169 -0
- package/dist/editor/core/EventBus.js.map +1 -0
- package/dist/editor/cssmanager.d.ts +6 -0
- package/dist/editor/cssmanager.d.ts.map +1 -0
- package/dist/editor/cssmanager.js +35 -0
- package/dist/editor/cssmanager.js.map +1 -0
- package/dist/editor/domline.d.ts +35 -0
- package/dist/editor/domline.d.ts.map +1 -0
- package/dist/editor/domline.js +267 -0
- package/dist/editor/domline.js.map +1 -0
- package/dist/editor/html_escape.d.ts +3 -0
- package/dist/editor/html_escape.d.ts.map +1 -0
- package/dist/editor/html_escape.js +8 -0
- package/dist/editor/html_escape.js.map +1 -0
- package/dist/editor/linestylefilter.d.ts +22 -0
- package/dist/editor/linestylefilter.d.ts.map +1 -0
- package/dist/editor/linestylefilter.js +298 -0
- package/dist/editor/linestylefilter.js.map +1 -0
- package/dist/editor/skiplist.d.ts +51 -0
- package/dist/editor/skiplist.d.ts.map +1 -0
- package/dist/editor/skiplist.js +327 -0
- package/dist/editor/skiplist.js.map +1 -0
- package/dist/editor/types/AText.d.ts +5 -0
- package/dist/editor/types/AText.d.ts.map +1 -0
- package/dist/editor/types/AText.js +2 -0
- package/dist/editor/types/AText.js.map +1 -0
- package/dist/editor/types/Attribute.d.ts +2 -0
- package/dist/editor/types/Attribute.d.ts.map +1 -0
- package/dist/editor/types/Attribute.js +2 -0
- package/dist/editor/types/Attribute.js.map +1 -0
- package/dist/editor/types/ChangeSet.d.ts +7 -0
- package/dist/editor/types/ChangeSet.d.ts.map +1 -0
- package/dist/editor/types/ChangeSet.js +2 -0
- package/dist/editor/types/ChangeSet.js.map +1 -0
- package/dist/editor/types/ChangeSetBuilder.d.ts +7 -0
- package/dist/editor/types/ChangeSetBuilder.d.ts.map +1 -0
- package/dist/editor/types/ChangeSetBuilder.js +2 -0
- package/dist/editor/types/ChangeSetBuilder.js.map +1 -0
- package/dist/editor/types/RepModel.d.ts +25 -0
- package/dist/editor/types/RepModel.d.ts.map +1 -0
- package/dist/editor/types/RepModel.js +2 -0
- package/dist/editor/types/RepModel.js.map +1 -0
- package/dist/editor/undomodule.d.ts +30 -0
- package/dist/editor/undomodule.d.ts.map +1 -0
- package/dist/editor/undomodule.js +266 -0
- package/dist/editor/undomodule.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { splitTextLines } from "./Changeset.js";
|
|
2
|
+
class TextLinesMutator {
|
|
3
|
+
constructor(lines) {
|
|
4
|
+
this._lines = lines;
|
|
5
|
+
this._curSplice = [0, 0];
|
|
6
|
+
this._inSplice = false;
|
|
7
|
+
this._curLine = 0;
|
|
8
|
+
this._curCol = 0;
|
|
9
|
+
}
|
|
10
|
+
_linesGet(idx) {
|
|
11
|
+
if ('get' in this._lines) {
|
|
12
|
+
return this._lines.get(idx);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return this._lines[idx];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
_linesSlice(start, end) {
|
|
19
|
+
if ('slice' in this._lines && typeof this._lines.slice === 'function') {
|
|
20
|
+
return this._lines.slice(start, end);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
_linesLength() {
|
|
27
|
+
if (Array.isArray(this._lines)) {
|
|
28
|
+
return this._lines.length;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return this._lines.length();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_enterSplice() {
|
|
35
|
+
this._curSplice[0] = this._curLine;
|
|
36
|
+
this._curSplice[1] = 0;
|
|
37
|
+
if (this._curCol > 0)
|
|
38
|
+
this._putCurLineInSplice();
|
|
39
|
+
this._inSplice = true;
|
|
40
|
+
}
|
|
41
|
+
_leaveSplice() {
|
|
42
|
+
if (Array.isArray(this._lines)) {
|
|
43
|
+
this._lines.splice(this._curSplice[0], this._curSplice[1], ...this._curSplice.slice(2));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this._lines.splice(...this._curSplice);
|
|
47
|
+
}
|
|
48
|
+
this._curSplice = [0, 0];
|
|
49
|
+
this._inSplice = false;
|
|
50
|
+
}
|
|
51
|
+
_isCurLineInSplice() {
|
|
52
|
+
return this._curLine - this._curSplice[0] < this._curSplice.length - 2;
|
|
53
|
+
}
|
|
54
|
+
_putCurLineInSplice() {
|
|
55
|
+
if (!this._isCurLineInSplice()) {
|
|
56
|
+
this._curSplice.push(this._linesGet(this._curSplice[0] + this._curSplice[1]));
|
|
57
|
+
this._curSplice[1]++;
|
|
58
|
+
}
|
|
59
|
+
return 2 + this._curLine - this._curSplice[0];
|
|
60
|
+
}
|
|
61
|
+
skipLines(L, includeInSplice) {
|
|
62
|
+
if (!L)
|
|
63
|
+
return;
|
|
64
|
+
if (includeInSplice) {
|
|
65
|
+
if (!this._inSplice)
|
|
66
|
+
this._enterSplice();
|
|
67
|
+
for (let i = 0; i < L; i++) {
|
|
68
|
+
this._curCol = 0;
|
|
69
|
+
this._putCurLineInSplice();
|
|
70
|
+
this._curLine++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
if (this._inSplice) {
|
|
75
|
+
if (L > 1) {
|
|
76
|
+
this._leaveSplice();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this._putCurLineInSplice();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
this._curLine += L;
|
|
83
|
+
this._curCol = 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
skip(N, L, includeInSplice) {
|
|
87
|
+
if (!N)
|
|
88
|
+
return;
|
|
89
|
+
if (L) {
|
|
90
|
+
this.skipLines(L, includeInSplice);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (includeInSplice && !this._inSplice)
|
|
94
|
+
this._enterSplice();
|
|
95
|
+
if (this._inSplice) {
|
|
96
|
+
this._putCurLineInSplice();
|
|
97
|
+
}
|
|
98
|
+
this._curCol += N;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
removeLines(L) {
|
|
102
|
+
if (!L)
|
|
103
|
+
return '';
|
|
104
|
+
if (!this._inSplice)
|
|
105
|
+
this._enterSplice();
|
|
106
|
+
const nextKLinesText = (k) => {
|
|
107
|
+
const m = this._curSplice[0] + this._curSplice[1];
|
|
108
|
+
return this._linesSlice(m, m + k).join('');
|
|
109
|
+
};
|
|
110
|
+
let removed = '';
|
|
111
|
+
if (this._isCurLineInSplice()) {
|
|
112
|
+
if (this._curCol === 0) {
|
|
113
|
+
removed = this._curSplice[this._curSplice.length - 1];
|
|
114
|
+
this._curSplice = [...this._curSplice.slice(0, -1)];
|
|
115
|
+
removed += nextKLinesText(L - 1);
|
|
116
|
+
this._curSplice[1] += L - 1;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
removed = nextKLinesText(L - 1);
|
|
120
|
+
this._curSplice[1] += L - 1;
|
|
121
|
+
const sline = this._curSplice.length - 1;
|
|
122
|
+
const slineVal = this._curSplice[sline];
|
|
123
|
+
removed = slineVal.substring(this._curCol) + removed;
|
|
124
|
+
this._curSplice[sline] = slineVal.substring(0, this._curCol) +
|
|
125
|
+
this._linesGet(this._curSplice[0] + this._curSplice[1]);
|
|
126
|
+
this._curSplice[1] += 1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
removed = nextKLinesText(L);
|
|
131
|
+
this._curSplice[1] += L;
|
|
132
|
+
}
|
|
133
|
+
return removed;
|
|
134
|
+
}
|
|
135
|
+
remove(N, L) {
|
|
136
|
+
if (!N)
|
|
137
|
+
return '';
|
|
138
|
+
if (L)
|
|
139
|
+
return this.removeLines(L);
|
|
140
|
+
if (!this._inSplice)
|
|
141
|
+
this._enterSplice();
|
|
142
|
+
const sline = this._putCurLineInSplice();
|
|
143
|
+
const slineVal = this._curSplice[sline];
|
|
144
|
+
const removed = slineVal.substring(this._curCol, this._curCol + N);
|
|
145
|
+
this._curSplice[sline] = slineVal.substring(0, this._curCol) +
|
|
146
|
+
slineVal.substring(this._curCol + N);
|
|
147
|
+
return removed;
|
|
148
|
+
}
|
|
149
|
+
insert(text, L) {
|
|
150
|
+
if (!text)
|
|
151
|
+
return;
|
|
152
|
+
if (!this._inSplice)
|
|
153
|
+
this._enterSplice();
|
|
154
|
+
if (L) {
|
|
155
|
+
const newLines = splitTextLines(text) || [];
|
|
156
|
+
if (this._isCurLineInSplice()) {
|
|
157
|
+
const sline = this._curSplice.length - 1;
|
|
158
|
+
const theLine = this._curSplice[sline];
|
|
159
|
+
const lineCol = this._curCol;
|
|
160
|
+
this._curSplice[sline] = theLine.substring(0, lineCol) + newLines[0];
|
|
161
|
+
this._curLine++;
|
|
162
|
+
newLines.splice(0, 1);
|
|
163
|
+
this._curSplice.push(...newLines);
|
|
164
|
+
this._curLine += newLines.length;
|
|
165
|
+
this._curSplice.push(theLine.substring(lineCol));
|
|
166
|
+
this._curCol = 0;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this._curSplice.push(...newLines);
|
|
170
|
+
this._curLine += newLines.length;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const sline = this._putCurLineInSplice();
|
|
175
|
+
const slineVal = this._curSplice[sline];
|
|
176
|
+
if (!slineVal) {
|
|
177
|
+
console.error('curSplice[sline] not populated, actual curSplice contents is ' +
|
|
178
|
+
`${JSON.stringify(this._curSplice)}`);
|
|
179
|
+
}
|
|
180
|
+
this._curSplice[sline] = slineVal.substring(0, this._curCol) + text +
|
|
181
|
+
slineVal.substring(this._curCol);
|
|
182
|
+
this._curCol += text.length;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
hasMore() {
|
|
186
|
+
let docLines = this._linesLength();
|
|
187
|
+
if (this._inSplice) {
|
|
188
|
+
docLines += this._curSplice.length - 2 - this._curSplice[1];
|
|
189
|
+
}
|
|
190
|
+
return this._curLine < docLines;
|
|
191
|
+
}
|
|
192
|
+
close() {
|
|
193
|
+
if (this._inSplice)
|
|
194
|
+
this._leaveSplice();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
export default TextLinesMutator;
|
|
198
|
+
//# sourceMappingURL=TextLinesMutator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextLinesMutator.js","sourceRoot":"","sources":["../../src/editor/TextLinesMutator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAkB9C,MAAM,gBAAgB;IAOpB,YAAY,KAAY;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,SAAS,CAAC,GAAW;QACnB,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACzB,OAAQ,IAA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AM,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAClC,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,YAAY,EAAE,CAAC;IAC1C,CAAC;CACF;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const isNodeText: (node: {
|
|
2
|
+
nodeType: number;
|
|
3
|
+
}) => boolean;
|
|
4
|
+
export declare const getAssoc: (obj: Record<string, any>, name: string) => any;
|
|
5
|
+
export declare const setAssoc: (obj: Record<string, any>, name: string, value: string) => void;
|
|
6
|
+
export declare const binarySearch: (numItems: number, func: (num: number) => boolean) => number;
|
|
7
|
+
export declare const binarySearchInfinite: (expectedLength: number, func: (num: number) => boolean) => number;
|
|
8
|
+
export declare const noop: () => void;
|
|
9
|
+
//# sourceMappingURL=ace2_common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ace2_common.d.ts","sourceRoot":"","sources":["../../src/editor/ace2_common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,MAAM;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,YAA0B,CAAC;AAEhF,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,MAAM,QAA6B,CAAC;AAE7F,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,MAAM,EAAE,OAAO,MAAM,SAE7E,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,WAY5E,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,gBAAgB,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,WAI1F,CAAC;AAEF,eAAO,MAAM,IAAI,YAAW,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const isNodeText = (node) => (node.nodeType === 3);
|
|
2
|
+
export const getAssoc = (obj, name) => obj[`_magicdom_${name}`];
|
|
3
|
+
export const setAssoc = (obj, name, value) => {
|
|
4
|
+
obj[`_magicdom_${name}`] = value;
|
|
5
|
+
};
|
|
6
|
+
export const binarySearch = (numItems, func) => {
|
|
7
|
+
if (numItems < 1)
|
|
8
|
+
return 0;
|
|
9
|
+
if (func(0))
|
|
10
|
+
return 0;
|
|
11
|
+
if (!func(numItems - 1))
|
|
12
|
+
return numItems;
|
|
13
|
+
let low = 0;
|
|
14
|
+
let high = numItems - 1;
|
|
15
|
+
while ((high - low) > 1) {
|
|
16
|
+
const x = Math.floor((low + high) / 2);
|
|
17
|
+
if (func(x))
|
|
18
|
+
high = x;
|
|
19
|
+
else
|
|
20
|
+
low = x;
|
|
21
|
+
}
|
|
22
|
+
return high;
|
|
23
|
+
};
|
|
24
|
+
export const binarySearchInfinite = (expectedLength, func) => {
|
|
25
|
+
let i = 0;
|
|
26
|
+
while (!func(i))
|
|
27
|
+
i += expectedLength;
|
|
28
|
+
return binarySearch(i, func);
|
|
29
|
+
};
|
|
30
|
+
export const noop = () => { };
|
|
31
|
+
//# sourceMappingURL=ace2_common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ace2_common.js","sourceRoot":"","sources":["../../src/editor/ace2_common.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAA0B,EAAE,EAAE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AAC,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import AttributePool from "./AttributePool.js";
|
|
2
|
+
import { Attribute } from "./types/Attribute.js";
|
|
3
|
+
export declare const decodeAttribString: (str: string) => Generator<number>;
|
|
4
|
+
export declare const encodeAttribString: (attribNums: Iterable<number>) => string;
|
|
5
|
+
export declare const attribsFromNums: (attribNums: Iterable<number>, pool: AttributePool) => Generator<Attribute>;
|
|
6
|
+
export declare const attribsToNums: (attribs: Iterable<Attribute>, pool: AttributePool) => Generator<number, void, unknown>;
|
|
7
|
+
export declare const attribsFromString: (str: string, pool: AttributePool) => Generator<Attribute>;
|
|
8
|
+
export declare const attribsToString: (attribs: Iterable<Attribute>, pool: AttributePool) => string;
|
|
9
|
+
export declare const sort: (attribs: Attribute[]) => Attribute[];
|
|
10
|
+
declare const _default: {
|
|
11
|
+
decodeAttribString: (str: string) => Generator<number>;
|
|
12
|
+
encodeAttribString: (attribNums: Iterable<number>) => string;
|
|
13
|
+
attribsFromNums: (attribNums: Iterable<number>, pool: AttributePool) => Generator<Attribute>;
|
|
14
|
+
attribsToNums: (attribs: Iterable<Attribute>, pool: AttributePool) => Generator<number, void, unknown>;
|
|
15
|
+
attribsFromString: (str: string, pool: AttributePool) => Generator<Attribute>;
|
|
16
|
+
attribsToString: (attribs: Iterable<Attribute>, pool: AttributePool) => string;
|
|
17
|
+
sort: (attribs: Attribute[]) => Attribute[];
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
20
|
+
//# sourceMappingURL=attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/editor/attributes.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAC,SAAS,EA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
|
|
6
|
+
if (n == null)
|
|
7
|
+
throw new Error(`invalid character in attribute string: ${m}`);
|
|
8
|
+
yield Number.parseInt(n, 36);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const checkAttribNum = (n) => {
|
|
12
|
+
if (typeof n !== 'number')
|
|
13
|
+
throw new TypeError(`not a number: ${n}`);
|
|
14
|
+
if (n < 0)
|
|
15
|
+
throw new Error(`attribute number is negative: ${n}`);
|
|
16
|
+
if (n !== Math.trunc(n))
|
|
17
|
+
throw new Error(`attribute number is not an integer: ${n}`);
|
|
18
|
+
};
|
|
19
|
+
export const encodeAttribString = (attribNums) => {
|
|
20
|
+
let str = '';
|
|
21
|
+
for (const n of attribNums) {
|
|
22
|
+
checkAttribNum(n);
|
|
23
|
+
str += `*${n.toString(36).toLowerCase()}`;
|
|
24
|
+
}
|
|
25
|
+
return str;
|
|
26
|
+
};
|
|
27
|
+
export const attribsFromNums = function* (attribNums, pool) {
|
|
28
|
+
for (const n of attribNums) {
|
|
29
|
+
checkAttribNum(n);
|
|
30
|
+
const attrib = pool.getAttrib(n);
|
|
31
|
+
if (attrib == null)
|
|
32
|
+
throw new Error(`attribute ${n} does not exist in pool`);
|
|
33
|
+
yield attrib;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const attribsToNums = function* (attribs, pool) {
|
|
37
|
+
for (const attrib of attribs)
|
|
38
|
+
yield pool.putAttrib(attrib);
|
|
39
|
+
};
|
|
40
|
+
export const attribsFromString = function* (str, pool) {
|
|
41
|
+
yield* attribsFromNums(decodeAttribString(str), pool);
|
|
42
|
+
};
|
|
43
|
+
export const attribsToString = (attribs, pool) => encodeAttribString(attribsToNums(attribs, pool));
|
|
44
|
+
export const sort = (attribs) => attribs.sort(([keyA], [keyB]) => (keyA > keyB ? 1 : 0) - (keyA < keyB ? 1 : 0));
|
|
45
|
+
export default {
|
|
46
|
+
decodeAttribString,
|
|
47
|
+
encodeAttribString,
|
|
48
|
+
attribsFromNums,
|
|
49
|
+
attribsToNums,
|
|
50
|
+
attribsFromString,
|
|
51
|
+
attribsToString,
|
|
52
|
+
sort,
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../src/editor/attributes.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,EAAE,GAAW;IACtD,MAAM,EAAE,GAAG,mBAAmB,CAAC;IAC/B,IAAI,KAAK,CAAC;IACV,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QACtC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,IAAI,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,EAAE,CAAC,CAAC;QAC9E,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,CAAgB,EAAE,EAAE;IAC1C,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACrE,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,EAAE,CAAC,CAAC;AACvF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,UAA4B,EAAU,EAAE;IACzE,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC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IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3I,eAAe;IACb,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,eAAe;IACf,IAAI;CACL,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser_flags.d.ts","sourceRoot":"","sources":["../../src/editor/browser_flags.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;CAKxB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const ua = (typeof navigator !== 'undefined' ? navigator.userAgent : '').toLowerCase();
|
|
2
|
+
export const browserFlags = {
|
|
3
|
+
opera: /opera|opr\//.test(ua),
|
|
4
|
+
safari: /safari/.test(ua) && !/chrome|crios|android/.test(ua),
|
|
5
|
+
chrome: /chrome|crios/.test(ua),
|
|
6
|
+
firefox: /firefox|iceweasel/.test(ua),
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=browser_flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser_flags.js","sourceRoot":"","sources":["../../src/editor/browser_flags.ts"],"names":[],"mappings":"AAAA,MAAM,EAAE,GAAG,CAAC,OAAO,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAEvF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;IAC7B,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC7D,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/B,OAAO,EAAE,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;CACtC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Changeset Tracker - Tracks user changes for collaborative editing.
|
|
3
|
+
*
|
|
4
|
+
* Maintains three layers of text state:
|
|
5
|
+
* - baseAText: the latest official text from the server
|
|
6
|
+
* - submittedChangeset: changes that have been sent to the server but not yet confirmed
|
|
7
|
+
* - userChangeset: changes made by the user since the last submission
|
|
8
|
+
*
|
|
9
|
+
* Invariant: baseAText + submittedChangeset + userChangeset = current editor state
|
|
10
|
+
*
|
|
11
|
+
* Copyright 2009 Google Inc.
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License.
|
|
15
|
+
* You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
import AttributePool from './AttributePool.js';
|
|
26
|
+
import type { AText } from './types/AText.js';
|
|
27
|
+
export interface ChangesetTrackerCallbacks {
|
|
28
|
+
setDocumentAttributedText: (atext: AText) => void;
|
|
29
|
+
applyChangesetToDocument: (changeset: string, preferInsertionAfterCaret: boolean) => void;
|
|
30
|
+
}
|
|
31
|
+
export interface AceCallbacksProvider {
|
|
32
|
+
withCallbacks: (operationName: string, f: (callbacks: ChangesetTrackerCallbacks) => void) => void;
|
|
33
|
+
}
|
|
34
|
+
interface Scheduler {
|
|
35
|
+
setTimeout: (fn: () => void, delay: number) => ReturnType<typeof setTimeout>;
|
|
36
|
+
clearTimeout: (id: ReturnType<typeof setTimeout>) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface ChangesetTracker {
|
|
39
|
+
isTracking: () => boolean;
|
|
40
|
+
setBaseText: (text: string) => void;
|
|
41
|
+
setBaseAttributedText: (atext: AText, apoolJsonObj: any) => void;
|
|
42
|
+
composeUserChangeset: (c: string) => void;
|
|
43
|
+
applyChangesToBase: (c: string, optAuthor: string | undefined, apoolJsonObj: any) => void;
|
|
44
|
+
prepareUserChangeset: () => {
|
|
45
|
+
changeset: string | null;
|
|
46
|
+
apool: any;
|
|
47
|
+
};
|
|
48
|
+
applyPreparedChangesetToBase: () => void;
|
|
49
|
+
setUserChangeNotificationCallback: (callback: () => void) => void;
|
|
50
|
+
hasUncommittedChanges: () => boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare const makeChangesetTracker: (scheduler: Scheduler, apool: AttributePool, aceCallbacksProvider: AceCallbacksProvider, getAuthorId: () => string) => ChangesetTracker;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=changesettracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changesettracker.d.ts","sourceRoot":"","sources":["../../src/editor/changesettracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAkB/C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,kBAAkB,CAAC;AAE5C,MAAM,WAAW,yBAAyB;IACxC,yBAAyB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAClD,wBAAwB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,yBAAyB,EAAE,OAAO,KAAK,IAAI,CAAC;CAC3F;AAED,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,yBAAyB,KAAK,IAAI,KAAK,IAAI,CAAC;CACnG;AAED,UAAU,SAAS;IACjB,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IAC7E,YAAY,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,qBAAqB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC;IACjE,oBAAoB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,kBAAkB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1F,oBAAoB,EAAE,MAAM;QAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,CAAC;IACrE,4BAA4B,EAAE,MAAM,IAAI,CAAC;IACzC,iCAAiC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAClE,qBAAqB,EAAE,MAAM,OAAO,CAAC;CACtC;AAED,eAAO,MAAM,oBAAoB,GAC/B,WAAW,SAAS,EACpB,OAAO,aAAa,EACpB,sBAAsB,oBAAoB,EAC1C,aAAa,MAAM,MAAM,KACxB,gBA0KF,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Changeset Tracker - Tracks user changes for collaborative editing.
|
|
3
|
+
*
|
|
4
|
+
* Maintains three layers of text state:
|
|
5
|
+
* - baseAText: the latest official text from the server
|
|
6
|
+
* - submittedChangeset: changes that have been sent to the server but not yet confirmed
|
|
7
|
+
* - userChangeset: changes made by the user since the last submission
|
|
8
|
+
*
|
|
9
|
+
* Invariant: baseAText + submittedChangeset + userChangeset = current editor state
|
|
10
|
+
*
|
|
11
|
+
* Copyright 2009 Google Inc.
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License.
|
|
15
|
+
* You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
import AttributeMap from './AttributeMap.js';
|
|
26
|
+
import AttributePool from './AttributePool.js';
|
|
27
|
+
import { applyToAText, checkRep, cloneAText, compose, deserializeOps, follow, identity, isIdentity, makeAText, moveOpsToNewPool, newLen, pack, prepareForWire, unpack, } from './Changeset.js';
|
|
28
|
+
import { MergingOpAssembler } from './MergingOpAssembler.js';
|
|
29
|
+
export const makeChangesetTracker = (scheduler, apool, aceCallbacksProvider, getAuthorId) => {
|
|
30
|
+
// latest official text from server
|
|
31
|
+
let baseAText = makeAText('\n');
|
|
32
|
+
// changes applied to baseText that have been submitted
|
|
33
|
+
let submittedChangeset = null;
|
|
34
|
+
// changes applied to submittedChangeset since it was prepared
|
|
35
|
+
let userChangeset = identity(1);
|
|
36
|
+
// is the changesetTracker enabled
|
|
37
|
+
let tracking = false;
|
|
38
|
+
// stack state flag so that when we change the rep we don't
|
|
39
|
+
// handle the notification recursively. When setting, always
|
|
40
|
+
// unset in a "finally" block. When set to true, the setter
|
|
41
|
+
// takes change of userChangeset.
|
|
42
|
+
let applyingNonUserChanges = false;
|
|
43
|
+
let changeCallback = null;
|
|
44
|
+
let changeCallbackTimeout = null;
|
|
45
|
+
const setChangeCallbackTimeout = () => {
|
|
46
|
+
// can call this multiple times per call-stack, because
|
|
47
|
+
// we only schedule a call to changeCallback if it exists
|
|
48
|
+
// and if there isn't a timeout already scheduled.
|
|
49
|
+
if (changeCallback && changeCallbackTimeout == null) {
|
|
50
|
+
changeCallbackTimeout = scheduler.setTimeout(() => {
|
|
51
|
+
try {
|
|
52
|
+
changeCallback();
|
|
53
|
+
}
|
|
54
|
+
catch (_pseudoError) {
|
|
55
|
+
// as empty as my soul
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
changeCallbackTimeout = null;
|
|
59
|
+
}
|
|
60
|
+
}, 0);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
let self;
|
|
64
|
+
return self = {
|
|
65
|
+
isTracking: () => tracking,
|
|
66
|
+
setBaseText: (text) => {
|
|
67
|
+
self.setBaseAttributedText(makeAText(text), null);
|
|
68
|
+
},
|
|
69
|
+
setBaseAttributedText: (atext, apoolJsonObj) => {
|
|
70
|
+
aceCallbacksProvider.withCallbacks('setBaseText', (callbacks) => {
|
|
71
|
+
tracking = true;
|
|
72
|
+
baseAText = cloneAText(atext);
|
|
73
|
+
if (apoolJsonObj) {
|
|
74
|
+
const wireApool = (new AttributePool()).fromJsonable(apoolJsonObj);
|
|
75
|
+
baseAText.attribs = moveOpsToNewPool(baseAText.attribs, wireApool, apool);
|
|
76
|
+
}
|
|
77
|
+
submittedChangeset = null;
|
|
78
|
+
userChangeset = identity(atext.text.length);
|
|
79
|
+
applyingNonUserChanges = true;
|
|
80
|
+
try {
|
|
81
|
+
callbacks.setDocumentAttributedText(atext);
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
applyingNonUserChanges = false;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
composeUserChangeset: (c) => {
|
|
89
|
+
if (!tracking)
|
|
90
|
+
return;
|
|
91
|
+
if (applyingNonUserChanges)
|
|
92
|
+
return;
|
|
93
|
+
if (isIdentity(c))
|
|
94
|
+
return;
|
|
95
|
+
userChangeset = compose(userChangeset, c, apool);
|
|
96
|
+
setChangeCallbackTimeout();
|
|
97
|
+
},
|
|
98
|
+
applyChangesToBase: (c, _optAuthor, apoolJsonObj) => {
|
|
99
|
+
if (!tracking)
|
|
100
|
+
return;
|
|
101
|
+
aceCallbacksProvider.withCallbacks('applyChangesToBase', (callbacks) => {
|
|
102
|
+
if (apoolJsonObj) {
|
|
103
|
+
const wireApool = (new AttributePool()).fromJsonable(apoolJsonObj);
|
|
104
|
+
c = moveOpsToNewPool(c, wireApool, apool);
|
|
105
|
+
}
|
|
106
|
+
baseAText = applyToAText(c, baseAText, apool);
|
|
107
|
+
let c2 = c;
|
|
108
|
+
if (submittedChangeset) {
|
|
109
|
+
const oldSubmittedChangeset = submittedChangeset;
|
|
110
|
+
submittedChangeset = follow(c, oldSubmittedChangeset, false, apool);
|
|
111
|
+
c2 = follow(oldSubmittedChangeset, c, true, apool);
|
|
112
|
+
}
|
|
113
|
+
const preferInsertingAfterUserChanges = true;
|
|
114
|
+
const oldUserChangeset = userChangeset;
|
|
115
|
+
userChangeset = follow(c2, oldUserChangeset, preferInsertingAfterUserChanges, apool);
|
|
116
|
+
const postChange = follow(oldUserChangeset, c2, !preferInsertingAfterUserChanges, apool);
|
|
117
|
+
const preferInsertionAfterCaret = true;
|
|
118
|
+
applyingNonUserChanges = true;
|
|
119
|
+
try {
|
|
120
|
+
callbacks.applyChangesetToDocument(postChange, preferInsertionAfterCaret);
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
applyingNonUserChanges = false;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
prepareUserChangeset: () => {
|
|
128
|
+
// If there are user changes to submit, 'changeset' will be the
|
|
129
|
+
// changeset, else it will be null.
|
|
130
|
+
let toSubmit;
|
|
131
|
+
if (submittedChangeset) {
|
|
132
|
+
// submission must have been canceled, prepare new changeset
|
|
133
|
+
// that includes old submittedChangeset
|
|
134
|
+
toSubmit = compose(submittedChangeset, userChangeset, apool);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// Get the author ID
|
|
138
|
+
const authorId = getAuthorId();
|
|
139
|
+
// Sanitize authorship: Replace all author attributes with this user's author ID in case the
|
|
140
|
+
// text was copied from another author.
|
|
141
|
+
const cs = unpack(userChangeset);
|
|
142
|
+
const assem = new MergingOpAssembler();
|
|
143
|
+
for (const op of deserializeOps(cs.ops)) {
|
|
144
|
+
if (op.opcode === '+') {
|
|
145
|
+
const attribs = AttributeMap.fromString(op.attribs, apool);
|
|
146
|
+
const oldAuthorId = attribs.get('author');
|
|
147
|
+
if (oldAuthorId != null && oldAuthorId !== authorId) {
|
|
148
|
+
attribs.set('author', authorId);
|
|
149
|
+
op.attribs = attribs.toString();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
assem.append(op);
|
|
153
|
+
}
|
|
154
|
+
assem.endDocument();
|
|
155
|
+
userChangeset = pack(cs.oldLen, cs.newLen, assem.toString(), cs.charBank);
|
|
156
|
+
checkRep(userChangeset);
|
|
157
|
+
if (isIdentity(userChangeset))
|
|
158
|
+
toSubmit = null;
|
|
159
|
+
else
|
|
160
|
+
toSubmit = userChangeset;
|
|
161
|
+
}
|
|
162
|
+
let cs = null;
|
|
163
|
+
if (toSubmit) {
|
|
164
|
+
submittedChangeset = toSubmit;
|
|
165
|
+
userChangeset = identity(newLen(toSubmit));
|
|
166
|
+
cs = toSubmit;
|
|
167
|
+
}
|
|
168
|
+
let wireApool = null;
|
|
169
|
+
if (cs) {
|
|
170
|
+
const forWire = prepareForWire(cs, apool);
|
|
171
|
+
wireApool = forWire.pool.toJsonable();
|
|
172
|
+
cs = forWire.translated;
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
changeset: cs,
|
|
176
|
+
apool: wireApool,
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
applyPreparedChangesetToBase: () => {
|
|
180
|
+
if (!submittedChangeset) {
|
|
181
|
+
// violation of protocol; use prepareUserChangeset first
|
|
182
|
+
throw new Error('applySubmittedChangesToBase: no submitted changes to apply');
|
|
183
|
+
}
|
|
184
|
+
baseAText = applyToAText(submittedChangeset, baseAText, apool);
|
|
185
|
+
submittedChangeset = null;
|
|
186
|
+
},
|
|
187
|
+
setUserChangeNotificationCallback: (callback) => {
|
|
188
|
+
changeCallback = callback;
|
|
189
|
+
},
|
|
190
|
+
hasUncommittedChanges: () => !!(submittedChangeset || (!isIdentity(userChangeset))),
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=changesettracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changesettracker.js","sourceRoot":"","sources":["../../src/editor/changesettracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,OAAO,EACP,cAAc,EACd,MAAM,EACN,QAAQ,EACR,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,MAAM,EACN,IAAI,EACJ,cAAc,EACd,MAAM,GACP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AA6B3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,SAAoB,EACpB,KAAoB,EACpB,oBAA0C,EAC1C,WAAyB,EACP,EAAE;IACpB,mCAAmC;IACnC,IAAI,SAAS,GAAU,SAAS,CAAC,IAAI,CAAC,CAAC;IACvC,uDAAuD;IACvD,IAAI,kBAAkB,GAAkB,IAAI,CAAC;IAC7C,8DAA8D;IAC9D,IAAI,aAAa,GAAW,QAAQ,CAAC,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