@univerjs-procollaborationinterfacesItransformservice

@univerjs-pro/collaboration v0.5.0-beta.1Docs


Interface: ITransformService

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.

Properties

PropertyTypeDescriptionDefined in
registerTransformAlgorithm(algorithms: IMutationTransformAlgorithm<any, any>) => voidRegister 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.packages/collaboration/src/services/transform/transform.service.ts:48
transformMutationsWithChangeset(c1: IChangeset, m2: IMutationInfo<object>[]) => ITransformMutationsWithChangesetResultInternal Transform mutations with changesets. We only wants transformed mutations here.packages/collaboration/src/services/transform/transform.service.ts:111

Methods

transformChangesets()

transformChangesets(c1, c2)

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

Internal

Transform two arrays of changesets

Parameters
ParameterType
c1IChangeset[]
c2IChangeset[]
Returns

IFailureTransformChangesetsResult | Omit<ISuccessTransformChangesetsResult, "c1Prime">

Defined in

packages/collaboration/src/services/transform/transform.service.ts:103

transformChangesets(c1, c2, onlyLater)

transformChangesets(
   c1, 
   c2, 
   onlyLater): ITransformChangesetsResult
Parameters
ParameterType
c1IChangeset[]
c2IChangeset[]
onlyLaterfalse
Returns

ITransformChangesetsResult

Defined in

packages/collaboration/src/services/transform/transform.service.ts:104


transformMutation()

transformMutation(m1, m2)

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

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<object>
m2IMutationInfo<object>
Returns

IFailureTransformMutationResult | Omit<ISuccessTransformMutationResult, "m1Prime">

Defined in

packages/collaboration/src/services/transform/transform.service.ts:68

transformMutation(m1, m2, onlyLater)

transformMutation(
   m1, 
   m2, 
   onlyLater): ITransformMutationResult
Parameters
ParameterType
m1IMutationInfo<object>
m2IMutationInfo<object>
onlyLaterfalse
Returns

ITransformMutationResult

Defined in

packages/collaboration/src/services/transform/transform.service.ts:69


transformMutations()

transformMutations(m1, m2)

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

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

IFailureTransformMutationsResult | Omit<ISuccessTransformMutationsResult, "m1Prime">

Defined in

packages/collaboration/src/services/transform/transform.service.ts:95

transformMutations(m1, m2, onlyLater)

transformMutations(
   m1, 
   m2, 
   onlyLater): ITransformMutationsResult
Parameters
ParameterType
m1IMutationInfo<object>[]
m2IMutationInfo<object>[]
onlyLaterboolean
Returns

ITransformMutationsResult

Defined in

packages/collaboration/src/services/transform/transform.service.ts:96