JS Build: Split markdown to own file, updated packages

Markdown-related code was growing, representing half of app.js main
bundle code while only being needed in one view/scenario.
This extracts markdown related code to its own built file.
Related to #4858
This commit is contained in:
Dan Brown 2024-04-08 14:41:51 +01:00
parent ee40adf11a
commit f5e6f9574d
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
5 changed files with 420 additions and 336 deletions

View File

@ -13,6 +13,7 @@ const entryPoints = {
app: path.join(__dirname, '../../resources/js/app.js'), app: path.join(__dirname, '../../resources/js/app.js'),
code: path.join(__dirname, '../../resources/js/code/index.mjs'), code: path.join(__dirname, '../../resources/js/code/index.mjs'),
'legacy-modes': path.join(__dirname, '../../resources/js/code/legacy-modes.mjs'), 'legacy-modes': path.join(__dirname, '../../resources/js/code/legacy-modes.mjs'),
markdown: path.join(__dirname, '../../resources/js/markdown/index.mjs'),
}; };
// Locate our output directory // Locate our output directory

727
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,6 @@
"eslint-plugin-import": "^2.29.0", "eslint-plugin-import": "^2.29.0",
"livereload": "^0.9.3", "livereload": "^0.9.3",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"punycode": "^2.3.1",
"sass": "^1.69.5" "sass": "^1.69.5"
}, },
"dependencies": { "dependencies": {
@ -47,7 +46,7 @@
"@ssddanbrown/codemirror-lang-twig": "^1.0.0", "@ssddanbrown/codemirror-lang-twig": "^1.0.0",
"codemirror": "^6.0.1", "codemirror": "^6.0.1",
"idb-keyval": "^6.2.1", "idb-keyval": "^6.2.1",
"markdown-it": "^13.0.2", "markdown-it": "^14.1.0",
"markdown-it-task-lists": "^2.1.1", "markdown-it-task-lists": "^2.1.1",
"snabbdom": "^3.5.1", "snabbdom": "^3.5.1",
"sortablejs": "^1.15.1" "sortablejs": "^1.15.1"

View File

@ -1,5 +1,4 @@
import {Component} from './component'; import {Component} from './component';
import {init as initEditor} from '../markdown/editor';
export class MarkdownEditor extends Component { export class MarkdownEditor extends Component {
@ -20,17 +19,19 @@ export class MarkdownEditor extends Component {
const settingInputs = settingContainer.querySelectorAll('input[type="checkbox"]'); const settingInputs = settingContainer.querySelectorAll('input[type="checkbox"]');
this.editor = null; this.editor = null;
initEditor({ window.importVersioned('markdown').then(markdown => {
pageId: this.pageId, return markdown.init({
container: this.elem, pageId: this.pageId,
displayEl: this.display, container: this.elem,
inputEl: this.input, displayEl: this.display,
drawioUrl: this.getDrawioUrl(), inputEl: this.input,
settingInputs: Array.from(settingInputs), drawioUrl: this.getDrawioUrl(),
text: { settingInputs: Array.from(settingInputs),
serverUploadLimit: this.serverUploadLimitText, text: {
imageUploadError: this.imageUploadErrorText, serverUploadLimit: this.serverUploadLimitText,
}, imageUploadError: this.imageUploadErrorText,
},
});
}).then(editor => { }).then(editor => {
this.editor = editor; this.editor = editor;
this.setupListeners(); this.setupListeners();