You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2025/06/05 11:39:19 UTC
(echarts) branch fix/rich-inherit-plain-label-2 created (now 5c11b747b)
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a change to branch fix/rich-inherit-plain-label-2
in repository https://gitbox.apache.org/repos/asf/echarts.git
at 5c11b747b fix(rich-text-inherit-plain): see https://github.com/apache/echarts/pull/20977/files#r2128424459
This branch includes the following new commits:
new 5c11b747b fix(rich-text-inherit-plain): see https://github.com/apache/echarts/pull/20977/files#r2128424459
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
(echarts) 01/01: fix(rich-text-inherit-plain): see https://github.com/apache/echarts/pull/20977/files#r2128424459
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch fix/rich-inherit-plain-label-2
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 5c11b747bb0cc21d5a86561ba0e9e088a3493d12
Author: 100pah <su...@gmail.com>
AuthorDate: Thu Jun 5 19:37:24 2025 +0800
fix(rich-text-inherit-plain): see https://github.com/apache/echarts/pull/20977/files#r2128424459
---
src/label/labelStyle.ts | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/src/label/labelStyle.ts b/src/label/labelStyle.ts
index 8e8fc0d04..d27ebea16 100644
--- a/src/label/labelStyle.ts
+++ b/src/label/labelStyle.ts
@@ -30,10 +30,11 @@ import {
ColorString,
ZRStyleProps,
AnimationOptionMixin,
- InterpolatableValue
+ InterpolatableValue,
+ NullUndefined
} from '../util/types';
import GlobalModel from '../model/Global';
-import { isFunction, retrieve2, extend, keys, trim } from 'zrender/src/core/util';
+import { isFunction, retrieve2, extend, keys, trim, retrieve3 } from 'zrender/src/core/util';
import { SPECIAL_STATES, DISPLAY_STATES } from '../util/states';
import { deprecateReplaceLog } from '../util/log';
import { makeInner, interpolateRawValues } from '../util/model';
@@ -398,15 +399,13 @@ function setTextStyleCommon(
const richInheritPlainLabelOptionName = 'richInheritPlainLabel' as const;
const richInheritPlainLabel = retrieve2(
textStyleModel.get(richInheritPlainLabelOptionName),
- ecModel && ecModel.get(richInheritPlainLabelOptionName)
+ ecModel ? ecModel.get(richInheritPlainLabelOptionName) : undefined
);
+ const plainTextStyle = textStyleModel.option ? textStyleModel.option.textStyle : null;
for (const name in richItemNames) {
if (richItemNames.hasOwnProperty(name)) {
// Cascade is supported in rich.
- const richTextStyle = textStyleModel.getModel(
- ['rich', name],
- richInheritPlainLabel !== false ? textStyleModel : void 0
- );
+ const richTextStyle = textStyleModel.getModel(['rich', name]);
// In rich, never `disableBox`.
// consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
// the default color `'blue'` will not be adopted if no color declared in `rich`.
@@ -415,7 +414,8 @@ function setTextStyleCommon(
// Since v6, the rich style inherits plain label by default
// but this behavior can be disabled by setting `richInheritPlainLabel` to `false`.
setTokenTextStyle(
- richResult[name] = {}, richTextStyle, globalTextStyle, opt, isNotNormal, isAttached, false, true
+ richResult[name] = {}, richTextStyle, globalTextStyle, plainTextStyle, richInheritPlainLabel,
+ opt, isNotNormal, isAttached, false, true
);
}
}
@@ -431,7 +431,9 @@ function setTextStyleCommon(
if (margin != null) {
textStyle.margin = margin;
}
- setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isNotNormal, isAttached, true, false);
+ setTokenTextStyle(
+ textStyle, textStyleModel, globalTextStyle, null, null, opt, isNotNormal, isAttached, true, false
+ );
}
// Consider case:
// {
@@ -482,6 +484,8 @@ function setTokenTextStyle(
textStyle: TextStyleProps['rich'][string],
textStyleModel: Model<LabelOption>,
globalTextStyle: LabelOption,
+ plainTextStyle: LabelOption | NullUndefined,
+ richInheritPlainLabel: boolean,
opt?: Pick<TextCommonParams, 'inheritColor' | 'defaultOpacity' | 'disableBox'>,
isNotNormal?: boolean,
isAttached?: boolean,
@@ -566,7 +570,17 @@ function setTokenTextStyle(
// others should remain their original value got from normal style.
for (let i = 0; i < TEXT_PROPS_WITH_GLOBAL.length; i++) {
const key = TEXT_PROPS_WITH_GLOBAL[i];
- const val = retrieve2(textStyleModel.getShallow(key), globalTextStyle[key]);
+ // props width, height, padding, margin, tag, backgroundColor, borderColor,
+ // borderWidth, borderRadius, shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY
+ // may inappropriate to inherit from plainTextStyle.
+ // And if some props is specified in default options, users may have to reset them one by one.
+ // Therefore, we only allow these props to inherit from plainTextStyle.
+ // `richInheritPlainLabel` is switch for backward compatibility
+ const val = richInheritPlainLabel !== false
+ ? retrieve3(
+ textStyleModel.getShallow(key), plainTextStyle ? plainTextStyle[key] : null, globalTextStyle[key]
+ )
+ : retrieve2(textStyleModel.getShallow(key), globalTextStyle[key]);
if (val != null) {
(textStyle as any)[key] = val;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org