diff --git a/components/lib/chart/Chart.js b/components/lib/chart/Chart.js index 8e8f37a746..c61cddd646 100644 --- a/components/lib/chart/Chart.js +++ b/components/lib/chart/Chart.js @@ -13,13 +13,19 @@ export const Chart = React.memo(React.forwardRef((props, ref) => { chartRef.current = null; } - if (module && module.default) { - chartRef.current = new module.default(canvasRef.current, { - type: props.type, - data: props.data, - options: props.options, - plugins: props.plugins - }); + const configuration = { + type: props.type, + data: props.data, + options: props.options, + plugins: props.plugins + }; + + if (module) { + if (module.default) { + chartRef.current = new module.default(canvasRef.current, configuration); + } else { + chartRef.current = new module(canvasRef.current, configuration); + } } }); } diff --git a/components/lib/editor/Editor.js b/components/lib/editor/Editor.js index dfce0af87e..f8ad8f9393 100644 --- a/components/lib/editor/Editor.js +++ b/components/lib/editor/Editor.js @@ -15,8 +15,8 @@ export const Editor = React.memo(React.forwardRef((props, ref) => { useMountEffect(() => { if (!isQuillLoaded.current) { import('quill').then((module) => { - if (module && module.default && DomHandler.isExist(contentRef.current)) { - quill.current = new module.default(contentRef.current, { + if (module && DomHandler.isExist(contentRef.current)) { + const configuration = { modules: { toolbar: props.showHeader ? toolbarRef.current : false, ...props.modules @@ -25,7 +25,15 @@ export const Editor = React.memo(React.forwardRef((props, ref) => { readOnly: props.readOnly, theme: props.theme, formats: props.formats - }); + }; + + if (module.default) { + // webpack + quill.current = new module.default(contentRef.current, configuration); + } else { + // parceljs + quill.current = new module(contentRef.current, configuration); + } if (props.value) { quill.current.setContents(quill.current.clipboard.convert(props.value));