开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.
fix(property): prevent set fill color opacity when color is none (#56)
pubuzhixing85cee80c2952e
diff --git a/packages/drawnix/src/transforms/property.ts b/packages/drawnix/src/transforms/property.tsindex d70dcba..54a2606 100644--- a/packages/drawnix/src/transforms/property.ts+++ b/packages/drawnix/src/transforms/property.ts@@ -12,6 +12,7 @@ import {hexAlphaToOpacity,isFullyOpaque,isNoColor,+ isValidColor,removeHexAlpha,} from '../utils/color';import {@@ -29,6 +30,9 @@ export const setFillColorOpacity = (board: PlaitBoard, fillOpacity: number) => {return;}const currentFill = getCurrentFill(board, element);+ if (!isValidColor(currentFill)) {+ return;+ }const currentFillColor = removeHexAlpha(currentFill);const newFill = isFullyOpaque(fillOpacity)? currentFillColordiff --git a/packages/drawnix/src/utils/color.ts b/packages/drawnix/src/utils/color.tsindex e6d3f1d..ab9cce4 100644--- a/packages/drawnix/src/utils/color.ts+++ b/packages/drawnix/src/utils/color.ts@@ -36,6 +36,13 @@ export function hexAlphaToOpacity(hexColor: string) {return 100 - alpha255ToTransparency(alpha);}+export function isValidColor(color: string) {+ if (color === 'none') {+ return false;+ }+ return true;+}+export function removeHexAlpha(hexColor: string) {// 移除可能存在的 # 前缀,并转换为大写const hexColorClone = hexColor.replace(/^#/, '').toUpperCase();