@univerjs-pro/collaboration v0.5.0-beta.1 • Docs
Class: TransformService
This service’s responsibility is to transform mutations (changesets).
Features could register transform algorithms to this service, so this the service could transform more mutations.
This should be used both on client and server.
This service is also business-agnostic, so it could be used in docs, sheets and slides.
Extends
Implements
Constructors
new TransformService()
new TransformService(): TransformService
Returns
Inherited from
Properties
Property | Modifier | Type | Default value | Inherited from | Defined in |
---|---|---|---|---|---|
_disposed | protected | boolean | false | Disposable ._disposed | submodules/univer/packages/core/src/shared/lifecycle.ts:93 |
Methods
dispose()
dispose(): void
Returns
void
Overrides
Defined in
packages/collaboration/src/services/transform/transform.service.ts:119
disposeWithMe()
disposeWithMe(disposable): IDisposable
Parameters
Parameter | Type |
---|---|
disposable | DisposableLike |
Returns
Inherited from
Defined in
submodules/univer/packages/core/src/shared/lifecycle.ts:96
ensureNotDisposed()
protected ensureNotDisposed(): void
Returns
void
Inherited from
Defined in
submodules/univer/packages/core/src/shared/lifecycle.ts:100
registerTransformAlgorithm()
registerTransformAlgorithm(algorithm): void
Register an algorithm to transform two kinds of mutations.
Note that this method is not the same as other registering methods in Univer, it wouldn’t return a disposable, because it would cause critical problems if you unregister a transform algorithm.
Parameters
Parameter | Type |
---|---|
algorithm | IMutationTransformAlgorithm <any , any > |
Returns
void
Implementation of
ITransformService
.registerTransformAlgorithm
Defined in
packages/collaboration/src/services/transform/transform.service.ts:123
transformChangesets()
transformChangesets(c1, c2)
transformChangesets(c1, c2): ITransformChangesetsResult
Internal
Transform two arrays of changesets
Parameters
Parameter | Type |
---|---|
c1 | IChangeset [] |
c2 | IChangeset [] |
Returns
Implementation of
ITransformService
.transformChangesets
Defined in
packages/collaboration/src/services/transform/transform.service.ts:280
transformChangesets(c1, c2, onlyLater)
transformChangesets(
c1,
c2,
onlyLater): IFailureTransformChangesetsResult | Omit<ISuccessTransformChangesetsResult, "c1Prime">
Parameters
Parameter | Type |
---|---|
c1 | IChangeset [] |
c2 | IChangeset [] |
onlyLater | true |
Returns
IFailureTransformChangesetsResult
| Omit
<ISuccessTransformChangesetsResult
, "c1Prime"
>
Implementation of
ITransformService
.transformChangesets
Defined in
packages/collaboration/src/services/transform/transform.service.ts:281
transformMutation()
transformMutation(m1, m2)
transformMutation(m1, m2): ITransformMutationResult
Internal
Transform two single mutations. Note that m1Prime and m2Prime may not be single mutations. 1x1 may result in nxn.
Visualization:
/\
m1 / \ m2
/ \
\ /
m2Prime \ / m1Prime
/
Parameters
Parameter | Type |
---|---|
m1 | IMutationInfo <object > |
m2 | IMutationInfo <object > |
Returns
Implementation of
ITransformService
.transformMutation
Defined in
packages/collaboration/src/services/transform/transform.service.ts:137
transformMutation(m1, m2, onlyLater)
transformMutation(
m1,
m2,
onlyLater): IFailureTransformMutationResult | Omit<ISuccessTransformMutationResult, "m1Prime">
Parameters
Parameter | Type |
---|---|
m1 | IMutationInfo <object > |
m2 | IMutationInfo <object > |
onlyLater | true |
Returns
IFailureTransformMutationResult
| Omit
<ISuccessTransformMutationResult
, "m1Prime"
>
Implementation of
ITransformService
.transformMutation
Defined in
packages/collaboration/src/services/transform/transform.service.ts:138
transformMutations()
transformMutations(m1, m2)
transformMutations(m1, m2): ITransformMutationsResult
Internal
Transform two array of mutations. Not that the time complexity (also memory complexity) of this method is O(m*n), in which m & n are numbers of mutations in each array.
Visualization:
/\
m1 / \ m2
/ \
/\ /\
/ \ / \
/ / \
\ /\ /
\ / \ /
/ /
\ /
\ /
m2Prime / m1Prime
Parameters
Parameter | Type |
---|---|
m1 | IMutationInfo <object >[] |
m2 | IMutationInfo <object >[] |
Returns
Implementation of
ITransformService
.transformMutations
Defined in
packages/collaboration/src/services/transform/transform.service.ts:158
transformMutations(m1, m2, onlyLater)
transformMutations(
m1,
m2,
onlyLater): IFailureTransformMutationsResult | Omit<ISuccessTransformMutationsResult, "m1Prime">
Parameters
Parameter | Type |
---|---|
m1 | IMutationInfo <object >[] |
m2 | IMutationInfo <object >[] |
onlyLater | true |
Returns
IFailureTransformMutationsResult
| Omit
<ISuccessTransformMutationsResult
, "m1Prime"
>
Implementation of
ITransformService
.transformMutations
Defined in
packages/collaboration/src/services/transform/transform.service.ts:159
transformMutationsWithChangeset()
transformMutationsWithChangeset(c1, m2): ITransformMutationsWithChangesetResult
Internal
Transform mutations with changesets. We only wants transformed mutations here.
Parameters
Parameter | Type |
---|---|
c1 | IChangeset |
m2 | IMutationInfo <object >[] |
Returns
ITransformMutationsWithChangesetResult
Implementation of
ITransformService
.transformMutationsWithChangeset
Defined in
packages/collaboration/src/services/transform/transform.service.ts:337