mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 02:13:00 +08:00
fix(editor): text color on toolbar when connector is selected (#12360)
Closes: [BS-3511](https://linear.app/affine-design/issue/BS-3511/当选中-connector-时,toolbar-上文字颜色选项颜色显示不正确) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Added end-to-end tests for the edgeless connector feature, verifying toolbar text color functionality and theme-based color changes. - **Refactor** - Improved performance of text toolbar actions by optimizing internal data handling for font and color selection. No changes to visible behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -127,18 +127,18 @@ export function createTextActions<
|
||||
);
|
||||
if (!allowed) return null;
|
||||
|
||||
const mappedModels = models.map(mapInto);
|
||||
|
||||
const fontFamily =
|
||||
getMostCommonValue(models.map(mapInto), 'fontFamily') ??
|
||||
FontFamily.Inter;
|
||||
getMostCommonValue(mappedModels, 'fontFamily') ?? FontFamily.Inter;
|
||||
const styleInfo = { fontFamily: TextUtils.wrapFontFamily(fontFamily) };
|
||||
|
||||
const onPick = (fontFamily: FontFamily) => {
|
||||
let fontWeight =
|
||||
getMostCommonValue(models.map(mapInto), 'fontWeight') ??
|
||||
getMostCommonValue(mappedModels, 'fontWeight') ??
|
||||
FontWeight.Regular;
|
||||
let fontStyle =
|
||||
getMostCommonValue(models.map(mapInto), 'fontStyle') ??
|
||||
FontStyle.Normal;
|
||||
getMostCommonValue(mappedModels, 'fontStyle') ?? FontStyle.Normal;
|
||||
|
||||
if (!isFontWeightSupported(fontFamily, fontWeight)) {
|
||||
fontWeight = FontWeight.Regular;
|
||||
@@ -199,11 +199,13 @@ export function createTextActions<
|
||||
? DefaultTheme.shapeTextColor
|
||||
: DefaultTheme.textColor;
|
||||
|
||||
const mappedModels = models.map(mapInto);
|
||||
|
||||
const field = 'color';
|
||||
const firstModel = models[0];
|
||||
const originalColor = mapInto(firstModel)[field];
|
||||
const firstModel = mappedModels[0];
|
||||
const originalColor = firstModel[field];
|
||||
const color =
|
||||
getMostCommonResolvedValue(models, field, color =>
|
||||
getMostCommonResolvedValue(mappedModels, field, color =>
|
||||
resolveColor(color, theme)
|
||||
) ?? resolveColor(defaultColor, theme);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user