@univerjs-procollaborationclassesTransformservice

@univerjs-pro/collaboration v0.5.4


Class: TransformService

Defined in: packages/collaboration/src/services/transform/transform.service.ts:116

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

TransformService

Inherited from

Disposable.constructor

Properties

PropertyModifierTypeDefault valueInherited fromDefined in
_disposedprotectedbooleanfalseDisposable._disposedsubmodules/univer/packages/core/src/shared/lifecycle.ts:96

Methods

dispose()

dispose(): void

Defined in: packages/collaboration/src/services/transform/transform.service.ts:119

Returns

void

Overrides

Disposable.dispose


disposeWithMe()

disposeWithMe(disposable): IDisposable

Defined in: submodules/univer/packages/core/src/shared/lifecycle.ts:99

Parameters

ParameterType
disposableDisposableLike

Returns

IDisposable

Inherited from

Disposable.disposeWithMe


ensureNotDisposed()

protected ensureNotDisposed(): void

Defined in: submodules/univer/packages/core/src/shared/lifecycle.ts:103

Returns

void

Inherited from

Disposable.ensureNotDisposed


registerTransformAlgorithm()

registerTransformAlgorithm(algorithm): void

Defined in: packages/collaboration/src/services/transform/transform.service.ts:123

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

ParameterType
algorithmIMutationTransformAlgorithm

Returns

void

Implementation of

ITransformService.registerTransformAlgorithm


transformChangesets()

Call Signature

transformChangesets(c1, c2): ITransformChangesetsResult

Defined in: packages/collaboration/src/services/transform/transform.service.ts:280

Internal

Transform two arrays of changesets

Parameters
ParameterType
c1IChangeset[]
c2IChangeset[]
Returns

ITransformChangesetsResult

Implementation of

ITransformService.transformChangesets

Call Signature

transformChangesets(
   c1, 
   c2, 
   onlyLater): 
  | IFailureTransformChangesetsResult
| Omit<ISuccessTransformChangesetsResult, "c1Prime">

Defined in: packages/collaboration/src/services/transform/transform.service.ts:281

Parameters
ParameterType
c1IChangeset[]
c2IChangeset[]
onlyLatertrue
Returns

| IFailureTransformChangesetsResult | Omit<ISuccessTransformChangesetsResult, "c1Prime">

Implementation of

ITransformService.transformChangesets


transformMutation()

Call Signature

transformMutation(m1, m2): ITransformMutationResult

Defined in: packages/collaboration/src/services/transform/transform.service.ts:137

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
ParameterType
m1IMutationInfo
m2IMutationInfo
Returns

ITransformMutationResult

Implementation of

ITransformService.transformMutation

Call Signature

transformMutation(
   m1, 
   m2, 
   onlyLater): 
  | IFailureTransformMutationResult
| Omit<ISuccessTransformMutationResult, "m1Prime">

Defined in: packages/collaboration/src/services/transform/transform.service.ts:138

Parameters
ParameterType
m1IMutationInfo
m2IMutationInfo
onlyLatertrue
Returns

| IFailureTransformMutationResult | Omit<ISuccessTransformMutationResult, "m1Prime">

Implementation of

ITransformService.transformMutation


transformMutations()

Call Signature

transformMutations(m1, m2): ITransformMutationsResult

Defined in: packages/collaboration/src/services/transform/transform.service.ts:158

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
ParameterType
m1IMutationInfo[]
m2IMutationInfo[]
Returns

ITransformMutationsResult

Implementation of

ITransformService.transformMutations

Call Signature

transformMutations(
   m1, 
   m2, 
   onlyLater): 
  | IFailureTransformMutationsResult
| Omit<ISuccessTransformMutationsResult, "m1Prime">

Defined in: packages/collaboration/src/services/transform/transform.service.ts:159

Parameters
ParameterType
m1IMutationInfo[]
m2IMutationInfo[]
onlyLatertrue
Returns

| IFailureTransformMutationsResult | Omit<ISuccessTransformMutationsResult, "m1Prime">

Implementation of

ITransformService.transformMutations


transformMutationsWithChangeset()

transformMutationsWithChangeset(c1, m2): ITransformMutationsWithChangesetResult

Defined in: packages/collaboration/src/services/transform/transform.service.ts:337

Internal

Transform mutations with changesets. We only wants transformed mutations here.

Parameters

ParameterType
c1IChangeset
m2IMutationInfo[]

Returns

ITransformMutationsWithChangesetResult

Implementation of

ITransformService.transformMutationsWithChangeset