Skip to content

Commit

Permalink
Fix #2999: Allow ParcelJS builds for Editor/Charts (#3000)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Jun 20, 2022
1 parent 2ccf3f4 commit 976a87b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
20 changes: 13 additions & 7 deletions components/lib/chart/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
});
}
Expand Down
14 changes: 11 additions & 3 deletions components/lib/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
Expand Down

0 comments on commit 976a87b

Please sign in to comment.