GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — lowcode-engine/packages/shell/src/material.ts at main · lecepin/lowcode-engine Expand file tree/ Copy pathmaterial.tsMore file actions 156 lines (140 loc) · 3.79 KB / Copy pathmaterial.tsFile metadata and controls156 lines (140 loc) · 3.79 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 import { Editor } from '@alilc/lowcode-editor-core'; import { Designer, registerMetadataTransducer, MetadataTransducer, getRegisteredMetadataTransducers, addBuiltinComponentAction, removeBuiltinComponentAction, modifyBuiltinComponentAction, isComponentMeta, } from '@alilc/lowcode-designer'; import { AssetsJson } from '@alilc/lowcode-utils'; import { ComponentAction, ComponentMetadata } from '@alilc/lowcode-types'; import { editorSymbol, designerSymbol } from './symbols'; import ComponentMeta from './component-meta'; export default class Material { private readonly [editorSymbol]: Editor; private readonly [designerSymbol]: Designer; constructor(editor: Editor) { this[editorSymbol] = editor; this[designerSymbol] = editor.get('designer')!; } /** * 获取组件 map 结构 */ get componentsMap() { return this[designerSymbol].componentsMap; } /** * 设置「资产包」结构 * @param assets * @returns */ async setAssets(assets: AssetsJson) { return await this[editorSymbol].setAssets(assets); } /** * 获取「资产包」结构 * @returns */ getAssets() { return this[editorSymbol].get('assets'); } /** * 加载增量的「资产包」结构,该增量包会与原有的合并 * @param incrementalAssets * @returns */ loadIncrementalAssets(incrementalAssets: AssetsJson) { return this[designerSymbol].loadIncrementalAssets(incrementalAssets); } /** * 注册物料元数据管道函数 * @param transducer * @param level * @param id */ registerMetadataTransducer( transducer: MetadataTransducer, level?: number, id?: string | undefined, ) { registerMetadataTransducer(transducer, level, id); } /** * 获取所有物料元数据管道函数 * @returns */ getRegisteredMetadataTransducers() { return getRegisteredMetadataTransducers(); } /** * 获取指定名称的物料元数据 * @param componentName * @returns */ getComponentMeta(componentName: string) { return ComponentMeta.create(this[designerSymbol].getComponentMeta(componentName)); } /** * create an instance of ComponentMeta by given metadata * @param metadata * @returns */ createComponentMeta(metadata: ComponentMetadata) { return ComponentMeta.create(this[designerSymbol].createComponentMeta(metadata)); } /** * test if the given object is a ComponentMeta instance or not * @param obj * @returns */ isComponentMeta(obj: any) { return isComponentMeta(obj); } /** * 获取所有已注册的物料元数据 * @returns */ getComponentMetasMap() { const map = new Map<string, ComponentMeta>(); const originalMap = this[designerSymbol].getComponentMetasMap(); for (let componentName of originalMap.keys()) { map.set(componentName, this.getComponentMeta(componentName)!); } return map; } /** * 在设计器辅助层增加一个扩展 action * @param action */ addBuiltinComponentAction(action: ComponentAction) { addBuiltinComponentAction(action); } /** * 移除设计器辅助层的指定 action * @param name */ removeBuiltinComponentAction(name: string) { removeBuiltinComponentAction(name); } /** * 修改已有的设计器辅助层的指定 action * @param actionName * @param handle */ modifyBuiltinComponentAction(actionName: string, handle: (action: ComponentAction) => void) { modifyBuiltinComponentAction(actionName, handle); } /** * 监听 assets 变化的事件 * @param fn */ onChangeAssets(fn: () => void) { // 设置 assets,经过 setAssets 赋值 this[editorSymbol].onGot('assets', fn); // 增量设置 assets,经过 loadIncrementalAssets 赋值 this[editorSymbol].on('designer.incrementalAssetsReady', fn); } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |