36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
|
|
// @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;
|