Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: active cell border color (#5855)

Roman Sergeevbe5c8c01bc0c
diff --git a/packages/core/src/sheets/util.ts b/packages/core/src/sheets/util.ts
index 2eacab2565..4bbb3511cf 100644
--- a/packages/core/src/sheets/util.ts
+++ b/packages/core/src/sheets/util.ts
@@ -168,7 +168,7 @@ export function getFontFormat(format?: Nullable<IStyleData>): IStyleBase {
if (!format) {
return {};
}
- const { ff, fs, it, bl, ul, st, ol, cl, bg } = format;
+ const { ff, fs, it, bl, ul, st, ol, cl, bg, bd } = format;
const style: IStyleBase = {};
ff && (style.ff = ff);
fs && (style.fs = fs);
@@ -179,6 +179,8 @@ export function getFontFormat(format?: Nullable<IStyleData>): IStyleBase {
ol && (style.ol = ol);
cl && (style.cl = cl);
bg && (style.bg = bg);
+ bd && (style.bd = bd);
+
return style;
}
diff --git a/packages/sheets-ui/src/components/border-panel/BorderPanel.tsx b/packages/sheets-ui/src/components/border-panel/BorderPanel.tsx
index 61c8069b0f..23d4b1b1f1 100644
--- a/packages/sheets-ui/src/components/border-panel/BorderPanel.tsx
+++ b/packages/sheets-ui/src/components/border-panel/BorderPanel.tsx
@@ -14,9 +14,15 @@
* limitations under the License.
*/
+import type { DocumentDataModel, IBorderData, Nullable,
+} from '@univerjs/core';
import type { IBorderInfo } from '@univerjs/sheets';
import type { IBorderPanelProps } from './interface';
-import { BorderStyleTypes } from '@univerjs/core';
+import {
+ BorderStyleTypes,
+ DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
+ IUniverInstanceService,
+} from '@univerjs/core';
import { clsx, ColorPicker, Dropdown, Separator } from '@univerjs/design';
import { MoreDownIcon, PaintBucketDoubleIcon } from '@univerjs/icons';
import { BorderStyleManagerService } from '@univerjs/sheets';
@@ -71,9 +77,21 @@ const BORDER_SIZE_CHILDREN = [
},
];
+function getBorderColor(borderData: Nullable<IBorderData>): string | undefined {
+ if (!borderData) return;
+ for (const key in borderData) {
+ const border = borderData[key as keyof IBorderData];
+ if (border?.cl?.rgb) return border.cl.rgb;
+ }
+}
+
export function BorderPanel(props: IBorderPanelProps) {
const componentManager = useDependency(ComponentManager);
const borderStyleManagerService = useDependency(BorderStyleManagerService);
+ const univerInstanceService = useDependency(IUniverInstanceService);
+ const editorDataModel = univerInstanceService.getUnit<DocumentDataModel>(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
+ const textRuns = editorDataModel?.getBody()?.textRuns;
+ const color = getBorderColor(textRuns?.[0]?.ts?.bd);
const { onChange, value } = props;
@@ -126,7 +144,7 @@ export function BorderPanel(props: IBorderPanelProps) {
<Dropdown
overlay={(
<div className="univer-rounded-lg univer-p-4">
- <ColorPicker onChange={(value) => handleClick(value, 'color')} />
+ <ColorPicker value={color} onChange={(value) => handleClick(value, 'color')} />
</div>
)}
>