Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(sheet): ordered list and unordered list
dream-numcc228d3aaab1
diff --git a/.vscode/settings.json b/.vscode/settings.jsonindex 6c91e68911..530851a271 100644--- a/.vscode/settings.json+++ b/.vscode/settings.json@@ -65,5 +65,8 @@"Xinwei"],"javascript.preferences.importModuleSpecifier": "relative",- "typescript.preferences.importModuleSpecifier": "relative"+ "typescript.preferences.importModuleSpecifier": "relative",+ "[xml]": {+ "editor.defaultFormatter": "redhat.vscode-xml"+ }}diff --git a/packages/base-render/src/BaseObject.ts b/packages/base-render/src/BaseObject.tsindex b21b6f143d..9492e4b047 100644--- a/packages/base-render/src/BaseObject.ts+++ b/packages/base-render/src/BaseObject.ts@@ -271,7 +271,7 @@ export abstract class BaseObject {return this._top;}- private set top(num: number | string) {+ protected set top(num: number | string) {this._topOrigin = num;this._top = toPx(num, this._parent?.height);}@@ -280,7 +280,7 @@ export abstract class BaseObject {return this._left;}- private set left(num: number | string) {+ protected set left(num: number | string) {this._leftOrigin = num;this._left = toPx(num, this._parent?.width);}@@ -289,7 +289,7 @@ export abstract class BaseObject {return this._width;}- private set width(num: number | string) {+ protected set width(num: number | string) {this._widthOrigin = num;this._width = toPx(num, this._parent?.width);}@@ -298,7 +298,7 @@ export abstract class BaseObject {return this._height;}- private set height(num: number | string) {+ protected set height(num: number | string) {this._heightOrigin = num;this._height = toPx(num, this._parent?.height);}@@ -307,7 +307,7 @@ export abstract class BaseObject {return this._strokeWidth;}- private set strokeWidth(width: number) {+ protected set strokeWidth(width: number) {this._strokeWidth = width;}@@ -315,7 +315,7 @@ export abstract class BaseObject {return this._angle;}- private set angle(angle: number) {+ protected set angle(angle: number) {this._angle = angle;}@@ -323,7 +323,7 @@ export abstract class BaseObject {return this._scaleX;}- private set scaleX(scaleX: number) {+ protected set scaleX(scaleX: number) {this._scaleX = scaleX;}@@ -331,7 +331,7 @@ export abstract class BaseObject {return this._scaleY;}- private set scaleY(scaleY: number) {+ protected set scaleY(scaleY: number) {this._scaleY = scaleY;}@@ -349,7 +349,7 @@ export abstract class BaseObject {return this._skewX;}- private set skewX(skewX: number) {+ protected set skewX(skewX: number) {this._skewX = skewX;}@@ -357,7 +357,7 @@ export abstract class BaseObject {return this._skewY;}- private set skewY(skewY: number) {+ protected set skewY(skewY: number) {this._skewY = skewY;}@@ -365,7 +365,7 @@ export abstract class BaseObject {return this._flipX;}- private set flipX(flipX: boolean) {+ protected set flipX(flipX: boolean) {this._flipX = flipX;}@@ -373,7 +373,7 @@ export abstract class BaseObject {return this._flipY;}- private set flipY(flipY: boolean) {+ protected set flipY(flipY: boolean) {this._flipY = flipY;}diff --git a/packages/base-render/src/Basics/IDocumentSkeletonCached.ts b/packages/base-render/src/Basics/IDocumentSkeletonCached.tsindex a21c91ed20..431df910f6 100644--- a/packages/base-render/src/Basics/IDocumentSkeletonCached.ts+++ b/packages/base-render/src/Basics/IDocumentSkeletonCached.ts@@ -1,4 +1,4 @@-import { BulletAlignment, ColumnSeparatorType, IDrawing, INestingLevel, IParagraphStyle, ITextStyle, IDocumentRenderConfig } from '@univer/core';+import { BulletAlignment, ColumnSeparatorType, IDrawing, INestingLevel, IParagraphStyle, ITextStyle, IDocumentRenderConfig, IIndentStart } from '@univer/core';export interface IDocumentSkeletonCached extends ISkeletonResourceReference {pages: IDocumentSkeletonPage[];@@ -145,7 +145,7 @@ export interface IDocumentSkeletonSpan {url?: string; // image url链接;}-export interface IDocumentSkeletonBullet {+export interface IDocumentSkeletonBullet extends IIndentStart {listId: string; // listIdsymbol: string; // symbol 列表的内容ts: ITextStyle; // 文字样式diff --git a/packages/base-render/src/Component/Docs/Block/Block.ts b/packages/base-render/src/Component/Docs/Block/Block.tsindex 91035b2ef1..732c5efa70 100644--- a/packages/base-render/src/Component/Docs/Block/Block.ts+++ b/packages/base-render/src/Component/Docs/Block/Block.ts@@ -40,7 +40,7 @@ export function dealWithBlocks(updateBlockIndex(blockSkeletonPages);- allCurrentSkeletonPages.push(...blockSkeletonPages);+ _pushPage(allCurrentSkeletonPages, blockSkeletonPages);renderedBlockIdMap.set(blockId, true);}@@ -51,5 +51,14 @@ export function dealWithBlocks(};}+function _pushPage(allCurrentSkeletonPages: IDocumentSkeletonPage[], blockSkeletonPages: IDocumentSkeletonPage[]) {+ const lastOldPage = allCurrentSkeletonPages[allCurrentSkeletonPages.length - 1];+ const firstNewPage = blockSkeletonPages[0];+ if (lastOldPage === firstNewPage) {+ blockSkeletonPages.splice(0, 1);+ }+ allCurrentSkeletonPages.push(...blockSkeletonPages);+}+// 当本节有多个列,且下一节为连续节类型的时候,需要按照列数分割,重新计算linesexport function dealWidthBlocksByMultiColumnAndContinuous() {}diff --git a/packages/base-render/src/Component/Docs/Block/Paragraph/Bullet.Ruler.ts b/packages/base-render/src/Component/Docs/Block/Paragraph/Bullet.Ruler.tsindex 3337b7b386..df3b3a6896 100644--- a/packages/base-render/src/Component/Docs/Block/Paragraph/Bullet.Ruler.ts+++ b/packages/base-render/src/Component/Docs/Block/Paragraph/Bullet.Ruler.ts@@ -50,12 +50,12 @@ function zeroDecimal(startIndex: number, startNumber: number) {// An uppercase letter, like A, B, or C.function upperAlpha(startIndex: number, startNumber: number) {- return numberToListABC(startIndex + startNumber, true);+ return numberToListABC(startIndex + startNumber - 1, true);}// A lowercase letter, like a, b, or c.function alpha(startIndex: number, startNumber: number) {- return numberToListABC(startIndex + startNumber, false);+ return numberToListABC(startIndex + startNumber - 1, false);}// An uppercase Roman numeral, like I, II, or III.diff --git a/packages/base-render/src/Component/Docs/Block/Paragraph/Bullet.ts b/packages/base-render/src/Component/Docs/Block/Paragraph/Bullet.tsindex 965958fb4c..9d0f426e53 100644--- a/packages/base-render/src/Component/Docs/Block/Paragraph/Bullet.ts+++ b/packages/base-render/src/Component/Docs/Block/Paragraph/Bullet.ts@@ -1,11 +1,11 @@-import { Context, IBullet, ILists, INestingLevel, ITextStyle } from '@univer/core';+import { Context, IBullet, ILists, INestingLevel, ITextStyle, Nullable } from '@univer/core';import { FontCache, getFontStyleString, IDocumentSkeletonBullet, IFontLocale } from '../../../..';import { getBulletOrderedSymbol } from '.';export function dealWidthBullet(bullet?: IBullet,lists?: ILists,- listLevelAncestors?: IDocumentSkeletonBullet[],+ listLevelAncestors?: Array<Nullable<IDocumentSkeletonBullet>>,fontLocale?: IFontLocale,context?: Context): IDocumentSkeletonBullet | undefined {@@ -52,6 +52,9 @@ export function getDefaultBulletSke(listId: string, startIndex: number = 1, fontspr: 0.5,spo: 0,},+ indentFirstLine: 0,+ hanging: 21,+ indentStart: 0,};}@@ -59,13 +62,13 @@ function _getBulletSke(listId: string,nestingLevel: number,nestings: INestingLevel[],- listLevelAncestors?: IDocumentSkeletonBullet[],+ listLevelAncestors?: Array<Nullable<IDocumentSkeletonBullet>>,textStyleConfig?: ITextStyle,fontLocale?: IFontLocale,context?: Context): IDocumentSkeletonBullet {const nesting = nestings[nestingLevel];- const { bulletAlignment, glyphFormat, textStyle: textStyleFirst, startNumber, glyphType, glyphSymbol } = nesting;+ const { bulletAlignment, glyphFormat, textStyle: textStyleFirst, startNumber, glyphType, glyphSymbol, indentFirstLine, hanging, indentStart } = nesting;const textStyle = { ...textStyleConfig, ...textStyleFirst };@@ -77,26 +80,35 @@ function _getBulletSke(symbolContent = glyphSymbol;} else {// 有序列表- symbolContent = __generateOrderedListSymbol(glyphFormat, nestings, listLevelAncestors, context); // 有序列表的处理+ symbolContent = __generateOrderedListSymbol(glyphFormat, nestingLevel, nestings, listLevelAncestors, context); // 有序列表的处理}const bBox = FontCache.getTextSize(symbolContent, fontStyle);- const startIndex = listLevelAncestors?.[nestingLevel]?.startIndexItem ?? 0;+ const startIndex = listLevelAncestors?.[nestingLevel]?.startIndexItem ?? 1;return {listId,symbol: symbolContent, // symbol 列表的内容ts: textStyle, // 文字样式fontStyle, //- startIndexItem: startIndex,+ startIndexItem: startIndex + 1,bBox,nestingLevel: nesting,bulletAlign: bulletAlignment,bulletType: glyphSymbol ? false : !!glyphType, // 默认是无序列表,假如glyphSymbol为空且glyphType不为空才是有序列表+ indentFirstLine,+ hanging,+ indentStart,};}-function __generateOrderedListSymbol(glyphFormat: string, nestings: INestingLevel[], listLevelAncestors?: IDocumentSkeletonBullet[], context?: Context) {+function __generateOrderedListSymbol(+ glyphFormat: string,+ nestingLevel: number,+ nestings: INestingLevel[],+ listLevelAncestors?: Array<Nullable<IDocumentSkeletonBullet>>,+ context?: Context+) {// const indexNumber = startNumber + startIndex;// parse <prefix>%[nestingLevelMinusOne]<suffix>, return symbolContent// <w:lvl w:ilvl="0">@@ -109,9 +121,23 @@ function __generateOrderedListSymbol(glyphFormat: string, nestings: INestingLeveconst prefix = glyphFormatSplit[0];const resultSymbol = [prefix];for (let i = 1; i < glyphFormatSplit.length; i++) {- const levelAndSuffixPre = glyphFormatSplit[1];+ const levelAndSuffixPre = glyphFormatSplit[i];const { level, suffix } = ___getLevelAndSuffix(levelAndSuffixPre);- const singleSymbol = ___getSymbolByBesting(listLevelAncestors?.[level]?.startIndexItem, nestings[level], context);+ let startIndexItem = listLevelAncestors?.[level]?.startIndexItem || 1;+ if (level !== nestingLevel && listLevelAncestors?.[level] !== null) {+ startIndexItem -= 1;+ }+ const singleSymbol = ___getSymbolByBesting(startIndexItem, nestings[level], context);+ // console.log(+ // '___getSymbolByBesting',+ // singleSymbol,+ // level,+ // suffix,+ // listLevelAncestors?.length,+ // listLevelAncestors?.[level]?.startIndexItem,+ // listLevelAncestors?.[level]?.symbol,+ // nestings+ // );resultSymbol.push(singleSymbol, suffix);}return resultSymbol.join('');diff --git a/packages/base-render/src/Component/Docs/Block/Paragraph/Layout.Ruler.ts b/packages/base-render/src/Component/Docs/Block/Paragraph/Layout.Ruler.tsindex 2cdcf91e5f..412ffd9a08 100644--- a/packages/base-render/src/Component/Docs/Block/Paragraph/Layout.Ruler.ts+++ b/packages/base-render/src/Component/Docs/Block/Paragraph/Layout.Ruler.ts@@ -1,4 +1,4 @@-import { BooleanNumber, GridType, HorizontalAlign, INumberUnit, NamedStyleType, SpacingRule } from '@univer/core';+import { BooleanNumber, GridType, HorizontalAlign, INumberUnit, IParagraphStyle, NamedStyleType, SpacingRule } from '@univer/core';import {calculateLineTopByDrawings,createAndUpdateBlockAnchor,@@ -27,7 +27,7 @@ import {setSpanGroupLeft,} from '../..';import {- DEFAULT_DOCUMENT_FONTSIZE,+ IDocumentSkeletonBullet,IDocumentSkeletonColumn,IDocumentSkeletonDrawing,IDocumentSkeletonLine,@@ -52,13 +52,13 @@ export function calculateParagraphLayout(if (paragraphConfig.bulletSkeleton) {const { bulletSkeleton, paragraphStyle = {} } = paragraphConfig;// 如果是一个段落的开头,需要加入bullet- const { gridType = GridType.LINES, charSpace = 0, documentTextStyle = {}, defaultTabStop = 1 } = sectionBreakConfig;-- const { fs: documentFontSize = DEFAULT_DOCUMENT_FONTSIZE } = documentTextStyle;+ const { gridType = GridType.LINES, charSpace = 0, defaultTabStop = 1 } = sectionBreakConfig;const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;- const charSpaceApply = getCharSpaceApply(charSpace, documentFontSize, defaultTabStop, gridType, snapToGrid);+ const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);++ __bulletIndentHandler(paragraphStyle, bulletSkeleton, charSpaceApply);const bulletSpan = createSkeletonBulletSpan(spanGroup[0], bulletSkeleton, charSpaceApply);_lineOperator([bulletSpan, ...spanGroup], pages, sectionBreakConfig, paragraphConfig, elementIndex, isFirstSpan);@@ -258,8 +258,8 @@ function _lineOperator(// line不超过Col高度,或者行超列高列中没有其他内容,或者行超页高页中没有其他内容;const lineIndex = line ? line.lineIndex + 1 : 0;- const { charSpace, documentFontSize, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);- const charSpaceApply = getCharSpaceApply(charSpace, documentFontSize, defaultTabStop, gridType, snapToGrid);+ const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);+ const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);const { paddingLeft, paddingRight, changeBulletWidth } = __getIndentPadding(spanGroup[0], indentFirstLine, hanging, indentStart, indentEnd, charSpaceApply);if (changeBulletWidth.state) {// 为了保持__getIndentPadding的纯函数特性,把修改首行列表宽度的逻辑外置到这里@@ -327,6 +327,9 @@ function _pageOperator(_columnOperator(spanGroup, pages, sectionBreakConfig, paragraphConfig, elementIndex, isFirstSpan, defaultSpanLineHeight);}+/**+ * 17.3.1.12 ind (Paragraph Indentation)+ */function __getIndentPadding(span: IDocumentSkeletonSpan,indentFirstLine: INumberUnit | number = 0,@@ -586,3 +589,17 @@ function __getSpanGroupByLine(line: IDocumentSkeletonLine) {}return spanGroup;}++function __bulletIndentHandler(paragraphStyle: IParagraphStyle, bulletSkeleton: IDocumentSkeletonBullet, charSpaceApply: number) {+ const { hanging, indentStart } = paragraphStyle;++ const { hanging: hangingBullet, indentStart: indentStartBullet } = bulletSkeleton;++ if (hanging === undefined) {+ paragraphStyle.hanging = hangingBullet;+ }++ if (indentStart === undefined) {+ paragraphStyle.indentStart = getNumberUnitValue(indentStartBullet || 0, charSpaceApply) - getNumberUnitValue(hangingBullet || 0, charSpaceApply);+ }+}diff --git a/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts b/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.tsindex c2bed396c6..3ef4fbd191 100644--- a/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts+++ b/packages/base-render/src/Component/Docs/Block/Paragraph/Paragraph.ts@@ -1,4 +1,4 @@-import { ColumnSeparatorType, Context, IBullet, IDrawing, IDrawings, IElementsOrder, IParagraph, ParagraphElementType, PositionedObjectLayoutType } from '@univer/core';+import { ColumnSeparatorType, Context, IBullet, IDrawing, IDrawings, IElementsOrder, IParagraph, Nullable, ParagraphElementType, PositionedObjectLayoutType } from '@univer/core';import { dealWidthBullet, dealWidthInlineDrawing, dealWidthTextRun } from '.';import { createSkeletonPage, getLastNotFullColumnInfo, setColumnFullState } from '../..';import {@@ -40,7 +40,7 @@ export function dealWidthParagraph(fontLocale,} = sectionBreakConfig;- const { elements, elementOrder, paragraphStyle, bullet } = paragraph;+ const { elements, elementOrder, paragraphStyle = {}, bullet } = paragraph;// const paragraphAffectSkeDrawings = _changeDrawingToSkeletonFormat(drawingIds, drawings);@@ -126,7 +126,7 @@ export function dealWidthParagraph(return pages;}-function _getListLevelAncestors(bullet?: IBullet, listLevel?: Map<string, IDocumentSkeletonBullet[]>): IDocumentSkeletonBullet[] | undefined {+function _getListLevelAncestors(bullet?: IBullet, listLevel?: Map<string, IDocumentSkeletonBullet[]>): Array<Nullable<IDocumentSkeletonBullet>> | undefined {if (!bullet || !listLevel) {return;}@@ -137,19 +137,19 @@ function _getListLevelAncestors(bullet?: IBullet, listLevel?: Map<string, IDocumlet level = nestingLevel;- const listLevelAncestors: IDocumentSkeletonBullet[] = [];-- while (sameList?.[level]) {- const bs = sameList[level];- listLevelAncestors[level] = bs!;- level -= 1;+ if (level < 0) {+ level = 0;}- if (level > 0) {- // 证明sameList存储的信息确实,一个list的level要从0开始- return;+ const listLevelAncestors: Array<Nullable<IDocumentSkeletonBullet>> = [];++ for (let i = level; i >= 0; i--) {+ const bs = sameList?.[i];+ listLevelAncestors[i] = bs || null;}+ // console.log('SymbolByBesting', sameList, listLevelAncestors, level, listId, listLevel);+return listLevelAncestors;}@@ -160,7 +160,7 @@ function _updateListLevelAncestors(bullet?: IBullet, bulletSkeleton?: IDocumentSconst { listId, nestingLevel } = bullet;- const cacheItem: IDocumentSkeletonBullet[] = [...(listLevel?.[listId] || [])];+ const cacheItem: IDocumentSkeletonBullet[] = [...(listLevel?.get(listId) || [])];// [[nestingLevel, bulletSkeleton]];diff --git a/packages/base-render/src/Component/Docs/Block/Paragraph/TextRun.ts b/packages/base-render/src/Component/Docs/Block/Paragraph/TextRun.tsindex 3c10d9d59d..4d5dd7d7c8 100644--- a/packages/base-render/src/Component/Docs/Block/Paragraph/TextRun.ts+++ b/packages/base-render/src/Component/Docs/Block/Paragraph/TextRun.ts@@ -38,7 +38,6 @@ export function dealWidthTextRun(marginLeft = 0,marginRight = 0,} = sectionBreakConfig;- const { fs: documentFontSize = 0 } = documentTextStyle;const {namedStyleType = NamedStyleType.NAMED_STYLE_TYPE_UNSPECIFIED,horizontalAlign = HorizontalAlign.UNSPECIFIED,@@ -82,7 +81,7 @@ export function dealWidthTextRun(};if (tab) {- const charSpaceApply = getCharSpaceApply(charSpace, documentFontSize, defaultTabStop, gridType, snapToGrid);+ const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);const tabSpan = createSkeletonTabSpan(fontCreateConfig, charSpaceApply); // measureText收敛到create中执行allPages = calculateParagraphLayout([tabSpan], allPages, sectionBreakConfig, paragraphConfig, elementIndex, true);return allPages;@@ -139,1389 +138,3 @@ function horizontalAlignHandler(line: IDocumentSkeletonLine, horizontalAlign: Ho}}}--// export class TextRun {-// private static _context: CanvasRenderingContext2D;--// private static _verticalText() {}--// private static _normalText() {}--// private static _oneTextRun() {}--// 获取单元格文本内容的渲染信息-// let measureTextCache = {}, measureTextCacheTimeOut = null;-// option {cellWidth,cellHeight,space_width,space_height}-// static getCellTextInfo(cell, ctx, option) {-// let cellWidth = option.cellWidth;-// let cellHeight = option.cellHeight;-// let isMode = '',-// isModeSplit = '';-// // console.log("initialinfo", cell, option);-// if (cellWidth == null) {-// isMode = 'onlyWidth';-// isModeSplit = '_';-// }-// let textInfo = Store.measureTextCellInfoCache[option.r + '_' + option.c + isModeSplit + isMode];-// if (textInfo != null) {-// return textInfo;-// }--// // let cell = Store.flowdata[r][c];-// let space_width = option.space_width,-// space_height = option.space_height; //用户设置或者默认的宽高方向 间隙--// if (space_width == null) {-// space_width = 2;-// }--// if (space_height == null) {-// space_height = 2;-// }--// //水平对齐-// let horizonAlign = checkstatusByCell(cell, 'ht');-// //垂直对齐-// let verticalAlign = checkstatusByCell(cell, 'vt');--// let tb = checkstatusByCell(cell, 'tb'); //wrap overflow-// let tr = checkstatusByCell(cell, 'tr'); //rotate-// let rt = checkstatusByCell(cell, 'rt'); //rotate angle--// let isRotateUp = 1,-// isRotateDown = 0;-// //根据tr判断旋转角度,这里也支持自动输入旋转角度-// if (rt == null) {-// if (tr == '0') {-// rt = 0;-// } else if (tr == '1') {-// rt = 45;-// } else if (tr == '4') {-// rt = 90;-// } else if (tr == '2') {-// rt = 135;-// } else if (tr == '5') {-// rt = 180;-// }--// if (rt == null) {-// rt = 0;-// }-// }--// if (rt > 180 || rt < 0) {-// rt = 0;-// }--// //根据角度判断是文字方向向上还是向下-// rt = parseInt(rt);-// if (rt > 90) {-// rt = 90 - rt;-// isRotateUp = 0;-// isRotateDown = 1;-// }--// ctx.textAlign = 'start';--// let textContent = {};-// textContent.values = [];--// let fontset,-// cancelLine = '0',-// underLine = '0',-// fontSize = 11,-// isInline = false,-// value,-// inlineStringArr = [];-// if (isInlineStringCell(cell)) {-// //判断是否富文本,做一些前置准备工作-// //主要是把富文本按照换行符和不用样式拆分开,为之后的缓存长宽高做准备-// let sharedStrings = cell.ct.s,-// similarIndex = 0;-// for (let i = 0; i < sharedStrings.length; i++) {-// let shareCell = sharedStrings[i];-// let scfontset = universheetfontformat(shareCell);-// let fc = shareCell.fc,-// cl = shareCell.cl,-// un = shareCell.un,-// v = shareCell.v,-// fs = shareCell.fs;-// v = v-// .replace(/\r\n/g, '_x000D_')-// .replace(/ /g, '_x000D_')-// .replace(/\r/g, '_x000D_')-// .replace(/\n/g, '_x000D_');-// let splitArr = v.split('_x000D_');-// for (let x = 0; x < splitArr.length; x++) {-// let newValue = splitArr[x];--// if (newValue == '' && x != splitArr.length - 1) {-// //单独换行符的情况,wrap表示用户换行-// inlineStringArr.push({-// fontset: scfontset,-// fc: fc == null ? '#000' : fc,-// cl: cl == null ? 0 : cl,-// un: un == null ? 0 : un,-// wrap: true,-// fs: fs == null ? 11 : fs,-// });-// similarIndex++;-// } else {-// let newValueArray = newValue.split('');-// for (let n = 0; n < newValueArray.length; n++) {-// //一行重的每一个字符入栈-// let nv = newValueArray[n];--// inlineStringArr.push({-// fontset: scfontset,-// fc: fc == null ? '#000' : fc,-// cl: cl == null ? 0 : cl,-// un: un == null ? 0 : un,-// v: nv,-// si: similarIndex,-// fs: fs == null ? 11 : fs,-// });-// }--// if (x != splitArr.length - 1) {-// //整行文字的末尾,需要加换行符,wrap表示用户换行-// inlineStringArr.push({-// fontset: scfontset,-// fc: fc == null ? '#000' : fc,-// cl: cl == null ? 0 : cl,-// un: un == null ? 0 : un,-// wrap: true,-// fs: fs == null ? 11 : fs,-// });-// similarIndex++;-// }-// }-// }--// similarIndex++;-// }-// isInline = true;-// } else {-// //处理非富文本的情况,提前设置ctx为文本样式-// fontset = universheetfontformat(cell);-// ctx.font = fontset;--// cancelLine = checkstatusByCell(cell, 'cl'); //cancelLine-// underLine = checkstatusByCell(cell, 'un'); //underLine-// fontSize = checkstatusByCell(cell, 'fs');--// if (cell instanceof Object) {-// //读取单元格的值-// value = cell.m;-// if (value == null) {-// value = cell.v;-// }-// } else {-// value = cell;-// }--// if (isRealNull(value)) {-// return null;-// }-// }--// if (tr == '3') {-// //vertical text 竖排文字-// ctx.textBaseline = 'top';--// let textW_all = 0; //拆分后宽高度合计-// let textH_all = 0;-// let colIndex = 0,-// textH_all_cache = 0,-// textH_all_Column = {},-// textH_all_ColumnHeight = [];-// if (isInline) {-// //处理列的步骤,因为这里是竖排文字,所以列和正常模式下的行等价,这个按照单字来测量了宽度和高度-// //富文本时单独处理-// let preShareCell = null;-// for (let i = 0; i < inlineStringArr.length; i++) {-// let shareCell = inlineStringArr[i];-// let value = shareCell.v,-// showValue = shareCell.v;-// if (shareCell.wrap === true) {-// //处理用户手动换行,无论是否触碰边界都要换行-// value = 'M';-// showValue = '';--// if (preShareCell != null && preShareCell.wrap !== true && i < inlineStringArr.length - 1) {-// // console.log("wrap",i,colIndex,preShareCell.wrap);-// textH_all_ColumnHeight.push(textH_all_cache); //列的高度,由于是竖排文本,所以记录高度而不是宽度-// textH_all_cache = 0; //一列的高度缓存清零,开始累加下一列的高度-// colIndex += 1;--// preShareCell = shareCell;-// continue;-// }-// }--// let measureText = getMeasureText(value, ctx, shareCell.fontset);--// let textW = measureText.width + space_width; //-// let textH = measureText.actualBoundingBoxAscent + measureText.actualBoundingBoxDescent + space_height;--// // textW_all += textW;-// textH_all_cache += textH;--// if (tb == '2' && !shareCell.wrap) {-// //tb==2表示自动换行,其他两种方式为溢出和截断,不必须要处理-// if (textH_all_cache > cellHeight && textH_all_Column[colIndex] != null) {-// // textW_all += textW;-// // textH_all = Math.max(textH_all,textH_all_cache);-// // console.log(">",i,colIndex);-// textH_all_ColumnHeight.push(textH_all_cache - textH);-// textH_all_cache = textH;-// colIndex += 1;-// }-// }--// if (i == inlineStringArr.length - 1) {-// textH_all_ColumnHeight.push(textH_all_cache);-// }--// if (textH_all_Column[colIndex] == null) {-// textH_all_Column[colIndex] = [];-// }--// let item = {-// content: showValue,-// style: shareCell,-// width: textW,-// height: textH,-// left: 0,-// top: 0,-// colIndex: colIndex,-// asc: measureText.actualBoundingBoxAscent,-// desc: measureText.actualBoundingBoxDescent,-// inline: true,-// };--// if (shareCell.wrap === true) {-// item.wrap = true;-// }--// textH_all_Column[colIndex].push(item);-// console.log('normal', i, colIndex, shareCell, preShareCell, textH_all_Column);-// preShareCell = shareCell;-// }-// } else {-// let measureText = getMeasureText(value, ctx);-// let textHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;--// value = value.toString();--// let vArr = [];-// if (value.length > 1) {-// vArr = value.split('');-// } else {-// vArr.push(value);-// }-// let oneWordWidth = getMeasureText(vArr[0], ctx).width;--// for (let i = 0; i < vArr.length; i++) {-// let textW = oneWordWidth + space_width;-// let textH = textHeight + space_height;--// // textW_all += textW;-// textH_all_cache += textH;--// if (tb == '2') {-// if (textH_all_cache > cellHeight && textH_all_Column[colIndex] != null) {-// // textW_all += textW;-// // textH_all = Math.max(textH_all,textH_all_cache);-// textH_all_ColumnHeight.push(textH_all_cache - textH);-// textH_all_cache = textH;-// colIndex += 1;-// }-// }--// if (i == vArr.length - 1) {-// textH_all_ColumnHeight.push(textH_all_cache);-// }--// if (textH_all_Column[colIndex] == null) {-// textH_all_Column[colIndex] = [];-// }--// textH_all_Column[colIndex].push({-// content: vArr[i],-// style: fontset,-// width: textW,-// height: textH,-// left: 0,-// top: 0,-// colIndex: colIndex,-// asc: measureText.actualBoundingBoxAscent,-// desc: measureText.actualBoundingBoxDescent,-// });-// }-// }--// let textH_all_ColumWidth = [];-// for (let i = 0; i < textH_all_ColumnHeight.length; i++) {-// //根据上下文计算单元格文本整个的总行高和列宽-// let columnHeight = textH_all_ColumnHeight[i];-// let col = textH_all_Column[i],-// colMaxW = 0;-// for (let c = 0; c < col.length; c++) {-// let word = col[c];-// colMaxW = Math.max(colMaxW, word.width);-// }-// textH_all_ColumWidth.push(colMaxW);-// textW_all += colMaxW;-// textH_all = Math.max(textH_all, columnHeight);-// }--// textContent.type = 'verticalWrap';-// textContent.textWidthAll = textW_all;-// textContent.textHeightAll = textH_all;--// if (isMode == 'onlyWidth') {-// //只取总宽高,3.0这里应该拆分出去-// // console.log("verticalWrap", textContent,cell, option);-// return textContent;-// }--// let cumColumnWidth = 0;-// for (let i = 0; i < textH_all_ColumnHeight.length; i++) {-// //处理每一行的位置-// let columnHeight = textH_all_ColumnHeight[i];-// let columnWidth = textH_all_ColumWidth[i];--// let col = textH_all_Column[i];-// let cumWordHeight = 0;-// for (let c = 0; c < col.length; c++) {-// let word = col[c];-// //vt verticaltype Vertical alignment 0 middle, 1 up, 2 down setVerticalAlignment-// // ht horizontaltype Horizontal alignment 0 center, 1 left, 2 right setHorizontalAlignment-// let left = space_width + cumColumnWidth;-// if (horizonAlign == '0') {-// left = cellWidth / 2 + cumColumnWidth - textW_all / 2 + space_width * textH_all_ColumnHeight.length;-// } else if (horizonAlign == '2') {-// left = cellWidth + cumColumnWidth - textW_all + space_width;-// }--// let top = cellHeight - space_height + cumWordHeight - columnHeight;-// if (verticalAlign == '0') {-// top = cellHeight / 2 + cumWordHeight - columnHeight / 2;-// } else if (verticalAlign == '1') {-// top = space_height + cumWordHeight;-// }--// cumWordHeight += word.height;--// word.left = left;-// word.top = top;--// drawLineInfo(word, cancelLine, underLine, {-// width: columnWidth,-// height: word.height,-// left: left,-// top: top + word.height - space_height,-// asc: word.height,-// desc: 0,-// fs: fontSize,-// });--// textContent.values.push(word);-// }--// cumColumnWidth += columnWidth;-// }-// } else {-// let supportBoundBox = isSupportBoundingBox(ctx);-// if (supportBoundBox) {-// ctx.textBaseline = 'alphabetic';-// } else {-// ctx.textBaseline = 'bottom';-// }-// //0 truncation, 1 overflow, 2 word wrap-// if (tb == '2' || isInline) {-// //wrap--// let textW_all = 0; //拆分后宽高度合计-// let textH_all = 0;-// let textW_all_inner = 0;--// // let oneWordWidth = getMeasureText(vArr[0], ctx).width;-// let splitIndex = 0,-// text_all_cache = 0,-// text_all_split = {},-// text_all_splitLen = [];--// textContent.rotate = rt;-// rt = Math.abs(rt);--// let anchor = 0,-// preHeight = 0,-// preWidth = 0,-// preStr,-// preTextHeight,-// preTextWidth,-// preMeasureText,-// i = 1,-// wrapStyle = {},-// spaceOrTwoByte = null,-// spaceOrTwoByteIndex = null;-// if (isInline) {-// while (i <= inlineStringArr.length) {-// let shareCells = inlineStringArr.slice(anchor, i);-// if (shareCells[shareCells.length - 1].wrap === true) {-// anchor = i;--// if (shareCells.length > 1) {-// for (let s = 0; s < shareCells.length - 1; s++) {-// let sc = shareCells[s];-// let item = {-// content: sc.v,-// style: sc,-// width: sc.measureText.width,-// height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: sc.measureText.actualBoundingBoxAscent,-// desc: sc.measureText.actualBoundingBoxDescent,-// inline: true,-// fs: sc.fs,-// };--// // if(rt!=0){//rotate-// // item.textHeight = sc.textHeight;-// // item.textWidth = sc.textWidth;-// // }--// text_all_split[splitIndex].push(item);-// }-// }--// if (shareCells.length == 1 || i == inlineStringArr.length) {-// let sc = shareCells[0];-// let measureText = getMeasureText('M', ctx, sc.fontset);-// if (text_all_split[splitIndex] == null) {-// text_all_split[splitIndex] = [];-// }-// text_all_split[splitIndex].push({-// content: '',-// style: sc,-// width: measureText.width,-// height: measureText.actualBoundingBoxAscent + measureText.actualBoundingBoxDescent,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: measureText.actualBoundingBoxAscent,-// desc: measureText.actualBoundingBoxDescent,-// inline: true,-// wrap: true,-// fs: sc.fs,-// });-// }--// splitIndex += 1;--// i++;--// continue;-// }--// let textWidth = 0,-// textHeight = 0;-// for (let s = 0; s < shareCells.length; s++) {-// let sc = shareCells[s];-// if (sc.measureText == null) {-// sc.measureText = getMeasureText(sc.v, ctx, sc.fontset);-// }-// textWidth += sc.measureText.width;-// textHeight = Math.max(sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent);-// // console.log(sc.v,sc.measureText.width,sc.measureText.actualBoundingBoxAscent,sc.measureText.actualBoundingBoxDescent);-// }--// let width = textWidth * Math.cos((rt * Math.PI) / 180) + textHeight * Math.sin((rt * Math.PI) / 180); //consider text box wdith and line height--// let height = textWidth * Math.sin((rt * Math.PI) / 180) + textHeight * Math.cos((rt * Math.PI) / 180); //consider text box wdith and line height--// // textW_all += textW;--// let lastWord = shareCells[shareCells.length - 1];-// if (lastWord.v == ' ' || checkWordByteLength(lastWord.v) == 2) {-// spaceOrTwoByteIndex = i;-// }--// if (rt != 0) {-// //rotate-// // console.log("all",anchor, i , str);-// console.log(height, space_height, cellHeight, shareCells, height + space_height > cellHeight);-// if (height + space_height > cellHeight && text_all_split[splitIndex] != null && tb == '2' && i != inlineStringArr.length) {-// // console.log("cut",anchor, i , str);--// if (spaceOrTwoByteIndex != null && spaceOrTwoByteIndex < i) {-// for (let s = 0; s < spaceOrTwoByteIndex - anchor; s++) {-// let sc = shareCells[s];-// text_all_split[splitIndex].push({-// content: sc.v,-// style: sc,-// width: sc.measureText.width,-// height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: sc.measureText.actualBoundingBoxAscent,-// desc: sc.measureText.actualBoundingBoxDescent,-// inline: true,-// fs: sc.fs,-// });-// }-// anchor = spaceOrTwoByteIndex;--// i = spaceOrTwoByteIndex + 1;--// splitIndex += 1;--// spaceOrTwoByteIndex = null;-// } else {-// anchor = i - 1;--// for (let s = 0; s < shareCells.length - 1; s++) {-// let sc = shareCells[s];-// text_all_split[splitIndex].push({-// content: sc.v,-// style: sc,-// width: sc.measureText.width,-// height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: sc.measureText.actualBoundingBoxAscent,-// desc: sc.measureText.actualBoundingBoxDescent,-// inline: true,-// fs: sc.fs,-// });-// }--// splitIndex += 1;-// }-// } else if (i == inlineStringArr.length) {-// // console.log("last",anchor, i , str);-// if (text_all_split[splitIndex] == null) {-// text_all_split[splitIndex] = [];-// }-// for (let s = 0; s < shareCells.length; s++) {-// let sc = shareCells[s];-// text_all_split[splitIndex].push({-// content: sc.v,-// style: sc,-// width: sc.measureText.width,-// height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: sc.measureText.actualBoundingBoxAscent,-// desc: sc.measureText.actualBoundingBoxDescent,-// inline: true,-// fs: sc.fs,-// });-// }-// break;-// } else {-// if (text_all_split[splitIndex] == null) {-// text_all_split[splitIndex] = [];-// }-// i++;-// }-// } else {-// //plain-// if (width + space_width > cellWidth && text_all_split[splitIndex] != null && tb == '2' && i != inlineStringArr.length) {-// if (spaceOrTwoByteIndex != null && spaceOrTwoByteIndex < i) {-// for (let s = 0; s < spaceOrTwoByteIndex - anchor; s++) {-// let sc = shareCells[s];-// text_all_split[splitIndex].push({-// content: sc.v,-// style: sc,-// width: sc.measureText.width,-// height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: sc.measureText.actualBoundingBoxAscent,-// desc: sc.measureText.actualBoundingBoxDescent,-// inline: true,-// fs: sc.fs,-// });-// }-// anchor = spaceOrTwoByteIndex;--// i = spaceOrTwoByteIndex + 1;--// splitIndex += 1;--// spaceOrTwoByteIndex = null;-// } else {-// anchor = i - 1;--// for (let s = 0; s < shareCells.length - 1; s++) {-// let sc = shareCells[s];-// text_all_split[splitIndex].push({-// content: sc.v,-// style: sc,-// width: sc.measureText.width,-// height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: sc.measureText.actualBoundingBoxAscent,-// desc: sc.measureText.actualBoundingBoxDescent,-// inline: true,-// fs: sc.fs,-// });-// }--// splitIndex += 1;-// }-// } else if (i == inlineStringArr.length) {-// if (text_all_split[splitIndex] == null) {-// text_all_split[splitIndex] = [];-// }--// for (let s = 0; s < shareCells.length; s++) {-// let sc = shareCells[s];-// text_all_split[splitIndex].push({-// content: sc.v,-// style: sc,-// width: sc.measureText.width,-// height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: sc.measureText.actualBoundingBoxAscent,-// desc: sc.measureText.actualBoundingBoxDescent,-// inline: true,-// fs: sc.fs,-// });-// }--// break;-// } else {-// if (text_all_split[splitIndex] == null) {-// text_all_split[splitIndex] = [];-// }-// i++;-// }-// }-// }-// } else {-// value = value.toString();-// while (i <= value.length) {-// let str = value.substring(anchor, i);-// let measureText = getMeasureText(str, ctx);-// let textWidth = measureText.width;-// let textHeight = measureText.actualBoundingBoxAscent + measureText.actualBoundingBoxDescent;-// //width,height 换算为旋转后的宽高,旋转后再与单元格大小做对比-// let width = textWidth * Math.cos((rt * Math.PI) / 180) + textHeight * Math.sin((rt * Math.PI) / 180); //consider text box wdith and line height--// let height = textWidth * Math.sin((rt * Math.PI) / 180) + textHeight * Math.cos((rt * Math.PI) / 180); //consider text box wdith and line height-// let lastWord = str.substr(str.length - 1, 1);-// if (lastWord == ' ' || checkWordByteLength(lastWord) == 2) {-// if (preMeasureText != null) {-// spaceOrTwoByte = {-// index: i,-// str: preStr + lastWord,-// width: preTextWidth,-// height: preTextHeight,-// asc: preMeasureText.actualBoundingBoxAscent,-// desc: preMeasureText.actualBoundingBoxDescent,-// };-// }-// }-// // textW_all += textW;-// // console.log(str,anchor,i);-// if (rt != 0) {-// //rotate-// // console.log("all",anchor, i , str);-// if (height + space_height > cellHeight && text_all_split[splitIndex] != null && i != value.length) {-// // console.log("cut",anchor, i , str);--// if (spaceOrTwoByte != null && spaceOrTwoByte.index < i) {-// anchor = spaceOrTwoByte.index;--// i = spaceOrTwoByte.index + 1;--// text_all_split[splitIndex].push({-// content: spaceOrTwoByte.str,-// style: fontset,-// width: spaceOrTwoByte.width,-// height: spaceOrTwoByte.height,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: spaceOrTwoByte.asc,-// desc: spaceOrTwoByte.desc,-// fs: fontSize,-// });--// // console.log(1,anchor,i,splitIndex , spaceOrTwoByte.str);--// splitIndex += 1;--// spaceOrTwoByte = null;-// } else {-// anchor = i - 1;--// text_all_split[splitIndex].push({-// content: preStr,-// style: fontset,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// height: preTextHeight,-// width: preTextWidth,-// asc: measureText.actualBoundingBoxAscent,-// desc: measureText.actualBoundingBoxDescent,-// fs: fontSize,-// });--// // console.log(2,anchor,i, splitIndex, preStr);--// splitIndex += 1;-// }-// } else if (i == value.length) {-// // console.log("last",anchor, i , str);-// if (text_all_split[splitIndex] == null) {-// text_all_split[splitIndex] = [];-// }-// text_all_split[splitIndex].push({-// content: str,-// style: fontset,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// height: textHeight,-// width: textWidth,-// asc: measureText.actualBoundingBoxAscent,-// desc: measureText.actualBoundingBoxDescent,-// fs: fontSize,-// });-// break;-// } else {-// if (text_all_split[splitIndex] == null) {-// text_all_split[splitIndex] = [];-// }-// i++;-// }-// } else {-// //plain-// if (width + space_width > cellWidth && text_all_split[splitIndex] != null && i != value.length) {-// // console.log(spaceOrTwoByte, i, anchor);-// if (spaceOrTwoByte != null && spaceOrTwoByte.index < i) {-// anchor = spaceOrTwoByte.index;--// i = spaceOrTwoByte.index + 1;--// text_all_split[splitIndex].push({-// content: spaceOrTwoByte.str,-// style: fontset,-// width: spaceOrTwoByte.width,-// height: spaceOrTwoByte.height,-// left: 0,--// top: 0,-// splitIndex: splitIndex,-// asc: spaceOrTwoByte.asc,-// desc: spaceOrTwoByte.desc,-// fs: fontSize,-// });--// splitIndex += 1;--// spaceOrTwoByte = null;-// } else {-// spaceOrTwoByte = null;-// anchor = i - 1;--// text_all_split[splitIndex].push({-// content: preStr,-// style: fontset,-// width: preTextWidth,-// height: preTextHeight,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: measureText.actualBoundingBoxAscent,-// desc: measureText.actualBoundingBoxDescent,-// fs: fontSize,-// });--// // console.log(2);--// splitIndex += 1;-// }-// } else if (i == value.length) {-// if (text_all_split[splitIndex] == null) {-// text_all_split[splitIndex] = [];-// }-// text_all_split[splitIndex].push({-// content: str,-// style: fontset,-// width: textWidth,-// height: textHeight,-// left: 0,-// top: 0,-// splitIndex: splitIndex,-// asc: measureText.actualBoundingBoxAscent,-// desc: measureText.actualBoundingBoxDescent,-// fs: fontSize,-// });--// break;-// } else {-// if (text_all_split[splitIndex] == null) {-// text_all_split[splitIndex] = [];-// }-// i++;-// }-// }--// preStr = str;-// preTextHeight = textHeight;-// preTextWidth = textWidth;-// preMeasureText = measureText;-// }--// // console.log(text_all_split)-// }--// let split_all_size = [],-// oneLinemaxWordCount = 0;-// // console.log("split",splitIndex, text_all_split);-// let splitLen = Object.keys(text_all_split).length;-// for (let i = 0; i < splitLen; i++) {-// let splitLists = text_all_split[i];-// if (splitLists == null) {-// continue;-// }-// let sWidth = 0,-// sHeight = 0,-// maxDesc = 0,-// maxAsc = 0,-// lineHeight = 0,-// maxWordCount = 0;-// for (let s = 0; s < splitLists.length; s++) {-// let sp = splitLists[s];-// if (rt != 0) {-// //rotate-// sWidth += sp.width;-// sHeight = Math.max(sHeight, sp.height - (supportBoundBox ? sp.desc : 0));-// } else {-// //plain-// sWidth += sp.width;-// sHeight = Math.max(sHeight, sp.height - (supportBoundBox ? sp.desc : 0));-// }-// maxDesc = Math.max(maxDesc, supportBoundBox ? sp.desc : 0);-// maxAsc = Math.max(maxAsc, sp.asc);-// maxWordCount++;-// }--// lineHeight = sHeight / 2;-// oneLinemaxWordCount = Math.max(oneLinemaxWordCount, maxWordCount);-// if (rt != 0) {-// //rotate-// sHeight += lineHeight;-// textW_all_inner = Math.max(textW_all_inner, sWidth);-// // textW_all = Math.max(textW_all, sWidth+ (textH_all)/Math.tan(rt*Math.PI/180));-// textH_all += sHeight;-// } else {-// //plain-// // console.log("textH_all",textW_all, textH_all);-// sHeight += lineHeight;-// textW_all = Math.max(textW_all, sWidth);-// textH_all += sHeight;-// }--// split_all_size.push({-// width: sWidth,-// height: sHeight,-// desc: maxDesc,-// asc: maxAsc,-// lineHeight: lineHeight,-// wordCount: maxWordCount,-// });-// }-// // console.log(textH_all,textW_all,textW_all_inner);-// // let cumColumnWidth = 0;-// let cumWordHeight = 0,-// cumColumnWidth = 0;-// let rtPI = (rt * Math.PI) / 180;-// let lastLine = split_all_size[splitLen - 1];-// let lastLineSpaceHeight = lastLine.lineHeight;-// textH_all = textH_all - lastLineSpaceHeight + lastLine.desc; //旋转前的高度, textW_all_inner旋转前的行最长宽度-// let rw = textH_all / Math.sin(rtPI) + textW_all_inner * Math.cos(rtPI); //进行旋转后文本的总宽度-// let rh = textW_all_inner * Math.sin(rtPI),-// fixOneLineLeft = 0; //进行旋转后文本的总高度,会比原高度小-// //textW_all为旋转前的总宽度,因为做到旋转后的排列需要把文字进行错落排列,所以这个宽度是错落排列后的叠加总宽度。-// if (rt != 0) {-// if (splitLen == 1) {-// textW_all = textW_all_inner + 2 * (textH_all / Math.tan(rtPI));-// fixOneLineLeft = textH_all / Math.tan(rtPI);-// } else {-// textW_all = textW_all_inner + textH_all / Math.tan(rtPI);-// }-// textContent.textWidthAll = rw;-// textContent.textHeightAll = rh;-// } else {-// textContent.textWidthAll = textW_all;-// textContent.textHeightAll = textH_all;-// }--// if (isMode == 'onlyWidth') {-// // console.log("plainWrap", textContent,cell, option);-// return textContent;-// }--// if (rt != 0 && isRotateUp == '1') {-// ctx.textAlign = 'end';-// for (let i = 0; i < splitLen; i++) {-// let splitLists = text_all_split[i];-// if (splitLists == null) {-// continue;-// }-// let size = split_all_size[i];--// cumColumnWidth = 0;--// for (let c = splitLists.length - 1; c >= 0; c--) {-// let spanGroup = splitLists[c];-// let left, top;-// if (rt != 0) {-// //rotate-// let x,-// y = cumWordHeight + size.asc;--// x = cumWordHeight / Math.tan(rtPI) - cumColumnWidth + textW_all_inner;-// if (horizonAlign == '0') {-// //center-// let sh = textH_all / Math.sin(rtPI);-// if (verticalAlign == '0') {-// //mid--// left = x + cellWidth / 2 - textW_all / 2 + (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// top = y + cellHeight / 2 - textH_all / 2 - (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// } else if (verticalAlign == '1') {-// //top-// left = x + cellWidth / 2 - textW_all / 2;-// top = y - (textH_all / 2 - rh / 2);-// } else if (verticalAlign == '2') {-// //bottom-// left = x + cellWidth / 2 - textW_all / 2 + lastLineSpaceHeight * Math.cos(rtPI);-// top = y + cellHeight - rh / 2 - textH_all / 2 - lastLineSpaceHeight * Math.cos(rtPI);-// }-// } else if (horizonAlign == '1') {-// //left-// if (verticalAlign == '0') {-// //mid-// left = x - (rh * Math.sin(rtPI)) / 2 + (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// top = y + cellHeight / 2 + (rh * Math.cos(rtPI)) / 2 - (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// } else if (verticalAlign == '1') {-// //top-// left = x - rh * Math.sin(rtPI);-// top = y + rh * Math.cos(rtPI);-// } else if (verticalAlign == '2') {-// //bottom-// left = x + lastLineSpaceHeight * Math.cos(rtPI);-// top = y + cellHeight - lastLineSpaceHeight * Math.cos(rtPI);-// }-// } else if (horizonAlign == '2') {-// //right-// if (verticalAlign == '0') {-// //mid-// left = x + cellWidth - rw / 2 - (textW_all_inner / 2 + textH_all / 2 / Math.tan(rtPI)) + (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// top = y + cellHeight / 2 - textH_all / 2 - (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// } else if (verticalAlign == '1') {-// //top fixOneLineLeft-// left = x + cellWidth - textW_all + fixOneLineLeft;-// top = y - textH_all;-// } else if (verticalAlign == '2') {-// //bottom-// left = x + cellWidth - rw * Math.cos(rtPI) + lastLineSpaceHeight * Math.cos(rtPI);-// top = y + cellHeight - rw * Math.sin(rtPI) - lastLineSpaceHeight * Math.cos(rtPI);-// }-// }-// }--// spanGroup.left = left;-// spanGroup.top = top;--// // console.log(left, top, cumWordHeight, size.height);--// drawLineInfo(spanGroup, cancelLine, underLine, {-// width: spanGroup.width,-// height: spanGroup.height,-// left: left - spanGroup.width,-// top: top,-// asc: size.asc,-// desc: size.desc,-// fs: spanGroup.fs,-// });--// textContent.values.push(spanGroup);--// cumColumnWidth += spanGroup.width;-// }--// cumWordHeight += size.height;-// }-// } else {-// for (let i = 0; i < splitLen; i++) {-// let splitLists = text_all_split[i];-// if (splitLists == null) {-// continue;-// }-// let size = split_all_size[i];--// cumColumnWidth = 0;--// for (let c = 0; c < splitLists.length; c++) {-// let spanGroup = splitLists[c];-// let left, top;-// if (rt != 0) {-// //rotate-// let x,-// y = cumWordHeight + size.asc;--// x = (textH_all - cumWordHeight) / Math.tan(rtPI) + cumColumnWidth;--// if (horizonAlign == '0') {-// //center-// let sh = textH_all / Math.sin(rtPI);-// if (verticalAlign == '0') {-// //mid--// left = x + cellWidth / 2 - textW_all / 2 - (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// top = y + cellHeight / 2 - textH_all / 2 + (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// } else if (verticalAlign == '1') {-// //top-// left = x + cellWidth / 2 - textW_all / 2 - (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// top = y - (textH_all / 2 - rh / 2) + (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// } else if (verticalAlign == '2') {-// //bottom-// left = x + cellWidth / 2 - textW_all / 2 - lastLineSpaceHeight * Math.cos(rtPI);-// top = y + cellHeight - rh / 2 - textH_all / 2 - lastLineSpaceHeight * Math.cos(rtPI);-// }-// } else if (horizonAlign == '1') {-// //left-// if (verticalAlign == '0') {-// //mid-// left = x - (rh * Math.sin(rtPI)) / 2 - (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// top = y - textH_all + cellHeight / 2 - (rh * Math.cos(rtPI)) / 2 - (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// } else if (verticalAlign == '1') {-// //top-// left = x;-// top = y - textH_all;-// } else if (verticalAlign == '2') {-// //bottom-// left = x - rh * Math.sin(rtPI) - lastLineSpaceHeight * Math.cos(rtPI);-// top = y - textH_all + cellHeight - rh * Math.cos(rtPI) - lastLineSpaceHeight * Math.cos(rtPI);-// }-// } else if (horizonAlign == '2') {-// //right-// if (verticalAlign == '0') {-// //mid-// left = x + cellWidth - rw / 2 - textW_all / 2 - (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// top = y + cellHeight / 2 - textH_all / 2 - (lastLineSpaceHeight * Math.cos(rtPI)) / 2;-// } else if (verticalAlign == '1') {-// //top fixOneLineLeft-// left = x + cellWidth - rw * Math.cos(rtPI);-// top = y + rh * Math.cos(rtPI);-// } else if (verticalAlign == '2') {-// //bottom-// left = x + cellWidth - textW_all - lastLineSpaceHeight * Math.cos(rtPI) + fixOneLineLeft;-// top = y + cellHeight - lastLineSpaceHeight * Math.cos(rtPI);-// }-// }--// drawLineInfo(spanGroup, cancelLine, underLine, {-// width: spanGroup.width,-// height: spanGroup.height,-// left: left,-// top: top,-// asc: size.asc,-// desc: size.desc,-// fs: spanGroup.fs,-// });-// } else {-// //plain-// left = space_width + cumColumnWidth;-// if (horizonAlign == '0') {-// //+ space_width*textH_all_ColumnHeight.length-// left = cellWidth / 2 + cumColumnWidth - size.width / 2;-// } else if (horizonAlign == '2') {-// left = cellWidth + cumColumnWidth - size.width;-// }--// top = cellHeight - space_height + cumWordHeight + size.asc - textH_all;-// if (verticalAlign == '0') {-// top = cellHeight / 2 + cumWordHeight - textH_all / 2 + size.asc;-// } else if (verticalAlign == '1') {-// top = space_height + cumWordHeight + size.asc;-// }--// drawLineInfo(spanGroup, cancelLine, underLine, {-// width: spanGroup.width,-// height: spanGroup.height,-// left: left,-// top: top,-// asc: size.asc,-// desc: size.desc,-// fs: spanGroup.fs,-// });-// }--// spanGroup.left = left;-// spanGroup.top = top;--// textContent.values.push(spanGroup);--// cumColumnWidth += spanGroup.width;-// }--// cumWordHeight += size.height;-// }-// }--// textContent.type = 'plainWrap';--// if (rt != 0) {-// // let leftCenter = (textW_all + textH_all/Math.tan(rt*Math.PI/180))/2;-// // let topCenter = textH_all/2;--// // if(isRotateUp=="1"){-// // textContent.textLeftAll += leftCenter;-// // textContent.textTopAll += topCenter;-// // }-// // else {-// // textContent.textLeftAll += leftCenter;-// // textContent.textTopAll -= topCenter;-// // }--// if (horizonAlign == '0') {-// //center-// if (verticalAlign == '0') {-// //mid-// textContent.textLeftAll = cellWidth / 2;-// textContent.textTopAll = cellHeight / 2;-// } else if (verticalAlign == '1') {-// //top-// textContent.textLeftAll = cellWidth / 2;-// textContent.textTopAll = rh / 2;-// } else if (verticalAlign == '2') {-// //bottom-// textContent.textLeftAll = cellWidth / 2;-// textContent.textTopAll = cellHeight - rh / 2;-// }-// } else if (horizonAlign == '1') {-// //left-// if (verticalAlign == '0') {-// //mid-// textContent.textLeftAll = 0;-// textContent.textTopAll = cellHeight / 2;-// } else if (verticalAlign == '1') {-// //top-// textContent.textLeftAll = 0;-// textContent.textTopAll = 0;-// } else if (verticalAlign == '2') {-// //bottom-// textContent.textLeftAll = 0;-// textContent.textTopAll = cellHeight;-// }-// } else if (horizonAlign == '2') {-// //right-// if (verticalAlign == '0') {-// //mid-// textContent.textLeftAll = cellWidth - rw / 2;-// textContent.textTopAll = cellHeight / 2;-// } else if (verticalAlign == '1') {-// //top-// textContent.textLeftAll = cellWidth;-// textContent.textTopAll = 0;-// } else if (verticalAlign == '2') {-// //bottom-// textContent.textLeftAll = cellWidth;-// textContent.textTopAll = cellHeight;-// }-// }-// }-// // else{-// // textContent.textWidthAll = textW_all;-// // textContent.textHeightAll = textH_all;-// // }-// } else {-// let measureText = getMeasureText(value, ctx);-// let textWidth = measureText.width;-// let textHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;--// textContent.rotate = rt;--// rt = Math.abs(rt);-// let rtPI = (rt * Math.PI) / 180;--// let textWidthAll = textWidth * Math.cos(rtPI) + textHeight * Math.sin(rtPI); //consider text box wdith and line height--// let textHeightAll = textWidth * Math.sin(rtPI) + textHeight * Math.cos(rtPI); //consider text box wdith and line height--// if (rt != 0) {-// textContent.textHeightAll = textHeightAll;-// } else {-// textContent.textHeightAll = textHeightAll + textHeight / 2 - measureText.actualBoundingBoxDescent - space_height;-// }-// textContent.textWidthAll = textWidthAll;--// // console.log(textContent.textWidthAll , textContent.textHeightAll);-// if (isMode == 'onlyWidth') {-// // console.log("plain", textContent,cell, option);-// return textContent;-// }--// let width = textWidthAll,-// height = textHeightAll;--// let left = space_width + textHeight * Math.sin(rtPI) * isRotateUp; //默认为1,左对齐-// if (horizonAlign == '0') {-// //居中对齐-// left = cellWidth / 2 - width / 2 + textHeight * Math.sin(rtPI) * isRotateUp;-// } else if (horizonAlign == '2') {-// //右对齐-// left = cellWidth - space_width - width + textHeight * Math.sin(rtPI) * isRotateUp;-// }--// let top = cellHeight - space_height - height + measureText.actualBoundingBoxAscent * Math.cos(rtPI) + textWidth * Math.sin(rtPI) * isRotateUp; //默认为2,下对齐-// if (verticalAlign == '0') {-// //居中对齐-// top = cellHeight / 2 - height / 2 + measureText.actualBoundingBoxAscent * Math.cos(rtPI) + textWidth * Math.sin(rtPI) * isRotateUp;-// } else if (verticalAlign == '1') {-// //上对齐-// top = space_height + measureText.actualBoundingBoxAscent * Math.cos(rtPI) + textWidth * Math.sin(rtPI) * isRotateUp;-// }--// textContent.type = 'plain';--// let spanGroup = {-// content: value,-// style: fontset,-// width: width,-// height: height,-// left: left,-// top: top,-// };--// drawLineInfo(spanGroup, cancelLine, underLine, {-// width: textWidth,-// height: textHeight,-// left: left,-// top: top,-// asc: measureText.actualBoundingBoxAscent,-// desc: measureText.actualBoundingBoxDescent,-// fs: fontSize,-// });--// textContent.values.push(spanGroup);--// textContent.textLeftAll = left;-// textContent.textTopAll = top;--// textContent.asc = measureText.actualBoundingBoxAscent;-// textContent.desc = measureText.actualBoundingBoxDescent;--// // console.log("plain",left,top);-// }-// }--// return textContent;-// }--// private static drawLineInfo(spanGroup, cancelLine, underLine, option) {-// let left = option.left,-// top = option.top,-// width = option.width,-// height = option.height,-// asc = option.asc,-// desc = option.desc,-// fs = option.fs;--// if (spanGroup.wrap === true) {-// return;-// }--// if (spanGroup.inline == true && spanGroup.style != null) {-// cancelLine = spanGroup.style.cl;-// underLine = spanGroup.style.un;-// }--// if (cancelLine != '0') {-// spanGroup.cancelLine = {};-// spanGroup.cancelLine.startX = left;-// spanGroup.cancelLine.startY = top - asc / 2 + 1;--// spanGroup.cancelLine.endX = left + width;-// spanGroup.cancelLine.endY = top - asc / 2 + 1;--// spanGroup.cancelLine.fs = fs;-// }--// if (underLine != '0') {-// spanGroup.underLine = [];-// if (underLine == '1' || underLine == '2') {-// let item = {};-// item.startX = left;-// item.startY = top + 3;--// item.endX = left + width;-// item.endY = top + 3;--// item.fs = fs;--// spanGroup.underLine.push(item);-// }--// if (underLine == '2') {-// let item = {};-// item.startX = left;-// item.startY = top + desc;--// item.endX = left + width;-// item.endY = top + desc;--// item.fs = fs;--// spanGroup.underLine.push(item);-// }--// if (underLine == '3' || underLine == '4') {-// let item = {};-// item.startX = left;-// item.startY = top + desc;--// item.endX = left + width;-// item.endY = top + desc;--// item.fs = fs;--// spanGroup.underLine.push(item);-// }--// if (underLine == '4') {-// let item = {};-// item.startX = left;-// item.startY = top + desc + 2;--// item.endX = left + width;-// item.endY = top + desc + 2;--// item.fs = fs;--// spanGroup.underLine.push(item);-// }-// }-// }-// }diff --git a/packages/base-render/src/Component/Docs/Common/Line.ts b/packages/base-render/src/Component/Docs/Common/Line.tsindex a9a49fb391..0de2d530f6 100644--- a/packages/base-render/src/Component/Docs/Common/Line.ts+++ b/packages/base-render/src/Component/Docs/Common/Line.ts@@ -356,10 +356,12 @@ function _calculateDivideByDrawings(columnWidth: number, drawingSplit: IDrawingsconst { left, width } = split;if (left > start) {// 插入start到left的间隔divide- const divide = __getDivideSKe(start, left);+ let width = left - start;+ width = width < columnWidth ? width : columnWidth - start;+ const divide = __getDivideSKe(start, width);divideSkeleton.push(divide);- start = Math.max(left + width, start);}+ start = Math.max(left + width, start);if (i === splitLength - 1 && left + width < columnWidth) {// 最后一个split到右边界的dividediff --git a/packages/base-render/src/Component/Docs/Common/Tools.ts b/packages/base-render/src/Component/Docs/Common/Tools.tsindex 296e992070..717b91dc15 100644--- a/packages/base-render/src/Component/Docs/Common/Tools.ts+++ b/packages/base-render/src/Component/Docs/Common/Tools.ts@@ -213,8 +213,8 @@ export function getNumberUnitValue(unitValue: number | INumberUnit, benchMark: n}// 返回charSpaceApply,选择网格还是字体来计算一个tab的长度,一个tab代表1字符长度-export function getCharSpaceApply(charSpace: number = 0, documentFontSize: number, defaultTabStop: number, gridType = GridType.LINES, snapToGrid = BooleanNumber.TRUE) {- let charSpaceApply = documentFontSize;+export function getCharSpaceApply(charSpace: number = 0, defaultTabStop: number, gridType = GridType.LINES, snapToGrid = BooleanNumber.TRUE) {+ let charSpaceApply = 1;if (validationGrid(gridType, snapToGrid)) {// 启用了char网格的情况下,defaultTabStop的参照物是charSpace@@ -351,21 +351,14 @@ export function updateBlockIndex(pages: IDocumentSkeletonPage[]) {section.st = sectionStartIndex;section.ed = sectionEndIndex;- if (section.height === Infinity) {- section.height = maxSectionHeight;- }+ section.height = maxSectionHeight;pageHeight += maxSectionHeight;}page.st = pageStartIndex;page.ed = pageEndIndex;- if (page.height === Infinity) {- page.height = pageHeight;- }-- if (page.width === Infinity) {- page.width = maxPageWidth;- }+ page.height = pageHeight;+ page.width = maxPageWidth;prePageStartIndex = pageEndIndex;}diff --git a/packages/base-render/src/Component/Docs/DocsSkeleton.ts b/packages/base-render/src/Component/Docs/DocsSkeleton.tsindex 26e6cf4957..e77ddd0684 100644--- a/packages/base-render/src/Component/Docs/DocsSkeleton.ts+++ b/packages/base-render/src/Component/Docs/DocsSkeleton.ts@@ -220,8 +220,10 @@ export class DocumentSkeleton extends Skeleton {linePitch = 15.6, // linePitch ptgridType = GridType.LINES, // gridTypeparagraphLineGapDefault = 3,- defaultTabStop = 36,- textStyle,+ defaultTabStop = 10.5,+ textStyle = {+ fs: 10.5,+ },renderConfig: global_renderConfig = {horizontalAlign: HorizontalAlign.UNSPECIFIED,verticalAlign: VerticalAlign.UNSPECIFIED,diff --git a/packages/base-render/src/Component/Docs/Document.ts b/packages/base-render/src/Component/Docs/Document.tsindex 255d2835e5..c07acd21a3 100644--- a/packages/base-render/src/Component/Docs/Document.ts+++ b/packages/base-render/src/Component/Docs/Document.ts@@ -22,8 +22,8 @@ export class Documents extends docsComponent {isCalculateSkeleton = true;- constructor(oKey: string, spreadsheetSkeleton?: DocumentSkeleton, allowCache: boolean = true) {- super(oKey, spreadsheetSkeleton, allowCache);+ constructor(oKey: string, documentSkeleton?: DocumentSkeleton, allowCache: boolean = true) {+ super(oKey, documentSkeleton, allowCache);this._initialDefaultExtension();diff --git a/packages/base-render/src/Component/Docs/Extensions/FontAndBaseLine.ts b/packages/base-render/src/Component/Docs/Extensions/FontAndBaseLine.tsindex 42ee08e211..a5b90b2669 100644--- a/packages/base-render/src/Component/Docs/Extensions/FontAndBaseLine.ts+++ b/packages/base-render/src/Component/Docs/Extensions/FontAndBaseLine.ts@@ -56,7 +56,7 @@ export class FontAndBaseLine extends docsExtension {const { centerAngle = 0 } = renderConfig;let offset = bBox.spo;- if (baselineOffset === BaselineOffset.SUBSCRIPT) {+ if (baselineOffset === BaselineOffset.SUPERSCRIPT) {offset = -bBox.sbo;}diff --git a/packages/base-render/src/Shape/Circle.ts b/packages/base-render/src/Shape/Circle.tsnew file mode 100644index 0000000000..d6ab57e6b6--- /dev/null+++ b/packages/base-render/src/Shape/Circle.ts@@ -0,0 +1,67 @@+// import { IShapeProps, Shape, IObjectFullState, Group, Scene } from '.';++import { IKeyValue } from '@univer/core';+import { IShapeProps, Shape } from './Shape';++export interface ICircleProps extends IShapeProps {+ radius: number;+}++export const CIRCLE_OBJECT_ARRAY = ['radius'];++export class Circle extends Shape<ICircleProps> {+ private _radius: number;++ get radius() {+ return this._radius;+ }++ constructor(key?: string, props?: ICircleProps) {+ super(key, props);+ this._radius = props?.radius || 10;++ this._setFixBoundingBox();+ }++ private _setFixBoundingBox() {+ this.transformByState({+ width: this._radius * 2,+ height: this._radius * 2,+ });+ }++ protected _draw(ctx: CanvasRenderingContext2D) {+ Circle.drawWith(ctx, this);+ }++ static drawWith(ctx: CanvasRenderingContext2D, props: ICircleProps | Circle) {+ let { radius } = props;++ radius = radius ?? 10;++ ctx.beginPath();++ if (props.strokeDashArray) {+ ctx.setLineDash(props.strokeDashArray);+ }++ ctx.beginPath();+ ctx.arc(radius, radius, radius || 0, 0, Math.PI * 2, false);+ ctx.closePath();++ this._renderPaintInOrder(ctx, props);+ }++ toJson() {+ const props: IKeyValue = {};+ CIRCLE_OBJECT_ARRAY.forEach((key) => {+ if (this[key]) {+ props[key] = this[key];+ }+ });+ return {+ ...super.toJson(),+ ...props,+ };+ }+}diff --git a/packages/base-render/src/Shape/Path.ts b/packages/base-render/src/Shape/Path.tsnew file mode 100644index 0000000000..3abeaba6d7--- /dev/null+++ b/packages/base-render/src/Shape/Path.ts@@ -0,0 +1,859 @@+// import { IShapeProps, Shape, IObjectFullState, Group, Scene } from '.';++import { IKeyValue, Nullable } from '@univer/core';+import { IShapeProps, Shape } from './Shape';++interface IPathDataArray {+ command: string;+ points: number[];+ start: {+ x: number;+ y: number;+ };+ pathLength: number;+}++interface IPathFixConfig {+ left: number;+ top: number;+ width: number;+ height: number;+}++export interface IPathProps extends IShapeProps {+ data?: string;+ dataArray?: IPathDataArray[];+}++export const PATH_OBJECT_ARRAY = ['dataArray'];++export class Path extends Shape<IPathProps> {+ private _dataArray: IPathDataArray[];++ private pathLength: number = 0;++ private _fixLeft = 0;++ private _fixTop = 0;++ get dataArray() {+ return this._dataArray;+ }++ constructor(key?: string, props?: IPathProps) {+ super(key, props);+ if (props?.data) {+ this._dataArray = Path.parsePathData(props.data);+ } else if (props?.dataArray) {+ this._dataArray = props.dataArray;+ }++ for (let i = 0; i < this.dataArray.length; ++i) {+ this.pathLength += this.dataArray[i].pathLength;+ }++ this._setFixBoundingBox();+ }++ protected _draw(ctx: CanvasRenderingContext2D) {+ Path.drawWith(ctx, this);+ }++ static drawWith(ctx: CanvasRenderingContext2D, props: IPathProps | Path) {+ const ca = props.dataArray;+ if (!ca) {+ return;+ }+ // context position+ ctx.beginPath();+ let isClosed = false;+ for (let n = 0; n < ca.length; n++) {+ let c = ca[n].command;+ let p = ca[n].points;+ switch (c) {+ case 'L':+ ctx.lineTo(p[0], p[1]);+ break;+ case 'M':+ ctx.moveTo(p[0], p[1]);+ break;+ case 'C':+ ctx.bezierCurveTo(p[0], p[1], p[2], p[3], p[4], p[5]);+ break;+ case 'Q':+ ctx.quadraticCurveTo(p[0], p[1], p[2], p[3]);+ break;+ case 'A': {+ const cx = p[0];+ const cy = p[1];+ const rx = p[2];+ const ry = p[3];+ const theta = p[4];+ const dTheta = p[5];+ const psi = p[6];+ const fs = p[7];++ const r = rx > ry ? rx : ry;+ const scaleX = rx > ry ? 1 : rx / ry;+ const scaleY = rx > ry ? ry / rx : 1;++ ctx.translate(cx, cy);+ ctx.rotate(psi);+ ctx.scale(scaleX, scaleY);+ ctx.arc(0, 0, r, theta, theta + dTheta, !!(1 - fs));+ ctx.scale(1 / scaleX, 1 / scaleY);+ ctx.rotate(-psi);+ ctx.translate(-cx, -cy);++ break;+ }+ case 'z':+ isClosed = true;+ ctx.closePath();+ break;+ }+ }++ this._renderPaintInOrder(ctx, props);+ }++ private _setFixBoundingBox() {+ const { left, top, width, height } = this._getSelfRect();++ // this.left = (this.left as number) - left;+ // this.top = (this.top as number) - top;+ const fixScaleX = (this.width as number) / width;+ const fixScaleY = (this.height as number) / height;++ this.transformByState({+ left: (this.left as number) - left * fixScaleX,+ top: (this.top as number) - top * fixScaleY,+ scaleX: fixScaleX,+ scaleY: fixScaleY,+ width,+ height,+ });++ this._fixLeft = left;+ this._fixTop = top;+ }++ toJson() {+ const props: IKeyValue = {};+ PATH_OBJECT_ARRAY.forEach((key) => {+ if (this[key]) {+ props[key] = this[key];+ }+ });+ return {+ ...super.toJson(),+ ...props,+ };+ }++ getRect() {+ const { left, top, width, height } = this._getSelfRect();+ return {+ left: left * this.scaleX + this.left,+ top: top * this.scaleX + this.top,+ width: width * this.scaleX,+ height: height * this.scaleY,+ };+ }++ private _getSelfRect() {+ let points: number[] = [];+ this.dataArray.forEach((data) => {+ if (data.command === 'A') {+ // Approximates by breaking curve into line segments+ let start = data.points[4];+ // 4 = theta+ let dTheta = data.points[5];+ // 5 = dTheta+ let end = data.points[4] + dTheta;+ let inc = Math.PI / 180.0;+ // 1 degree resolution+ if (Math.abs(start - end) < inc) {+ inc = Math.abs(start - end);+ }+ if (dTheta < 0) {+ // clockwise+ for (let t = start - inc; t > end; t -= inc) {+ const point = Path.getPointOnEllipticalArc(data.points[0], data.points[1], data.points[2], data.points[3], t, 0);+ points.push(point.x, point.y);+ }+ } else {+ // counter-clockwise+ for (let t = start + inc; t < end; t += inc) {+ const point = Path.getPointOnEllipticalArc(data.points[0], data.points[1], data.points[2], data.points[3], t, 0);+ points.push(point.x, point.y);+ }+ }+ } else if (data.command === 'C') {+ // Approximates by breaking curve into 100 line segments+ for (let t = 0.0; t <= 1; t += 0.01) {+ const point = Path.getPointOnCubicBezier(+ t,+ data.start.x,+ data.start.y,+ data.points[0],+ data.points[1],+ data.points[2],+ data.points[3],+ data.points[4],+ data.points[5]+ );+ points.push(point.x, point.y);+ }+ } else {+ // TODO: how can we calculate bezier curves better?+ points = points.concat(data.points);+ }+ });+ let minX = points[0];+ let maxX = points[0];+ let minY = points[1];+ let maxY = points[1];+ let x;+ let y;+ for (let i = 0; i < points.length / 2; i++) {+ x = points[i * 2];+ y = points[i * 2 + 1];++ // skip bad values+ if (!isNaN(x)) {+ minX = Math.min(minX, x);+ maxX = Math.max(maxX, x);+ }+ if (!isNaN(y)) {+ minY = Math.min(minY, y);+ maxY = Math.max(maxY, y);+ }+ }+ return {+ left: minX,+ top: minY,+ width: maxX - minX,+ height: maxY - minY,+ };+ }++ /**+ * Return length of the path.+ * @method+ * @returns {Number} length+ * @example+ * var length = path.getLength();+ */+ getLength() {+ return this.pathLength;+ }++ /**+ * Get point on path at specific length of the path+ * @method+ * @param {Number} length length+ * @returns {Object} point {x,y} point+ * @example+ * var point = path.getPointAtLength(10);+ */+ getPointAtLength(length: number) {+ let point;+ let i = 0;+ let ii = this.dataArray.length;++ if (!ii) {+ return null;+ }++ while (i < ii && length > this.dataArray[i].pathLength) {+ length -= this.dataArray[i].pathLength;+ ++i;+ }++ if (i === ii) {+ point = this.dataArray[i - 1].points.slice(-2);+ return {+ x: point[0],+ y: point[1],+ };+ }++ if (length < 0.01) {+ point = this.dataArray[i].points.slice(0, 2);+ return {+ x: point[0],+ y: point[1],+ };+ }++ let cp = this.dataArray[i];+ let p = cp.points;+ switch (cp.command) {+ case 'L':+ return Path.getPointOnLine(length, cp.start.x, cp.start.y, p[0], p[1]);+ case 'C':+ return Path.getPointOnCubicBezier(length / cp.pathLength, cp.start.x, cp.start.y, p[0], p[1], p[2], p[3], p[4], p[5]);+ case 'Q':+ return Path.getPointOnQuadraticBezier(length / cp.pathLength, cp.start.x, cp.start.y, p[0], p[1], p[2], p[3]);+ case 'A': {+ let cx = p[0];+ let cy = p[1];+ let rx = p[2];+ let ry = p[3];+ let theta = p[4];+ let dTheta = p[5];+ let psi = p[6];+ theta += (dTheta * length) / cp.pathLength;+ return Path.getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi);+ }+ }++ return null;+ }++ static getLineLength(x1: number, y1: number, x2: number, y2: number) {+ return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));+ }++ static getPointOnLine(dist: number, P1x: number, P1y: number, P2x: number, P2y: number, fromX?: number, fromY?: number) {+ if (fromX === undefined) {+ fromX = P1x;+ }+ if (fromY === undefined) {+ fromY = P1y;+ }++ let m = (P2y - P1y) / (P2x - P1x + 0.00000001);+ let run = Math.sqrt((dist * dist) / (1 + m * m));+ if (P2x < P1x) {+ run *= -1;+ }+ let rise = m * run;+ let pt;++ if (P2x === P1x) {+ // vertical line+ pt = {+ x: fromX,+ y: fromY + rise,+ };+ } else if ((fromY - P1y) / (fromX - P1x + 0.00000001) === m) {+ pt = {+ x: fromX + run,+ y: fromY + rise,+ };+ } else {+ let ix;+ let iy;++ let len = this.getLineLength(P1x, P1y, P2x, P2y);+ // if (len < 0.00000001) {+ // return {+ // x: P1x,+ // y: P1y,+ // };+ // }+ let u = (fromX - P1x) * (P2x - P1x) + (fromY - P1y) * (P2y - P1y);+ u /= len * len;+ ix = P1x + u * (P2x - P1x);+ iy = P1y + u * (P2y - P1y);++ let pRise = this.getLineLength(fromX, fromY, ix, iy);+ let pRun = Math.sqrt(dist * dist - pRise * pRise);+ run = Math.sqrt((pRun * pRun) / (1 + m * m));+ if (P2x < P1x) {+ run *= -1;+ }+ rise = m * run;+ pt = {+ x: ix + run,+ y: iy + rise,+ };+ }++ return pt;+ }++ static getPointOnCubicBezier(pct: number, P1x: number, P1y: number, P2x: number, P2y: number, P3x: number, P3y: number, P4x: number, P4y: number) {+ function CB1(t: number) {+ return t * t * t;+ }+ function CB2(t: number) {+ return 3 * t * t * (1 - t);+ }+ function CB3(t: number) {+ return 3 * t * (1 - t) * (1 - t);+ }+ function CB4(t: number) {+ return (1 - t) * (1 - t) * (1 - t);+ }+ let x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);+ let y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);++ return {+ x,+ y,+ };+ }++ static getPointOnQuadraticBezier(pct: number, P1x: number, P1y: number, P2x: number, P2y: number, P3x: number, P3y: number) {+ function QB1(t: number) {+ return t * t;+ }+ function QB2(t: number) {+ return 2 * t * (1 - t);+ }+ function QB3(t: number) {+ return (1 - t) * (1 - t);+ }+ let x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);+ let y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);++ return {+ x,+ y,+ };+ }++ static getPointOnEllipticalArc(cx: number, cy: number, rx: number, ry: number, theta: number, psi: number) {+ let cosPsi = Math.cos(psi);+ let sinPsi = Math.sin(psi);+ let pt = {+ x: rx * Math.cos(theta),+ y: ry * Math.sin(theta),+ };+ return {+ x: cx + (pt.x * cosPsi - pt.y * sinPsi),+ y: cy + (pt.x * sinPsi + pt.y * cosPsi),+ };+ }++ /*+ * get parsed data array from the data+ * string. V, v, H, h, and l data are converted to+ * L data for the purpose of high performance Path+ * rendering+ */+ static parsePathData(data: string) {+ // Path Data Segment must begin with a moveTo+ //m (x y)+ Relative moveTo (subsequent points are treated as lineTo)+ //M (x y)+ Absolute moveTo (subsequent points are treated as lineTo)+ //l (x y)+ Relative lineTo+ //L (x y)+ Absolute LineTo+ //h (x)+ Relative horizontal lineTo+ //H (x)+ Absolute horizontal lineTo+ //v (y)+ Relative vertical lineTo+ //V (y)+ Absolute vertical lineTo+ //z (closepath)+ //Z (closepath)+ //c (x1 y1 x2 y2 x y)+ Relative Bezier curve+ //C (x1 y1 x2 y2 x y)+ Absolute Bezier curve+ //q (x1 y1 x y)+ Relative Quadratic Bezier+ //Q (x1 y1 x y)+ Absolute Quadratic Bezier+ //t (x y)+ Shorthand/Smooth Relative Quadratic Bezier+ //T (x y)+ Shorthand/Smooth Absolute Quadratic Bezier+ //s (x2 y2 x y)+ Shorthand/Smooth Relative Bezier curve+ //S (x2 y2 x y)+ Shorthand/Smooth Absolute Bezier curve+ //a (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ Relative Elliptical Arc+ //A (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ Absolute Elliptical Arc++ // return early if data is not defined+ if (!data) {+ return [];+ }++ // command string+ let cs = data;++ // command chars+ let cc = ['m', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z', 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A'];+ // convert white spaces to commas+ cs = cs.replace(new RegExp(' ', 'g'), ',');+ // create pipes so that we can split the data+ for (let n = 0, len = cc.length; n < len; n++) {+ cs = cs.replace(new RegExp(cc[n], 'g'), `|${cc[n]}`);+ }+ // create array+ let arr = cs.split('|');+ let ca: IPathDataArray[] = [];+ let coords = [];+ // init context point+ let cpx = 0;+ let cpy = 0;++ let re = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;+ let match;+ for (let n = 1, len = arr.length; n < len; n++) {+ let str = arr[n];+ let c = str.charAt(0);+ str = str.slice(1);++ coords.length = 0;+ while ((match = re.exec(str))) {+ coords.push(match[0]);+ }++ // while ((match = re.exec(str))) {+ // coords.push(match[0]);+ // }+ let p = [];++ for (let j = 0, jLen = coords.length; j < jLen; j++) {+ // extra case for merged flags+ if (coords[j] === '00') {+ p.push(0, 0);+ continue;+ }+ let parsed = parseFloat(coords[j]);+ if (!isNaN(parsed)) {+ p.push(parsed);+ } else {+ p.push(0);+ }+ }++ while (p.length > 0) {+ if (isNaN(p[0])) {+ // case for a trailing comma before next command+ break;+ }++ let cmd: Nullable<string>;+ let points: number[] = [];+ let startX = cpx;+ let startY = cpy;+ // Move var from within the switch to up here (jshint)+ let prevCmd: IPathDataArray;+ let ctlPtx: number;+ let ctlPty: number; // Ss, Tt+ let rx: number;+ let ry: number;+ let psi: number;+ let fa: number;+ let fs: number;+ let x1: number;+ let y1: number; // Aa++ // convert l, H, h, V, and v to L+ switch (c) {+ // Note: Keep the lineTo's above the moveTo's in this switch+ case 'l':+ cpx += p.shift() || 0;+ cpy += p.shift() || 0;+ cmd = 'L';+ points.push(cpx, cpy);+ break;+ case 'L':+ cpx = p.shift() || 0;+ cpy = p.shift() || 0;+ points.push(cpx, cpy);+ break;+ // Note: lineTo handlers need to be above this point+ case 'm': {+ let dx = p.shift() || 0;+ let dy = p.shift() || 0;+ cpx += dx;+ cpy += dy;+ cmd = 'M';+ // After closing the path move the current position+ // to the the first point of the path (if any).+ if (ca.length > 2 && ca[ca.length - 1].command === 'z') {+ for (let idx = ca.length - 2; idx >= 0; idx--) {+ if (ca[idx].command === 'M') {+ cpx = ca[idx].points[0] + dx;+ cpy = ca[idx].points[1] + dy;+ break;+ }+ }+ }+ points.push(cpx, cpy);+ c = 'l';+ // subsequent points are treated as relative lineTo+ break;+ }+ case 'M':+ cpx = p.shift() || 0;+ cpy = p.shift() || 0;+ cmd = 'M';+ points.push(cpx, cpy);+ c = 'L';+ // subsequent points are treated as absolute lineTo+ break;++ case 'h':+ cpx += p.shift() || 0;+ cmd = 'L';+ points.push(cpx, cpy);+ break;+ case 'H':+ cpx = p.shift() || 0;+ cmd = 'L';+ points.push(cpx, cpy);+ break;+ case 'v':+ cpy += p.shift() || 0;+ cmd = 'L';+ points.push(cpx, cpy);+ break;+ case 'V':+ cpy = p.shift() || 0;+ cmd = 'L';+ points.push(cpx, cpy);+ break;+ case 'C':+ points.push(p.shift() || 0, p.shift() || 0, p.shift() || 0, p.shift() || 0);+ cpx = p.shift() || 0;+ cpy = p.shift() || 0;+ points.push(cpx, cpy);+ break;+ case 'c':+ points.push(cpx + (p.shift() || 0), cpy + (p.shift() || 0), cpx + (p.shift() || 0), cpy + (p.shift() || 0));+ cpx += p.shift() || 0;+ cpy += p.shift() || 0;+ cmd = 'C';+ points.push(cpx, cpy);+ break;+ case 'S':+ ctlPtx = cpx;+ ctlPty = cpy;+ prevCmd = ca[ca.length - 1];+ if (prevCmd.command === 'C') {+ ctlPtx = cpx + (cpx - prevCmd.points[2]);+ ctlPty = cpy + (cpy - prevCmd.points[3]);+ }+ points.push(ctlPtx, ctlPty, p.shift() || 0, p.shift() || 0);+ cpx = p.shift() || 0;+ cpy = p.shift() || 0;+ cmd = 'C';+ points.push(cpx, cpy);+ break;+ case 's':+ ctlPtx = cpx;+ ctlPty = cpy;+ prevCmd = ca[ca.length - 1];+ if (prevCmd.command === 'C') {+ ctlPtx = cpx + (cpx - prevCmd.points[2]);+ ctlPty = cpy + (cpy - prevCmd.points[3]);+ }+ points.push(ctlPtx, ctlPty, cpx + (p.shift() || 0), cpy + (p.shift() || 0));+ cpx += p.shift() || 0;+ cpy += p.shift() || 0;+ cmd = 'C';+ points.push(cpx, cpy);+ break;+ case 'Q':+ points.push(p.shift() || 0, p.shift() || 0);+ cpx = p.shift() || 0;+ cpy = p.shift() || 0;+ points.push(cpx, cpy);+ break;+ case 'q':+ points.push(cpx + (p.shift() || 0), cpy + (p.shift() || 0));+ cpx += p.shift() || 0;+ cpy += p.shift() || 0;+ cmd = 'Q';+ points.push(cpx, cpy);+ break;+ case 'T':+ ctlPtx = cpx;+ ctlPty = cpy;+ prevCmd = ca[ca.length - 1];+ if (prevCmd.command === 'Q') {+ ctlPtx = cpx + (cpx - prevCmd.points[0]);+ ctlPty = cpy + (cpy - prevCmd.points[1]);+ }+ cpx = p.shift() || 0;+ cpy = p.shift() || 0;+ cmd = 'Q';+ points.push(ctlPtx, ctlPty, cpx, cpy);+ break;+ case 't':+ ctlPtx = cpx;+ ctlPty = cpy;+ prevCmd = ca[ca.length - 1];+ if (prevCmd.command === 'Q') {+ ctlPtx = cpx + (cpx - prevCmd.points[0]);+ ctlPty = cpy + (cpy - prevCmd.points[1]);+ }+ cpx += p.shift() || 0;+ cpy += p.shift() || 0;+ cmd = 'Q';+ points.push(ctlPtx, ctlPty, cpx, cpy);+ break;+ case 'A':+ rx = p.shift() || 0;+ ry = p.shift() || 0;+ psi = p.shift() || 0;+ fa = p.shift() || 0;+ fs = p.shift() || 0;+ x1 = cpx;+ y1 = cpy;+ cpx = p.shift() || 0;+ cpy = p.shift() || 0;+ cmd = 'A';+ points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);+ break;+ case 'a':+ rx = p.shift() || 0;+ ry = p.shift() || 0;+ psi = p.shift() || 0;+ fa = p.shift() || 0;+ fs = p.shift() || 0;+ x1 = cpx;+ y1 = cpy;+ cpx += p.shift() || 0;+ cpy += p.shift() || 0;+ cmd = 'A';+ points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);+ break;+ }++ ca.push({+ command: cmd || c,+ points,+ start: {+ x: startX,+ y: startY,+ },+ pathLength: this.calcLength(startX, startY, cmd || c, points),+ });+ }++ if (c === 'z' || c === 'Z') {+ ca.push({+ command: 'z',+ points: [],+ start: {+ x: 0,+ y: 0,+ },+ pathLength: 0,+ });+ }+ }++ return ca;+ }++ static calcLength(x: number, y: number, cmd: string, points: number[]) {+ let len;+ let p1;+ let p2;+ let t;+ let path = Path;++ switch (cmd) {+ case 'L':+ return path.getLineLength(x, y, points[0], points[1]);+ case 'C':+ // Approximates by breaking curve into 100 line segments+ len = 0.0;+ p1 = path.getPointOnCubicBezier(0, x, y, points[0], points[1], points[2], points[3], points[4], points[5]);+ for (t = 0.01; t <= 1; t += 0.01) {+ p2 = path.getPointOnCubicBezier(t, x, y, points[0], points[1], points[2], points[3], points[4], points[5]);+ len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);+ p1 = p2;+ }+ return len;+ case 'Q':+ // Approximates by breaking curve into 100 line segments+ len = 0.0;+ p1 = path.getPointOnQuadraticBezier(0, x, y, points[0], points[1], points[2], points[3]);+ for (t = 0.01; t <= 1; t += 0.01) {+ p2 = path.getPointOnQuadraticBezier(t, x, y, points[0], points[1], points[2], points[3]);+ len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);+ p1 = p2;+ }+ return len;+ case 'A': {+ // Approximates by breaking curve into line segments+ len = 0.0;+ let start = points[4];+ // 4 = theta+ let dTheta = points[5];+ // 5 = dTheta+ let end = points[4] + dTheta;+ let inc = Math.PI / 180.0;+ // 1 degree resolution+ if (Math.abs(start - end) < inc) {+ inc = Math.abs(start - end);+ }+ // Note: for purpose of calculating arc length, not going to worry about rotating X-axis by angle psi+ p1 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], start, 0);+ if (dTheta < 0) {+ // clockwise+ for (t = start - inc; t > end; t -= inc) {+ p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], t, 0);+ len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);+ p1 = p2;+ }+ } else {+ // counter-clockwise+ for (t = start + inc; t < end; t += inc) {+ p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], t, 0);+ len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);+ p1 = p2;+ }+ }+ p2 = path.getPointOnEllipticalArc(points[0], points[1], points[2], points[3], end, 0);+ len += path.getLineLength(p1.x, p1.y, p2.x, p2.y);++ return len;+ }+ }++ return 0;+ }++ static convertEndpointToCenterParameterization(x1: number, y1: number, x2: number, y2: number, fa: number, fs: number, rx: number, ry: number, psiDeg: number) {+ // Derived from: http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes+ let psi = psiDeg * (Math.PI / 180.0);+ let xp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0;+ let yp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 + (Math.cos(psi) * (y1 - y2)) / 2.0;++ let lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);++ if (lambda > 1) {+ rx *= Math.sqrt(lambda);+ ry *= Math.sqrt(lambda);+ }++ let f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) / (rx * rx * (yp * yp) + ry * ry * (xp * xp)));++ if (fa === fs) {+ f *= -1;+ }+ if (isNaN(f)) {+ f = 0;+ }++ let cxp = (f * rx * yp) / ry;+ let cyp = (f * -ry * xp) / rx;++ let cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;+ let cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;++ let vMag = (v: number[]) => Math.sqrt(v[0] * v[0] + v[1] * v[1]);+ let vRatio = (u: number[], v: number[]) => (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));+ let vAngle = (u: number[], v: number[]) => (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));+ let theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);+ let u = [(xp - cxp) / rx, (yp - cyp) / ry];+ let v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];+ let dTheta = vAngle(u, v);++ if (vRatio(u, v) <= -1) {+ dTheta = Math.PI;+ }+ if (vRatio(u, v) >= 1) {+ dTheta = 0;+ }+ if (fs === 0 && dTheta > 0) {+ dTheta -= 2 * Math.PI;+ }+ if (fs === 1 && dTheta < 0) {+ dTheta += 2 * Math.PI;+ }+ return [cx, cy, rx, ry, theta, dTheta, psi, fs];+ }+}diff --git a/packages/base-render/src/Shape/RichText.ts b/packages/base-render/src/Shape/RichText.tsnew file mode 100644index 0000000000..56eca6f1f6--- /dev/null+++ b/packages/base-render/src/Shape/RichText.ts@@ -0,0 +1,226 @@+// import { IShapeProps, Shape, IObjectFullState, Group, Scene } from '.';++import { BlockType, Context, IDocumentData, IKeyValue, ParagraphElementType } from '@univer/core';+import { Canvas } from '..';+import { BaseObject } from '../BaseObject';+import { IBoundRect, IObjectFullState } from '../Basics';+import { Documents, DocumentSkeleton } from '../Component';++export interface IRichTextProps extends IObjectFullState {+ text?: string;+ richText?: IDocumentData;+}++export const RICHTEXT_OBJECT_ARRAY = ['text', 'richText'];++export class RichText extends BaseObject {+ private _documentData: IDocumentData;++ private _context: Context;++ private _allowCache: boolean = false;++ private _cacheCanvas: Canvas;++ private _documentSkeleton: DocumentSkeleton;++ private _documents: Documents;++ get documentData() {+ return this._documentData;+ }++ constructor(context: Context, key?: string, props?: IRichTextProps) {+ super(key);+ if (props?.richText) {+ this._documentData = props.richText;+ } else {+ this._documentData = this.convertToDocumentData(props?.text || '');+ }++ if (this._allowCache) {+ this._cacheCanvas = new Canvas();+ this.onTransformChangeObservable.add(() => {+ this.resizeCacheCanvas();+ });+ }++ this._context = context;++ this._documentSkeleton = DocumentSkeleton.create(this._documentData, this._context);++ this._documents = new Documents(`${this.oKey}_DOCUMENTS`, this._documentSkeleton);++ this._initialProps(props);+ }++ private convertToDocumentData(text: string) {+ const contentLength = text.length;+ const documentData: IDocumentData = {+ documentId: 'd',+ body: {+ blockElements: {+ oneParagraph: {+ blockId: 'oneParagraph',+ st: 0,+ ed: contentLength,+ blockType: BlockType.PARAGRAPH,+ paragraph: {+ elements: {+ oneElement: {+ eId: 'oneElement',+ st: 0,+ ed: contentLength,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: text,+ },+ },+ },+ elementOrder: [{ elementId: 'oneElement', paragraphElementType: ParagraphElementType.TEXT_RUN }],+ },+ },+ },+ blockElementOrder: ['oneParagraph'],+ },+ documentStyle: {+ pageSize: {+ width: Infinity,+ height: Infinity,+ },+ },+ };+ return documentData;+ }++ private _initialProps(props?: IRichTextProps) {+ this._documentSkeleton.updateDocumentDataPageSize(props?.width, props?.height);++ this._documentSkeleton.calculate();++ const contentSize = this._documentSkeleton.getLastPageSize();++ this.transformByState({+ width: contentSize?.width || 0,+ height: contentSize?.height || 0,+ left: props?.left || 0,+ top: props?.top || 0,+ angle: props?.angle,+ });++ this.setProps(props);++ this.makeDirty(true);+ }++ setProps(props?: IRichTextProps) {+ if (!props) {+ return;+ }++ const themeKeys = Object.keys(props);+ if (themeKeys.length === 0) {+ return;+ }+ themeKeys.forEach((key) => {+ if (props[key] === undefined) {+ return true;+ }++ if (RICHTEXT_OBJECT_ARRAY.indexOf(key) === -1) {+ this[`_${key}`] = props[key];+ }+ });+ this.makeDirty(true);+ return this;+ }++ protected _draw(ctx: CanvasRenderingContext2D) {+ this._documents.render(ctx);+ }++ render(mainCtx: CanvasRenderingContext2D, bounds?: IBoundRect) {+ if (!this.visible) {+ this.makeDirty(false);+ return this;+ }++ // Temporarily ignore the on-demand display of elements within a group:this.isInGroup+ if (bounds && !this.isInGroup) {+ const tl = this.transform.clone().invert().applyPoint(bounds.tl);+ const tr = this.transform.clone().invert().applyPoint(bounds.tr);+ const bl = this.transform.clone().invert().applyPoint(bounds.bl);+ const br = this.transform.clone().invert().applyPoint(bounds.br);++ const xList = [tl.x, tr.x, bl.x, br.x];+ const yList = [tl.y, tr.y, bl.y, br.y];++ const maxX = Math.max(...xList);+ const minX = Math.min(...xList);+ const maxY = Math.max(...yList);+ const minY = Math.min(...yList);++ if (this.width + this.strokeWidth < minX || maxX < 0 || this.height + this.strokeWidth < minY || maxY < 0) {+ // console.warn('ignore object', this);+ return this;+ }+ }++ const m = this.transform.getMatrix();+ mainCtx.save();+ mainCtx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);+ if (this._allowCache) {+ if (this.isDirty()) {+ const ctx = this._cacheCanvas.getContext();+ this._cacheCanvas.clear();+ ctx.save();+ ctx.translate(this.strokeWidth / 2, this.strokeWidth / 2); // 边框会按照宽度画在边界上,分别占据内外二分之一+ this._draw(ctx);+ ctx.restore();+ }+ this._applyCache(mainCtx);+ } else {+ this._draw(mainCtx);+ }+ mainCtx.restore();+ this.makeDirty(false);+ return this;+ }++ private _applyCache(ctx?: CanvasRenderingContext2D) {+ if (!ctx || !this._cacheCanvas) {+ return;+ }+ const pixelRatio = this._cacheCanvas.getPixelRatio();+ const width = this._cacheCanvas.getWidth() * pixelRatio;+ const height = this._cacheCanvas.getHeight() * pixelRatio;+ ctx.drawImage(+ this._cacheCanvas.getCanvasEle(),+ 0,+ 0,+ width,+ height,+ -this.strokeWidth / 2,+ -this.strokeWidth / 2,+ this.width + this.strokeWidth,+ this.height + this.strokeWidth+ );+ }++ getContext() {+ return this._context;+ }++ toJson() {+ const props: IKeyValue = {};+ RICHTEXT_OBJECT_ARRAY.forEach((key) => {+ if (this[key]) {+ props[key] = this[key];+ }+ });+ return {+ ...super.toJson(),+ ...props,+ };+ }+}diff --git a/packages/base-render/src/Shape/index.ts b/packages/base-render/src/Shape/index.tsindex cf031811ca..a538feca4a 100644--- a/packages/base-render/src/Shape/index.ts+++ b/packages/base-render/src/Shape/index.ts@@ -6,3 +6,6 @@ export * from './Selection';export * from './TextSelection';export * from './ScrollBar';export * from './Picture';+export * from './Path';+export * from './Circle';+export * from './RichText';diff --git a/packages/base-render/src/Viewport.ts b/packages/base-render/src/Viewport.tsindex 6a08183906..3fef1bc09e 100644--- a/packages/base-render/src/Viewport.ts+++ b/packages/base-render/src/Viewport.ts@@ -576,9 +576,12 @@ export class Viewport {return;}let isLimitedStore;- if (evt.inputIndex === PointerInput.MouseWheelX && evt.deltaX !== 0) {+ if (evt.inputIndex === PointerInput.MouseWheelX) {const deltaFactor = Math.abs(evt.deltaX);- let scrollNum = deltaFactor < 40 ? 2 : deltaFactor < 80 ? 3 : 4;+ // let magicNumber = deltaFactor < 40 ? 2 : deltaFactor < 80 ? 3 : 4;+ const allWidth = this._scene.width;+ const viewWidth = this.width || 1;+ let scrollNum = (viewWidth / allWidth) * deltaFactor;if (evt.deltaX > 0) {isLimitedStore = this.scrollBy({@@ -601,9 +604,12 @@ export class Viewport {evt.preventDefault();}}- if (evt.inputIndex === PointerInput.MouseWheelY && evt.deltaY !== 0) {+ if (evt.inputIndex === PointerInput.MouseWheelY) {const deltaFactor = Math.abs(evt.deltaY);- let scrollNum = deltaFactor < 40 ? 2 : deltaFactor < 80 ? 3 : 4;+ const allHeight = this._scene.height;+ const viewHeight = this.height || 1;+ // let magicNumber = deltaFactor < 40 ? 2 : deltaFactor < 80 ? 3 : 4;+ let scrollNum = (viewHeight / allHeight) * deltaFactor;if (evt.shiftKey) {if (evt.deltaY > 0) {isLimitedStore = this.scrollBy({diff --git a/packages/base-sheets/src/View/Render/Views/OtherViewTest.ts b/packages/base-sheets/src/View/Render/Views/OtherViewTest.tsnew file mode 100644index 0000000000..ec1830f4a9--- /dev/null+++ b/packages/base-sheets/src/View/Render/Views/OtherViewTest.ts@@ -0,0 +1,416 @@+import { getColor, Path, Picture, Rect, Circle, RichText } from '@univer/base-render';+import { BaselineOffset, BlockType, BulletAlignment, GlyphType, IDocumentData, ParagraphElementType } from '@univer/core';+import { BaseView, CanvasViewRegistry } from '../BaseView';++const richTextTest: IDocumentData = {+ documentId: 'd',+ lists: {+ testBullet: {+ listId: 'testBullet',+ nestingLevel: [+ {+ bulletAlignment: BulletAlignment.START,+ glyphFormat: ' %1.',+ textStyle: {+ fs: 12,+ },+ startNumber: 0,+ glyphType: GlyphType.ROMAN,+ hanging: 21,+ indentStart: 21,+ },+ {+ bulletAlignment: BulletAlignment.START,+ glyphFormat: ' %1.%2)',+ textStyle: {+ fs: 12,+ },+ startNumber: 0,+ glyphType: GlyphType.ROMAN,+ hanging: 21,+ indentStart: 42,+ },+ {+ bulletAlignment: BulletAlignment.START,+ glyphFormat: ' %1.%2.%3.',+ textStyle: {+ fs: 12,+ },+ startNumber: 0,+ glyphType: GlyphType.ROMAN,+ hanging: 21,+ indentStart: 63,+ },+ ],+ // nestingLevel: [+ // {+ // bulletAlignment: BulletAlignment.START,+ // glyphFormat: ' %0',+ // textStyle: {+ // fs: 12,+ // },+ // startNumber: 0,+ // glyphSymbol: '\u25CF',+ // hanging: 21,+ // indentStart: 21,+ // },+ // {+ // bulletAlignment: BulletAlignment.START,+ // glyphFormat: ' %1',+ // textStyle: {+ // fs: 12,+ // },+ // startNumber: 0,+ // glyphSymbol: '\u25A0',+ // hanging: 21,+ // indentStart: 42,+ // },+ // {+ // bulletAlignment: BulletAlignment.START,+ // glyphFormat: ' %1',+ // textStyle: {+ // fs: 12,+ // },+ // startNumber: 0,+ // glyphSymbol: '\u25C6',+ // hanging: 21,+ // indentStart: 63,+ // },+ // ],+ },+ },+ body: {+ blockElements: {+ oneParagraph: {+ blockId: 'oneParagraph',+ st: 0,+ ed: 15,+ blockType: BlockType.PARAGRAPH,+ paragraph: {+ bullet: {+ listId: 'testBullet',+ nestingLevel: 0,+ textStyle: {+ fs: 20,+ },+ },+ elements: {+ oneElement: {+ eId: 'oneElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '在“第1题”工作表中完成以下操作',+ ts: {+ fs: 12,+ bg: {+ rgb: 'rgb(200,0,90)',+ },+ cl: {+ rgb: 'rgb(255,130,0)',+ },+ },+ },+ },+ smallSub: {+ eId: 'smallSub',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '上标',+ ts: {+ fs: 14,+ bg: {+ rgb: 'rgb(2,128,2)',+ },+ cl: {+ rgb: 'rgb(0,1,55)',+ },+ va: BaselineOffset.SUPERSCRIPT,+ },+ },+ },+ twoElement: {+ eId: 'twoElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)',+ ts: {+ fs: 14,+ bg: {+ rgb: 'rgb(90,128,255)',+ },+ cl: {+ rgb: 'rgb(0,1,255)',+ },+ },+ },+ },+ },+ elementOrder: [+ {+ elementId: 'oneElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ {+ elementId: 'smallSub',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ {+ elementId: 'twoElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ ],+ },+ },+ twoParagraph: {+ blockId: 'twoParagraph',+ st: 0,+ ed: 15,+ blockType: BlockType.PARAGRAPH,+ paragraph: {+ bullet: {+ listId: 'testBullet',+ nestingLevel: 1,+ textStyle: {+ fs: 20,+ },+ },+ elements: {+ oneElement: {+ eId: 'oneElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '细化埋点上报链路和指标方案梳理',+ },+ },+ twoElement: {+ eId: 'twoElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '目前通过每日定时任务发送报告',+ },+ },+ },+ elementOrder: [+ {+ elementId: 'oneElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ {+ elementId: 'twoElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ ],+ },+ },+ threeParagraph: {+ blockId: 'threeParagraph',+ st: 0,+ ed: 15,+ blockType: BlockType.PARAGRAPH,+ paragraph: {+ bullet: {+ listId: 'testBullet',+ nestingLevel: 0,+ textStyle: {+ fs: 20,+ },+ },+ elements: {+ oneElement: {+ eId: 'oneElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '自2018年首届进博会举办以来,进博会已经成为全球新品的首发地、前沿技术的首选地、创新服务的首推地。',+ },+ },+ twoElement: {+ eId: 'twoElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '中国这十年”对外开放成就展湖北展区主要以图文、图表、数据、视频、企业展品、实物模型、光电科技等体现湖北十年开放成就、重大开放平台及产业。湖北省共计17家企业、机构的展品将在这一展区展示',+ },+ },+ },+ elementOrder: [+ {+ elementId: 'oneElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ {+ elementId: 'twoElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ ],+ },+ },+ fourParagraph: {+ blockId: 'fourParagraph',+ st: 0,+ ed: 15,+ blockType: BlockType.PARAGRAPH,+ paragraph: {+ bullet: {+ listId: 'testBullet',+ nestingLevel: 1,+ textStyle: {+ fs: 20,+ },+ },+ elements: {+ oneElement: {+ eId: 'oneElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '国家主席习近平以视频方式出席在上海举行的第五届中国国际进口博览会开幕式并发表题为《共创开放繁荣的美好未来》的致辞',+ },+ },+ twoElement: {+ eId: 'twoElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '中国将推动各国各方共享深化国际合作机遇,全面深入参与世界贸易组织改革谈判',+ },+ },+ },+ elementOrder: [+ {+ elementId: 'oneElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ {+ elementId: 'twoElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ ],+ },+ },+ fiveParagraph: {+ blockId: 'fiveParagraph',+ st: 0,+ ed: 15,+ blockType: BlockType.PARAGRAPH,+ paragraph: {+ bullet: {+ listId: 'testBullet',+ nestingLevel: 2,+ textStyle: {+ fs: 20,+ },+ },+ elements: {+ oneElement: {+ eId: 'oneElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '中国男排两名现役国手彭世坤和张秉龙分别效力的三得利太阳鸟和东京大熊本轮遭遇。',+ },+ },+ twoElement: {+ eId: 'twoElement',+ st: 0,+ ed: 15,+ et: ParagraphElementType.TEXT_RUN,+ tr: {+ ct: '双方经过激战,主场作战的卫冕冠军三得利技高一筹3-2逆转击败对手,力夺第3场胜利',+ },+ },+ },+ elementOrder: [+ {+ elementId: 'oneElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ {+ elementId: 'twoElement',+ paragraphElementType: ParagraphElementType.TEXT_RUN,+ },+ ],+ },+ },+ },+ blockElementOrder: ['oneParagraph', 'twoParagraph', 'threeParagraph', 'fourParagraph', 'fiveParagraph'],+ },+ documentStyle: {+ pageSize: {+ width: Infinity,+ height: Infinity,+ },+ marginTop: 0,+ marginBottom: 0,+ marginRight: 2,+ marginLeft: 2,+ },+};++export class OtherViewTest extends BaseView {+ protected _initialize() {+ const mainScene = this.getScene();+ const path = new Path('path1', {+ data: 'M848.2028 624.638c61.7667 0 111.9928-50.2538 111.9928-111.9928 0-61.7667-50.2262-111.9949-111.9928-111.9949h-19.414016c-3.9373-11.1831-8.448-22.1194-13.4779-32.7014l13.6704-13.698c21.0811-21.0801 32.7025-49.2165 32.7025-79.1828 0-29.995-11.6214-58.1028-32.7025-79.1839-21.0801-21.1098-49.2165-32.7035-79.1839-32.7035-29.9704 0-58.1048 11.5937-79.1818 32.7035l-13.6704 13.6714c-10.6107-5.033-21.5214-9.5437-32.7311-13.481v-19.412992c0-61.7656-50.2292-111.9939-111.9949-111.9939-61.7636 0-111.9928 50.2282-111.9928 111.9939v19.412992c-11.2118 3.9373-22.1225 8.448-32.7322 13.481l-13.6714-13.6714c-21.077-21.1098-49.2124-32.7035-79.1828-32.7035-29.9663 0-58.0987 11.5937-79.1839 32.7035-21.076 21.0801-32.7014 49.1889-32.7014 79.1839 0 29.9674 11.6255 58.1028 32.7014 79.1828l13.6714 13.6704c-5.0289 10.6097-9.5406 21.5194-13.4779 32.7291h-19.414016c-61.7636 0-111.9928 50.2282-111.9928 111.9949 0 61.739 50.2292 111.9928 111.9928 111.9928h19.414016c3.9373 11.2118 8.449 22.1215 13.4779 32.7291l-13.6714 13.6714c-21.076 21.0811-32.7014 49.1909-32.7014 79.1849 0 29.996 11.6255 58.1028 32.7014 79.1828 21.0852 21.078 49.2175 32.7035 79.1839 32.7035 29.9715 0 58.1059-11.6255 79.1828-32.7035l13.6714-13.6704c10.6097 5.0309 21.5204 9.5119 32.7322 13.4789v19.416064c0 61.7359 50.2292 111.9928 111.9928 111.9928 61.7656 0 111.9949-50.2569 111.9949-111.9928v-19.416064c11.2097-3.967 22.1204-8.448 32.7311-13.5045l13.6704 13.695c21.077 21.078 49.2124 32.7035 79.1818 32.7035 29.9674 0 58.1038-11.6255 79.1839-32.7035 21.0811-21.0801 32.7025-49.1868 32.7025-79.1828 0-29.994-11.6214-58.1038-32.7025-79.1849l-13.6704-13.698c5.0299-10.6076 9.5406-21.5194 13.4779-32.7025H848.202752zM789.3873 710.6294c10.5277 10.5001 16.297 24.5555 16.297 39.594 0 15.0108-5.7692 29.0673-16.297 39.5909-21.0504 21.0278-58.1294 21.0278-79.1808 0l-43.1186-43.1452-18.4842 10.3629c-18.647 10.4172-38.826 18.7556-60.0177 24.7695l-20.3694 5.7723v61.057024c0 30.8675-25.1279 55.9933-55.9985 55.9933s-55.9985-25.1259-55.9985-55.9933v-61.057024l-20.3674-5.7723c-21.2183-6.0416-41.4259-14.3534-60.0156-24.7695l-18.4852-10.3363-43.1206 43.1176c-21.0534 21.0278-58.1294 21.0278-79.1828 0-10.5267-10.5236-16.2939-24.5801-16.2939-39.5909 0-15.0385 5.7672-29.0939 16.2939-39.594l43.1176-43.1165-10.3588-18.4852c-10.3916-18.5907-18.7054-38.7697-24.746-60.0412l-5.7733-20.3448h-61.053951999999995c-30.8695 0-55.9954-25.1279-55.9954-55.9964 0-30.8705 25.1249-55.9985 55.9954-55.9985h61.053951999999995l5.7733-20.3704c6.0406-21.2449 14.3544-41.4505 24.746-60.0156l10.3588-18.4832-43.1176-43.1186c-10.5267-10.5277-16.2939-24.5811-16.2939-39.5919 0-15.0395 5.7672-29.0939 16.2939-39.5919 21.0545-21.0278 58.1304-21.0278 79.1828 0l43.1206 43.1176 18.4852-10.3608c18.5897-10.3905 38.7983-18.731 60.0156-24.746l20.3674-5.7702v-61.056000000000004c0-30.8951 25.1279-55.9964 55.9985-55.9964s55.9985 25.1013 55.9985 55.9964v61.056000000000004l20.3694 5.7702c21.1917 6.016 41.3706 14.3278 60.0177 24.7716l18.4842 10.3352 43.1186-43.1176c21.0524-21.0278 58.1315-21.0278 79.1808 0 10.5277 10.498 16.297 24.5524 16.297 39.5919 0 15.0108-5.7692 29.0642-16.297 39.5919l-43.0909 43.1186 10.3076 18.4832c10.4479 18.6737 18.7832 38.8813 24.7706 60.0156l5.7733 20.3704h61.053951999999995c30.8695 0 55.9974 25.1279 55.9974 55.9985 0 30.8685-25.1279 55.9964-55.9974 55.9964h-61.053951999999995l-5.7733 20.3448c-5.9884 21.161-14.3227 41.342-24.7706 60.0412l-10.3076 18.4852L789.3873 710.6294zM512.2181 344.6528c-92.6372 0-167.9913 75.3551-167.9913 167.9923 0 92.6351 75.3541 167.9913 167.9913 167.9913s167.9913-75.3562 167.9913-167.9913C680.2094 420.0079 604.8553 344.6528 512.2181 344.6528zM512.2181 624.638c-61.7636 0-111.9928-50.2538-111.9928-111.9928 0-61.7667 50.2292-111.9949 111.9928-111.9949 61.7656 0 111.9949 50.2282 111.9949 111.9949C624.213 574.3841 573.9848 624.638 512.2181 624.638z',+ width: 200,+ height: 200,+ left: 600,+ top: 300,+ zIndex: 14,+ strokeWidth: 1,+ stroke: getColor([102, 111, 99], 1),+ fill: getColor([102, 255, 99], 1),+ });++ const pathRect = path.getRect();+ console.log('pathRect', pathRect, path);+ const rect3 = new Rect('pathRect', {+ ...pathRect,+ strokeWidth: 1,+ stroke: 'rgba(102,111,99, 0.8)',+ zIndex: 11,+ });+ const picture = new Picture({+ url: 'https://cnbabylon.com/assets/img/agents.png',+ top: 500,+ left: 800,+ zIndex: 13,+ });++ const circle1 = new Circle('circle1', {+ left: 800,+ top: 200,+ radius: 100,+ fill: 'rgba(255,111,99, 0.8)',+ zIndex: 14,+ });++ const richText = new RichText(this.getContext(), 'richText1', {+ richText: richTextTest,+ width: 300,+ zIndex: 20,+ left: 100,+ top: 400,+ });++ console.log('insert path test', mainScene);+ mainScene.addObjects([path, picture, circle1, richText]);+ }+}++CanvasViewRegistry.add(new OtherViewTest());diff --git a/packages/base-sheets/src/View/Render/Views/index.ts b/packages/base-sheets/src/View/Render/Views/index.tsindex 1a54fccc4d..bc359aa2fe 100644--- a/packages/base-sheets/src/View/Render/Views/index.ts+++ b/packages/base-sheets/src/View/Render/Views/index.ts@@ -2,3 +2,4 @@ export * from './SheetViewKeyboardEvent';export * from './SheetView';export * from './TestView';export * from './SceneViewerTestView';+export * from './OtherViewTest';diff --git a/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts b/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.tsindex 51f1810fea..34c7a15e8d 100644--- a/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts+++ b/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts@@ -58,7 +58,7 @@ const richTextTest: IDocumentData = {cl: {rgb: 'rgb(0,1,55)',},- va: BaselineOffset.SUBSCRIPT,+ va: BaselineOffset.SUPERSCRIPT,},},},diff --git a/packages/core/src/Interfaces/IDocumentData.ts b/packages/core/src/Interfaces/IDocumentData.tsindex 8217731af9..c3dc035671 100644--- a/packages/core/src/Interfaces/IDocumentData.ts+++ b/packages/core/src/Interfaces/IDocumentData.ts@@ -448,8 +448,8 @@ export interface IShapeProperties {}* Properties of Image*/export interface IImageProperties {- contentUri: string;- sourceUri: string;+ contentUrl: string;+ sourceUrl: string;brightness: number;contrast: number;transparency: number;