Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat: riddle 支持配置 package.json #376

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions @antv/gatsby-theme-antv/site/components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ interface ToolbarProps {
[key: string]: string;
};
htmlCodeTemplate?: string;
json?: {
[key: string]: any;
};
};
isFullScreen?: boolean;
editorTabs: EDITOR_TABS[];
Expand Down Expand Up @@ -137,9 +140,8 @@ const Toolbar: React.FC<ToolbarProps> = ({
return text;
}

codeSandboxConfig.files[`index.${fileExtension}`].content = replaceFetchUrl(
sourceCode,
);
codeSandboxConfig.files[`index.${fileExtension}`].content =
replaceFetchUrl(sourceCode);

function getHtmlCodeTemplate() {
const { htmlCodeTemplate = '', container = '' } = playground;
Expand Down Expand Up @@ -174,6 +176,12 @@ const Toolbar: React.FC<ToolbarProps> = ({
title: exmapleTitle,
js: sourceCode,
html: playground.container || '<div id="container" />',
// 预填的 package.json 代码
json: JSON.stringify({
dependencies: deps,
devDependencies,
...playground.json,
}),
};

const stackblitzPrefillConfig = {
Expand Down