修复 chart 渲染问题

This commit is contained in:
liaoxuezhi 2022-06-06 11:12:38 +08:00
parent f329692c62
commit 9f993bedba
6 changed files with 43 additions and 99 deletions

View File

@ -925,82 +925,3 @@ if (fis.project.currentMedia() === 'publish-sdk') {
});
}
// function docsGennerator(contents, file) {
// if (file.subpath !== '/examples/components/Doc.tsx') {
// return contents;
// }
// return contents.replace('// {{renderer-docs}}', function () {
// const dir = path.join(__dirname, 'docs/renderers');
// const files = [];
// let fn = (dir, colleciton, prefix = '') => {
// const entries = fs.readdirSync(dir);
// entries.forEach(entry => {
// const subdir = path.join(dir, entry);
// if (fs.lstatSync(subdir).isDirectory()) {
// let files = [];
// fn(subdir, files, path.join(prefix, entry));
// colleciton.push({
// name: entry,
// children: files,
// path: path.join(prefix, entry)
// });
// } else if (/\.md$/.test(entry)) {
// colleciton.push({
// name: path.basename(entry, '.md'),
// path: path.join(prefix, entry)
// });
// }
// });
// };
// let fn2 = item => {
// if (item.children) {
// const child = item.children.find(
// child => child.name === `${item.name}.md`
// );
// return `{
// label: '${item.name}',
// ${
// child
// ? `path: '/docs/renderers/${child.path.replace(
// /\.md$/,
// ''
// )}',`
// : ''
// }
// children: [
// ${item.children.map(fn2).join(',\n')}
// ]
// }`;
// }
// return `{
// label: '${item.name}',
// path: '/docs/renderers/${item.path.replace(/\.md$/, '')}',
// getComponent: (location, cb) =>
// require(['../../docs/renderers/${item.path}'], doc => {
// cb(null, makeMarkdownRenderer(doc));
// })
// }`;
// };
// fn(dir, files);
// return `{
// label: '渲染器手册',
// icon: 'fa fa-diamond',
// path: '/docs/renderers',
// getComponent: (location, cb) =>
// require(['../../docs/renderers.md'], doc => {
// cb(null, makeMarkdownRenderer(doc));
// }),
// children: [
// ${files.map(fn2).join(',\n')}
// ]
// },`;
// });
// }

View File

@ -86,12 +86,18 @@ function transpileDynamicImportForCJS(options) {
}
return {
left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require.ensure([',
left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require([',
right:
'], function(r) {fullfill(_interopDefaultLegacy(r("' +
targetModuleId +
'")))})})})'
'], function(mod) {fullfill(tslib.__importStar(mod))})})})'
};
// return {
// left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require.ensure([',
// right:
// '], function(r) {fullfill(_interopDefaultLegacy(r("' +
// targetModuleId +
// '")))})})})'
// };
}
};
}

View File

@ -2,15 +2,20 @@
* @file markdown
*/
import markdownIt from 'markdown-it';
// @ts-ignore
import {html5Media} from 'markdown-it-html5-media';
import type markdownIt from 'markdown-it';
const doMarkdown = markdownIt();
doMarkdown.use(html5Media);
let doMarkdown:any;
export async function markdown(content: string, options?: markdownIt.Options) {
if (!doMarkdown) {
const {default: markdownIt} = await import('markdown-it');
// @ts-ignore
const {default: {html5Media}} = await import('markdown-it-html5-media');
doMarkdown = markdownIt();
doMarkdown.use(html5Media);
}
export function markdown(content: string, options?: markdownIt.Options) {
if (options) {
doMarkdown.set(options);
}

View File

@ -114,12 +114,18 @@ function transpileDynamicImportForCJS(options) {
}
return {
left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require.ensure([',
left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require([',
right:
'], function(r) {fullfill(_interopDefaultLegacy(r("' +
targetModuleId +
'")))})})})'
'], function(mod) {fullfill(tslib.__importStar(mod))})})})'
};
// return {
// left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require.ensure([',
// right:
// '], function(r) {fullfill(_interopDefaultLegacy(r("' +
// targetModuleId +
// '")))})})})'
// };
}
};
}

View File

@ -36,9 +36,9 @@ export default class Markdown extends React.Component<MarkdownProps> {
}
}
_render() {
async _render() {
const {content, options} = this.props;
this.dom.innerHTML = markdownRender(content, options);
this.dom.innerHTML = await markdownRender(content, options);
}
render() {

View File

@ -76,12 +76,18 @@ function transpileDynamicImportForCJS(options) {
}
return {
left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require.ensure([',
left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require([',
right:
'], function(r) {fullfill(_interopDefaultLegacy(r("' +
targetModuleId +
'")))})})})'
'], function(mod) {fullfill(tslib.__importStar(mod))})})})'
};
// return {
// left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require.ensure([',
// right:
// '], function(r) {fullfill(_interopDefaultLegacy(r("' +
// targetModuleId +
// '")))})})})'
// };
}
};
}