Skip to content

Commit b7d4893

Browse files
authored
Merge pull request #20977 from apache/fix/rich-inherit-plain-label
fix(label): fix label rich style does not inherit the plain label style
2 parents a24e8aa + 2204b1a commit b7d4893

File tree

5 files changed

+134
-3
lines changed

5 files changed

+134
-3
lines changed

src/label/labelStyle.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,25 @@ function setTextStyleCommon(
395395
let richResult: TextStyleProps['rich'];
396396
if (richItemNames) {
397397
richResult = {};
398+
const richInheritPlainLabelOptionName = 'richInheritPlainLabel' as const;
399+
const richInheritPlainLabel = retrieve2(
400+
textStyleModel.get(richInheritPlainLabelOptionName),
401+
ecModel && ecModel.get(richInheritPlainLabelOptionName)
402+
);
398403
for (const name in richItemNames) {
399404
if (richItemNames.hasOwnProperty(name)) {
400405
// Cascade is supported in rich.
401-
const richTextStyle = textStyleModel.getModel(['rich', name]);
406+
const richTextStyle = textStyleModel.getModel(
407+
['rich', name],
408+
richInheritPlainLabel !== false ? textStyleModel : void 0
409+
);
402410
// In rich, never `disableBox`.
403-
// FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
411+
// consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
404412
// the default color `'blue'` will not be adopted if no color declared in `rich`.
405413
// That might confuses users. So probably we should put `textStyleModel` as the
406414
// root ancestor of the `richTextStyle`. But that would be a break change.
415+
// Since v6, the rich style inherits plain label by default
416+
// but this behavior can be disabled by setting `richInheritPlainLabel` to `false`.
407417
setTokenTextStyle(
408418
richResult[name] = {}, richTextStyle, globalTextStyle, opt, isNotNormal, isAttached, false, true
409419
);

test/rich-inherit-plain-label.html

Lines changed: 119 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/richText.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/runTest/actions/__meta__.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/runTest/actions/rich-inherit-plain-label.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)