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 2020/03/30 23:48:12 UTC

[incubator-echarts] branch next updated: refact: rename RichText to ZRText

This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/next by this push:
     new dc9bb35  refact: rename RichText to ZRText
dc9bb35 is described below

commit dc9bb355b3ef3073f277bd04c99fbff9c33e68f4
Author: 100pah <su...@gmail.com>
AuthorDate: Tue Mar 31 07:47:27 2020 +0800

    refact: rename RichText to ZRText
---
 src/chart/helper/Line.ts                     |  6 ++--
 src/component/axisPointer/BaseAxisPointer.ts |  4 +--
 src/component/calendar/CalendarView.ts       |  8 ++---
 src/component/toolbox/ToolboxView.ts         |  6 ++--
 src/component/tooltip/TooltipRichContent.ts  |  6 ++--
 src/model/mixin/textStyle.ts                 |  4 +--
 src/util/graphic.ts                          | 52 ++++++++++++++--------------
 src/util/types.ts                            |  8 ++---
 8 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/src/chart/helper/Line.ts b/src/chart/helper/Line.ts
index 1f7109b..1835716 100644
--- a/src/chart/helper/Line.ts
+++ b/src/chart/helper/Line.ts
@@ -27,7 +27,7 @@ import List from '../../data/List';
 import { ZRTextAlign, ZRTextVerticalAlign, LineLabelOption } from '../../util/types';
 import SeriesModel from '../../model/Series';
 import type { LineDrawSeriesScope, LineDrawModelOption } from './LineDraw';
-import { RichTextStyleProps } from 'zrender/src/graphic/RichText';
+import { TextStyleProps } from 'zrender/src/graphic/Text';
 
 const SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'] as const;
 
@@ -38,8 +38,8 @@ export interface LineLabel extends graphic.Text {
 }
 
 interface InnerLineLabel extends LineLabel {
-    __align: RichTextStyleProps['align']
-    __verticalAlign: RichTextStyleProps['verticalAlign']
+    __align: TextStyleProps['align']
+    __verticalAlign: TextStyleProps['verticalAlign']
     __position: LineLabelOption['position']
     __labelDistance: number[]
 }
diff --git a/src/component/axisPointer/BaseAxisPointer.ts b/src/component/axisPointer/BaseAxisPointer.ts
index a57d205..7dcd472 100644
--- a/src/component/axisPointer/BaseAxisPointer.ts
+++ b/src/component/axisPointer/BaseAxisPointer.ts
@@ -32,7 +32,7 @@ import Element from 'zrender/src/Element';
 import { VerticalAlign, HorizontalAlign, CommonAxisPointerOption } from '../../util/types';
 import { PathProps } from 'zrender/src/graphic/Path';
 import Model from '../../model/Model';
-import { RichTextProps } from 'zrender/src/graphic/RichText';
+import { TextProps } from 'zrender/src/graphic/Text';
 
 const inner = makeInner<{
     lastProp?: DisplayableProps
@@ -86,7 +86,7 @@ export interface AxisPointerElementOptions {
         type: 'Line' | 'Rect' | 'Circle' | 'Sector'
     }
 
-    label: RichTextProps
+    label: TextProps
 }
 /**
  * Base axis pointer class in 2D.
diff --git a/src/component/calendar/CalendarView.ts b/src/component/calendar/CalendarView.ts
index d4e0bc6..571bd3b 100644
--- a/src/component/calendar/CalendarView.ts
+++ b/src/component/calendar/CalendarView.ts
@@ -28,7 +28,7 @@ import ExtensionAPI from '../../ExtensionAPI';
 import { LayoutOrient, OptionDataValueDate, ZRTextAlign, ZRTextVerticalAlign } from '../../util/types';
 import ComponentView from '../../view/Component';
 import { PathStyleProps } from 'zrender/src/graphic/Path';
-import { RichTextStyleProps, RichTextProps } from 'zrender/src/graphic/RichText';
+import { TextStyleProps, TextProps } from 'zrender/src/graphic/Text';
 
 const MONTH_TEXT = {
     EN: [
@@ -261,7 +261,7 @@ class CalendarView extends ComponentView {
         orient: LayoutOrient,
         position: 'left' | 'right' | 'top' | 'bottom',
         margin: number
-    ): RichTextProps {
+    ): TextProps {
 
         let x = point[0];
         let y = point[1];
@@ -364,7 +364,7 @@ class CalendarView extends ComponentView {
         orient: LayoutOrient,
         position: 'start' | 'end',
         margin: number
-    ): RichTextStyleProps {
+    ): TextStyleProps {
         let align: ZRTextAlign = 'left';
         let vAlign: ZRTextVerticalAlign = 'top';
         let x = point[0];
@@ -465,7 +465,7 @@ class CalendarView extends ComponentView {
         position: 'start' | 'end',
         margin: number,
         cellSize: number[]
-    ): RichTextStyleProps {
+    ): TextStyleProps {
         let align: ZRTextAlign = 'center';
         let vAlign: ZRTextVerticalAlign = 'middle';
         let x = point[0];
diff --git a/src/component/toolbox/ToolboxView.ts b/src/component/toolbox/ToolboxView.ts
index 70212dc..daf8328 100644
--- a/src/component/toolbox/ToolboxView.ts
+++ b/src/component/toolbox/ToolboxView.ts
@@ -37,7 +37,7 @@ import {
 } from './featureManager';
 import { getUID } from '../../util/component';
 import Displayable from 'zrender/src/graphic/Displayable';
-import RichText from 'zrender/src/graphic/RichText';
+import ZRText from 'zrender/src/graphic/Text';
 
 type IconPath = ToolboxFeatureModel['iconPaths'][string];
 
@@ -210,7 +210,7 @@ class ToolboxView extends ComponentView {
                 pathEmphasisState.style = iconStyleEmphasisModel.getItemStyle();
 
                 // Text position calculation
-                const textContent = new RichText({
+                const textContent = new ZRText({
                     style: {
                         text: titlesMap[iconName],
                         align: iconStyleEmphasisModel.get('textAlign'),
@@ -294,7 +294,7 @@ class ToolboxView extends ComponentView {
             if (emphasisTextState && titleText) {
                 const emphasisTextStyle = emphasisTextState.style || (emphasisTextState.style = {});
                 const rect = textContain.getBoundingRect(
-                    titleText, RichText.makeFont(emphasisTextStyle)
+                    titleText, ZRText.makeFont(emphasisTextStyle)
                 );
                 const offsetX = icon.x + group.x;
                 const offsetY = icon.y + group.y + itemSize;
diff --git a/src/component/tooltip/TooltipRichContent.ts b/src/component/tooltip/TooltipRichContent.ts
index bf660ca..5d036a0 100644
--- a/src/component/tooltip/TooltipRichContent.ts
+++ b/src/component/tooltip/TooltipRichContent.ts
@@ -25,7 +25,7 @@ import * as graphic from '../../util/graphic';
 import { Dictionary } from 'zrender/src/core/types';
 import { ColorString } from '../../util/types';
 import Model from '../../model/Model';
-import RichText, { RichTextStyleProps } from 'zrender/src/graphic/RichText';
+import ZRText, { TextStyleProps } from 'zrender/src/graphic/Text';
 
 class TooltipRichContent {
 
@@ -75,7 +75,7 @@ class TooltipRichContent {
             this._zr.remove(this.el);
         }
 
-        const markers: RichTextStyleProps['rich'] = {};
+        const markers: TextStyleProps['rich'] = {};
         let text = content;
         const prefix = '{marker';
         const suffix = '|}';
@@ -107,7 +107,7 @@ class TooltipRichContent {
             startId = text.indexOf('{marker');
         }
 
-        this.el = new RichText({
+        this.el = new ZRText({
             style: {
                 rich: markers,
                 text: content,
diff --git a/src/model/mixin/textStyle.ts b/src/model/mixin/textStyle.ts
index 743dae4..907bba4 100644
--- a/src/model/mixin/textStyle.ts
+++ b/src/model/mixin/textStyle.ts
@@ -20,7 +20,7 @@
 import * as graphicUtil from '../../util/graphic';
 import Model from '../Model';
 import { LabelOption, ColorString } from '../../util/types';
-import RichText from 'zrender/src/graphic/RichText';
+import ZRText from 'zrender/src/graphic/Text';
 
 const PATH_COLOR = ['textStyle', 'color'] as const;
 
@@ -30,7 +30,7 @@ type LabelRectRelatedOption = Pick<LabelOption,
 > & LabelFontOption;
 
 // TODO Performance improvement?
-const tmpRichText = new RichText();
+const tmpRichText = new ZRText();
 class TextStyleMixin {
     /**
      * Get color property or get color from option.textStyle.color
diff --git a/src/util/graphic.ts b/src/util/graphic.ts
index 243ad13..311f883 100644
--- a/src/util/graphic.ts
+++ b/src/util/graphic.ts
@@ -23,9 +23,9 @@ import * as matrix from 'zrender/src/core/matrix';
 import * as vector from 'zrender/src/core/vector';
 import Path, { PathProps } from 'zrender/src/graphic/Path';
 import Transformable from 'zrender/src/core/Transformable';
-import ZImage, { ImageStyleProps } from 'zrender/src/graphic/Image';
+import ZRImage, { ImageStyleProps } from 'zrender/src/graphic/Image';
 import Group from 'zrender/src/graphic/Group';
-import RichText, { RichTextStyleProps } from 'zrender/src/graphic/RichText';
+import ZRText, { TextStyleProps } from 'zrender/src/graphic/Text';
 import Circle from 'zrender/src/graphic/shape/Circle';
 import Sector from 'zrender/src/graphic/shape/Sector';
 import Ring from 'zrender/src/graphic/shape/Ring';
@@ -225,7 +225,7 @@ export function makeImage(
     rect: ZRRectLike,
     layout?: 'center' | 'cover'
 ) {
-    const path = new ZImage({
+    const path = new ZRImage({
         style: {
             image: imageUrl,
             x: rect.x,
@@ -588,24 +588,24 @@ interface SetLabelStyleOpt<LDI> extends TextCommonParams {
 
 /**
  * Set normal styles and emphasis styles about text on target element
- * If target is a RichText. It will create a new style object.
- * If target is other Element. It will create or reuse RichText which is attached on the target.
+ * If target is a ZRText. It will create a new style object.
+ * If target is other Element. It will create or reuse ZRText which is attached on the target.
  * And create a new style object.
  *
- * NOTICE: Because the style on RichText will be replaced with new(only x, y are keeped).
- * So please use the style on RichText after use this method.
+ * NOTICE: Because the style on ZRText will be replaced with new(only x, y are keeped).
+ * So please use the style on ZRText after use this method.
  */
 export function setLabelStyle<LDI>(
     targetEl: Element,
     normalModel: Model,
     emphasisModel: Model,
     opt?: SetLabelStyleOpt<LDI>,
-    normalSpecified?: RichTextStyleProps,
-    emphasisSpecified?: RichTextStyleProps
+    normalSpecified?: TextStyleProps,
+    emphasisSpecified?: TextStyleProps
     // TODO specified position?
 ) {
     opt = opt || EMPTY_OBJ;
-    const isSetOnRichText = targetEl instanceof RichText;
+    const isSetOnText = targetEl instanceof ZRText;
     const labelFetcher = opt.labelFetcher;
     const labelDataIndex = opt.labelDataIndex;
     const labelDimIndex = opt.labelDimIndex;
@@ -636,14 +636,14 @@ export function setLabelStyle<LDI>(
         baseText
     );
 
-    let richText = isSetOnRichText ? targetEl as RichText : null;
+    let richText = isSetOnText ? targetEl as ZRText : null;
     // Optimize: If style.text is null, text will not be drawn.
     if (showNormal || showEmphasis) {
-        if (!isSetOnRichText) {
+        if (!isSetOnText) {
             // Reuse the previous
             richText = targetEl.getTextContent();
             if (!richText) {
-                richText = new RichText();
+                richText = new ZRText();
                 targetEl.setTextContent(richText);
             }
         }
@@ -663,17 +663,17 @@ export function setLabelStyle<LDI>(
             normalSpecified,
             opt,
             false,
-            !isSetOnRichText
+            !isSetOnText
         );
         emphasisState.style = createTextStyle(
             emphasisModel,
             emphasisSpecified,
             opt,
             true,
-            !isSetOnRichText
+            !isSetOnText
         );
 
-        if (!isSetOnRichText) {
+        if (!isSetOnText) {
             // Always create new
             targetEl.setTextConfig(createTextConfig(
                 normalStyle,
@@ -717,12 +717,12 @@ export function setLabelStyle<LDI>(
  */
 export function createTextStyle(
     textStyleModel: Model,
-    specifiedTextStyle?: RichTextStyleProps,    // Can be overrided by settings in model.
+    specifiedTextStyle?: TextStyleProps,    // Can be overrided by settings in model.
     opt?: TextCommonParams,
     isEmphasis?: boolean,
     isAttached?: boolean // If text is attached on an element. If so, auto color will handling in zrender.
 ) {
-    const textStyle: RichTextStyleProps = {};
+    const textStyle: TextStyleProps = {};
     setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis, isAttached);
     specifiedTextStyle && extend(textStyle, specifiedTextStyle);
     // textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
@@ -731,7 +731,7 @@ export function createTextStyle(
 }
 
 export function createTextConfig(
-    textStyle: RichTextStyleProps,
+    textStyle: TextStyleProps,
     textStyleModel: Model,
     opt?: TextCommonParams,
     isEmphasis?: boolean
@@ -796,7 +796,7 @@ export function createTextConfig(
  * to manage.)
  */
 function setTextStyleCommon(
-    textStyle: RichTextStyleProps,
+    textStyle: TextStyleProps,
     textStyleModel: Model,
     opt?: TextCommonParams,
     isEmphasis?: boolean,
@@ -823,7 +823,7 @@ function setTextStyleCommon(
     //     }
     // }
     const richItemNames = getRichItemNames(textStyleModel);
-    let richResult: RichTextStyleProps['rich'];
+    let richResult: TextStyleProps['rich'];
     if (richItemNames) {
         richResult = {};
         for (const name in richItemNames) {
@@ -905,7 +905,7 @@ const TEXT_PROPS_BOX = [
 ] as const;
 
 function setTokenTextStyle(
-    textStyle: RichTextStyleProps['rich'][string],
+    textStyle: TextStyleProps['rich'][string],
     textStyleModel: Model<LabelOption>,
     globalTextStyle: LabelOption,
     opt?: TextCommonParams,
@@ -1275,7 +1275,7 @@ export function createIcon(
     iconStr: string,    // Support 'image://' or 'path://' or direct svg path.
     opt?: Omit<DisplayableProps, 'style'>,
     rect?: ZRRectLike
-): SVGPath | ZImage {
+): SVGPath | ZRImage {
     const innerOpts: DisplayableProps = extend({rectHover: true}, opt);
     const style: ZRStyleProps = innerOpts.style = {strokeNoScale: true};
     rect = rect || {x: -1, y: -1, width: 2, height: 2};
@@ -1285,7 +1285,7 @@ export function createIcon(
             ? (
                 (style as ImageStyleProps).image = iconStr.slice(8),
                 defaults(style, rect),
-                new ZImage(innerOpts)
+                new ZRImage(innerOpts)
             )
             : (
                 makePath(
@@ -1397,8 +1397,8 @@ registerShape('arc', Arc);
 
 export {
     Group,
-    ZImage as Image,
-    RichText as Text,
+    ZRImage as Image,
+    ZRText as Text,
     Circle,
     Sector,
     Ring,
diff --git a/src/util/types.ts b/src/util/types.ts
index 6bae3ed..4e4ea3c 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -45,7 +45,7 @@ import { RectLike } from 'zrender/src/core/BoundingRect';
 import { TSpanStyleProps } from 'zrender/src/graphic/TSpan';
 import { PathStyleProps } from 'zrender/src/graphic/Path';
 import { ImageStyleProps } from 'zrender/src/graphic/Image';
-import RichText, { RichTextStyleProps } from 'zrender/src/graphic/RichText';
+import ZRText, { TextStyleProps } from 'zrender/src/graphic/Text';
 
 
 
@@ -78,7 +78,7 @@ export type ZRElementEvent = ElementEvent;
 
 export type ZRRectLike = RectLike;
 
-export type ZRStyleProps = PathStyleProps | ImageStyleProps | TSpanStyleProps | RichTextStyleProps;
+export type ZRStyleProps = PathStyleProps | ImageStyleProps | TSpanStyleProps | TextStyleProps;
 
 // ComponentFullType can be:
 //     'xxx.yyy': means ComponentMainType.ComponentSubType.
@@ -758,7 +758,7 @@ export interface LabelOption extends TextCommonOption {
     rotate?: number
     offset?: number[]
 
-    overflow?: RichTextStyleProps['overflow']
+    overflow?: TextStyleProps['overflow']
 
     // TODO: TYPE not all label support formatter
     // formatter?: string | ((params: CallbackDataParams) => string)
@@ -829,7 +829,7 @@ interface PositionCallback {
          * Will be HTMLDivElement when renderMode is html
          * Otherwise it's graphic.Text
          */
-        el: HTMLDivElement | RichText | null,
+        el: HTMLDivElement | ZRText | null,
         /**
          * Rect of hover elements. Will be null if not hovered
          */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org