@visactor/vrender-core 0.17.20 → 0.17.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/cjs/graphic/config.js +1 -1
  2. package/cjs/graphic/config.js.map +1 -1
  3. package/cjs/graphic/graphic.js +2 -1
  4. package/cjs/graphic/graphic.js.map +1 -1
  5. package/cjs/graphic/group.d.ts +1 -1
  6. package/cjs/graphic/group.js +2 -2
  7. package/cjs/graphic/group.js.map +1 -1
  8. package/cjs/graphic/node-tree.d.ts +1 -1
  9. package/cjs/graphic/node-tree.js +1 -1
  10. package/cjs/graphic/node-tree.js.map +1 -1
  11. package/cjs/graphic/richtext.d.ts +44 -1
  12. package/cjs/graphic/richtext.js +13 -2
  13. package/cjs/graphic/richtext.js.map +1 -1
  14. package/cjs/interface/graphic/richText.js.map +1 -1
  15. package/cjs/interface/node-tree.d.ts +1 -1
  16. package/cjs/interface/node-tree.js.map +1 -1
  17. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +24 -20
  18. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
  19. package/es/graphic/config.js +1 -1
  20. package/es/graphic/config.js.map +1 -1
  21. package/es/graphic/graphic.js +2 -1
  22. package/es/graphic/graphic.js.map +1 -1
  23. package/es/graphic/group.d.ts +1 -1
  24. package/es/graphic/group.js +2 -2
  25. package/es/graphic/group.js.map +1 -1
  26. package/es/graphic/node-tree.d.ts +1 -1
  27. package/es/graphic/node-tree.js +1 -1
  28. package/es/graphic/node-tree.js.map +1 -1
  29. package/es/graphic/richtext.d.ts +44 -1
  30. package/es/graphic/richtext.js +13 -2
  31. package/es/graphic/richtext.js.map +1 -1
  32. package/es/interface/graphic/richText.js.map +1 -1
  33. package/es/interface/node-tree.d.ts +1 -1
  34. package/es/interface/node-tree.js.map +1 -1
  35. package/es/plugins/builtin-plugin/html-attribute-plugin.js +24 -20
  36. package/es/plugins/builtin-plugin/html-attribute-plug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I,CAAC,CAAC;QAEzC,OAAO,IAAI,CAAC;IACd,CAAC;IASD,GAAG,CACD,IAAY,EACZ,QAA4D,EAC5D,OAA2C;QAE3C,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CACF,IAAY,EACZ,QAA4D,EAC5D,OAA2C;QAE3C,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE;YACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;YACpB,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SACvD;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,uBAAuB;QACrB,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kBAAkB;QAChB,OAAO,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACxC,CAAC;IAED,aAAa,CAAC,KAAU,EAAE,GAAG,IAAS;QACpC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QACvC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC;IACjC,CAAC;IAED,IAAI,CAAC,KAAU,EAAE,IAAgB;QAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,OAAO;QAEL,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;CACF","file":"node-tree.js","sourcesContent":["import type { Dict, LooseFunction } from '@visactor/vutils';\nimport { EventEmitter, Logger, isBoolean, isFunction, isObject } from '@visactor/vutils';\nimport { Generator } from '../common/generator';\nimport type { INode, IGroup } from '../interface';\n\nexport class Node extends EventEmitter<any, any> implements INode {\n parent: any;\n declare name: string;\n declare id: string | number;\n\n declare _uid: number;\n _prev?: INode;\n _next?: INode;\n protected _firstChild: INode | null;\n protected _lastChild: INode | null;\n protected _idMap?: Map<number, INode>;\n protected _count: number;\n // protected _dirty?: boolean; // dirty表示属性是否有修改\n protected _structEdit?: boolean; // 树的结构是否发生修改\n protected _nodeList?: INode[]; // 用于有顺序的插入(正常情况用不到)\n\n declare _ignoreWarn?: boolean;\n\n get previousSibling(): INode | null {\n return this._prev;\n }\n\n get nextSibling(): INode | null {\n return this._next;\n }\n\n get children(): INode[] {\n return this.getChildren();\n }\n get firstChild(): INode | null {\n return this._firstChild;\n }\n get lastChild(): INode | null {\n return this._lastChild;\n }\n get count(): number {\n return this._count;\n }\n get childrenCount(): number {\n if (!this._idMap) {\n return 0;\n }\n return this._idMap.size;\n }\n // get dirty(): boolean {\n // return !!this._dirty;\n // }\n\n constructor() {\n super();\n this._uid = Generator.GenAutoIncrementId();\n this._firstChild = null;\n this._lastChild = null;\n this.parent = null;\n this._count = 1;\n }\n\n forEachChildren<T extends INode = INode>(cb: (item: T, index: number) => void | boolean, reverse: boolean = false) {\n if (reverse) {\n let child = this._lastChild;\n let i = 0;\n while (child) {\n const breakTag = cb(child as T, i++);\n if (breakTag) {\n return;\n }\n child = child._prev;\n }\n } else {\n let child = this._firstChild;\n let i = 0;\n while (child) {\n const breakTag = cb(child as T, i++);\n if (breakTag) {\n return;\n }\n child = child._next;\n }\n }\n }\n\n async forEachChildrenAsync<T extends INode = INode>(\n cb: (item: T, index: number) => Promise<void | boolean> | void | boolean,\n reverse: boolean = false\n ) {\n if (reverse) {\n let child = this._lastChild;\n let i = 0;\n while (child) {\n let breakTag = cb(child as T, i++);\n if ((breakTag as any).then) {\n breakTag = await breakTag;\n }\n if (breakTag) {\n return;\n }\n child = child._prev;\n }\n } else {\n let child = this._firstChild;\n let i = 0;\n while (child) {\n let breakTag = cb(child as T, i++);\n if ((breakTag as any).then) {\n breakTag = await breakTag;\n }\n if (breakTag) {\n return;\n }\n child = child._next;\n }\n }\n }\n\n forEach<T extends INode = INode>(cb: (item: T, index: number) => void): void {\n return this.forEachChildren<T>(cb);\n }\n\n /**\n * 方法将一个节点附加到指定父节点的子节点列表的末尾处。\n * 如果将被插入的节点已经存在于当前文档的文档树中,那么 appendChild() 只会将它从原先的位置移动到新的位置(不需要事先移除要移动的节点)。\n * 不能append父级元素\n * @param node 要插入的节点\n */\n appendChild(node: INode, highPerformance: boolean = true): INode | null {\n if (this._uid === node._uid) {\n return null;\n }\n if (!highPerformance && node.isAncestorsOf(this)) {\n throw new Error('【Node::appendChild】不能将父辈元素append为子元素');\n }\n\n // 清理该节点的上次关系\n node.parent && node.parent.removeChild(node);\n node.parent = this as unknown as Node;\n\n if (!this._lastChild) {\n this._firstChild = this._lastChild = node;\n node._prev = node._next = null;\n } else {\n this._lastChild._next = node;\n node._prev = this._lastChild;\n this._lastChild = node;\n }\n if (!this._idMap) {\n this._idMap = new Map();\n }\n this._idMap.set(node._uid, node);\n\n this.setCount(node.count);\n\n this._structEdit = true;\n return node;\n }\n\n /**\n * 方法将一个节点数组附加到指定父节点的子节点列表的末尾处。\n * 不会判断元素是否是自身以及是否是父元素或者是否是其他节点的子元素\n * @param nodes 要插入的节点数组\n */\n appendChildArrHighPerformance(nodes: INode[], replace: boolean = false): INode[] | null {\n console.error('暂不支持该函数');\n\n return nodes;\n }\n\n /**\n * 方法在参考节点之前插入一个拥有指定父节点的子节点。\n * 如果给定的子节点是对文档中现有节点的引用,\n * insertBefore() 会将其从当前位置移动到新位置(在将节点附加到其他节点之前,不需要从其父节点删除该节点)。\n * 不能insert父级元素\n * @param newNode 要插入的节点\n * @param referenceNode 插入到referenceNode之前\n */\n insertBefore(newNode: INode, referenceNode: INode | undefined): INode | null {\n if (!referenceNode) {\n return this.appendChild(newNode);\n }\n if (this._uid === newNode._uid) {\n return null;\n }\n if (newNode.isAncestorsOf(this)) {\n throw new Error('【Node::insertBefore】不能将父辈元素insert为子元素');\n }\n if (referenceNode.parent !== (this as unknown as Node)) {\n return null;\n }\n\n newNode.parent && newNode.parent.removeChild(newNode);\n newNode.parent = this as unknown as Node;\n\n newNode._prev = referenceNode._prev;\n if (!referenceNode._prev) {\n this._firstChild = newNode;\n } else {\n referenceNode._prev._next = newNode;\n }\n referenceNode._prev = newNode;\n newNode._next = referenceNode;\n if (!this._idMap) {\n this._idMap = new Map();\n }\n this._idMap.set(newNode._uid, newNode);\n\n this._structEdit = true;\n this.setCount(newNode.count);\n\n return newNode;\n }\n\n /**\n * 方法在参考节点之后插入一个拥有指定父节点的子节点。\n * 如果给定的子节点是对文档中现有节点的引用,\n * insertAfter() 会将其从当前位置移动到新位置(在将节点附加到其他节点之前,不需要从其父节点删除该节点)。\n * 不能insert父级元素\n * @param newNode 要插入的节点\n * @param referenceNode 插入到referenceNode之后\n */\n insertAfter(newNode: INode, referenceNode: INode | undefined): INode | null {\n if (!referenceNode) {\n return this.appendChild(newNode);\n }\n if (this._uid === newNode._uid) {\n return null;\n }\n if (newNode.isAncestorsOf(this)) {\n throw new Error('【Node::insertAfter】不能将父辈元素insert为子元素');\n }\n if (referenceNode.parent !== (this as unknown as Node)) {\n return null;\n }\n\n newNode.parent && newNode.parent.removeChild(newNode);\n newNode.parent = this as unknown as Node;\n\n if (!referenceNode._next) {\n this._lastChild = newNode;\n } else {\n referenceNode._next._prev = newNode;\n newNode._next = referenceNode._next;\n }\n referenceNode._next = newNode;\n newNode._prev = referenceNode;\n if (!this._idMap) {\n this._idMap = new Map();\n }\n this._idMap.set(newNode._uid, newNode);\n\n this._structEdit = true;\n this.setCount(newNode.count);\n\n return newNode;\n }\n\n /**\n * 方法在参考节点之前插入一个拥有指定父节点的子节点。\n * 如果给定的子节点是对文档中现有节点的引用,\n * insertBefore() 会将其从当前位置移动到新位置(在将节点附加到其他节点之前,不需要从其父节点删除该节点)。\n * 不能insert父级元素\n * @param newNode 要插入的节点\n * @param referenceNode 插入到referenceNode之前\n */\n insertInto(newNode: INode, idx: number): INode | null {\n if (!this._ignoreWarn && this._nodeList) {\n Logger.getInstance().warn('insertIntoKeepIdx和insertInto混用可能会存在错误');\n }\n if (idx >= this.childrenCount) {\n return this.appendChild(newNode);\n }\n if (this._uid === newNode._uid) {\n return null;\n }\n if (newNode.isAncestorsOf(this)) {\n throw new Error('【Node::insertBefore】不能将父辈元素insert为子元素');\n }\n\n newNode.parent && newNode.parent.removeChild(newNode);\n newNode.parent = this as unknown as Node;\n\n if (idx === 0) {\n newNode._next = this._firstChild;\n this._firstChild && (this._firstChild._prev = newNode);\n newNode._prev = null;\n this._firstChild = newNode;\n } else {\n let child = this._firstChild;\n for (let i = 0; i < idx; i++) {\n if (!child) {\n return null;\n }\n if (i > 0) {\n child = child._next;\n }\n }\n if (!child) {\n return null;\n }\n newNode._next = child._next;\n newNode._prev = child;\n child._next = newNode;\n if (newNode._next) {\n newNode._next._prev = newNode;\n }\n }\n if (!this._idMap) {\n this._idMap = new Map();\n }\n this._idMap.set(newNode._uid, newNode);\n\n // // 预期不会执行\n // if (idx === this.childrenCount) {\n // this._lastChild = newNode;\n // }\n this._structEdit = true;\n this.setCount(newNode.count);\n\n return newNode;\n }\n\n /**\n * 相比于insertInto,会保持idx顺序,举例:\n * 先插入idx:6的元素,再插入idx:2的元素,此时idx:2的元素会放置在idx为6的元素之前\n */\n insertIntoKeepIdx(newNode: INode, idx: number): INode | null {\n if (!this._nodeList) {\n this._nodeList = this.children;\n }\n // 如果这个位置有了,那就将这个位置之前的元素向后移动\n if (this._nodeList[idx]) {\n const node = this._nodeList[idx];\n this._nodeList.splice(idx, 0, newNode);\n return this.insertBefore(newNode, node);\n }\n // 查找idx之前的元素,插入到其后面\n this._nodeList[idx] = newNode;\n let node: INode | undefined;\n for (let i = idx - 1; i >= 0; i--) {\n node = this._nodeList[i];\n if (node) {\n break;\n }\n }\n if (node) {\n return node._next ? this.insertBefore(newNode, node._next) : this.appendChild(newNode);\n }\n this._ignoreWarn = true;\n const data = this.insertInto(newNode, 0);\n this._ignoreWarn = false;\n return data;\n }\n\n /**\n * 方法从DOM中删除一个子节点。返回删除的节点。\n * @param child 要删除的子节点\n */\n removeChild(child: INode): INode | null {\n if (!this._idMap) {\n return null;\n }\n if (!this._idMap.has(child._uid)) {\n return null;\n }\n this._idMap.delete(child._uid);\n if (this._nodeList) {\n // 找到idx\n const idx = this._nodeList.findIndex(n => n === child);\n if (idx > 0) {\n this._nodeList.splice(idx, 1);\n }\n }\n\n if (!child._prev) {\n this._firstChild = child._next;\n } else {\n child._prev._next = child._next;\n }\n if (child._next) {\n child._next._prev = child._prev;\n } else {\n this._lastChild = child._prev;\n }\n\n // 重置属性\n child.parent = null;\n child._prev = null;\n child._next = null;\n\n this._structEdit = true;\n this.setCount(-child.count);\n\n return child;\n }\n\n /**\n * 从当前节点的父节点删除当前节点\n */\n delete() {\n if (this.parent) {\n this.parent.removeChild(this);\n }\n }\n\n /**\n * 删除所有的孩子节点\n */\n removeAllChild() {\n if (!this._idMap) {\n return;\n }\n let child = this._firstChild;\n while (child) {\n const next = child._next;\n child.parent = null;\n // child._rootNode = child;\n child._prev = null;\n child._next = null;\n child = child._next;\n child = next;\n }\n\n this._firstChild = null;\n this._lastChild = null;\n this._idMap.clear();\n\n this._structEdit = true;\n this.setCount(-this._count + 1);\n }\n\n /**\n * 方法用指定的节点替换当前节点的一个子节点,并返回被替换掉的节点。\n * 如果该节点已经存在于DOM树中,则它首先会被从原始位置删除。\n * 不能replace父级元素\n * @param newChild 新节点\n * @param oldChild 旧节点\n */\n replaceChild(newChild: INode, oldChild: INode): INode | null {\n throw new Error('暂不支持');\n }\n\n /**\n * 根据自定义逻辑查找元素,返回单一图形元素\n * @param callback 自定义查找过滤器\n * @param deep 是否进行深度查找,默认为 false\n * @returns 返回匹配的图形元素\n */\n find<T extends INode = INode>(callback: (node: T, index: number) => boolean, deep: boolean = false): T | null {\n let target: T | null = null;\n this.forEachChildren((node: T, index: number) => {\n if (node !== (this as unknown as INode) && callback(node, index)) {\n target = node;\n return true; // 提前退出循环\n }\n return false;\n });\n\n if (deep) {\n this.forEachChildren(child => {\n if ((child as IGroup).isContainer) {\n const node = (child as IGroup).find(callback, true) as T;\n if (node) {\n target = node;\n return true; // 提前退出循环\n }\n }\n return false;\n });\n }\n\n return target;\n }\n\n /**\n * 根据自定义逻辑查找元素,返回匹配的元素集合\n * @param callback 自定义查找过滤器\n * @param deep 是否进行深度查找,默认为 false\n * @returns 返回匹配的图形元素集合\n */\n findAll<T extends INode = INode>(callback: (node: T, index: number) => boolean, deep: boolean = false): T[] {\n let nodes: T[] = [];\n this.forEachChildren((node: T, index) => {\n if (node !== (this as unknown as INode) && callback(node, index)) {\n nodes.push(node);\n }\n });\n\n if (deep) {\n this.forEachChildren(child => {\n if ((child as IGroup).isContainer) {\n const targets = (child as IGroup).findAll(callback, true) as T[];\n if (targets.length) {\n nodes = nodes.concat(targets);\n }\n }\n });\n }\n return nodes;\n }\n\n /**\n * 通过用户设置的 id 查找对应的图形元素\n * @param id 子节点的 id\n */\n getElementById(id: string | number): INode | null {\n return this.find(node => node.id === id, true);\n }\n\n /**\n * @alias getElementById\n * 通过用户设置的 id 查找对应的图形元素\n * @param id 子节点的 id\n */\n findChildById(id: string | number): INode | null {\n return this.getElementById(id);\n }\n\n /**\n * 通过内部生成的节点 id:_uid 查找对应的图形元素\n * @param id 子节点的key\n */\n findChildByUid(uid: number): INode | null {\n if (!this._idMap) {\n return null;\n }\n return this._idMap.get(uid) || null;\n }\n\n /**\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n getElementsByName(name: string) {\n return this.findAll(node => node.name === name, true);\n }\n\n /**\n * @alias getElementsByName\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n findChildrenByName(name: string) {\n return this.getElementsByName(name);\n }\n /**\n * 根据用户传入的 type 查找元素,返回匹配的元素集合\n * @param type 用户设置的图形类型\n * @returns 匹配 type 的元素集合\n */\n getElementsByType(type: string) {\n return this.findAll(node => node.type === type, true);\n }\n\n /**\n * 根据名字查找元素,只返回第一个查找到的元素\n * @deprecated 待 vis-component & chartspace 修改之后删除\n * @param name\n * @param deep\n * @returns\n */\n getChildByName(name: string, deep: boolean = false) {\n return this.find(node => node.name === name, deep);\n }\n\n getChildAt(idx: number): INode | null {\n let c = this._firstChild;\n if (!c) {\n return null;\n }\n for (let i = 0; i < idx; i++) {\n if (!c._next) {\n return null;\n }\n c = c._next;\n }\n return c;\n }\n\n at(idx: number): INode | null {\n return this.getChildAt(idx);\n }\n\n /**\n * 返回的是一个布尔值,来表示传入的节点是否为该节点的后代节点。\n * @param node 判断是否包含的节点\n */\n containNode(node: INode): boolean {\n if (!this._idMap) {\n return false;\n }\n if (this._idMap.has(node._uid)) {\n return true;\n }\n let child = this._firstChild;\n while (child) {\n if (child.containNode(node)) {\n return true;\n }\n child = child._next;\n }\n return false;\n }\n\n /**\n * 方法返回上下文中的根节点,不常用\n */\n getRootNode(): INode {\n let parent = this.parent;\n while (parent?.parent) {\n parent = parent.parent;\n }\n return parent || this;\n }\n\n /**\n * 方法返回一个布尔值,表明当前节点是否包含有子节点.\n */\n hasChildNodes(): boolean {\n return this._firstChild !== null;\n }\n\n /* 语法糖 */\n addChild(node: INode): INode | null {\n return this.appendChild(node);\n }\n add(node: INode): INode | null {\n return this.appendChild(node);\n }\n getChildren(): INode[] {\n const nodes: INode[] = [];\n let child = this._firstChild;\n while (child) {\n nodes.push(child);\n child = child._next;\n }\n return nodes;\n }\n\n /**\n * 判断该节点是否是node的子节点\n * @param node\n */\n isChildOf(node: INode): boolean {\n if (!this.parent) {\n return false;\n }\n return this.parent._uid === node._uid;\n }\n\n /**\n * 判断该节点是否是node的父节点\n * @param node\n */\n isParentOf(node: INode): boolean {\n return node.isChildOf(this);\n }\n\n /**\n * 判断节点是否是node的后代节点\n * @param node\n */\n isDescendantsOf(node: INode): boolean {\n let parent = this.parent;\n if (!parent) {\n return false;\n }\n do {\n if (parent._uid === node._uid) {\n return true;\n }\n parent = parent.parent;\n } while (parent !== null);\n\n return false;\n }\n\n /**\n * 判断节点是否是node的祖先节点\n * @param node\n */\n isAncestorsOf(node: INode): boolean {\n return node.isDescendantsOf(this);\n }\n\n getAncestor(idx: number): INode {\n throw new Error('暂不支持');\n }\n\n /**\n * 设置该节点的所有后代节点某个属性\n * @param propsName 属性名\n * @param propsValue 属性值\n */\n setAllDescendantsProps(propsName: string, propsValue: any) {\n let child = this._firstChild;\n while (child) {\n child[propsName] = propsValue;\n child.setAllDescendantsProps(propsName, propsValue);\n child = child._next;\n }\n }\n /**\n * 设置当前节点的count属性,会更改父节点的count属性\n * @param deltaCount delta count\n */\n private setCount(deltaCount: number): void {\n this._count += deltaCount;\n let parent = this.parent;\n if (!parent) {\n return;\n }\n do {\n parent._count += deltaCount;\n parent = parent.parent;\n } while (parent !== null);\n }\n\n clone(): INode {\n throw new Error('暂不支持');\n }\n\n /**\n * clone to node\n * @param node\n */\n cloneTo(node: INode): void {\n throw new Error('暂不支持');\n }\n\n /***************语法糖***************/\n getParent(): INode | null {\n return this.parent;\n }\n\n del(child: INode): INode | null {\n return this.removeChild(child);\n }\n\n // 事件相关别名\n /**\n * @alias on\n * @param type\n * @param listener\n * @param options\n */\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n const capture =\n (isBoolean(options, true) && options) || (isObject(options) && (options as AddEventListenerOptions).capture);\n const once = isObject(options) && (options as AddEventListenerOptions).once;\n const context = isFunction(listener) ? undefined : listener;\n\n type = capture ? `${type}capture` : type;\n listener = isFunction(listener) ? (listener as LooseFunction) : (listener as EventListenerObject).handleEvent;\n\n if (once) {\n super.once(type, listener, context);\n } else {\n super.on(type, listener, context);\n }\n return this;\n }\n\n on(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n return this.addEventListener(type, listener, options);\n }\n\n /**\n * @alias off\n * @param type\n * @param listener\n * @param options\n * @returns\n */\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n const capture =\n (isBoolean(options, true) && options) || (isObject(options) && (options as AddEventListenerOptions).capture);\n const context = isFunction(listener) ? undefined : listener;\n\n type = capture ? `${type}capture` : type;\n listener = isFunction(listener) ? (listener as LooseFunction) : (listener as EventListenerObject).handleEvent;\n\n const once = isObject(options) && (options as AddEventListenerOptions).once;\n super.off(type, listener, context, once);\n\n return this;\n }\n\n /**\n * @alias off\n * @param type\n * @param listener\n * @param options\n * @returns\n */\n off(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n return this.removeEventListener(type, listener, options);\n }\n\n once(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n if (isObject(options)) {\n options.once = true;\n return this.addEventListener(type, listener, options);\n }\n return this.addEventListener(type, listener, { once: true });\n }\n\n removeAllEventListeners() {\n super.removeAllListeners();\n return this;\n }\n\n removeAllListeners(): this {\n return this.removeAllEventListeners();\n }\n\n dispatchEvent(event: any, ...args: any) {\n super.emit(event.type, event, ...args);\n return !event.defaultPrevented;\n }\n\n emit(event: any, data?: Dict<any>) {\n return this.dispatchEvent(event, data);\n }\n\n release() {\n // 卸载事件\n this.removeAllListeners();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/node-tree.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,MAAM,OAAO,IAAK,SAAQ,YAAsB;IAkB9C,IAAI,eAAe;QACjB,OAAO,IAAI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AG,IAAI,CAAC;YACpB,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SACvD;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,uBAAuB;QACrB,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kBAAkB;QAChB,OAAO,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACxC,CAAC;IAED,aAAa,CAAC,KAAU,EAAE,GAAG,IAAS;QACpC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;QACvC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC;IACjC,CAAC;IAED,IAAI,CAAC,KAAU,EAAE,IAAgB;QAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,OAAO;QAEL,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;CACF","file":"node-tree.js","sourcesContent":["import type { Dict, LooseFunction } from '@visactor/vutils';\nimport { EventEmitter, Logger, isBoolean, isFunction, isObject } from '@visactor/vutils';\nimport { Generator } from '../common/generator';\nimport type { INode, IGroup } from '../interface';\n\nexport class Node extends EventEmitter<any, any> implements INode {\n parent: any;\n declare name: string;\n declare id: string | number;\n\n declare _uid: number;\n _prev?: INode;\n _next?: INode;\n protected _firstChild: INode | null;\n protected _lastChild: INode | null;\n protected _idMap?: Map<number, INode>;\n protected _count: number;\n // protected _dirty?: boolean; // dirty表示属性是否有修改\n protected _structEdit?: boolean; // 树的结构是否发生修改\n protected _nodeList?: INode[]; // 用于有顺序的插入(正常情况用不到)\n\n declare _ignoreWarn?: boolean;\n\n get previousSibling(): INode | null {\n return this._prev;\n }\n\n get nextSibling(): INode | null {\n return this._next;\n }\n\n get children(): INode[] {\n return this.getChildren();\n }\n get firstChild(): INode | null {\n return this._firstChild;\n }\n get lastChild(): INode | null {\n return this._lastChild;\n }\n get count(): number {\n return this._count;\n }\n get childrenCount(): number {\n if (!this._idMap) {\n return 0;\n }\n return this._idMap.size;\n }\n // get dirty(): boolean {\n // return !!this._dirty;\n // }\n\n constructor() {\n super();\n this._uid = Generator.GenAutoIncrementId();\n this._firstChild = null;\n this._lastChild = null;\n this.parent = null;\n this._count = 1;\n }\n\n forEachChildren<T extends INode = INode>(cb: (item: T, index: number) => void | boolean, reverse: boolean = false) {\n if (reverse) {\n let child = this._lastChild;\n let i = 0;\n while (child) {\n const breakTag = cb(child as T, i++);\n if (breakTag) {\n return;\n }\n child = child._prev;\n }\n } else {\n let child = this._firstChild;\n let i = 0;\n while (child) {\n const breakTag = cb(child as T, i++);\n if (breakTag) {\n return;\n }\n child = child._next;\n }\n }\n }\n\n async forEachChildrenAsync<T extends INode = INode>(\n cb: (item: T, index: number) => Promise<void | boolean> | void | boolean,\n reverse: boolean = false\n ) {\n if (reverse) {\n let child = this._lastChild;\n let i = 0;\n while (child) {\n let breakTag = cb(child as T, i++);\n if ((breakTag as any).then) {\n breakTag = await breakTag;\n }\n if (breakTag) {\n return;\n }\n child = child._prev;\n }\n } else {\n let child = this._firstChild;\n let i = 0;\n while (child) {\n let breakTag = cb(child as T, i++);\n if ((breakTag as any).then) {\n breakTag = await breakTag;\n }\n if (breakTag) {\n return;\n }\n child = child._next;\n }\n }\n }\n\n forEach<T extends INode = INode>(cb: (item: T, index: number) => void): void {\n return this.forEachChildren<T>(cb);\n }\n\n /**\n * 方法将一个节点附加到指定父节点的子节点列表的末尾处。\n * 如果将被插入的节点已经存在于当前文档的文档树中,那么 appendChild() 只会将它从原先的位置移动到新的位置(不需要事先移除要移动的节点)。\n * 不能append父级元素\n * @param node 要插入的节点\n */\n appendChild(node: INode, highPerformance: boolean = true): INode | null {\n if (this._uid === node._uid) {\n return null;\n }\n if (!highPerformance && node.isAncestorsOf(this)) {\n throw new Error('【Node::appendChild】不能将父辈元素append为子元素');\n }\n\n // 清理该节点的上次关系\n node.parent && node.parent.removeChild(node);\n node.parent = this as unknown as Node;\n\n if (!this._lastChild) {\n this._firstChild = this._lastChild = node;\n node._prev = node._next = null;\n } else {\n this._lastChild._next = node;\n node._prev = this._lastChild;\n this._lastChild = node;\n }\n if (!this._idMap) {\n this._idMap = new Map();\n }\n this._idMap.set(node._uid, node);\n\n this.setCount(node.count);\n\n this._structEdit = true;\n return node;\n }\n\n /**\n * 方法将一个节点数组附加到指定父节点的子节点列表的末尾处。\n * 不会判断元素是否是自身以及是否是父元素或者是否是其他节点的子元素\n * @param nodes 要插入的节点数组\n */\n appendChildArrHighPerformance(nodes: INode[], replace: boolean = false): INode[] | null {\n console.error('暂不支持该函数');\n\n return nodes;\n }\n\n /**\n * 方法在参考节点之前插入一个拥有指定父节点的子节点。\n * 如果给定的子节点是对文档中现有节点的引用,\n * insertBefore() 会将其从当前位置移动到新位置(在将节点附加到其他节点之前,不需要从其父节点删除该节点)。\n * 不能insert父级元素\n * @param newNode 要插入的节点\n * @param referenceNode 插入到referenceNode之前\n */\n insertBefore(newNode: INode, referenceNode: INode | undefined): INode | null {\n if (!referenceNode) {\n return this.appendChild(newNode);\n }\n if (this._uid === newNode._uid) {\n return null;\n }\n if (newNode.isAncestorsOf(this)) {\n throw new Error('【Node::insertBefore】不能将父辈元素insert为子元素');\n }\n if (referenceNode.parent !== (this as unknown as Node)) {\n return null;\n }\n\n newNode.parent && newNode.parent.removeChild(newNode);\n newNode.parent = this as unknown as Node;\n\n newNode._prev = referenceNode._prev;\n if (!referenceNode._prev) {\n this._firstChild = newNode;\n } else {\n referenceNode._prev._next = newNode;\n }\n referenceNode._prev = newNode;\n newNode._next = referenceNode;\n if (!this._idMap) {\n this._idMap = new Map();\n }\n this._idMap.set(newNode._uid, newNode);\n\n this._structEdit = true;\n this.setCount(newNode.count);\n\n return newNode;\n }\n\n /**\n * 方法在参考节点之后插入一个拥有指定父节点的子节点。\n * 如果给定的子节点是对文档中现有节点的引用,\n * insertAfter() 会将其从当前位置移动到新位置(在将节点附加到其他节点之前,不需要从其父节点删除该节点)。\n * 不能insert父级元素\n * @param newNode 要插入的节点\n * @param referenceNode 插入到referenceNode之后\n */\n insertAfter(newNode: INode, referenceNode: INode | undefined): INode | null {\n if (!referenceNode) {\n return this.appendChild(newNode);\n }\n if (this._uid === newNode._uid) {\n return null;\n }\n if (newNode.isAncestorsOf(this)) {\n throw new Error('【Node::insertAfter】不能将父辈元素insert为子元素');\n }\n if (referenceNode.parent !== (this as unknown as Node)) {\n return null;\n }\n\n newNode.parent && newNode.parent.removeChild(newNode);\n newNode.parent = this as unknown as Node;\n\n if (!referenceNode._next) {\n this._lastChild = newNode;\n } else {\n referenceNode._next._prev = newNode;\n newNode._next = referenceNode._next;\n }\n referenceNode._next = newNode;\n newNode._prev = referenceNode;\n if (!this._idMap) {\n this._idMap = new Map();\n }\n this._idMap.set(newNode._uid, newNode);\n\n this._structEdit = true;\n this.setCount(newNode.count);\n\n return newNode;\n }\n\n /**\n * 方法在参考节点之前插入一个拥有指定父节点的子节点。\n * 如果给定的子节点是对文档中现有节点的引用,\n * insertBefore() 会将其从当前位置移动到新位置(在将节点附加到其他节点之前,不需要从其父节点删除该节点)。\n * 不能insert父级元素\n * @param newNode 要插入的节点\n * @param referenceNode 插入到referenceNode之前\n */\n insertInto(newNode: INode, idx: number): INode | null {\n if (!this._ignoreWarn && this._nodeList) {\n Logger.getInstance().warn('insertIntoKeepIdx和insertInto混用可能会存在错误');\n }\n if (idx >= this.childrenCount) {\n return this.appendChild(newNode);\n }\n if (this._uid === newNode._uid) {\n return null;\n }\n if (newNode.isAncestorsOf(this)) {\n throw new Error('【Node::insertBefore】不能将父辈元素insert为子元素');\n }\n\n newNode.parent && newNode.parent.removeChild(newNode);\n newNode.parent = this as unknown as Node;\n\n if (idx === 0) {\n newNode._next = this._firstChild;\n this._firstChild && (this._firstChild._prev = newNode);\n newNode._prev = null;\n this._firstChild = newNode;\n } else {\n let child = this._firstChild;\n for (let i = 0; i < idx; i++) {\n if (!child) {\n return null;\n }\n if (i > 0) {\n child = child._next;\n }\n }\n if (!child) {\n return null;\n }\n newNode._next = child._next;\n newNode._prev = child;\n child._next = newNode;\n if (newNode._next) {\n newNode._next._prev = newNode;\n }\n }\n if (!this._idMap) {\n this._idMap = new Map();\n }\n this._idMap.set(newNode._uid, newNode);\n\n // // 预期不会执行\n // if (idx === this.childrenCount) {\n // this._lastChild = newNode;\n // }\n this._structEdit = true;\n this.setCount(newNode.count);\n\n return newNode;\n }\n\n /**\n * 相比于insertInto,会保持idx顺序,举例:\n * 先插入idx:6的元素,再插入idx:2的元素,此时idx:2的元素会放置在idx为6的元素之前\n */\n insertIntoKeepIdx(newNode: INode, idx: number): INode | null {\n if (!this._nodeList) {\n this._nodeList = this.children;\n }\n // 如果这个位置有了,那就将这个位置之前的元素向后移动\n if (this._nodeList[idx]) {\n const node = this._nodeList[idx];\n this._nodeList.splice(idx, 0, newNode);\n return this.insertBefore(newNode, node);\n }\n // 查找idx之前的元素,插入到其后面\n this._nodeList[idx] = newNode;\n let node: INode | undefined;\n for (let i = idx - 1; i >= 0; i--) {\n node = this._nodeList[i];\n if (node) {\n break;\n }\n }\n if (node) {\n return node._next ? this.insertBefore(newNode, node._next) : this.appendChild(newNode);\n }\n this._ignoreWarn = true;\n const data = this.insertInto(newNode, 0);\n this._ignoreWarn = false;\n return data;\n }\n\n /**\n * 方法从DOM中删除一个子节点。返回删除的节点。\n * @param child 要删除的子节点\n */\n removeChild(child: INode): INode | null {\n if (!this._idMap) {\n return null;\n }\n if (!this._idMap.has(child._uid)) {\n return null;\n }\n this._idMap.delete(child._uid);\n if (this._nodeList) {\n // 找到idx\n const idx = this._nodeList.findIndex(n => n === child);\n if (idx > 0) {\n this._nodeList.splice(idx, 1);\n }\n }\n\n if (!child._prev) {\n this._firstChild = child._next;\n } else {\n child._prev._next = child._next;\n }\n if (child._next) {\n child._next._prev = child._prev;\n } else {\n this._lastChild = child._prev;\n }\n\n // 重置属性\n child.parent = null;\n child._prev = null;\n child._next = null;\n\n this._structEdit = true;\n this.setCount(-child.count);\n\n return child;\n }\n\n /**\n * 从当前节点的父节点删除当前节点\n */\n delete() {\n if (this.parent) {\n this.parent.removeChild(this);\n }\n }\n\n /**\n * 删除所有的孩子节点\n */\n removeAllChild(deep?: boolean) {\n if (!this._idMap) {\n return;\n }\n let child = this._firstChild;\n while (child) {\n const next = child._next;\n child.parent = null;\n // child._rootNode = child;\n child._prev = null;\n child._next = null;\n child = child._next;\n child = next;\n }\n\n this._firstChild = null;\n this._lastChild = null;\n this._idMap.clear();\n\n this._structEdit = true;\n this.setCount(-this._count + 1);\n }\n\n /**\n * 方法用指定的节点替换当前节点的一个子节点,并返回被替换掉的节点。\n * 如果该节点已经存在于DOM树中,则它首先会被从原始位置删除。\n * 不能replace父级元素\n * @param newChild 新节点\n * @param oldChild 旧节点\n */\n replaceChild(newChild: INode, oldChild: INode): INode | null {\n throw new Error('暂不支持');\n }\n\n /**\n * 根据自定义逻辑查找元素,返回单一图形元素\n * @param callback 自定义查找过滤器\n * @param deep 是否进行深度查找,默认为 false\n * @returns 返回匹配的图形元素\n */\n find<T extends INode = INode>(callback: (node: T, index: number) => boolean, deep: boolean = false): T | null {\n let target: T | null = null;\n this.forEachChildren((node: T, index: number) => {\n if (node !== (this as unknown as INode) && callback(node, index)) {\n target = node;\n return true; // 提前退出循环\n }\n return false;\n });\n\n if (deep) {\n this.forEachChildren(child => {\n if ((child as IGroup).isContainer) {\n const node = (child as IGroup).find(callback, true) as T;\n if (node) {\n target = node;\n return true; // 提前退出循环\n }\n }\n return false;\n });\n }\n\n return target;\n }\n\n /**\n * 根据自定义逻辑查找元素,返回匹配的元素集合\n * @param callback 自定义查找过滤器\n * @param deep 是否进行深度查找,默认为 false\n * @returns 返回匹配的图形元素集合\n */\n findAll<T extends INode = INode>(callback: (node: T, index: number) => boolean, deep: boolean = false): T[] {\n let nodes: T[] = [];\n this.forEachChildren((node: T, index) => {\n if (node !== (this as unknown as INode) && callback(node, index)) {\n nodes.push(node);\n }\n });\n\n if (deep) {\n this.forEachChildren(child => {\n if ((child as IGroup).isContainer) {\n const targets = (child as IGroup).findAll(callback, true) as T[];\n if (targets.length) {\n nodes = nodes.concat(targets);\n }\n }\n });\n }\n return nodes;\n }\n\n /**\n * 通过用户设置的 id 查找对应的图形元素\n * @param id 子节点的 id\n */\n getElementById(id: string | number): INode | null {\n return this.find(node => node.id === id, true);\n }\n\n /**\n * @alias getElementById\n * 通过用户设置的 id 查找对应的图形元素\n * @param id 子节点的 id\n */\n findChildById(id: string | number): INode | null {\n return this.getElementById(id);\n }\n\n /**\n * 通过内部生成的节点 id:_uid 查找对应的图形元素\n * @param id 子节点的key\n */\n findChildByUid(uid: number): INode | null {\n if (!this._idMap) {\n return null;\n }\n return this._idMap.get(uid) || null;\n }\n\n /**\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n getElementsByName(name: string) {\n return this.findAll(node => node.name === name, true);\n }\n\n /**\n * @alias getElementsByName\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n findChildrenByName(name: string) {\n return this.getElementsByName(name);\n }\n /**\n * 根据用户传入的 type 查找元素,返回匹配的元素集合\n * @param type 用户设置的图形类型\n * @returns 匹配 type 的元素集合\n */\n getElementsByType(type: string) {\n return this.findAll(node => node.type === type, true);\n }\n\n /**\n * 根据名字查找元素,只返回第一个查找到的元素\n * @deprecated 待 vis-component & chartspace 修改之后删除\n * @param name\n * @param deep\n * @returns\n */\n getChildByName(name: string, deep: boolean = false) {\n return this.find(node => node.name === name, deep);\n }\n\n getChildAt(idx: number): INode | null {\n let c = this._firstChild;\n if (!c) {\n return null;\n }\n for (let i = 0; i < idx; i++) {\n if (!c._next) {\n return null;\n }\n c = c._next;\n }\n return c;\n }\n\n at(idx: number): INode | null {\n return this.getChildAt(idx);\n }\n\n /**\n * 返回的是一个布尔值,来表示传入的节点是否为该节点的后代节点。\n * @param node 判断是否包含的节点\n */\n containNode(node: INode): boolean {\n if (!this._idMap) {\n return false;\n }\n if (this._idMap.has(node._uid)) {\n return true;\n }\n let child = this._firstChild;\n while (child) {\n if (child.containNode(node)) {\n return true;\n }\n child = child._next;\n }\n return false;\n }\n\n /**\n * 方法返回上下文中的根节点,不常用\n */\n getRootNode(): INode {\n let parent = this.parent;\n while (parent?.parent) {\n parent = parent.parent;\n }\n return parent || this;\n }\n\n /**\n * 方法返回一个布尔值,表明当前节点是否包含有子节点.\n */\n hasChildNodes(): boolean {\n return this._firstChild !== null;\n }\n\n /* 语法糖 */\n addChild(node: INode): INode | null {\n return this.appendChild(node);\n }\n add(node: INode): INode | null {\n return this.appendChild(node);\n }\n getChildren(): INode[] {\n const nodes: INode[] = [];\n let child = this._firstChild;\n while (child) {\n nodes.push(child);\n child = child._next;\n }\n return nodes;\n }\n\n /**\n * 判断该节点是否是node的子节点\n * @param node\n */\n isChildOf(node: INode): boolean {\n if (!this.parent) {\n return false;\n }\n return this.parent._uid === node._uid;\n }\n\n /**\n * 判断该节点是否是node的父节点\n * @param node\n */\n isParentOf(node: INode): boolean {\n return node.isChildOf(this);\n }\n\n /**\n * 判断节点是否是node的后代节点\n * @param node\n */\n isDescendantsOf(node: INode): boolean {\n let parent = this.parent;\n if (!parent) {\n return false;\n }\n do {\n if (parent._uid === node._uid) {\n return true;\n }\n parent = parent.parent;\n } while (parent !== null);\n\n return false;\n }\n\n /**\n * 判断节点是否是node的祖先节点\n * @param node\n */\n isAncestorsOf(node: INode): boolean {\n return node.isDescendantsOf(this);\n }\n\n getAncestor(idx: number): INode {\n throw new Error('暂不支持');\n }\n\n /**\n * 设置该节点的所有后代节点某个属性\n * @param propsName 属性名\n * @param propsValue 属性值\n */\n setAllDescendantsProps(propsName: string, propsValue: any) {\n let child = this._firstChild;\n while (child) {\n child[propsName] = propsValue;\n child.setAllDescendantsProps(propsName, propsValue);\n child = child._next;\n }\n }\n /**\n * 设置当前节点的count属性,会更改父节点的count属性\n * @param deltaCount delta count\n */\n private setCount(deltaCount: number): void {\n this._count += deltaCount;\n let parent = this.parent;\n if (!parent) {\n return;\n }\n do {\n parent._count += deltaCount;\n parent = parent.parent;\n } while (parent !== null);\n }\n\n clone(): INode {\n throw new Error('暂不支持');\n }\n\n /**\n * clone to node\n * @param node\n */\n cloneTo(node: INode): void {\n throw new Error('暂不支持');\n }\n\n /***************语法糖***************/\n getParent(): INode | null {\n return this.parent;\n }\n\n del(child: INode): INode | null {\n return this.removeChild(child);\n }\n\n // 事件相关别名\n /**\n * @alias on\n * @param type\n * @param listener\n * @param options\n */\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n const capture =\n (isBoolean(options, true) && options) || (isObject(options) && (options as AddEventListenerOptions).capture);\n const once = isObject(options) && (options as AddEventListenerOptions).once;\n const context = isFunction(listener) ? undefined : listener;\n\n type = capture ? `${type}capture` : type;\n listener = isFunction(listener) ? (listener as LooseFunction) : (listener as EventListenerObject).handleEvent;\n\n if (once) {\n super.once(type, listener, context);\n } else {\n super.on(type, listener, context);\n }\n return this;\n }\n\n on(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n return this.addEventListener(type, listener, options);\n }\n\n /**\n * @alias off\n * @param type\n * @param listener\n * @param options\n * @returns\n */\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n const capture =\n (isBoolean(options, true) && options) || (isObject(options) && (options as AddEventListenerOptions).capture);\n const context = isFunction(listener) ? undefined : listener;\n\n type = capture ? `${type}capture` : type;\n listener = isFunction(listener) ? (listener as LooseFunction) : (listener as EventListenerObject).handleEvent;\n\n const once = isObject(options) && (options as AddEventListenerOptions).once;\n super.off(type, listener, context, once);\n\n return this;\n }\n\n /**\n * @alias off\n * @param type\n * @param listener\n * @param options\n * @returns\n */\n off(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n return this.removeEventListener(type, listener, options);\n }\n\n once(\n type: string,\n listener: EventListenerOrEventListenerObject | LooseFunction,\n options?: AddEventListenerOptions | boolean\n ) {\n if (isObject(options)) {\n options.once = true;\n return this.addEventListener(type, listener, options);\n }\n return this.addEventListener(type, listener, { once: true });\n }\n\n removeAllEventListeners() {\n super.removeAllListeners();\n return this;\n }\n\n removeAllListeners(): this {\n return this.removeAllEventListeners();\n }\n\n dispatchEvent(event: any, ...args: any) {\n super.emit(event.type, event, ...args);\n return !event.defaultPrevented;\n }\n\n emit(event: any, data?: Dict<any>) {\n return this.dispatchEvent(event, data);\n }\n\n release() {\n // 卸载事件\n this.removeAllListeners();\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type AABBBounds, type OBBBounds } from '@visactor/vutils';
2
- import type { IRichText, IRichTextCharacter, RichTextGlobalAlignType, RichTextGlobalBaselineType, RichTextVerticalDirection, RichTextWordBreak, IRichTextGraphicAttribute, IStage, ILayer, IRichTextIcon, EventPoint } from '../interface';
2
+ import type { IRichText, IRichTextCharacter, RichTextGlobalAlignType, RichTextGlobalBaselineType, RichTextVerticalDirection, RichTextWordBreak, IRichTextGraphicAttribute, IRichTextImageCharacter, IRichTextParagraphCharacter, IStage, ILayer, IRichTextIcon, EventPoint } from '../interface';
3
3
  import { Graphic } from './graphic';
4
4
  import Frame from './richtext/frame';
5
5
  export declare class RichText extends Graphic<IRichTextGraphicAttribute> implements IRichText {
@@ -69,6 +69,49 @@ export declare class RichText extends Graphic<IRichTextGraphicAttribute> impleme
69
69
  protected needUpdateTags(keys: string[]): boolean;
70
70
  protected needUpdateTag(key: string): boolean;
71
71
  getFrameCache(): Frame;
72
+ combinedStyleToCharacter(config: IRichTextImageCharacter | IRichTextParagraphCharacter): {
73
+ lineHeight?: string | number;
74
+ textAlign?: CanvasTextAlign;
75
+ textBaseline?: CanvasTextBaseline;
76
+ direction?: import("../interface").RichTextLayoutDirectionType;
77
+ text: string | number;
78
+ fontSize: any;
79
+ fontFamily: any;
80
+ fill: any;
81
+ stroke: any;
82
+ fontWeight: any;
83
+ fontStyle: any;
84
+ textDecoration?: import("../interface").RichTextTextDecoration;
85
+ script?: import("../interface").RichTextScript;
86
+ underline?: boolean;
87
+ lineThrough?: boolean;
88
+ } | {
89
+ lineHeight?: string | number;
90
+ textAlign?: CanvasTextAlign;
91
+ textBaseline?: CanvasTextBaseline;
92
+ direction?: import("../interface").RichTextLayoutDirectionType;
93
+ image: string | HTMLImageElement | HTMLCanvasElement;
94
+ width: number;
95
+ height: number;
96
+ backgroundShowMode?: "always" | "hover";
97
+ backgroundFill?: boolean | import("../interface").IColor;
98
+ backgroundFillOpacity?: number;
99
+ backgroundStroke?: boolean | import("../interface").IColor;
100
+ backgroundStrokeOpacity?: number;
101
+ backgroundRadius?: number;
102
+ backgroundWidth?: number;
103
+ backgroundHeight?: number;
104
+ id?: string;
105
+ margin?: number | number[];
106
+ funcType?: string;
107
+ hoverImage?: string | HTMLImageElement | HTMLCanvasElement;
108
+ fill: any;
109
+ stroke: any;
110
+ fontSize: any;
111
+ fontFamily: any;
112
+ fontStyle: any;
113
+ fontWeight: any;
114
+ };
72
115
  doUpdateFrameCache(): void;
73
116
  clone(): RichText;
74
117
  setStage(stage?: IStage, layer?: ILayer): void;
@@ -119,11 +119,22 @@ export class RichText extends Graphic {
119
119
  return this.shouldUpdateShape() && (this.doUpdateFrameCache(), this.clearUpdateShapeTag()),
120
120
  this._frameCache;
121
121
  }
122
+ combinedStyleToCharacter(config) {
123
+ const {fill: fill, stroke: stroke, fontSize: fontSize, fontFamily: fontFamily, fontStyle: fontStyle, fontWeight: fontWeight} = this.attribute;
124
+ return Object.assign({
125
+ fill: fill,
126
+ stroke: stroke,
127
+ fontSize: fontSize,
128
+ fontFamily: fontFamily,
129
+ fontStyle: fontStyle,
130
+ fontWeight: fontWeight
131
+ }, config);
132
+ }
122
133
  doUpdateFrameCache() {
123
134
  var _a;
124
135
  const {textConfig: textConfig = [], maxWidth: maxWidth, maxHeight: maxHeight, width: width, height: height, ellipsis: ellipsis, wordBreak: wordBreak, verticalDirection: verticalDirection, textAlign: textAlign, textBaseline: textBaseline, layoutDirection: layoutDirection, singleLine: singleLine} = this.attribute, paragraphs = [];
125
136
  for (let i = 0; i < textConfig.length; i++) if ("image" in textConfig[i]) {
126
- const config = textConfig[i], iconCache = config.id && this._frameCache && this._frameCache.icons && this._frameCache.icons.get(config.id);
137
+ const config = this.combinedStyleToCharacter(textConfig[i]), iconCache = config.id && this._frameCache && this._frameCache.icons && this._frameCache.icons.get(config.id);
127
138
  if (iconCache) paragraphs.push(iconCache); else {
128
139
  const icon = new RichTextIcon(config);
129
140
  icon.successCallback = () => {
@@ -132,7 +143,7 @@ export class RichText extends Graphic {
132
143
  }, icon.richtextId = config.id, paragraphs.push(icon);
133
144
  }
134
145
  } else {
135
- const richTextConfig = textConfig[i];
146
+ const richTextConfig = this.combinedStyleToCharacter(textConfig[i]);
136
147
  if (isNumber(richTextConfig.text) && (richTextConfig.text = `${richTextConfig.text}`),
137
148
  richTextConfig.text && richTextConfig.text.includes("\n")) {
138
149
  const textParts = richTextConfig.text.split("\n");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/richtext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmC,MAAM,kBAAkB,CAAC;AAgB7E,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,sBAAsB,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AI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBACrE,QAAQ,GAAG,IAAI,CAAC;gBAEhB,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAA,QAAQ,CAAC,SAAS,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBACnD,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAA,QAAQ,CAAC,SAAS,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;aACpD;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,oBAAoB;QAClB,OAAO,QAAQ,CAAC,mBAAmB,CAAC;IACtC,CAAC;;AA3WM,4BAAmB,mBACxB,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,CAAC,EACZ,iBAAiB,EAAE,CAAC,EACpB,SAAS,EAAE,CAAC,EACZ,YAAY,EAAE,CAAC,EACf,UAAU,EAAE,CAAC,EACb,eAAe,EAAE,CAAC,IACf,mBAAmB,EACtB;AAqWJ,MAAM,UAAU,cAAc,CAAC,UAAqC;IAClE,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC","file":"richtext.js","sourcesContent":["import { isNumber, type AABBBounds, type OBBBounds } from '@visactor/vutils';\nimport type {\n IRichText,\n IRichTextCharacter,\n RichTextGlobalAlignType,\n RichTextGlobalBaselineType,\n RichTextVerticalDirection,\n RichTextWordBreak,\n IRichTextGraphicAttribute,\n IRichTextImageCharacter,\n IRichTextParagraphCharacter,\n IStage,\n ILayer,\n IRichTextIcon,\n EventPoint\n} from '../interface';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport { DefaultRichTextAttribute } from './config';\nimport Frame from './richtext/frame';\nimport Paragraph from './richtext/paragraph';\nimport Wrapper from './richtext/wrapper';\nimport { getTheme } from './theme';\nimport { RichTextIcon } from './richtext/icon';\nimport type { FederatedMouseEvent } from '../event';\nimport { application } from '../application';\nimport { parsePadding } from '../common/utils';\nimport { RICHTEXT_NUMBER_TYPE } from './constants';\n\nconst RICHTEXT_UPDATE_TAG_KEY = [\n 'width',\n 'height',\n 'ellipsis',\n 'wordBreak',\n 'verticalDirection',\n 'maxHeight',\n 'maxWidth',\n 'textAlign',\n 'textBaseline',\n 'textConfig',\n 'layoutDirection',\n ...GRAPHIC_UPDATE_TAG_KEY\n];\n\nexport class RichText extends Graphic<IRichTextGraphicAttribute> implements IRichText {\n type: 'richtext' = 'richtext';\n\n _frameCache: Frame; // 富文本布局画布\n _currentHoverIcon: IRichTextIcon | null = null;\n\n static NOWORK_ANIMATE_ATTR = {\n ellipsis: 1,\n wordBreak: 1,\n verticalDirection: 1,\n textAlign: 1,\n textBaseline: 1,\n textConfig: 1,\n layoutDirection: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n constructor(params?: IRichTextGraphicAttribute) {\n super(params);\n this.numberType = RICHTEXT_NUMBER_TYPE;\n }\n\n get width(): number {\n return this.attribute.width ?? DefaultRichTextAttribute.width;\n }\n set width(w: number) {\n if (this.attribute.width === w) {\n return;\n }\n this.attribute.width = w;\n this.addUpdateShapeAndBoundsTag();\n }\n get height(): number {\n return this.attribute.height ?? DefaultRichTextAttribute.height;\n }\n set height(h: number) {\n if (this.attribute.height === h) {\n return;\n }\n this.attribute.height = h;\n this.addUpdateShapeAndBoundsTag();\n }\n get maxWidth(): number | undefined {\n return this.attribute.maxWidth;\n }\n set maxWidth(mw: number | undefined) {\n if (this.attribute.maxWidth === mw) {\n return;\n }\n this.attribute.maxWidth = mw;\n this.addUpdateShapeAndBoundsTag();\n }\n get maxHeight(): number | undefined {\n return this.attribute.maxHeight;\n }\n set maxHeight(mh: number | undefined) {\n if (this.attribute.maxHeight === mh) {\n return;\n }\n this.attribute.maxHeight = mh;\n this.addUpdateShapeAndBoundsTag();\n }\n get ellipsis(): boolean | string {\n return this.attribute.ellipsis ?? DefaultRichTextAttribute.ellipsis;\n }\n set ellipsis(e: boolean | string) {\n if (this.attribute.ellipsis === e) {\n return;\n }\n this.attribute.ellipsis = e;\n this.addUpdateShapeAndBoundsTag();\n }\n get wordBreak(): RichTextWordBreak {\n return this.attribute.wordBreak ?? DefaultRichTextAttribute.wordBreak;\n }\n set wordBreak(wb: RichTextWordBreak) {\n if (this.attribute.wordBreak === wb) {\n return;\n }\n this.attribute.wordBreak = wb;\n this.addUpdateShapeAndBoundsTag();\n }\n get verticalDirection(): RichTextVerticalDirection {\n return this.attribute.verticalDirection ?? DefaultRichTextAttribute.verticalDirection;\n }\n set verticalDirection(vd: RichTextVerticalDirection) {\n if (this.attribute.verticalDirection === vd) {\n return;\n }\n this.attribute.verticalDirection = vd;\n this.addUpdateShapeAndBoundsTag();\n }\n get textAlign(): RichTextGlobalAlignType {\n return this.attribute.textAlign ?? DefaultRichTextAttribute.textAlign;\n }\n set textAlign(align: RichTextGlobalAlignType) {\n if (this.attribute.textAlign === align) {\n return;\n }\n this.attribute.textAlign = align;\n this.addUpdateShapeAndBoundsTag();\n }\n get textBaseline(): RichTextGlobalBaselineType {\n return this.attribute.textBaseline ?? DefaultRichTextAttribute.textBaseline;\n }\n set textBaseline(baseline: RichTextGlobalBaselineType) {\n if (this.attribute.textBaseline === baseline) {\n return;\n }\n this.attribute.textBaseline = baseline;\n this.addUpdateShapeAndBoundsTag();\n }\n get textConfig(): IRichTextCharacter[] {\n return this.attribute.textConfig ?? DefaultRichTextAttribute.textConfig;\n }\n set textConfig(config: IRichTextCharacter[]) {\n this.attribute.textConfig = config;\n this.addUpdateShapeAndBoundsTag();\n }\n\n protected doUpdateAABBBounds(): AABBBounds {\n const richTextTheme = getTheme(this).richtext;\n this._AABBBounds.clear();\n const attribute = this.attribute;\n const bounds = application.graphicService.updateRichTextAABBBounds(\n attribute,\n getTheme(this).richtext,\n this._AABBBounds,\n this\n ) as AABBBounds;\n\n const { boundsPadding = richTextTheme.boundsPadding } = attribute;\n const paddingArray = parsePadding(boundsPadding);\n if (paddingArray) {\n bounds.expand(paddingArray);\n }\n\n this.clearUpdateBoundTag();\n return bounds;\n }\n\n protected tryUpdateOBBBounds(): OBBBounds {\n throw new Error('暂不支持');\n }\n\n getDefaultAttribute(name: string) {\n return DefaultRichTextAttribute[name];\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, RICHTEXT_UPDATE_TAG_KEY);\n }\n getFrameCache(): Frame {\n if (this.shouldUpdateShape()) {\n this.doUpdateFrameCache();\n this.clearUpdateShapeTag();\n }\n return this._frameCache;\n }\n doUpdateFrameCache() {\n // 1. 测量,生成paragraph\n const {\n textConfig = [],\n maxWidth,\n maxHeight,\n width,\n height,\n ellipsis,\n wordBreak,\n verticalDirection,\n textAlign,\n textBaseline,\n layoutDirection,\n singleLine\n } = this.attribute;\n const paragraphs: (Paragraph | RichTextIcon)[] = [];\n\n for (let i = 0; i < textConfig.length; i++) {\n if ('image' in textConfig[i]) {\n const config = textConfig[i] as IRichTextImageCharacter;\n // 直接创建icon Mark\n const iconCache =\n config.id && this._frameCache && this._frameCache.icons && this._frameCache.icons.get(config.id);\n if (iconCache) {\n paragraphs.push(iconCache as RichTextIcon);\n } else {\n const icon = new RichTextIcon(config);\n icon.successCallback = () => {\n this.addUpdateBoundTag();\n this.stage?.renderNextFrame();\n };\n icon.richtextId = config.id;\n paragraphs.push(icon);\n }\n } else {\n const richTextConfig = textConfig[i] as IRichTextParagraphCharacter;\n if (isNumber(richTextConfig.text)) {\n richTextConfig.text = `${richTextConfig.text}`;\n }\n if (richTextConfig.text && richTextConfig.text.includes('\\n')) {\n // 如果有文字内有换行符,将该段文字切为多段,并在后一段加入newLine标记\n const textParts = richTextConfig.text.split('\\n');\n for (let j = 0; j < textParts.length; j++) {\n paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig));\n }\n } else if (richTextConfig.text) {\n paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig));\n }\n }\n }\n\n // 2. 布局,生成frame\n // const frameHeight =\n // typeof maxHeight === 'number' && (!height || height > maxHeight) // height = 0或height>maxHeight,使用maxHeight布局\n // ? maxHeight\n // : height;\n // const frameWidth =\n // typeof maxWidth === 'number' && (!width || width > maxWidth) // height = 0或height>maxWidth,使用maxWidth布局\n // ? maxWidth\n // : width;\n\n const maxWidthFinite = typeof maxWidth === 'number' && Number.isFinite(maxWidth) && maxWidth > 0;\n const maxHeightFinite = typeof maxHeight === 'number' && Number.isFinite(maxHeight) && maxHeight > 0;\n\n const richTextWidthEnable =\n typeof width === 'number' &&\n Number.isFinite(width) &&\n width > 0 &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (!maxWidthFinite || width <= maxWidth);\n const richTextHeightEnable =\n typeof height === 'number' &&\n Number.isFinite(height) &&\n height > 0 &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (!maxHeightFinite || height <= maxHeight);\n\n const frameWidth = richTextWidthEnable ? width : maxWidthFinite ? maxWidth : 0;\n const frameHeight = richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0;\n\n const frame = new Frame(\n 0,\n 0,\n frameWidth || 0,\n frameHeight || 0,\n ellipsis,\n wordBreak,\n verticalDirection,\n textAlign,\n textBaseline,\n layoutDirection || 'horizontal',\n // typeof maxWidth === 'number' && (!width || width > maxWidth),\n // typeof maxHeight === 'number' && (!height || height > maxHeight),\n !richTextWidthEnable && maxWidthFinite,\n !richTextHeightEnable && maxHeightFinite,\n singleLine || false,\n this._frameCache?.icons\n );\n const wrapper = new Wrapper(frame);\n for (let i = 0; i < paragraphs.length; i++) {\n wrapper.deal(paragraphs[i]);\n }\n\n wrapper.send(); // 最后一行手动输出\n\n // 如果对应的配置宽度不可用,那么需要额外进行一次对齐\n const directionEnable = frame.layoutDirection === 'horizontal' ? richTextWidthEnable : richTextHeightEnable;\n if (!directionEnable) {\n // 使用实际宽度\n const frameSize = frame.getActualSizeWidthEllipsis();\n let offsetSize = frame.layoutDirection === 'horizontal' ? frameSize.width : frameSize.height;\n // 如果最大值可用\n if (frame.layoutDirection === 'horizontal' ? maxWidthFinite : maxHeightFinite) {\n // 取2者中的较小值\n offsetSize = Math.min(\n offsetSize,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n frame.layoutDirection === 'horizontal' ? maxWidth : maxHeight\n );\n }\n\n frame.lines.forEach(function (l) {\n l.calcOffset(offsetSize, false);\n });\n }\n\n this._frameCache = frame;\n\n // this.bindIconEvent();\n }\n\n clone() {\n return new RichText({ ...this.attribute });\n }\n\n setStage(stage?: IStage, layer?: ILayer) {\n super.setStage(stage, layer);\n const frameCache = this.getFrameCache();\n // for (let i = 0; i < frameCache.icons.length; i++) {\n // const icon = frameCache.icons[i];\n // icon.setStage(stage, layer);\n // }\n frameCache.icons.forEach(icon => {\n icon.setStage(stage, layer);\n });\n }\n\n // richtext绑定icon交互事件,供外部调用\n bindIconEvent() {\n this.addEventListener('pointermove', (e: FederatedMouseEvent) => {\n const pickedIcon = this.pickIcon(e.global);\n if (pickedIcon && pickedIcon === this._currentHoverIcon) {\n // do nothing\n } else if (pickedIcon) {\n this._currentHoverIcon?.setHoverState(false);\n this._currentHoverIcon = pickedIcon;\n this._currentHoverIcon.setHoverState(true);\n this.stage?.setCursor(pickedIcon.attribute.cursor);\n this.stage?.renderNextFrame();\n } else if (!pickedIcon && this._currentHoverIcon) {\n this._currentHoverIcon.setHoverState(false);\n this._currentHoverIcon = null;\n this.stage?.setCursor();\n // console.log('setCursor()');\n\n this.stage?.renderNextFrame();\n }\n });\n\n this.addEventListener('pointerleave', (e: FederatedMouseEvent) => {\n if (this._currentHoverIcon) {\n this._currentHoverIcon.setHoverState(false);\n this._currentHoverIcon = null;\n this.stage?.setCursor();\n this.stage?.renderNextFrame();\n }\n });\n }\n\n pickIcon(point: EventPoint): IRichTextIcon | undefined {\n const frameCache = this.getFrameCache();\n const { e: x, f: y } = this.globalTransMatrix;\n // for (let i = 0; i < frameCache.icons.length; i++) {\n // const icon = frameCache.icons[i];\n // if (icon.containsPoint(point.x - x, point.y - y)) {\n // return icon;\n // }\n // }\n let pickIcon: IRichTextIcon | undefined;\n frameCache.icons.forEach(icon => {\n if (icon.AABBBounds.containsPoint({ x: point.x - x, y: point.y - y })) {\n pickIcon = icon;\n\n pickIcon.globalX = (pickIcon.attribute.x ?? 0) + x;\n pickIcon.globalY = (pickIcon.attribute.y ?? 0) + y;\n }\n });\n\n return pickIcon;\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return RichText.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createRichText(attributes: IRichTextGraphicAttribute): IRichText {\n return new RichText(attributes);\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/richtext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmC,MAAM,kBAAkB,CAAC;AAgB7E,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,uBAAuB,GA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AAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBACrE,QAAQ,GAAG,IAAI,CAAC;gBAEhB,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAA,QAAQ,CAAC,SAAS,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBACnD,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAA,QAAQ,CAAC,SAAS,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;aACpD;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,oBAAoB;QAClB,OAAO,QAAQ,CAAC,mBAAmB,CAAC;IACtC,CAAC;;AAnXM,4BAAmB,mBACxB,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,CAAC,EACZ,iBAAiB,EAAE,CAAC,EACpB,SAAS,EAAE,CAAC,EACZ,YAAY,EAAE,CAAC,EACf,UAAU,EAAE,CAAC,EACb,eAAe,EAAE,CAAC,IACf,mBAAmB,EACtB;AA6WJ,MAAM,UAAU,cAAc,CAAC,UAAqC;IAClE,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC","file":"richtext.js","sourcesContent":["import { isNumber, type AABBBounds, type OBBBounds } from '@visactor/vutils';\nimport type {\n IRichText,\n IRichTextCharacter,\n RichTextGlobalAlignType,\n RichTextGlobalBaselineType,\n RichTextVerticalDirection,\n RichTextWordBreak,\n IRichTextGraphicAttribute,\n IRichTextImageCharacter,\n IRichTextParagraphCharacter,\n IStage,\n ILayer,\n IRichTextIcon,\n EventPoint\n} from '../interface';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport { DefaultRichTextAttribute } from './config';\nimport Frame from './richtext/frame';\nimport Paragraph from './richtext/paragraph';\nimport Wrapper from './richtext/wrapper';\nimport { getTheme } from './theme';\nimport { RichTextIcon } from './richtext/icon';\nimport type { FederatedMouseEvent } from '../event';\nimport { application } from '../application';\nimport { parsePadding } from '../common/utils';\nimport { RICHTEXT_NUMBER_TYPE } from './constants';\n\nconst RICHTEXT_UPDATE_TAG_KEY = [\n 'width',\n 'height',\n 'ellipsis',\n 'wordBreak',\n 'verticalDirection',\n 'maxHeight',\n 'maxWidth',\n 'textAlign',\n 'textBaseline',\n 'textConfig',\n 'layoutDirection',\n ...GRAPHIC_UPDATE_TAG_KEY\n];\n\nexport class RichText extends Graphic<IRichTextGraphicAttribute> implements IRichText {\n type: 'richtext' = 'richtext';\n\n _frameCache: Frame; // 富文本布局画布\n _currentHoverIcon: IRichTextIcon | null = null;\n\n static NOWORK_ANIMATE_ATTR = {\n ellipsis: 1,\n wordBreak: 1,\n verticalDirection: 1,\n textAlign: 1,\n textBaseline: 1,\n textConfig: 1,\n layoutDirection: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n constructor(params?: IRichTextGraphicAttribute) {\n super(params);\n this.numberType = RICHTEXT_NUMBER_TYPE;\n }\n\n get width(): number {\n return this.attribute.width ?? DefaultRichTextAttribute.width;\n }\n set width(w: number) {\n if (this.attribute.width === w) {\n return;\n }\n this.attribute.width = w;\n this.addUpdateShapeAndBoundsTag();\n }\n get height(): number {\n return this.attribute.height ?? DefaultRichTextAttribute.height;\n }\n set height(h: number) {\n if (this.attribute.height === h) {\n return;\n }\n this.attribute.height = h;\n this.addUpdateShapeAndBoundsTag();\n }\n get maxWidth(): number | undefined {\n return this.attribute.maxWidth;\n }\n set maxWidth(mw: number | undefined) {\n if (this.attribute.maxWidth === mw) {\n return;\n }\n this.attribute.maxWidth = mw;\n this.addUpdateShapeAndBoundsTag();\n }\n get maxHeight(): number | undefined {\n return this.attribute.maxHeight;\n }\n set maxHeight(mh: number | undefined) {\n if (this.attribute.maxHeight === mh) {\n return;\n }\n this.attribute.maxHeight = mh;\n this.addUpdateShapeAndBoundsTag();\n }\n get ellipsis(): boolean | string {\n return this.attribute.ellipsis ?? DefaultRichTextAttribute.ellipsis;\n }\n set ellipsis(e: boolean | string) {\n if (this.attribute.ellipsis === e) {\n return;\n }\n this.attribute.ellipsis = e;\n this.addUpdateShapeAndBoundsTag();\n }\n get wordBreak(): RichTextWordBreak {\n return this.attribute.wordBreak ?? DefaultRichTextAttribute.wordBreak;\n }\n set wordBreak(wb: RichTextWordBreak) {\n if (this.attribute.wordBreak === wb) {\n return;\n }\n this.attribute.wordBreak = wb;\n this.addUpdateShapeAndBoundsTag();\n }\n get verticalDirection(): RichTextVerticalDirection {\n return this.attribute.verticalDirection ?? DefaultRichTextAttribute.verticalDirection;\n }\n set verticalDirection(vd: RichTextVerticalDirection) {\n if (this.attribute.verticalDirection === vd) {\n return;\n }\n this.attribute.verticalDirection = vd;\n this.addUpdateShapeAndBoundsTag();\n }\n get textAlign(): RichTextGlobalAlignType {\n return this.attribute.textAlign ?? DefaultRichTextAttribute.textAlign;\n }\n set textAlign(align: RichTextGlobalAlignType) {\n if (this.attribute.textAlign === align) {\n return;\n }\n this.attribute.textAlign = align;\n this.addUpdateShapeAndBoundsTag();\n }\n get textBaseline(): RichTextGlobalBaselineType {\n return this.attribute.textBaseline ?? DefaultRichTextAttribute.textBaseline;\n }\n set textBaseline(baseline: RichTextGlobalBaselineType) {\n if (this.attribute.textBaseline === baseline) {\n return;\n }\n this.attribute.textBaseline = baseline;\n this.addUpdateShapeAndBoundsTag();\n }\n get textConfig(): IRichTextCharacter[] {\n return this.attribute.textConfig ?? DefaultRichTextAttribute.textConfig;\n }\n set textConfig(config: IRichTextCharacter[]) {\n this.attribute.textConfig = config;\n this.addUpdateShapeAndBoundsTag();\n }\n\n protected doUpdateAABBBounds(): AABBBounds {\n const richTextTheme = getTheme(this).richtext;\n this._AABBBounds.clear();\n const attribute = this.attribute;\n const bounds = application.graphicService.updateRichTextAABBBounds(\n attribute,\n getTheme(this).richtext,\n this._AABBBounds,\n this\n ) as AABBBounds;\n\n const { boundsPadding = richTextTheme.boundsPadding } = attribute;\n const paddingArray = parsePadding(boundsPadding);\n if (paddingArray) {\n bounds.expand(paddingArray);\n }\n\n this.clearUpdateBoundTag();\n return bounds;\n }\n\n protected tryUpdateOBBBounds(): OBBBounds {\n throw new Error('暂不支持');\n }\n\n getDefaultAttribute(name: string) {\n return DefaultRichTextAttribute[name];\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, RICHTEXT_UPDATE_TAG_KEY);\n }\n getFrameCache(): Frame {\n if (this.shouldUpdateShape()) {\n this.doUpdateFrameCache();\n this.clearUpdateShapeTag();\n }\n return this._frameCache;\n }\n combinedStyleToCharacter(config: IRichTextImageCharacter | IRichTextParagraphCharacter) {\n const { fill, stroke, fontSize, fontFamily, fontStyle, fontWeight } = this.attribute as any;\n return { fill, stroke, fontSize, fontFamily, fontStyle, fontWeight, ...config };\n }\n doUpdateFrameCache() {\n // 1. 测量,生成paragraph\n const {\n textConfig = [],\n maxWidth,\n maxHeight,\n width,\n height,\n ellipsis,\n wordBreak,\n verticalDirection,\n textAlign,\n textBaseline,\n layoutDirection,\n singleLine\n } = this.attribute;\n const paragraphs: (Paragraph | RichTextIcon)[] = [];\n\n for (let i = 0; i < textConfig.length; i++) {\n if ('image' in textConfig[i]) {\n const config = this.combinedStyleToCharacter(\n textConfig[i] as IRichTextImageCharacter\n ) as IRichTextImageCharacter;\n // 直接创建icon Mark\n const iconCache =\n config.id && this._frameCache && this._frameCache.icons && this._frameCache.icons.get(config.id);\n if (iconCache) {\n paragraphs.push(iconCache as RichTextIcon);\n } else {\n const icon = new RichTextIcon(config);\n icon.successCallback = () => {\n this.addUpdateBoundTag();\n this.stage?.renderNextFrame();\n };\n icon.richtextId = config.id;\n paragraphs.push(icon);\n }\n } else {\n const richTextConfig = this.combinedStyleToCharacter(\n textConfig[i] as IRichTextParagraphCharacter\n ) as IRichTextParagraphCharacter;\n if (isNumber(richTextConfig.text)) {\n richTextConfig.text = `${richTextConfig.text}`;\n }\n if (richTextConfig.text && richTextConfig.text.includes('\\n')) {\n // 如果有文字内有换行符,将该段文字切为多段,并在后一段加入newLine标记\n const textParts = richTextConfig.text.split('\\n');\n for (let j = 0; j < textParts.length; j++) {\n paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig));\n }\n } else if (richTextConfig.text) {\n paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig));\n }\n }\n }\n\n // 2. 布局,生成frame\n // const frameHeight =\n // typeof maxHeight === 'number' && (!height || height > maxHeight) // height = 0或height>maxHeight,使用maxHeight布局\n // ? maxHeight\n // : height;\n // const frameWidth =\n // typeof maxWidth === 'number' && (!width || width > maxWidth) // height = 0或height>maxWidth,使用maxWidth布局\n // ? maxWidth\n // : width;\n\n const maxWidthFinite = typeof maxWidth === 'number' && Number.isFinite(maxWidth) && maxWidth > 0;\n const maxHeightFinite = typeof maxHeight === 'number' && Number.isFinite(maxHeight) && maxHeight > 0;\n\n const richTextWidthEnable =\n typeof width === 'number' &&\n Number.isFinite(width) &&\n width > 0 &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (!maxWidthFinite || width <= maxWidth);\n const richTextHeightEnable =\n typeof height === 'number' &&\n Number.isFinite(height) &&\n height > 0 &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (!maxHeightFinite || height <= maxHeight);\n\n const frameWidth = richTextWidthEnable ? width : maxWidthFinite ? maxWidth : 0;\n const frameHeight = richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0;\n\n const frame = new Frame(\n 0,\n 0,\n frameWidth || 0,\n frameHeight || 0,\n ellipsis,\n wordBreak,\n verticalDirection,\n textAlign,\n textBaseline,\n layoutDirection || 'horizontal',\n // typeof maxWidth === 'number' && (!width || width > maxWidth),\n // typeof maxHeight === 'number' && (!height || height > maxHeight),\n !richTextWidthEnable && maxWidthFinite,\n !richTextHeightEnable && maxHeightFinite,\n singleLine || false,\n this._frameCache?.icons\n );\n const wrapper = new Wrapper(frame);\n for (let i = 0; i < paragraphs.length; i++) {\n wrapper.deal(paragraphs[i]);\n }\n\n wrapper.send(); // 最后一行手动输出\n\n // 如果对应的配置宽度不可用,那么需要额外进行一次对齐\n const directionEnable = frame.layoutDirection === 'horizontal' ? richTextWidthEnable : richTextHeightEnable;\n if (!directionEnable) {\n // 使用实际宽度\n const frameSize = frame.getActualSizeWidthEllipsis();\n let offsetSize = frame.layoutDirection === 'horizontal' ? frameSize.width : frameSize.height;\n // 如果最大值可用\n if (frame.layoutDirection === 'horizontal' ? maxWidthFinite : maxHeightFinite) {\n // 取2者中的较小值\n offsetSize = Math.min(\n offsetSize,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n frame.layoutDirection === 'horizontal' ? maxWidth : maxHeight\n );\n }\n\n frame.lines.forEach(function (l) {\n l.calcOffset(offsetSize, false);\n });\n }\n\n this._frameCache = frame;\n\n // this.bindIconEvent();\n }\n\n clone() {\n return new RichText({ ...this.attribute });\n }\n\n setStage(stage?: IStage, layer?: ILayer) {\n super.setStage(stage, layer);\n const frameCache = this.getFrameCache();\n // for (let i = 0; i < frameCache.icons.length; i++) {\n // const icon = frameCache.icons[i];\n // icon.setStage(stage, layer);\n // }\n frameCache.icons.forEach(icon => {\n icon.setStage(stage, layer);\n });\n }\n\n // richtext绑定icon交互事件,供外部调用\n bindIconEvent() {\n this.addEventListener('pointermove', (e: FederatedMouseEvent) => {\n const pickedIcon = this.pickIcon(e.global);\n if (pickedIcon && pickedIcon === this._currentHoverIcon) {\n // do nothing\n } else if (pickedIcon) {\n this._currentHoverIcon?.setHoverState(false);\n this._currentHoverIcon = pickedIcon;\n this._currentHoverIcon.setHoverState(true);\n this.stage?.setCursor(pickedIcon.attribute.cursor);\n this.stage?.renderNextFrame();\n } else if (!pickedIcon && this._currentHoverIcon) {\n this._currentHoverIcon.setHoverState(false);\n this._currentHoverIcon = null;\n this.stage?.setCursor();\n // console.log('setCursor()');\n\n this.stage?.renderNextFrame();\n }\n });\n\n this.addEventListener('pointerleave', (e: FederatedMouseEvent) => {\n if (this._currentHoverIcon) {\n this._currentHoverIcon.setHoverState(false);\n this._currentHoverIcon = null;\n this.stage?.setCursor();\n this.stage?.renderNextFrame();\n }\n });\n }\n\n pickIcon(point: EventPoint): IRichTextIcon | undefined {\n const frameCache = this.getFrameCache();\n const { e: x, f: y } = this.globalTransMatrix;\n // for (let i = 0; i < frameCache.icons.length; i++) {\n // const icon = frameCache.icons[i];\n // if (icon.containsPoint(point.x - x, point.y - y)) {\n // return icon;\n // }\n // }\n let pickIcon: IRichTextIcon | undefined;\n frameCache.icons.forEach(icon => {\n if (icon.AABBBounds.containsPoint({ x: point.x - x, y: point.y - y })) {\n pickIcon = icon;\n\n pickIcon.globalX = (pickIcon.attribute.x ?? 0) + x;\n pickIcon.globalY = (pickIcon.attribute.y ?? 0) + y;\n }\n });\n\n return pickIcon;\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return RichText.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createRichText(attributes: IRichTextGraphicAttribute): IRichText {\n return new RichText(attributes);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\n\nexport type IRichTextAttribute = {\n width: number;\n height: number;\n ellipsis: boolean | string;\n wordBreak: RichTextWordBreak;\n verticalDirection: RichTextVerticalDirection;\n maxHeight: number;\n maxWidth: number;\n textAlign: RichTextGlobalAlignType;\n textBaseline: RichTextGlobalBaselineType;\n layoutDirection: RichTextLayoutDirectionType;\n textConfig: IRichTextCharacter[];\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute> & Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n lineHeight?: number | string;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n text: string | number;\n fontSize?: number;\n fontFamily?: string;\n fill?: IColor | boolean;\n stroke?: IColor | boolean;\n fontWeight?: string;\n // lineHeight?: number;\n fontStyle?: RichTextFontStyle; // normal, italic, oblique\n textDecoration?: RichTextTextDecoration; // none, underline, line-through\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n underline?: boolean;\n lineThrough?: boolean;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n // 图片基础属性\n image: string | HTMLImageElement | HTMLCanvasElement;\n width: number;\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n backgroundShowMode?: 'always' | 'hover';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n // background size 同时控制了该icon的响应范围\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // 唯一标识符\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n id?: string;\n backgroundShowMode?: 'always' | 'hover' | 'never';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: () => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right' | 'start' | 'end';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\nimport type { ITextGraphicAttribute } from './text';\n\nexport type IRichTextAttribute = {\n width: number;\n height: number;\n ellipsis: boolean | string;\n wordBreak: RichTextWordBreak;\n verticalDirection: RichTextVerticalDirection;\n maxHeight: number;\n maxWidth: number;\n textAlign: RichTextGlobalAlignType;\n textBaseline: RichTextGlobalBaselineType;\n layoutDirection: RichTextLayoutDirectionType;\n textConfig: IRichTextCharacter[];\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute> & Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n lineHeight?: number | string;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n text: string | number;\n fontSize?: number;\n fontFamily?: string;\n fill?: IColor | boolean;\n stroke?: IColor | boolean;\n fontWeight?: string;\n // lineHeight?: number;\n fontStyle?: RichTextFontStyle; // normal, italic, oblique\n textDecoration?: RichTextTextDecoration; // none, underline, line-through\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n underline?: boolean;\n lineThrough?: boolean;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n // 图片基础属性\n image: string | HTMLImageElement | HTMLCanvasElement;\n width: number;\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n backgroundShowMode?: 'always' | 'hover';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n // background size 同时控制了该icon的响应范围\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // 唯一标识符\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n id?: string;\n backgroundShowMode?: 'always' | 'hover' | 'never';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: () => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right' | 'start' | 'end';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
@@ -24,7 +24,7 @@ export interface INode extends Releaseable, IEventElement {
24
24
  add: (node: INode, highPerformance?: boolean) => INode | null;
25
25
  delete: () => void;
26
26
  removeChild: (node: INode, highPerformance?: boolean) => INode | null;
27
- removeAllChild: () => void;
27
+ removeAllChild: (deep?: boolean) => void;
28
28
  isChildOf: (node: INode) => boolean;
29
29
  isParentOf: (node: INode) => boolean;
30
30
  isDescendantsOf: (node: INode) => boolean;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/node-tree.ts"],"names":[],"mappings":"","file":"node-tree.js","sourcesContent":["import type { IEventElement, Releaseable } from './common';\n\nexport interface INode extends Releaseable, IEventElement {\n _prev?: INode;\n _next?: INode;\n /**\n * 内部图形的唯一标识\n */\n _uid: number;\n\n /**\n * 用户配置的图形唯一标识\n */\n id?: number | string;\n /** 图形名称标识 */\n name?: string;\n /**\n * 图形类型\n */\n type?: string;\n parent: INode | null;\n // dirty: boolean; // 脏位,标记当前节点和子节点是否有修改\n count: number;\n childrenCount: number;\n firstChild: INode | null;\n lastChild: INode | null;\n /**\n * 获取子节点数组\n */\n getChildren: () => INode[];\n /**\n * 获取某个idx的节点\n */\n getChildAt: (idx: number) => INode | null;\n at: (idx: number) => INode | null;\n\n insertBefore: (newNode: INode, referenceNode: INode) => INode | null;\n insertAfter: (newNode: INode, referenceNode: INode) => INode | null;\n\n /**\n * 向某个位置插入\n */\n insertInto: (ele: INode, idx: number) => INode | null;\n\n insertIntoKeepIdx: (ele: INode, idx: number) => INode | null;\n /**\n * 遍历子节点\n * @param cb 返回true则停止遍历\n */\n forEachChildren: (cb: (n: INode, i: number) => void | boolean, reverse?: boolean) => void;\n forEachChildrenAsync: (\n cb: (n: INode, i: number) => Promise<void | boolean> | void | boolean,\n reverse?: boolean\n ) => Promise<void>;\n /**\n * 添加子节点\n * @param node\n * @param highPerformance 是否高性能模式(不检查是否合法)\n */\n appendChild: (node: INode, highPerformance?: boolean) => INode | null;\n /**\n * 添加子节点\n * @param node\n * @param highPerformance 是否高性能模式(不检查是否合法)\n */\n add: (node: INode, highPerformance?: boolean) => INode | null;\n /**\n * 从当前节点的父节点删除当前节点\n */\n delete: () => void;\n /**\n * 删除节点\n * @param node\n * @param highPerformance 是否高性能模式(不检查是否合法)\n */\n removeChild: (node: INode, highPerformance?: boolean) => INode | null;\n /**\n * 移除所有节点\n */\n removeAllChild: () => void;\n /**\n * 判断该节点是否是node的子节点\n * @param node\n */\n isChildOf: (node: INode) => boolean;\n /**\n * 判断该节点是否是node的父节点\n * @param node\n */\n isParentOf: (node: INode) => boolean;\n /**\n * 判断节点是否是node的后代节点\n * @param node\n */\n isDescendantsOf: (node: INode) => boolean;\n /**\n * 判断节点是否是node的祖先节点\n * @param node\n */\n isAncestorsOf: (node: INode) => boolean;\n\n // 事件相关的别名\n /**\n * Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.\n * */\n dispatchEvent: (event: Event) => boolean;\n\n /**\n * 返回的是一个布尔值,来表示传入的节点是否为该节点的后代节点。\n * @param node 判断是否包含的节点\n */\n containNode: (node: INode) => boolean;\n\n /**\n * 设置该节点的所有后代节点某个属性\n * @param propsName 属性名\n * @param propsValue 属性值\n */\n setAllDescendantsProps: (propsName: string, propsValue: any) => any;\n\n // 查找相关的接口\n /**\n * 根据自定义逻辑查找元素,返回单一图形元素\n * @param callback 自定义查找过滤器\n * @param deep 是否进行深度查找,默认为 false\n * @returns 返回匹配的图形元素\n */\n find: (callback: (node: INode, index: number) => boolean, deep: boolean) => INode | null;\n /**\n * 根据自定义逻辑查找元素,返回匹配的元素集合\n * @param callback 自定义查找过滤器\n * @param deep 是否进行深度查找,默认为 false\n * @returns 返回匹配的图形元素集合\n */\n findAll: (callback: (node: INode, index: number) => boolean, deep: boolean) => INode[];\n /**\n * 通过用户设置的 id 查找对应的图形元素\n * @param id 子节点的 id\n */\n getElementById: (id: string | number) => INode | null;\n /**\n * @alias getElementById\n * 通过用户设置的 id 查找对应的图形元素\n * @param id 子节点的 id\n */\n findChildById: (id: string | number) => INode | null;\n /**\n * 通过内部生成的节点 id:_uid 查找对应的图形元素\n * @param id 子节点的key\n */\n findChildByUid: (uid: number) => INode | null;\n /**\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n getElementsByName: (name: string) => INode[];\n /**\n * @alias getElementsByName\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n findChildrenByName: (name: string) => INode[];\n /**\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n getElementsByType: (type: string) => INode[];\n // 其他不常用\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/node-tree.ts"],"names":[],"mappings":"","file":"node-tree.js","sourcesContent":["import type { IEventElement, Releaseable } from './common';\n\nexport interface INode extends Releaseable, IEventElement {\n _prev?: INode;\n _next?: INode;\n /**\n * 内部图形的唯一标识\n */\n _uid: number;\n\n /**\n * 用户配置的图形唯一标识\n */\n id?: number | string;\n /** 图形名称标识 */\n name?: string;\n /**\n * 图形类型\n */\n type?: string;\n parent: INode | null;\n // dirty: boolean; // 脏位,标记当前节点和子节点是否有修改\n count: number;\n childrenCount: number;\n firstChild: INode | null;\n lastChild: INode | null;\n /**\n * 获取子节点数组\n */\n getChildren: () => INode[];\n /**\n * 获取某个idx的节点\n */\n getChildAt: (idx: number) => INode | null;\n at: (idx: number) => INode | null;\n\n insertBefore: (newNode: INode, referenceNode: INode) => INode | null;\n insertAfter: (newNode: INode, referenceNode: INode) => INode | null;\n\n /**\n * 向某个位置插入\n */\n insertInto: (ele: INode, idx: number) => INode | null;\n\n insertIntoKeepIdx: (ele: INode, idx: number) => INode | null;\n /**\n * 遍历子节点\n * @param cb 返回true则停止遍历\n */\n forEachChildren: (cb: (n: INode, i: number) => void | boolean, reverse?: boolean) => void;\n forEachChildrenAsync: (\n cb: (n: INode, i: number) => Promise<void | boolean> | void | boolean,\n reverse?: boolean\n ) => Promise<void>;\n /**\n * 添加子节点\n * @param node\n * @param highPerformance 是否高性能模式(不检查是否合法)\n */\n appendChild: (node: INode, highPerformance?: boolean) => INode | null;\n /**\n * 添加子节点\n * @param node\n * @param highPerformance 是否高性能模式(不检查是否合法)\n */\n add: (node: INode, highPerformance?: boolean) => INode | null;\n /**\n * 从当前节点的父节点删除当前节点\n */\n delete: () => void;\n /**\n * 删除节点\n * @param node\n * @param highPerformance 是否高性能模式(不检查是否合法)\n */\n removeChild: (node: INode, highPerformance?: boolean) => INode | null;\n /**\n * 移除所有节点\n */\n removeAllChild: (deep?: boolean) => void;\n /**\n * 判断该节点是否是node的子节点\n * @param node\n */\n isChildOf: (node: INode) => boolean;\n /**\n * 判断该节点是否是node的父节点\n * @param node\n */\n isParentOf: (node: INode) => boolean;\n /**\n * 判断节点是否是node的后代节点\n * @param node\n */\n isDescendantsOf: (node: INode) => boolean;\n /**\n * 判断节点是否是node的祖先节点\n * @param node\n */\n isAncestorsOf: (node: INode) => boolean;\n\n // 事件相关的别名\n /**\n * Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.\n * */\n dispatchEvent: (event: Event) => boolean;\n\n /**\n * 返回的是一个布尔值,来表示传入的节点是否为该节点的后代节点。\n * @param node 判断是否包含的节点\n */\n containNode: (node: INode) => boolean;\n\n /**\n * 设置该节点的所有后代节点某个属性\n * @param propsName 属性名\n * @param propsValue 属性值\n */\n setAllDescendantsProps: (propsName: string, propsValue: any) => any;\n\n // 查找相关的接口\n /**\n * 根据自定义逻辑查找元素,返回单一图形元素\n * @param callback 自定义查找过滤器\n * @param deep 是否进行深度查找,默认为 false\n * @returns 返回匹配的图形元素\n */\n find: (callback: (node: INode, index: number) => boolean, deep: boolean) => INode | null;\n /**\n * 根据自定义逻辑查找元素,返回匹配的元素集合\n * @param callback 自定义查找过滤器\n * @param deep 是否进行深度查找,默认为 false\n * @returns 返回匹配的图形元素集合\n */\n findAll: (callback: (node: INode, index: number) => boolean, deep: boolean) => INode[];\n /**\n * 通过用户设置的 id 查找对应的图形元素\n * @param id 子节点的 id\n */\n getElementById: (id: string | number) => INode | null;\n /**\n * @alias getElementById\n * 通过用户设置的 id 查找对应的图形元素\n * @param id 子节点的 id\n */\n findChildById: (id: string | number) => INode | null;\n /**\n * 通过内部生成的节点 id:_uid 查找对应的图形元素\n * @param id 子节点的key\n */\n findChildByUid: (uid: number) => INode | null;\n /**\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n getElementsByName: (name: string) => INode[];\n /**\n * @alias getElementsByName\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n findChildrenByName: (name: string) => INode[];\n /**\n * 根据用户传入的 name 查找元素,返回匹配的元素集合\n * @param name 用户设置的图形名称\n * @returns 匹配 name 的元素集合\n */\n getElementsByType: (type: string) => INode[];\n // 其他不常用\n}\n"]}
@@ -12,6 +12,8 @@ export class HtmlAttributePlugin {
12
12
  activate(context) {
13
13
  this.pluginService = context, context.stage.hooks.afterRender.tap(this.key, (stage => {
14
14
  stage && stage === this.pluginService.stage && this.drawHTML(context.stage.renderService);
15
+ })), application.graphicService.hooks.onRemove.tap(this.key, (graphic => {
16
+ this.removeDom(graphic);
15
17
  })), application.graphicService.hooks.onRelease.tap(this.key, (graphic => {
16
18
  this.removeDom(graphic);
17
19
  }));
@@ -47,26 +49,28 @@ export class HtmlAttributePlugin {
47
49
  const {dom: dom, container: container, width: width, height: height, style: style, anchorType: anchorType = "boundsLeftTop"} = html;
48
50
  graphic.bindDom || (graphic.bindDom = new Map);
49
51
  const lastDom = graphic.bindDom.get(dom);
50
- if (lastDom && (!container || container === lastDom.container)) return;
51
- let nativeDom, nativeContainer;
52
- graphic.bindDom.forEach((({wrapGroup: wrapGroup}) => {
53
- application.global.removeDom(wrapGroup);
54
- })), "string" == typeof dom ? (nativeDom = (new DOMParser).parseFromString(dom, "text/html").firstChild,
55
- nativeDom.lastChild && (nativeDom = nativeDom.lastChild.firstChild)) : nativeDom = dom;
56
- const _container = container || (!0 === stage.params.enableHtmlAttribute ? null : stage.params.enableHtmlAttribute);
57
- nativeContainer = _container ? "string" == typeof _container ? application.global.getElementById(_container) : _container : graphic.stage.window.getContainer();
58
- const wrapGroup = application.global.createDom({
59
- tagName: "div",
60
- width: width,
61
- height: height,
62
- style: style,
63
- parent: nativeContainer
64
- });
65
- wrapGroup && (wrapGroup.appendChild(nativeDom), graphic.bindDom.set(dom, {
66
- dom: nativeDom,
67
- container: container,
68
- wrapGroup: wrapGroup
69
- })), wrapGroup.style.pointerEvents = "none", wrapGroup.style.position || (wrapGroup.style.position = "absolute",
52
+ let wrapGroup, nativeContainer;
53
+ if (!lastDom || container && container !== lastDom.container) {
54
+ let nativeDom;
55
+ graphic.bindDom.forEach((({wrapGroup: wrapGroup}) => {
56
+ application.global.removeDom(wrapGroup);
57
+ })), "string" == typeof dom ? (nativeDom = (new DOMParser).parseFromString(dom, "text/html").firstChild,
58
+ nativeDom.lastChild && (nativeDom = nativeDom.lastChild.firstChild)) : nativeDom = dom;
59
+ const _container = container || (!0 === stage.params.enableHtmlAttribute ? null : stage.params.enableHtmlAttribute);
60
+ nativeContainer = _container ? "string" == typeof _container ? application.global.getElementById(_container) : _container : graphic.stage.window.getContainer(),
61
+ wrapGroup = application.global.createDom({
62
+ tagName: "div",
63
+ width: width,
64
+ height: height,
65
+ style: style,
66
+ parent: nativeContainer
67
+ }), wrapGroup && (wrapGroup.appendChild(nativeDom), graphic.bindDom.set(dom, {
68
+ dom: nativeDom,
69
+ container: container,
70
+ wrapGroup: wrapGroup
71
+ }));
72
+ } else wrapGroup = lastDom.wrapGroup, nativeContainer = wrapGroup.parentNode;
73
+ wrapGroup.style.pointerEvents = "none", wrapGroup.style.position || (wrapGroup.style.position = "absolute",
70
74
  nativeContainer.style.position = "relative");
71
75
  let left = 0, top = 0;
72
76
  const b = graphic.globalAABBBounds;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugins/builtin-plugin/html-attribute-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,OAAO,mBAAmB;IAAhC;QACE,SAAI,GAA0B,qBAAqB,CAAC;QACpD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IA6ItC,CAAC;IA3IC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE;YACpD,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;gBAClD,OAAO;aACR;YAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;YACjE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IACD,UAAU,CAAC,OAAuB;QAChC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAA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AM,CAAC;QAEvC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC7B,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;YACtC,eAAe,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;SAC7C;QACD,IAAI,IAAI,GAAW,CAAC,CAAC;QACrB,IAAI,GAAG,GAAW,CAAC,CAAC;QACpB,MAAM,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACnC,IAAI,UAAU,KAAK,UAAU,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;YACzC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;YAChB,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC;SAChB;aAAM;YACL,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;YACZ,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;SACZ;QAGD,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QACjF,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,IAAI,GAAG,QAAQ,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;QACxD,MAAM,SAAS,GAAG,GAAG,GAAG,QAAQ,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;QAEvD,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,OAAO,IAAI,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,SAAS,IAAI,CAAC;IACzC,CAAC;CACF","file":"html-attribute-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport type { IGraphic, IPlugin, IPluginService, IRenderService, IDrawContext, IGroup } from '../../interface';\nimport { application } from '../../application';\nimport { DefaultAttribute } from '../../graphic';\n\nexport class HtmlAttributePlugin implements IPlugin {\n name: 'HtmlAttributePlugin' = 'HtmlAttributePlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n\n this.drawHTML(context.stage.renderService);\n });\n application.graphicService.hooks.onRelease.tap(this.key, graphic => {\n this.removeDom(graphic);\n });\n }\n deactivate(context: IPluginService): void {\n context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n\n protected drawHTML(renderService: IRenderService) {\n if (application.global.env === 'browser') {\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroupHTML(group as IGroup);\n });\n }\n }\n\n renderGroupHTML(group: IGroup) {\n this.renderGraphicHTML(group);\n group.forEachChildren((g: IGraphic) => {\n if (g.isContainer) {\n this.renderGroupHTML(g as IGroup);\n } else {\n this.renderGraphicHTML(g);\n }\n });\n }\n\n removeDom(graphic: IGraphic) {\n if (graphic.bindDom && graphic.bindDom.size) {\n // 删除dom\n graphic.bindDom.forEach(item => {\n item.dom && item.dom.parentElement.removeChild(item.dom);\n });\n graphic.bindDom.clear();\n }\n }\n\n renderGraphicHTML(graphic: IGraphic) {\n const { html } = graphic.attribute;\n if (!html) {\n if (graphic.bindDom && graphic.bindDom.size) {\n // 删除dom\n graphic.bindDom.forEach(item => {\n item.dom && item.dom.parentElement.removeChild(item.dom);\n });\n graphic.bindDom.clear();\n }\n return;\n }\n const stage = graphic.stage;\n if (!stage) {\n return;\n }\n const { dom, container, width, height, style, anchorType = 'boundsLeftTop' } = html;\n if (!graphic.bindDom) {\n graphic.bindDom = new Map();\n }\n const lastDom = graphic.bindDom.get(dom);\n // 如果存在了(dom存在,且container没有变化),就跳过\n if (lastDom && !(container && container !== lastDom.container)) {\n return;\n }\n // 清除上一次的dom\n graphic.bindDom.forEach(({ wrapGroup }) => {\n application.global.removeDom(wrapGroup);\n });\n // 转化这个dom为nativeDOM\n let nativeDom: HTMLElement;\n if (typeof dom === 'string') {\n nativeDom = new DOMParser().parseFromString(dom, 'text/html').firstChild as any;\n if ((nativeDom as any).lastChild) {\n nativeDom = (nativeDom as any).lastChild.firstChild;\n }\n } else {\n nativeDom = dom;\n }\n // 获取container的dom,默认为window的container\n let nativeContainer;\n const _container =\n container || (stage.params.enableHtmlAttribute === true ? null : stage.params.enableHtmlAttribute);\n if (_container) {\n if (typeof _container === 'string') {\n nativeContainer = application.global.getElementById(_container);\n } else {\n nativeContainer = _container;\n }\n } else {\n // nativeContainer = application.global.getRootElement();\n nativeContainer = graphic.stage.window.getContainer();\n }\n // 创建wrapGroup\n const wrapGroup = application.global.createDom({ tagName: 'div', width, height, style, parent: nativeContainer });\n if (wrapGroup) {\n wrapGroup.appendChild(nativeDom);\n graphic.bindDom.set(dom, { dom: nativeDom, container, wrapGroup: wrapGroup as any });\n }\n // 事件穿透\n wrapGroup.style.pointerEvents = 'none';\n // 定位wrapGroup\n if (!wrapGroup.style.position) {\n wrapGroup.style.position = 'absolute';\n nativeContainer.style.position = 'relative';\n }\n let left: number = 0;\n let top: number = 0;\n const b = graphic.globalAABBBounds;\n if (anchorType === 'position' || b.empty()) {\n const matrix = graphic.globalTransMatrix;\n left = matrix.e;\n top = matrix.f;\n } else {\n left = b.x1;\n top = b.y1;\n }\n // 查看wrapGroup的位置\n // const wrapGroupTL = application.global.getElementTopLeft(wrapGroup, false);\n const containerTL = application.global.getElementTopLeft(nativeContainer, false);\n const windowTL = stage.window.getTopLeft(false);\n const offsetX = left + windowTL.left - containerTL.left;\n const offsetTop = top + windowTL.top - containerTL.top;\n // wrapGroup.style.transform = `translate(${offsetX}px, ${offsetTop}px)`;\n wrapGroup.style.left = `${offsetX}px`;\n wrapGroup.style.top = `${offsetTop}px`;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/plugins/builtin-plugin/html-attribute-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,OAAO,mBAAmB;IAAhC;QACE,SAAI,GAA0B,qBAAqB,CAAC;QACpD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IAsJtC,CAAC;IApJC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE;YACpD,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;gBAClD,OAAO;aACR;YAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;YAChE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;QACH,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;YACj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D,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,OAAO,IAAI,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,SAAS,IAAI,CAAC;IACzC,CAAC;CACF","file":"html-attribute-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport type { IGraphic, IPlugin, IPluginService, IRenderService, IDrawContext, IGroup } from '../../interface';\nimport { application } from '../../application';\nimport { DefaultAttribute } from '../../graphic';\n\nexport class HtmlAttributePlugin implements IPlugin {\n name: 'HtmlAttributePlugin' = 'HtmlAttributePlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n\n this.drawHTML(context.stage.renderService);\n });\n application.graphicService.hooks.onRemove.tap(this.key, graphic => {\n this.removeDom(graphic);\n });\n application.graphicService.hooks.onRelease.tap(this.key, graphic => {\n this.removeDom(graphic);\n });\n }\n deactivate(context: IPluginService): void {\n context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n\n protected drawHTML(renderService: IRenderService) {\n if (application.global.env === 'browser') {\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroupHTML(group as IGroup);\n });\n }\n }\n\n renderGroupHTML(group: IGroup) {\n this.renderGraphicHTML(group);\n group.forEachChildren((g: IGraphic) => {\n if (g.isContainer) {\n this.renderGroupHTML(g as IGroup);\n } else {\n this.renderGraphicHTML(g);\n }\n });\n }\n\n removeDom(graphic: IGraphic) {\n if (graphic.bindDom && graphic.bindDom.size) {\n // 删除dom\n graphic.bindDom.forEach(item => {\n item.dom && item.dom.parentElement.removeChild(item.dom);\n });\n graphic.bindDom.clear();\n }\n }\n\n renderGraphicHTML(graphic: IGraphic) {\n const { html } = graphic.attribute;\n if (!html) {\n if (graphic.bindDom && graphic.bindDom.size) {\n // 删除dom\n graphic.bindDom.forEach(item => {\n item.dom && item.dom.parentElement.removeChild(item.dom);\n });\n graphic.bindDom.clear();\n }\n return;\n }\n const stage = graphic.stage;\n if (!stage) {\n return;\n }\n const { dom, container, width, height, style, anchorType = 'boundsLeftTop' } = html;\n if (!graphic.bindDom) {\n graphic.bindDom = new Map();\n }\n const lastDom = graphic.bindDom.get(dom);\n\n let wrapGroup;\n // 获取container的dom,默认为window的container\n let nativeContainer;\n // 如果存在了(dom存在,且container没有变化),就不做事情\n if (lastDom && !(container && container !== lastDom.container)) {\n wrapGroup = lastDom.wrapGroup;\n nativeContainer = wrapGroup.parentNode;\n } else {\n // 清除上一次的dom\n graphic.bindDom.forEach(({ wrapGroup }) => {\n application.global.removeDom(wrapGroup);\n });\n // 转化这个dom为nativeDOM\n let nativeDom: HTMLElement;\n if (typeof dom === 'string') {\n nativeDom = new DOMParser().parseFromString(dom, 'text/html').firstChild as any;\n if ((nativeDom as any).lastChild) {\n nativeDom = (nativeDom as any).lastChild.firstChild;\n }\n } else {\n nativeDom = dom;\n }\n\n const _container =\n container || (stage.params.enableHtmlAttribute === true ? null : stage.params.enableHtmlAttribute);\n if (_container) {\n if (typeof _container === 'string') {\n nativeContainer = application.global.getElementById(_container);\n } else {\n nativeContainer = _container;\n }\n } else {\n // nativeContainer = application.global.getRootElement();\n nativeContainer = graphic.stage.window.getContainer();\n }\n // 创建wrapGroup\n wrapGroup = application.global.createDom({ tagName: 'div', width, height, style, parent: nativeContainer });\n if (wrapGroup) {\n wrapGroup.appendChild(nativeDom);\n graphic.bindDom.set(dom, { dom: nativeDom, container, wrapGroup: wrapGroup as any });\n }\n }\n\n // 事件穿透\n wrapGroup.style.pointerEvents = 'none';\n // 定位wrapGroup\n if (!wrapGroup.style.position) {\n wrapGroup.style.position = 'absolute';\n nativeContainer.style.position = 'relative';\n }\n let left: number = 0;\n let top: number = 0;\n const b = graphic.globalAABBBounds;\n if (anchorType === 'position' || b.empty()) {\n const matrix = graphic.globalTransMatrix;\n left = matrix.e;\n top = matrix.f;\n } else {\n left = b.x1;\n top = b.y1;\n }\n // 查看wrapGroup的位置\n // const wrapGroupTL = application.global.getElementTopLeft(wrapGroup, false);\n const containerTL = application.global.getElementTopLeft(nativeContainer, false);\n const windowTL = stage.window.getTopLeft(false);\n const offsetX = left + windowTL.left - containerTL.left;\n const offsetTop = top + windowTL.top - containerTL.top;\n // wrapGroup.style.transform = `translate(${offsetX}px, ${offsetTop}px)`;\n wrapGroup.style.left = `${offsetX}px`;\n wrapGroup.style.top = `${offsetTop}px`;\n }\n}\n"]}