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

fix(docs-ui): paste link on link #3518

Merged
merged 5 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export const InnerPasteCommand: ICommand<IInnerPasteCommandParams> = {
const commandService = accessor.get(ICommandService);
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
const univerInstanceService = accessor.get(IUniverInstanceService);
const selections = docSelectionManagerService.getTextRanges();
const _selections = docSelectionManagerService.getTextRanges();
const { body, tableSource, drawings } = doc;
if (!Array.isArray(selections) || selections.length === 0 || body == null) {
if (!Array.isArray(_selections) || _selections.length === 0 || body == null) {
return false;
}

Expand All @@ -100,7 +100,7 @@ export const InnerPasteCommand: ICommand<IInnerPasteCommandParams> = {
if (docDataModel == null || originBody == null) {
return false;
}

const selections = _selections.map((range) => BuildTextUtils.selection.getInsertSelection(range, originBody));
const unitId = docDataModel.getUnitId();

const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/

import type { IOperation } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
import { IRenderManagerService } from '@univerjs/engine-render';
import type { IOperation } from '@univerjs/core';
import { SheetsZoomRenderController } from '../../controllers/render-controllers/zoom.render-controller';
import { IEditorBridgeService } from '../../services/editor-bridge.service';

export interface ISetZoomRatioOperationParams {
zoomRatio: number;
Expand All @@ -31,8 +32,11 @@ export const SetZoomRatioOperation: IOperation<ISetZoomRatioOperationParams> = {
handler: (accessor, params: ISetZoomRatioOperationParams) => {
const renderManagerService = accessor.get(IRenderManagerService);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个需要在源头阻止操作的生成,担心在 live share 场景下会有问题:本地虽然没有缩放但是 follower 缩放了

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉编辑的时候很多操作都应该阻止,不仅仅是缩放

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前编辑器好多bug都和在编辑态时,用户做了其他一些操作导致的,比如切换 sheet,放大缩小等。编辑cell和这些操作不能并行,要么关闭编辑器要么阻止操作?

const renderUnit = renderManagerService.getRenderById(params.unitId);

const editorBridgeService = accessor.get(IEditorBridgeService);
if (!renderUnit) return false;
const state = editorBridgeService.isVisible();
if (state.unitId === params.unitId && state.visible) return false;

return renderUnit.with(SheetsZoomRenderController).updateZoom(params.subUnitId, params.zoomRatio);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -1096,13 +1096,6 @@ export function getCellDataByInput(
cellData.si = null;
cellData.p = null;
cellData.t = CellValueType.FORCE_STRING;
} else if (numfmt.parseDate(newDataStream) || numfmt.parseNumber(newDataStream) || numfmt.parseTime(newDataStream)) {
// If it can be converted to a number and is not forced to be a string, then the style should keep prev style.
cellData.v = newDataStream;
cellData.f = null;
cellData.si = null;
cellData.p = null;
cellData.t = CellValueType.NUMBER;
} else if (isRichText(body)) {
if (body.dataStream === '\r\n') {
cellData.v = '';
Expand All @@ -1115,6 +1108,13 @@ export function getCellDataByInput(
cellData.f = null;
cellData.si = null;
}
} else if (numfmt.parseDate(newDataStream) || numfmt.parseNumber(newDataStream) || numfmt.parseTime(newDataStream)) {
// If it can be converted to a number and is not forced to be a string, then the style should keep prev style.
cellData.v = newDataStream;
cellData.f = null;
cellData.si = null;
cellData.p = null;
cellData.t = CellValueType.NUMBER;
} else {
// If the data is empty, the data is set to null.
if ((newDataStream === cellData.v || (newDataStream === '' && cellData.v == null)) && cellData.p == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

import type { IOperation } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
import type { IOperation } from '@univerjs/core';

import type { ISelectionWithStyle } from '../../basics/selection';
import { getSelectionsService } from '../utils/selection-command-util';
import type { ISelectionWithStyle } from '../../basics/selection';
import type { SelectionMoveType } from '../../services/selections/selection-manager.service';

export interface ISetSelectionsOperationParams {
Expand Down
Loading