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(sheet): editor shortcuts #332

Merged
merged 42 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
911ac51
refactor(sheet): sheet selection and theme
DR-Univer Oct 24, 2023
a363c61
refactor(sheet): sheet selection and theme
DR-Univer Oct 24, 2023
262061b
fix(sheet): conflict
DR-Univer Oct 24, 2023
0c3ecc3
fix(sheet): import error
DR-Univer Oct 24, 2023
5d4113a
fix(sheet): import error
DR-Univer Oct 24, 2023
2794d64
fix(sheet): test error
DR-Univer Oct 24, 2023
7748137
feat(sheet): editor shortcuts
DR-Univer Oct 26, 2023
686541a
fix(ui-sheets): fix potential null subscription handling (#333)
jikkai Oct 27, 2023
5ead17e
chore: upgrade dependencies (#327)
jikkai Oct 27, 2023
bc362ae
feat: refactor `ColorPicker` (#329)
jikkai Oct 27, 2023
53907ad
fix(sheet): render refresh
DR-Univer Oct 27, 2023
6decc81
fix(sheet): code review fix
DR-Univer Oct 27, 2023
b6bbda4
refactor(sheet): sheet selection and theme
DR-Univer Oct 24, 2023
59b0f26
fix(sheet): import error
DR-Univer Oct 24, 2023
e51200b
feat(sheet): editor shortcuts
DR-Univer Oct 26, 2023
3710e69
fix(sheet): render refresh
DR-Univer Oct 27, 2023
ce6137f
fix(sheet): code review fix
DR-Univer Oct 27, 2023
b4c4719
fix(sheet): conflict
DR-Univer Oct 27, 2023
bba7631
fix(sheet): ts check
DR-Univer Oct 27, 2023
84d11d1
fix(sheet): test fix
DR-Univer Oct 27, 2023
c1685de
fix(sheet): expand method
DR-Univer Oct 27, 2023
6d41329
fix(sheet): expand error
DR-Univer Oct 27, 2023
5189c13
feat(design): create `design` repo for developing UI components (#335)
jikkai Oct 27, 2023
bc028b7
fix(sheet): type error
DR-Univer Oct 27, 2023
99a43bb
fix(sheet): uppercase letters
DR-Univer Oct 27, 2023
9e67e0a
refactor(sheet): sheet selection and theme
DR-Univer Oct 24, 2023
4ccd9fc
fix(sheet): import error
DR-Univer Oct 24, 2023
7a057da
feat(sheet): editor shortcuts
DR-Univer Oct 26, 2023
ee3219d
fix(sheet): render refresh
DR-Univer Oct 27, 2023
bf4ea52
fix(sheet): code review fix
DR-Univer Oct 27, 2023
058b724
refactor(sheet): sheet selection and theme
DR-Univer Oct 24, 2023
9f2baaa
refactor(sheet): sheet selection and theme
DR-Univer Oct 24, 2023
bfd66e8
fix(sheet): import error
DR-Univer Oct 24, 2023
6597a50
feat(sheet): editor shortcuts
DR-Univer Oct 26, 2023
c6a2cd6
fix(sheet): render refresh
DR-Univer Oct 27, 2023
8d3c79b
fix(sheet): code review fix
DR-Univer Oct 27, 2023
c5a2240
fix(sheet): ts check
DR-Univer Oct 27, 2023
9908a07
fix(sheet): test fix
DR-Univer Oct 27, 2023
fde0338
fix(sheet): expand method
DR-Univer Oct 27, 2023
d574ebf
fix(sheet): expand error
DR-Univer Oct 27, 2023
8735506
fix(sheet): type error
DR-Univer Oct 27, 2023
3a6bb62
fix(sheet): conflict
DR-Univer Oct 27, 2023
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
4 changes: 2 additions & 2 deletions packages/base-docs/src/Controller/doc-render.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ export class DocRenderController extends Disposable {

if (engineWidth > docsWidth) {
docsLeft = engineWidth / 2 - docsWidth / 2;
sceneWidth = engineWidth - 30;
sceneWidth = engineWidth - 34;
} else {
docsLeft = pageMarginLeft;
sceneWidth = docsWidth + pageMarginLeft * 2;
}

if (engineHeight > docsHeight) {
docsTop = engineHeight / 2 - docsHeight / 2;
sceneHeight = engineHeight - 30;
sceneHeight = engineHeight - 34;
} else {
docsTop = pageMarginTop;
sceneHeight = docsHeight + pageMarginTop * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ export const MoveCursorOperation: IOperation<IMoveCursorOperationParams> = {
return false;
}

// const univerInstanceService = accessor.get(IUniverInstanceService);
// const inputController = accessor.get(InputController);

// inputController.moveCursor(univerInstanceService.getCurrentUniverDocInstance(), params.direction);

return true;
},
};
2 changes: 2 additions & 0 deletions packages/base-docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export {
type IUpdateCommandParams,
UpdateCommand,
} from './commands/commands/core-editing.command';
export { BreakLineCommand, DeleteLeftCommand } from './commands/commands/core-editing.command';
export {
type IRichTextEditingMutationParams,
RichTextEditingMutation,
} from './commands/mutations/core-editing.mutation';
export { MoveCursorOperation } from './commands/operations/cursor.operation';
export * from './DocPlugin';
export * from './Locale';
export { DocSkeletonManagerService } from './services/doc-skeleton-manager.service';
Expand Down
1 change: 0 additions & 1 deletion packages/base-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"esbuild": "node ./esbuild.config.mjs"
},
"dependencies": {
"@ctrl/tinycolor": "^4.0.2",
"@univerjs/core": "workspace:^0.0.1",
"@wendellhu/redi": "^0.12.8",
"react": "^18.2.0",
Expand Down
118 changes: 0 additions & 118 deletions packages/base-render/src/Basics/Selection.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/base-render/src/Basics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export * from './Interfaces';
export * from './Path2';
export * from './PerformanceMonitor';
export * from './ScrollXY';
export * from './Selection';
export * from './TextSelection';
export * from './Tools';
export * from './Transform';
Expand Down
3 changes: 0 additions & 3 deletions packages/base-render/src/Component/Sheets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ export * from './ColumnHeader';
export * from './Extensions';
export * from './Interfaces';
export * from './RowHeader';
export * from './Selection/selection-transformer-model';
export * from './Selection/selection-transformer-shape';
export * from './Selection/selection-transformer-shape-manager';
export * from './SheetComponent';
export * from './SheetSkeleton';
export * from './Spreadsheet';
5 changes: 3 additions & 2 deletions packages/base-sheets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"@wendellhu/redi": "^0.12.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rxjs": "^7.8.1"
"rxjs": "^7.8.1",
"@ctrl/tinycolor": "^4.0.2"
},
"devDependencies": {
"@types/node": "^18.14.0",
Expand All @@ -62,4 +63,4 @@
"ts-node": "^10.9.1",
"vitest": "^0.34.5"
}
}
}
158 changes: 158 additions & 0 deletions packages/base-sheets/src/Basics/selection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import { TinyColor } from '@ctrl/tinycolor';
import { getCellInfoInMergeData } from '@univerjs/base-render';
import {
IRange,
ISelection,
ISelectionWithCoord,
makeCellRangeToRangeData,
Nullable,
ThemeService,
} from '@univerjs/core';

export const SELECTION_CONTROL_BORDER_BUFFER_WIDTH = 4; // The draggable range of the selection is too thin, making it easy for users to miss. Therefore, a buffer gap is provided to make it easier for users to select.

export const SELECTION_CONTROL_BORDER_BUFFER_COLOR = 'rgba(255,255,255, 0.01)';

/**
* Whether to display the controller that modifies the selection, distributed in 8 locations
* tl top_left_corner
* tc top_center_corner
* tr top_right_corner
* ml middle_left_corner
* mr middle_right_corner
* bl bottom_left_corner
* bc bottom_center_corner
* br bottom_right_corner
*/
export interface ISelectionWidgetConfig {
tl?: boolean;
tc?: boolean;
tr?: boolean;
ml?: boolean;
mr?: boolean;
bl?: boolean;
bc?: boolean;
br?: boolean;
}

/**
* https://support.microsoft.com/en-us/office/select-cell-contents-in-excel-23f64223-2b6b-453a-8688-248355f10fa9
*/
export interface ISelectionStyle {
strokeWidth: number; // The volume of the selection border determines the thickness of the selection border
DR-Univer marked this conversation as resolved.
Show resolved Hide resolved
stroke: string; // The color of the selection border.
strokeDash?: number; // The dashed line of the selection border. Here, the dashed line is a numerical value, different from the canvas dashed line setting. It is implemented internally as [0, strokeDash]. Setting it to 8 will look more aesthetically pleasing.
fill: string; // The fill color inside the selection. It needs to have a level of transparency, otherwise content in the covered area of the selection will be obscured.
widgets: ISelectionWidgetConfig; // The eight touch points of the selection. You can refer to Excel's formula and chart selections, which allow you to manually adjust the size of the selection. Univer has four more touch points (up, down, left, and right) than Excel. https://support.microsoft.com/en-us/office/select-data-for-a-chart-5fca57b7-8c52-4e09-979a-631085113862
widgetSize?: number; // The volume of the touch points.
widgetStrokeWidth?: number; // The thickness of the border of the touch points
widgetStroke?: string; // The color of the touch points.

// https://support.microsoft.com/en-us/office/copy-a-formula-by-dragging-the-fill-handle-in-excel-for-mac-dd928259-622b-473f-9a33-83aa1a63e218
hasAutoFill: boolean; // Whether to show the drop-down fill button at the bottom right corner of the selection.
AutofillSize?: number; // The size of the fill button.
AutofillStrokeWidth?: number; // The border size of the fill button.
AutofillStroke?: string; // The color of the fill button.

hasRowHeader?: boolean; // Whether to synchronize the display of row title highlights, the highlighting range is consistent with the horizontal range of the selection.
rowHeaderFill?: string; // The color of the row title highlight. A level of transparency should be set to avoid covering the row title content.
rowHeaderStroke?: string; // The color of the bottom border of the row title.
rowHeaderStrokeWidth?: number; // The color of the bottom border of the row title.

hasColumnHeader?: boolean; // The setting of column title highlight is similar to that of row title.
columnHeaderFill?: string;
columnHeaderStroke?: string;
columnHeaderStrokeWidth?: number;
}

export interface ISelectionWithCoordAndStyle extends ISelectionWithCoord {
style: Nullable<ISelectionStyle>;
}

export interface ISelectionWithStyle extends ISelection {
style: Nullable<ISelectionStyle>;
}

// The default configuration of the selection.
export function getNormalSelectionStyle(themeService: ThemeService): ISelectionStyle {
const style = themeService.getCurrentTheme();
const fill = new TinyColor(style.colorBlack).setAlpha(0.1).toString();
return {
strokeWidth: 2,
stroke: style.primaryColor,
// strokeDash: 8,
fill,
// widgets: { tl: true, tc: true, tr: true, ml: true, mr: true, bl: true, bc: true, br: true },
widgets: {},
widgetSize: 6,
widgetStrokeWidth: 1,
widgetStroke: style.colorWhite,

hasAutoFill: true,
AutofillSize: 6,
AutofillStrokeWidth: 1,
AutofillStroke: style.colorWhite,

hasRowHeader: true,
rowHeaderFill: fill,
rowHeaderStroke: style.primaryColor,
rowHeaderStrokeWidth: 1,

hasColumnHeader: true,
columnHeaderFill: fill,
columnHeaderStroke: style.primaryColor,
columnHeaderStrokeWidth: 1,
};
}

export function convertSelectionDataToRange(
selectionWithCoordAndStyle: ISelectionWithCoordAndStyle
): ISelectionWithStyle {
const { rangeWithCoord, primaryWithCoord, style } = selectionWithCoordAndStyle;
const result: ISelectionWithStyle = {
range: {
startRow: rangeWithCoord.startRow,
startColumn: rangeWithCoord.startColumn,
endRow: rangeWithCoord.endRow,
endColumn: rangeWithCoord.endColumn,
rangeType: rangeWithCoord.rangeType,
},
primary: null,
style,
};
if (primaryWithCoord != null) {
const { actualRow, actualColumn, isMerged, isMergedMainCell } = primaryWithCoord;
const { startRow, startColumn, endRow, endColumn } = primaryWithCoord.mergeInfo;
result.primary = {
actualRow,
actualColumn,
isMerged,
isMergedMainCell,
startRow,
startColumn,
endRow,
endColumn,
};
}
return result;
}

export function transformCellDataToSelectionData(
row: number,
column: number,
mergeData: IRange[]
): Nullable<ISelectionWithStyle> {
const newCellRange = getCellInfoInMergeData(row, column, mergeData);

const newSelectionData = makeCellRangeToRangeData(newCellRange);

if (!newSelectionData) {
return;
}

return {
range: newSelectionData,
primary: newCellRange,
style: null,
};
}
Loading