@y/y 14.0.0-rc.2 → 14.0.0-rc.20

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.
Files changed (166) hide show
  1. package/README.md +36 -12
  2. package/dist/src/index.d.ts +24 -1
  3. package/dist/src/index.d.ts.map +1 -1
  4. package/dist/src/structs/AbstractStruct.d.ts +14 -17
  5. package/dist/src/structs/AbstractStruct.d.ts.map +1 -1
  6. package/dist/src/structs/GC.d.ts +9 -14
  7. package/dist/src/structs/GC.d.ts.map +1 -1
  8. package/dist/src/structs/Item.d.ts +569 -31
  9. package/dist/src/structs/Item.d.ts.map +1 -1
  10. package/dist/src/structs/Skip.d.ts +9 -11
  11. package/dist/src/structs/Skip.d.ts.map +1 -1
  12. package/dist/src/utils/BlockSet.d.ts +8 -7
  13. package/dist/src/utils/BlockSet.d.ts.map +1 -1
  14. package/dist/src/utils/Doc.d.ts +4 -9
  15. package/dist/src/utils/Doc.d.ts.map +1 -1
  16. package/dist/src/utils/ID.d.ts +0 -1
  17. package/dist/src/utils/ID.d.ts.map +1 -1
  18. package/dist/src/utils/RelativePosition.d.ts +2 -5
  19. package/dist/src/utils/RelativePosition.d.ts.map +1 -1
  20. package/dist/src/utils/Renderer.d.ts +144 -0
  21. package/dist/src/utils/Renderer.d.ts.map +1 -0
  22. package/dist/src/utils/Snapshot.d.ts +7 -11
  23. package/dist/src/utils/Snapshot.d.ts.map +1 -1
  24. package/dist/src/utils/StructStore.d.ts +45 -23
  25. package/dist/src/utils/StructStore.d.ts.map +1 -1
  26. package/dist/src/utils/Transaction.d.ts +11 -21
  27. package/dist/src/utils/Transaction.d.ts.map +1 -1
  28. package/dist/src/utils/UndoManager.d.ts +13 -14
  29. package/dist/src/utils/UndoManager.d.ts.map +1 -1
  30. package/dist/src/utils/UpdateDecoder.d.ts +1 -1
  31. package/dist/src/utils/UpdateDecoder.d.ts.map +1 -1
  32. package/dist/src/utils/UpdateEncoder.d.ts +0 -1
  33. package/dist/src/utils/UpdateEncoder.d.ts.map +1 -1
  34. package/dist/src/utils/YEvent.d.ts +22 -26
  35. package/dist/src/utils/YEvent.d.ts.map +1 -1
  36. package/dist/src/utils/content-helper.d.ts +2 -0
  37. package/dist/src/utils/content-helper.d.ts.map +1 -0
  38. package/dist/src/utils/delta-helpers.d.ts +2 -3
  39. package/dist/src/utils/delta-helpers.d.ts.map +1 -1
  40. package/dist/src/utils/encoding-helpers.d.ts +6 -0
  41. package/dist/src/utils/encoding-helpers.d.ts.map +1 -0
  42. package/dist/src/utils/encoding.d.ts +16 -18
  43. package/dist/src/utils/encoding.d.ts.map +1 -1
  44. package/dist/src/utils/ids.d.ts +331 -0
  45. package/dist/src/utils/ids.d.ts.map +1 -0
  46. package/dist/src/utils/isParentOf.d.ts +1 -2
  47. package/dist/src/utils/isParentOf.d.ts.map +1 -1
  48. package/dist/src/utils/logging.d.ts +0 -1
  49. package/dist/src/utils/logging.d.ts.map +1 -1
  50. package/dist/src/utils/meta.d.ts +15 -64
  51. package/dist/src/utils/meta.d.ts.map +1 -1
  52. package/dist/src/utils/renderer-helpers.d.ts +99 -0
  53. package/dist/src/utils/renderer-helpers.d.ts.map +1 -0
  54. package/dist/src/utils/schemas.d.ts +3 -0
  55. package/dist/src/utils/schemas.d.ts.map +1 -0
  56. package/dist/src/utils/transaction-helpers.d.ts +18 -0
  57. package/dist/src/utils/transaction-helpers.d.ts.map +1 -0
  58. package/dist/src/utils/updates.d.ts +19 -25
  59. package/dist/src/utils/updates.d.ts.map +1 -1
  60. package/dist/src/ytype.d.ts +55 -24
  61. package/dist/src/ytype.d.ts.map +1 -1
  62. package/global.d.ts +53 -0
  63. package/package.json +12 -16
  64. package/src/index.js +32 -124
  65. package/src/structs/AbstractStruct.js +21 -16
  66. package/src/structs/GC.js +15 -20
  67. package/src/structs/Item.js +992 -318
  68. package/src/structs/Skip.js +16 -19
  69. package/src/utils/BlockSet.js +20 -20
  70. package/src/utils/Doc.js +15 -29
  71. package/src/utils/ID.js +0 -2
  72. package/src/utils/RelativePosition.js +15 -25
  73. package/src/utils/{AttributionManager.js → Renderer.js} +42 -197
  74. package/src/utils/Snapshot.js +15 -37
  75. package/src/utils/StructStore.js +89 -227
  76. package/src/utils/Transaction.js +63 -307
  77. package/src/utils/UndoManager.js +157 -19
  78. package/src/utils/UpdateDecoder.js +2 -3
  79. package/src/utils/UpdateEncoder.js +0 -4
  80. package/src/utils/YEvent.js +20 -26
  81. package/src/utils/content-helper.js +0 -0
  82. package/src/utils/delta-helpers.js +21 -42
  83. package/src/utils/encoding-helpers.js +110 -0
  84. package/src/utils/encoding.js +197 -122
  85. package/src/utils/ids.js +1527 -0
  86. package/src/utils/isParentOf.js +2 -4
  87. package/src/utils/logging.js +0 -4
  88. package/src/utils/meta.js +57 -46
  89. package/src/utils/renderer-helpers.js +110 -0
  90. package/src/utils/schemas.js +3 -0
  91. package/src/utils/transaction-helpers.js +413 -0
  92. package/src/utils/updates.js +24 -146
  93. package/src/ytype.js +325 -117
  94. package/tests/testHelper.js +10 -12
  95. package/dist/src/internals.d.ts +0 -36
  96. package/dist/src/internals.d.ts.map +0 -1
  97. package/dist/src/structs/ContentAny.d.ts +0 -67
  98. package/dist/src/structs/ContentAny.d.ts.map +0 -1
  99. package/dist/src/structs/ContentBinary.d.ts +0 -64
  100. package/dist/src/structs/ContentBinary.d.ts.map +0 -1
  101. package/dist/src/structs/ContentDeleted.d.ts +0 -64
  102. package/dist/src/structs/ContentDeleted.d.ts.map +0 -1
  103. package/dist/src/structs/ContentDoc.d.ts +0 -72
  104. package/dist/src/structs/ContentDoc.d.ts.map +0 -1
  105. package/dist/src/structs/ContentEmbed.d.ts +0 -67
  106. package/dist/src/structs/ContentEmbed.d.ts.map +0 -1
  107. package/dist/src/structs/ContentFormat.d.ts +0 -69
  108. package/dist/src/structs/ContentFormat.d.ts.map +0 -1
  109. package/dist/src/structs/ContentJSON.d.ts +0 -70
  110. package/dist/src/structs/ContentJSON.d.ts.map +0 -1
  111. package/dist/src/structs/ContentString.d.ts +0 -70
  112. package/dist/src/structs/ContentString.d.ts.map +0 -1
  113. package/dist/src/structs/ContentType.d.ts +0 -77
  114. package/dist/src/structs/ContentType.d.ts.map +0 -1
  115. package/dist/src/utils/AttributionManager.d.ts +0 -238
  116. package/dist/src/utils/AttributionManager.d.ts.map +0 -1
  117. package/dist/src/utils/IdMap.d.ts +0 -164
  118. package/dist/src/utils/IdMap.d.ts.map +0 -1
  119. package/dist/src/utils/IdSet.d.ts +0 -163
  120. package/dist/src/utils/IdSet.d.ts.map +0 -1
  121. package/dist/tests/IdMap.tests.d.ts +0 -9
  122. package/dist/tests/IdMap.tests.d.ts.map +0 -1
  123. package/dist/tests/IdSet.tests.d.ts +0 -9
  124. package/dist/tests/IdSet.tests.d.ts.map +0 -1
  125. package/dist/tests/attribution.tests.d.ts +0 -9
  126. package/dist/tests/attribution.tests.d.ts.map +0 -1
  127. package/dist/tests/compatibility.tests.d.ts +0 -5
  128. package/dist/tests/compatibility.tests.d.ts.map +0 -1
  129. package/dist/tests/delta.tests.d.ts +0 -7
  130. package/dist/tests/delta.tests.d.ts.map +0 -1
  131. package/dist/tests/doc.tests.d.ts +0 -13
  132. package/dist/tests/doc.tests.d.ts.map +0 -1
  133. package/dist/tests/encoding.tests.d.ts +0 -5
  134. package/dist/tests/encoding.tests.d.ts.map +0 -1
  135. package/dist/tests/index.d.ts +0 -2
  136. package/dist/tests/index.d.ts.map +0 -1
  137. package/dist/tests/relativePositions.tests.d.ts +0 -11
  138. package/dist/tests/relativePositions.tests.d.ts.map +0 -1
  139. package/dist/tests/snapshot.tests.d.ts +0 -14
  140. package/dist/tests/snapshot.tests.d.ts.map +0 -1
  141. package/dist/tests/testHelper.d.ts +0 -171
  142. package/dist/tests/testHelper.d.ts.map +0 -1
  143. package/dist/tests/undo-redo.tests.d.ts +0 -27
  144. package/dist/tests/undo-redo.tests.d.ts.map +0 -1
  145. package/dist/tests/updates.tests.d.ts +0 -26
  146. package/dist/tests/updates.tests.d.ts.map +0 -1
  147. package/dist/tests/y-array.tests.d.ts +0 -43
  148. package/dist/tests/y-array.tests.d.ts.map +0 -1
  149. package/dist/tests/y-map.tests.d.ts +0 -42
  150. package/dist/tests/y-map.tests.d.ts.map +0 -1
  151. package/dist/tests/y-text.tests.d.ts +0 -49
  152. package/dist/tests/y-text.tests.d.ts.map +0 -1
  153. package/dist/tests/y-xml.tests.d.ts +0 -14
  154. package/dist/tests/y-xml.tests.d.ts.map +0 -1
  155. package/src/internals.js +0 -35
  156. package/src/structs/ContentAny.js +0 -115
  157. package/src/structs/ContentBinary.js +0 -93
  158. package/src/structs/ContentDeleted.js +0 -101
  159. package/src/structs/ContentDoc.js +0 -141
  160. package/src/structs/ContentEmbed.js +0 -98
  161. package/src/structs/ContentFormat.js +0 -105
  162. package/src/structs/ContentJSON.js +0 -119
  163. package/src/structs/ContentString.js +0 -113
  164. package/src/structs/ContentType.js +0 -152
  165. package/src/utils/IdMap.js +0 -673
  166. package/src/utils/IdSet.js +0 -825
@@ -1,98 +0,0 @@
1
- import {
2
- UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Item, Transaction // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- import * as error from 'lib0/error'
6
-
7
- /**
8
- * @private
9
- */
10
- export class ContentEmbed {
11
- /**
12
- * @param {Object} embed
13
- */
14
- constructor (embed) {
15
- this.embed = embed
16
- }
17
-
18
- /**
19
- * @return {number}
20
- */
21
- getLength () {
22
- return 1
23
- }
24
-
25
- /**
26
- * @return {Array<any>}
27
- */
28
- getContent () {
29
- return [this.embed]
30
- }
31
-
32
- /**
33
- * @return {boolean}
34
- */
35
- isCountable () {
36
- return true
37
- }
38
-
39
- /**
40
- * @return {ContentEmbed}
41
- */
42
- copy () {
43
- return new ContentEmbed(this.embed)
44
- }
45
-
46
- /**
47
- * @param {number} offset
48
- * @return {ContentEmbed}
49
- */
50
- splice (offset) {
51
- throw error.methodUnimplemented()
52
- }
53
-
54
- /**
55
- * @param {ContentEmbed} right
56
- * @return {boolean}
57
- */
58
- mergeWith (right) {
59
- return false
60
- }
61
-
62
- /**
63
- * @param {Transaction} transaction
64
- * @param {Item} item
65
- */
66
- integrate (transaction, item) {}
67
- /**
68
- * @param {Transaction} transaction
69
- */
70
- delete (transaction) {}
71
- /**
72
- * @param {Transaction} _tr
73
- */
74
- gc (_tr) {}
75
- /**
76
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
77
- * @param {number} _offset
78
- * @param {number} _offsetEnd
79
- */
80
- write (encoder, _offset, _offsetEnd) {
81
- encoder.writeJSON(this.embed)
82
- }
83
-
84
- /**
85
- * @return {number}
86
- */
87
- getRef () {
88
- return 5
89
- }
90
- }
91
-
92
- /**
93
- * @private
94
- *
95
- * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
96
- * @return {ContentEmbed}
97
- */
98
- export const readContentEmbed = decoder => new ContentEmbed(decoder.readJSON())
@@ -1,105 +0,0 @@
1
- import {
2
- UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Item, Transaction // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- import * as error from 'lib0/error'
6
-
7
- /**
8
- * @private
9
- */
10
- export class ContentFormat {
11
- /**
12
- * @param {string} key
13
- * @param {Object} value
14
- */
15
- constructor (key, value) {
16
- this.key = key
17
- this.value = value
18
- }
19
-
20
- /**
21
- * @return {number}
22
- */
23
- getLength () {
24
- return 1
25
- }
26
-
27
- /**
28
- * @return {Array<any>}
29
- */
30
- getContent () {
31
- return []
32
- }
33
-
34
- /**
35
- * @return {boolean}
36
- */
37
- isCountable () {
38
- return false
39
- }
40
-
41
- /**
42
- * @return {ContentFormat}
43
- */
44
- copy () {
45
- return new ContentFormat(this.key, this.value)
46
- }
47
-
48
- /**
49
- * @param {number} _offset
50
- * @return {ContentFormat}
51
- */
52
- splice (_offset) {
53
- throw error.methodUnimplemented()
54
- }
55
-
56
- /**
57
- * @param {ContentFormat} _right
58
- * @return {boolean}
59
- */
60
- mergeWith (_right) {
61
- return false
62
- }
63
-
64
- /**
65
- * @param {Transaction} _transaction
66
- * @param {Item} item
67
- */
68
- integrate (_transaction, item) {
69
- // @todo searchmarker are currently unsupported for rich text documents
70
- const p = /** @type {import('../ytype.js').YType<any>} */ (item.parent)
71
- p._searchMarker = null
72
- p._hasFormatting = true
73
- }
74
-
75
- /**
76
- * @param {Transaction} _transaction
77
- */
78
- delete (_transaction) {}
79
- /**
80
- * @param {Transaction} _tr
81
- */
82
- gc (_tr) {}
83
- /**
84
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
85
- * @param {number} _offset
86
- * @param {number} _offsetEnd
87
- */
88
- write (encoder, _offset, _offsetEnd) {
89
- encoder.writeKey(this.key)
90
- encoder.writeJSON(this.value)
91
- }
92
-
93
- /**
94
- * @return {number}
95
- */
96
- getRef () {
97
- return 6
98
- }
99
- }
100
-
101
- /**
102
- * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
103
- * @return {ContentFormat}
104
- */
105
- export const readContentFormat = decoder => new ContentFormat(decoder.readKey(), decoder.readJSON())
@@ -1,119 +0,0 @@
1
- import {
2
- UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Transaction, Item, StructStore // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- /**
6
- * @private
7
- */
8
- export class ContentJSON {
9
- /**
10
- * @param {Array<any>} arr
11
- */
12
- constructor (arr) {
13
- /**
14
- * @type {Array<any>}
15
- */
16
- this.arr = arr
17
- }
18
-
19
- /**
20
- * @return {number}
21
- */
22
- getLength () {
23
- return this.arr.length
24
- }
25
-
26
- /**
27
- * @return {Array<any>}
28
- */
29
- getContent () {
30
- return this.arr
31
- }
32
-
33
- /**
34
- * @return {boolean}
35
- */
36
- isCountable () {
37
- return true
38
- }
39
-
40
- /**
41
- * @return {ContentJSON}
42
- */
43
- copy () {
44
- return new ContentJSON(this.arr)
45
- }
46
-
47
- /**
48
- * @param {number} offset
49
- * @return {ContentJSON}
50
- */
51
- splice (offset) {
52
- const right = new ContentJSON(this.arr.slice(offset))
53
- this.arr = this.arr.slice(0, offset)
54
- return right
55
- }
56
-
57
- /**
58
- * @param {ContentJSON} right
59
- * @return {boolean}
60
- */
61
- mergeWith (right) {
62
- this.arr = this.arr.concat(right.arr)
63
- return true
64
- }
65
-
66
- /**
67
- * @param {Transaction} transaction
68
- * @param {Item} item
69
- */
70
- integrate (transaction, item) {}
71
- /**
72
- * @param {Transaction} transaction
73
- */
74
- delete (transaction) {}
75
- /**
76
- * @param {Transaction} _tr
77
- */
78
- gc (_tr) {}
79
- /**
80
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
81
- * @param {number} offset
82
- * @param {number} offsetEnd
83
- */
84
- write (encoder, offset, offsetEnd) {
85
- const end = this.arr.length - offsetEnd
86
- encoder.writeLen(end - offset)
87
- for (let i = offset; i < end; i++) {
88
- const c = this.arr[i]
89
- encoder.writeString(c === undefined ? 'undefined' : JSON.stringify(c))
90
- }
91
- }
92
-
93
- /**
94
- * @return {number}
95
- */
96
- getRef () {
97
- return 2
98
- }
99
- }
100
-
101
- /**
102
- * @private
103
- *
104
- * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
105
- * @return {ContentJSON}
106
- */
107
- export const readContentJSON = decoder => {
108
- const len = decoder.readLen()
109
- const cs = []
110
- for (let i = 0; i < len; i++) {
111
- const c = decoder.readString()
112
- if (c === 'undefined') {
113
- cs.push(undefined)
114
- } else {
115
- cs.push(JSON.parse(c))
116
- }
117
- }
118
- return new ContentJSON(cs)
119
- }
@@ -1,113 +0,0 @@
1
- import {
2
- UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Transaction, Item, StructStore // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- /**
6
- * @private
7
- */
8
- export class ContentString {
9
- /**
10
- * @param {string} str
11
- */
12
- constructor (str) {
13
- /**
14
- * @type {string}
15
- */
16
- this.str = str
17
- }
18
-
19
- /**
20
- * @return {number}
21
- */
22
- getLength () {
23
- return this.str.length
24
- }
25
-
26
- /**
27
- * @return {Array<any>}
28
- */
29
- getContent () {
30
- return this.str.split('')
31
- }
32
-
33
- /**
34
- * @return {boolean}
35
- */
36
- isCountable () {
37
- return true
38
- }
39
-
40
- /**
41
- * @return {ContentString}
42
- */
43
- copy () {
44
- return new ContentString(this.str)
45
- }
46
-
47
- /**
48
- * @param {number} offset
49
- * @return {ContentString}
50
- */
51
- splice (offset) {
52
- const right = new ContentString(this.str.slice(offset))
53
- this.str = this.str.slice(0, offset)
54
-
55
- // Prevent encoding invalid documents because of splitting of surrogate pairs: https://github.com/yjs/yjs/issues/248
56
- const firstCharCode = this.str.charCodeAt(offset - 1)
57
- if (firstCharCode >= 0xD800 && firstCharCode <= 0xDBFF) {
58
- // Last character of the left split is the start of a surrogate utf16/ucs2 pair.
59
- // We don't support splitting of surrogate pairs because this may lead to invalid documents.
60
- // Replace the invalid character with a unicode replacement character (� / U+FFFD)
61
- this.str = this.str.slice(0, offset - 1) + '�'
62
- // replace right as well
63
- right.str = '�' + right.str.slice(1)
64
- }
65
- return right
66
- }
67
-
68
- /**
69
- * @param {ContentString} right
70
- * @return {boolean}
71
- */
72
- mergeWith (right) {
73
- this.str += right.str
74
- return true
75
- }
76
-
77
- /**
78
- * @param {Transaction} transaction
79
- * @param {Item} item
80
- */
81
- integrate (transaction, item) {}
82
- /**
83
- * @param {Transaction} transaction
84
- */
85
- delete (transaction) {}
86
- /**
87
- * @param {Transaction} _tr
88
- */
89
- gc (_tr) {}
90
- /**
91
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
92
- * @param {number} offset
93
- * @param {number} offsetEnd
94
- */
95
- write (encoder, offset, offsetEnd) {
96
- encoder.writeString((offset === 0 && offsetEnd === 0) ? this.str : this.str.slice(offset, this.str.length - offsetEnd))
97
- }
98
-
99
- /**
100
- * @return {number}
101
- */
102
- getRef () {
103
- return 4
104
- }
105
- }
106
-
107
- /**
108
- * @private
109
- *
110
- * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
111
- * @return {ContentString}
112
- */
113
- export const readContentString = decoder => new ContentString(decoder.readString())
@@ -1,152 +0,0 @@
1
- import {
2
- UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Transaction, Item // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- import * as error from 'lib0/error'
6
- import { readYType } from '../ytype.js'
7
-
8
- export const YArrayRefID = 0
9
- export const YMapRefID = 1
10
- export const YTextRefID = 2
11
- export const YXmlElementRefID = 3
12
- export const YXmlFragmentRefID = 4
13
- export const YXmlHookRefID = 5
14
- export const YXmlTextRefID = 6
15
-
16
- /**
17
- * @private
18
- */
19
- export class ContentType {
20
- /**
21
- * @param {import('../ytype.js').YType} type
22
- */
23
- constructor (type) {
24
- /**
25
- * @type {import('../ytype.js').YType}
26
- */
27
- this.type = type
28
- }
29
-
30
- /**
31
- * @return {number}
32
- */
33
- getLength () {
34
- return 1
35
- }
36
-
37
- /**
38
- * @return {Array<any>}
39
- */
40
- getContent () {
41
- return [this.type]
42
- }
43
-
44
- /**
45
- * @return {boolean}
46
- */
47
- isCountable () {
48
- return true
49
- }
50
-
51
- /**
52
- * @return {ContentType}
53
- */
54
- copy () {
55
- return new ContentType(this.type._copy())
56
- }
57
-
58
- /**
59
- * @param {number} _offset
60
- * @return {ContentType}
61
- */
62
- splice (_offset) {
63
- throw error.methodUnimplemented()
64
- }
65
-
66
- /**
67
- * @param {ContentType} _right
68
- * @return {boolean}
69
- */
70
- mergeWith (_right) {
71
- return false
72
- }
73
-
74
- /**
75
- * @param {Transaction} transaction
76
- * @param {Item} item
77
- */
78
- integrate (transaction, item) {
79
- this.type._integrate(transaction.doc, item)
80
- }
81
-
82
- /**
83
- * @param {Transaction} transaction
84
- */
85
- delete (transaction) {
86
- let item = this.type._start
87
- while (item !== null) {
88
- if (!item.deleted) {
89
- item.delete(transaction)
90
- } else if (!transaction.insertSet.hasId(item.id)) {
91
- // This will be gc'd later and we want to merge it if possible
92
- // We try to merge all deleted items after each transaction,
93
- // but we have no knowledge about that this needs to be merged
94
- // since it is not in transaction.ds. Hence we add it to transaction._mergeStructs
95
- transaction._mergeStructs.push(item)
96
- }
97
- item = item.right
98
- }
99
- this.type._map.forEach(item => {
100
- if (!item.deleted) {
101
- item.delete(transaction)
102
- } else if (!transaction.insertSet.hasId(item.id)) {
103
- // same as above
104
- transaction._mergeStructs.push(item)
105
- }
106
- })
107
- transaction.changed.delete(this.type)
108
- }
109
-
110
- /**
111
- * @param {Transaction} tr
112
- */
113
- gc (tr) {
114
- let item = this.type._start
115
- while (item !== null) {
116
- item.gc(tr, true)
117
- item = item.right
118
- }
119
- this.type._start = null
120
- this.type._map.forEach(/** @param {Item | null} item */ (item) => {
121
- while (item !== null) {
122
- item.gc(tr, true)
123
- item = item.left
124
- }
125
- })
126
- this.type._map = new Map()
127
- }
128
-
129
- /**
130
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
131
- * @param {number} _offset
132
- * @param {number} _offsetEnd
133
- */
134
- write (encoder, _offset, _offsetEnd) {
135
- this.type._write(encoder)
136
- }
137
-
138
- /**
139
- * @return {number}
140
- */
141
- getRef () {
142
- return 7
143
- }
144
- }
145
-
146
- /**
147
- * @private
148
- *
149
- * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
150
- * @return {ContentType}
151
- */
152
- export const readContentType = decoder => new ContentType(readYType(decoder))