diff --git a/package-lock.json b/package-lock.json
index e4dae4a5b..bb8b6049b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,6 +18,7 @@
"@codemirror/state": "^6.2.0",
"@codemirror/theme-one-dark": "^6.1.1",
"@codemirror/view": "^6.9.4",
+ "@lezer/highlight": "^1.1.4",
"@ssddanbrown/codemirror-lang-smarty": "^1.0.0",
"@ssddanbrown/codemirror-lang-twig": "^1.0.0",
"codemirror": "^6.0.1",
diff --git a/package.json b/package.json
index 264180f81..39f088234 100644
--- a/package.json
+++ b/package.json
@@ -42,6 +42,7 @@
"@codemirror/state": "^6.2.0",
"@codemirror/theme-one-dark": "^6.1.1",
"@codemirror/view": "^6.9.4",
+ "@lezer/highlight": "^1.1.4",
"@ssddanbrown/codemirror-lang-smarty": "^1.0.0",
"@ssddanbrown/codemirror-lang-twig": "^1.0.0",
"codemirror": "^6.0.1",
@@ -58,48 +59,77 @@
"es2021": true
},
"extends": "airbnb-base",
- "ignorePatterns": ["resources/**/*-stub.js"],
- "overrides": [
+ "ignorePatterns": [
+ "resources/**/*-stub.js"
],
+ "overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
- "indent": ["error", 4],
- "arrow-parens": ["error", "as-needed"],
- "padded-blocks": ["error", {
+ "indent": [
+ "error",
+ 4
+ ],
+ "arrow-parens": [
+ "error",
+ "as-needed"
+ ],
+ "padded-blocks": [
+ "error",
+ {
"blocks": "never",
"classes": "always"
- }],
- "object-curly-spacing": ["error", "never"],
- "space-before-function-paren": ["error", {
- "anonymous": "never",
- "named": "never",
- "asyncArrow": "always"
- }],
+ }
+ ],
+ "object-curly-spacing": [
+ "error",
+ "never"
+ ],
+ "space-before-function-paren": [
+ "error",
+ {
+ "anonymous": "never",
+ "named": "never",
+ "asyncArrow": "always"
+ }
+ ],
"import/prefer-default-export": "off",
- "no-plusplus": ["error", {
- "allowForLoopAfterthoughts": true
- }],
+ "no-plusplus": [
+ "error",
+ {
+ "allowForLoopAfterthoughts": true
+ }
+ ],
"arrow-body-style": "off",
"no-restricted-syntax": "off",
"no-continue": "off",
- "no-console": ["warn", {
- "allow": ["error"]
- }],
- "max-len": ["error", {
- "code": 110,
- "tabWidth": 4,
- "ignoreUrls": true,
- "ignoreComments": false,
- "ignoreRegExpLiterals": true,
- "ignoreStrings": true,
- "ignoreTemplateLiterals": true
- }],
- "no-param-reassign": ["error", {
- "props": false
- }]
+ "prefer-destructuring": "off",
+ "class-methods-use-this": "off",
+ "no-param-reassign": "off",
+ "no-console": [
+ "warn",
+ {
+ "allow": [
+ "error",
+ "warn"
+ ]
+ }
+ ],
+ "no-new": "off",
+ "max-len": [
+ "error",
+ {
+ "code": 110,
+ "tabWidth": 4,
+ "ignoreUrls": true,
+ "ignoreComments": false,
+ "ignoreRegExpLiterals": true,
+ "ignoreStrings": true,
+ "ignoreTemplateLiterals": true
+ }
+ ]
}
}
}
diff --git a/resources/js/app.js b/resources/js/app.js
index 86c8d0802..5b822e900 100644
--- a/resources/js/app.js
+++ b/resources/js/app.js
@@ -1,4 +1,4 @@
-import events from './services/events';
+import * as events from './services/events';
import * as httpInstance from './services/http';
import Translations from './services/translations';
diff --git a/resources/js/code/index.mjs b/resources/js/code/index.mjs
index 450592c25..e51472dc4 100644
--- a/resources/js/code/index.mjs
+++ b/resources/js/code/index.mjs
@@ -6,24 +6,36 @@ import {createView} from './views';
import {SimpleEditorInterface} from './simple-editor-interface';
/**
- * Highlight pre elements on a page
+ * Add a button to a CodeMirror instance which copies the contents to the clipboard upon click.
+ * @param {EditorView} editorView
*/
-export function highlight() {
- const codeBlocks = document.querySelectorAll('.page-content pre, .comment-box .content pre');
- for (const codeBlock of codeBlocks) {
- highlightElem(codeBlock);
- }
-}
+function addCopyIcon(editorView) {
+ const copyIcon = '';
+ const checkIcon = '';
+ const copyButton = document.createElement('button');
+ copyButton.setAttribute('type', 'button');
+ copyButton.classList.add('cm-copy-button');
+ copyButton.innerHTML = copyIcon;
+ editorView.dom.appendChild(copyButton);
-/**
- * Highlight all code blocks within the given parent element
- * @param {HTMLElement} parent
- */
-export function highlightWithin(parent) {
- const codeBlocks = parent.querySelectorAll('pre');
- for (const codeBlock of codeBlocks) {
- highlightElem(codeBlock);
- }
+ const notifyTime = 620;
+ const transitionTime = 60;
+ copyButton.addEventListener('click', () => {
+ copyTextToClipboard(editorView.state.doc.toString());
+ copyButton.classList.add('success');
+
+ setTimeout(() => {
+ copyButton.innerHTML = checkIcon;
+ }, transitionTime / 2);
+
+ setTimeout(() => {
+ copyButton.classList.remove('success');
+ }, notifyTime);
+
+ setTimeout(() => {
+ copyButton.innerHTML = copyIcon;
+ }, notifyTime + (transitionTime / 2));
+ });
}
/**
@@ -32,7 +44,7 @@ export function highlightWithin(parent) {
*/
function highlightElem(elem) {
const innerCodeElem = elem.querySelector('code[class^=language-]');
- elem.innerHTML = elem.innerHTML.replace(/
/gi, '\n');
+ elem.innerHTML = elem.innerHTML.replace(/
/gi, '\n');
const content = elem.textContent.trimEnd();
let langName = '';
@@ -57,36 +69,24 @@ function highlightElem(elem) {
}
/**
- * Add a button to a CodeMirror instance which copies the contents to the clipboard upon click.
- * @param {EditorView} editorView
+ * Highlight all code blocks within the given parent element
+ * @param {HTMLElement} parent
*/
-function addCopyIcon(editorView) {
- const copyIcon = '';
- const checkIcon = '';
- const copyButton = document.createElement('button');
- copyButton.setAttribute('type', 'button');
- copyButton.classList.add('cm-copy-button');
- copyButton.innerHTML = copyIcon;
- editorView.dom.appendChild(copyButton);
+export function highlightWithin(parent) {
+ const codeBlocks = parent.querySelectorAll('pre');
+ for (const codeBlock of codeBlocks) {
+ highlightElem(codeBlock);
+ }
+}
- const notifyTime = 620;
- const transitionTime = 60;
- copyButton.addEventListener('click', event => {
- copyTextToClipboard(editorView.state.doc.toString());
- copyButton.classList.add('success');
-
- setTimeout(() => {
- copyButton.innerHTML = checkIcon;
- }, transitionTime / 2);
-
- setTimeout(() => {
- copyButton.classList.remove('success');
- }, notifyTime);
-
- setTimeout(() => {
- copyButton.innerHTML = copyIcon;
- }, notifyTime + (transitionTime / 2));
- });
+/**
+ * Highlight pre elements on a page
+ */
+export function highlight() {
+ const codeBlocks = document.querySelectorAll('.page-content pre, .comment-box .content pre');
+ for (const codeBlock of codeBlocks) {
+ highlightElem(codeBlock);
+ }
}
/**
diff --git a/resources/js/components/ajax-delete-row.js b/resources/js/components/ajax-delete-row.js
index f48db7939..aa2801f19 100644
--- a/resources/js/components/ajax-delete-row.js
+++ b/resources/js/components/ajax-delete-row.js
@@ -20,7 +20,7 @@ export class AjaxDeleteRow extends Component {
window.$events.emit('success', resp.data.message);
}
this.row.remove();
- }).catch(err => {
+ }).catch(() => {
this.row.style.opacity = null;
this.row.style.pointerEvents = null;
});
diff --git a/resources/js/components/attachments.js b/resources/js/components/attachments.js
index 0c25bd0c0..9555a59e8 100644
--- a/resources/js/components/attachments.js
+++ b/resources/js/components/attachments.js
@@ -27,7 +27,7 @@ export class Attachments extends Component {
this.startEdit(event.detail.id);
});
- this.container.addEventListener('event-emit-select-edit-back', event => {
+ this.container.addEventListener('event-emit-select-edit-back', () => {
this.stopEdit();
});
diff --git a/resources/js/components/auto-suggest.js b/resources/js/components/auto-suggest.js
index b2435961c..92a6c6af3 100644
--- a/resources/js/components/auto-suggest.js
+++ b/resources/js/components/auto-suggest.js
@@ -25,7 +25,7 @@ export class AutoSuggest extends Component {
setupListeners() {
const navHandler = new KeyboardNavigationHandler(
this.list,
- event => {
+ () => {
this.input.focus();
setTimeout(() => this.hideSuggestions(), 1);
},
@@ -104,7 +104,8 @@ export class AutoSuggest extends Component {
*/
displaySuggestions(suggestions) {
if (suggestions.length === 0) {
- return this.hideSuggestions();
+ this.hideSuggestions();
+ return;
}
// This used to use