Skip to content

Commit a1c4c3f

Browse files
committed
fix(label): fix label rich style does not inherit the plain label style & add new option richInheritPlainLabel to control this behavior.
1 parent 7d76132 commit a1c4c3f

File tree

5 files changed

+126
-3
lines changed

5 files changed

+126
-3
lines changed

src/label/labelStyle.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,18 @@ function setTextStyleCommon(
395395
let richResult: TextStyleProps['rich'];
396396
if (richItemNames) {
397397
richResult = {};
398+
const richInheritPlainLabel = textStyleModel.get('richInheritPlainLabel') !== false;
398399
for (const name in richItemNames) {
399400
if (richItemNames.hasOwnProperty(name)) {
400401
// Cascade is supported in rich.
401-
const richTextStyle = textStyleModel.getModel(['rich', name]);
402+
const richTextStyle = textStyleModel.getModel(['rich', name], richInheritPlainLabel && textStyleModel);
402403
// In rich, never `disableBox`.
403-
// FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
404+
// consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
404405
// the default color `'blue'` will not be adopted if no color declared in `rich`.
405406
// That might confuses users. So probably we should put `textStyleModel` as the
406407
// root ancestor of the `richTextStyle`. But that would be a break change.
408+
// Since v6, the rich style inherits plain label by default
409+
// but this behavior can be disabled by setting `richInheritPlainLabel` to `false`.
407410
setTokenTextStyle(
408411
richResult[name] = {}, richTextStyle, globalTextStyle, opt, isNotNormal, isAttached, false, true
409412
);

test/rich-inherit-plain-label.html

Lines changed: 118 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)