Skip to content

Commit

Permalink
feat: export is active for share cursor use (#1420)
Browse files Browse the repository at this point in the history
* feat: export is active for share cursor use

* feat: export is active for share cursor use
  • Loading branch information
Jocs committed Feb 24, 2024
1 parent c9d8944 commit ba51971
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/core/src/types/interfaces/i-selection-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ export interface ITextRange extends ITextRangeStart {

export interface ITextRangeParam extends ITextRange {
segmentId?: string; //The ID of the header, footer or footnote the location is in. An empty segment ID signifies the document's body.
isActive?: boolean; // Whether the text range is active or current range.
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

import type { IOperation } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
import type { ITextSelectionStyle, TextRange } from '@univerjs/engine-render';
import type { ITextRangeWithStyle, ITextSelectionStyle } from '@univerjs/engine-render';

export interface ISetTextSelectionsOperationParams {
unitId: string;
subUnitId: string;
segmentId: string;
style: ITextSelectionStyle;
ranges: TextRange[];
ranges: ITextRangeWithStyle[];
}

export const SetTextSelectionsOperation: IOperation<ISetTextSelectionsOperationParams> = {
Expand All @@ -32,7 +32,7 @@ export const SetTextSelectionsOperation: IOperation<ISetTextSelectionsOperationP
type: CommandType.OPERATION,

handler: (accessor, prams) => {
// for live share only.
// for live share and share cursor.
return true;
},
};
8 changes: 7 additions & 1 deletion packages/docs/src/services/text-selection-manager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ type ITextSelectionInfo = Map<string, Map<string, ITextSelectionInnerParam>>;
export function serializeTextRange(textRange: TextRange): ITextRangeWithStyle {
const { startOffset, endOffset, collapsed } = textRange;

return {
const serializedTextRange: ITextRangeWithStyle = {
startOffset: startOffset!,
endOffset: endOffset!,
collapsed,
};

if (typeof textRange.isActive === 'function') {
serializedTextRange.isActive = textRange.isActive();
}

return serializedTextRange;
}

/**
Expand Down

0 comments on commit ba51971

Please sign in to comment.