From ec6ced8408aa99af14f7bcbacfc8478e1ac6f14e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 16 Jul 2023 20:59:14 +0800 Subject: [PATCH] :art: resize --- app/src/assets/scss/business/_av.scss | 2 ++ app/src/assets/scss/protyle/_wysiwyg.scss | 1 + app/src/protyle/render/av/cell.ts | 18 ++++++++++++------ app/src/protyle/util/resize.ts | 5 ++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss index bbc3e5ac5..bc9d6ad83 100644 --- a/app/src/assets/scss/business/_av.scss +++ b/app/src/assets/scss/business/_av.scss @@ -108,6 +108,8 @@ flex-direction: row-reverse; box-sizing: border-box; opacity: 0; + line-height: 26px; + overflow: hidden; &.av__calc--ashow { opacity: 1; diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss index 25a86ff1a..48828af87 100644 --- a/app/src/assets/scss/protyle/_wysiwyg.scss +++ b/app/src/assets/scss/protyle/_wysiwyg.scss @@ -5,6 +5,7 @@ flex-direction: column; box-sizing: border-box; user-select: auto; + overflow-x: auto; .protyle-breadcrumb__bar { font-size: 14px; diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index 7c7d63dfc..7848190de 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -339,11 +339,17 @@ const updateCellValue = (protyle: IProtyle, cellElement: HTMLElement, type: TAVC const cellId = cellElement.getAttribute("data-id"); const colId = cellElement.getAttribute("data-col-id"); const avID = blockElement.getAttribute("data-av-id"); - let inputValue: string | number = (avMaskElement.querySelector(".b3-text-field") as HTMLInputElement).value; - let oldValue: string | number = cellElement.textContent.trim(); + const inputValue: { content: string | number, isNotEmpty?: boolean } = { + content: (avMaskElement.querySelector(".b3-text-field") as HTMLInputElement).value + }; + const oldValue: { content: string | number, isNotEmpty?: boolean } = { + content: cellElement.textContent.trim() + }; if (type === "number") { - inputValue = parseFloat(inputValue); - oldValue = parseFloat(oldValue); + oldValue.content = parseFloat(oldValue.content as string); + oldValue.isNotEmpty = !!oldValue.content + inputValue.content = parseFloat(inputValue.content as string); + inputValue.isNotEmpty = !!inputValue.content } transaction(protyle, [{ action: "updateAttrViewCell", @@ -352,7 +358,7 @@ const updateCellValue = (protyle: IProtyle, cellElement: HTMLElement, type: TAVC keyID: colId, rowID, data: { - [type]: {content: inputValue} + [type]: inputValue } }], [{ action: "updateAttrViewCell", @@ -361,7 +367,7 @@ const updateCellValue = (protyle: IProtyle, cellElement: HTMLElement, type: TAVC keyID: colId, rowID, data: { - [type]: {content: oldValue} + [type]: oldValue } }]); setTimeout(() => { diff --git a/app/src/protyle/util/resize.ts b/app/src/protyle/util/resize.ts index e30ed85d8..bda7887e6 100644 --- a/app/src/protyle/util/resize.ts +++ b/app/src/protyle/util/resize.ts @@ -3,12 +3,11 @@ import {setPadding} from "../ui/initUI"; import {hasClosestBlock} from "./hasClosest"; import {Constants} from "../../constants"; -let resizeTimeout: number; export const resize = (protyle: IProtyle) => { hideElements(["gutter"], protyle); setPadding(protyle); - clearTimeout(resizeTimeout); - resizeTimeout = window.setTimeout(() => { + // 不能 clearTimeout,否则 split 时左侧无法 resize + window.setTimeout(() => { if (typeof echarts !== "undefined") { protyle.wysiwyg.element.querySelectorAll('[data-subtype="echarts"], [data-subtype="mindmap"]').forEach((chartItem: HTMLElement) => { const chartInstance = echarts.getInstanceById(chartItem.firstElementChild.nextElementSibling.getAttribute("_echarts_instance_"));