1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Standardised module loading system & fixed build system

Fixed broken build system in broken webpack version.
Also updates module system to standardise on ES6 import/exports,
Especially since babel has changed it's 'default' logic for the old
module system.
This commit is contained in:
Dan Brown
2018-11-09 21:17:35 +00:00
parent 5b36ddb12f
commit e3230f8f21
37 changed files with 384 additions and 3372 deletions

View File

@ -56,4 +56,4 @@ class BackToTop {
}
module.exports = BackToTop;
export default BackToTop;

View File

@ -69,4 +69,4 @@ class ChapterToggle {
}
module.exports = ChapterToggle;
export default ChapterToggle;

View File

@ -34,4 +34,4 @@ class Collapsible {
}
module.exports = Collapsible;
export default Collapsible;

View File

@ -45,4 +45,4 @@ class DropDown {
}
module.exports = DropDown;
export default DropDown;

View File

@ -44,4 +44,4 @@ class EditorToolbox {
}
module.exports = EditorToolbox;
export default EditorToolbox;

View File

@ -44,4 +44,4 @@ class EntitySelectorPopup {
}
}
module.exports = EntitySelectorPopup;
export default EntitySelectorPopup;

View File

@ -115,4 +115,4 @@ class EntitySelector {
}
module.exports = EntitySelector;
export default EntitySelector;

View File

@ -62,4 +62,4 @@ class ExpandToggle {
}
module.exports = ExpandToggle;
export default ExpandToggle;

View File

@ -19,4 +19,4 @@ class HomepageControl {
}
module.exports = HomepageControl;
export default HomepageControl;

View File

@ -56,4 +56,4 @@ class ImagePicker {
}
module.exports = ImagePicker;
export default ImagePicker;

View File

@ -1,30 +1,51 @@
import dropdown from "./dropdown";
import overlay from "./overlay";
import backToTop from "./back-to-top";
import notification from "./notification";
import chapterToggle from "./chapter-toggle";
import expandToggle from "./expand-toggle";
import entitySelectorPopup from "./entity-selector-popup";
import entitySelector from "./entity-selector";
import sidebar from "./sidebar";
import pagePicker from "./page-picker";
import pageComments from "./page-comments";
import wysiwygEditor from "./wysiwyg-editor";
import markdownEditor from "./markdown-editor";
import editorToolbox from "./editor-toolbox";
import imagePicker from "./image-picker";
import collapsible from "./collapsible";
import toggleSwitch from "./toggle-switch";
import pageDisplay from "./page-display";
import shelfSort from "./shelf-sort";
import homepageControl from "./homepage-control";
let componentMapping = {
'dropdown': require('./dropdown'),
'overlay': require('./overlay'),
'back-to-top': require('./back-top-top'),
'notification': require('./notification'),
'chapter-toggle': require('./chapter-toggle'),
'expand-toggle': require('./expand-toggle'),
'entity-selector-popup': require('./entity-selector-popup'),
'entity-selector': require('./entity-selector'),
'sidebar': require('./sidebar'),
'page-picker': require('./page-picker'),
'page-comments': require('./page-comments'),
'wysiwyg-editor': require('./wysiwyg-editor'),
'markdown-editor': require('./markdown-editor'),
'editor-toolbox': require('./editor-toolbox'),
'image-picker': require('./image-picker'),
'collapsible': require('./collapsible'),
'toggle-switch': require('./toggle-switch'),
'page-display': require('./page-display'),
'shelf-sort': require('./shelf-sort'),
'homepage-control': require('./homepage-control'),
const componentMapping = {
'dropdown': dropdown,
'overlay': overlay,
'back-to-top': backToTop,
'notification': notification,
'chapter-toggle': chapterToggle,
'expand-toggle': expandToggle,
'entity-selector-popup': entitySelectorPopup,
'entity-selector': entitySelector,
'sidebar': sidebar,
'page-picker': pagePicker,
'page-comments': pageComments,
'wysiwyg-editor': wysiwygEditor,
'markdown-editor': markdownEditor,
'editor-toolbox': editorToolbox,
'image-picker': imagePicker,
'collapsible': collapsible,
'toggle-switch': toggleSwitch,
'page-display': pageDisplay,
'shelf-sort': shelfSort,
'homepage-control': homepageControl,
};
window.components = {};
let componentNames = Object.keys(componentMapping);
const componentNames = Object.keys(componentMapping);
/**
* Initialize components of the given name within the given element.

View File

@ -1,8 +1,8 @@
const MarkdownIt = require("markdown-it");
const mdTasksLists = require('markdown-it-task-lists');
const code = require('../services/code');
import MarkdownIt from "markdown-it";
import mdTasksLists from 'markdown-it-task-lists';
import code from '../services/code';
const DrawIO = require('../services/drawio');
import DrawIO from "../services/drawio";
class MarkdownEditor {
@ -427,4 +427,4 @@ class MarkdownEditor {
}
module.exports = MarkdownEditor ;
export default MarkdownEditor ;

View File

@ -43,4 +43,4 @@ class Notification {
}
module.exports = Notification;
export default Notification;

View File

@ -36,4 +36,4 @@ class Overlay {
}
module.exports = Overlay;
export default Overlay;

View File

@ -1,4 +1,4 @@
const MarkdownIt = require("markdown-it");
import MarkdownIt from "markdown-it";
const md = new MarkdownIt({ html: false });
class PageComments {
@ -172,4 +172,4 @@ class PageComments {
}
module.exports = PageComments;
export default PageComments;

View File

@ -233,4 +233,4 @@ class PageDisplay {
}
}
module.exports = PageDisplay;
export default PageDisplay;

View File

@ -59,4 +59,4 @@ function toggleElem(elem, show) {
elem.style.display = show ? display : 'none';
}
module.exports = PagePicker;
export default PagePicker;

View File

@ -1,3 +1,4 @@
import "jquery-sortable";
class ShelfSort {
@ -9,9 +10,8 @@ class ShelfSort {
}
initSortable() {
const sortable = require('jquery-sortable');
const placeHolderContent = this.getPlaceholderHTML();
// TODO - Load sortable at this point
return $('.scroll-box').sortable({
group: 'shelf-books',
exclude: '.instruction,.scroll-box-placeholder',
@ -68,4 +68,4 @@ class ShelfSort {
}
module.exports = ShelfSort;
export default ShelfSort;

View File

@ -13,4 +13,4 @@ class Sidebar {
}
module.exports = Sidebar;
export default Sidebar;

View File

@ -16,4 +16,4 @@ class ToggleSwitch {
}
module.exports = ToggleSwitch;
export default ToggleSwitch;

View File

@ -1,5 +1,5 @@
const Code = require('../services/code');
const DrawIO = require('../services/drawio');
import Code from "../services/code";
import DrawIO from "../services/drawio";
/**
* Handle pasting images from clipboard.
@ -593,4 +593,4 @@ class WysiwygEditor {
}
module.exports = WysiwygEditor;
export default WysiwygEditor;