feat:组件框架
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// @ts-nocheck
|
||||
// This file is generated by Umi automatically
|
||||
// DO NOT CHANGE IT MANUALLY!
|
||||
import type { nodeToGroup, nodeToSymbol, SketchFormat } from 'html2sketch';
|
||||
import { ApplyPluginsType } from 'dumi';
|
||||
import { getPluginManager } from '@@/core/plugin';
|
||||
|
||||
const html2sketch = typeof window !== 'undefined' ? window.html2sketch as {
|
||||
nodeToGroup: typeof nodeToGroup;
|
||||
nodeToSymbol: typeof nodeToSymbol;
|
||||
} : null;
|
||||
|
||||
async function toSketchJSON(
|
||||
node: HTMLElement,
|
||||
opts: { type: 'group' | 'symbol' },
|
||||
) {
|
||||
return opts.type === 'group'
|
||||
? (await html2sketch.nodeToGroup(node)).toSketchJSON()
|
||||
: (await html2sketch.nodeToSymbol(node)).toSketchJSON();
|
||||
}
|
||||
|
||||
function runtimeToSketchJSON(
|
||||
target: HTMLElement | Document,
|
||||
opts: Parameters<typeof toSketchJSON>[1],
|
||||
): ReturnType<typeof toSketchJSON> | Promise<null> {
|
||||
return getPluginManager().applyPlugins({
|
||||
key: 'toSketchJSON',
|
||||
type: ApplyPluginsType.modify,
|
||||
initialValue: null,
|
||||
args: { target, opts },
|
||||
async: true,
|
||||
});
|
||||
}
|
||||
|
||||
export const getSketchJSON = null;
|
||||
Reference in New Issue
Block a user