Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export is active for share cursor use #1420

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
},
};
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
Loading