Fixed some Javascript/Typescript issues
parent
4766d88585
commit
26a62c9d19
|
|
@ -598,6 +598,11 @@
|
||||||
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==",
|
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"acorn": {
|
||||||
|
"version": "8.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.4.1.tgz",
|
||||||
|
"integrity": "sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA=="
|
||||||
|
},
|
||||||
"acorn-import-assertions": {
|
"acorn-import-assertions": {
|
||||||
"version": "1.7.6",
|
"version": "1.7.6",
|
||||||
"resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.7.6.tgz",
|
"resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.7.6.tgz",
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
"@tiptap/extension-table-header": "^2.0.0-beta.16",
|
"@tiptap/extension-table-header": "^2.0.0-beta.16",
|
||||||
"@tiptap/extension-table-row": "^2.0.0-beta.14",
|
"@tiptap/extension-table-row": "^2.0.0-beta.14",
|
||||||
"@tiptap/starter-kit": "^2.0.0-beta.101",
|
"@tiptap/starter-kit": "^2.0.0-beta.101",
|
||||||
|
"acorn": "^8.4.1",
|
||||||
"bootstrap": "^4.6.0",
|
"bootstrap": "^4.6.0",
|
||||||
"bootstrap-icons": "^1.5.0",
|
"bootstrap-icons": "^1.5.0",
|
||||||
"jquery": "^3.6.0",
|
"jquery": "^3.6.0",
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ import TableHeader from "@tiptap/extension-table-header";
|
||||||
const BUTTONS: CmsEditorButton[] = [
|
const BUTTONS: CmsEditorButton[] = [
|
||||||
{
|
{
|
||||||
selector: ".tiptap-emph",
|
selector: ".tiptap-emph",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().toggleItalic().run();
|
return cmsEditor.getEditor().chain().focus().toggleItalic().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -24,14 +24,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleItalic()
|
.toggleItalic()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-strong-emph",
|
selector: ".tiptap-strong-emph",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().toggleBold().run();
|
return cmsEditor.getEditor().chain().focus().toggleBold().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -39,14 +39,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleBold()
|
.toggleBold()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-code",
|
selector: ".tiptap-code",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().toggleCode().run();
|
return cmsEditor.getEditor().chain().focus().toggleCode().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -54,14 +54,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleCode()
|
.toggleCode()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-strikethrough",
|
selector: ".tiptap-strikethrough",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().toggleStrike().run();
|
return cmsEditor.getEditor().chain().focus().toggleStrike().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -69,11 +69,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleStrike()
|
.toggleStrike()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-subscript",
|
selector: ".tiptap-subscript",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -81,7 +81,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleSubscript()
|
.toggleSubscript()
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -89,11 +89,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleSubscript()
|
.toggleSubscript()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-superscript",
|
selector: ".tiptap-superscript",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -101,7 +101,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleSuperscript()
|
.toggleSuperscript()
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -109,11 +109,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleSuperscript()
|
.toggleSuperscript()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-h1",
|
selector: ".tiptap-h1",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -121,7 +121,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleHeading({ level: 1 })
|
.toggleHeading({ level: 1 })
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -129,11 +129,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleHeading({ level: 1 })
|
.toggleHeading({ level: 1 })
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-h2",
|
selector: ".tiptap-h2",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -141,7 +141,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleHeading({ level: 2 })
|
.toggleHeading({ level: 2 })
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -149,11 +149,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleHeading({ level: 2 })
|
.toggleHeading({ level: 2 })
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-h3",
|
selector: ".tiptap-h3",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -161,7 +161,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleHeading({ level: 3 })
|
.toggleHeading({ level: 3 })
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -169,11 +169,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleHeading({ level: 3 })
|
.toggleHeading({ level: 3 })
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-h5",
|
selector: ".tiptap-h5",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -181,7 +181,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleHeading({ level: 5 })
|
.toggleHeading({ level: 5 })
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -189,11 +189,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleHeading({ level: 5 })
|
.toggleHeading({ level: 5 })
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-h6",
|
selector: ".tiptap-h6",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -201,7 +201,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleHeading({ level: 6 })
|
.toggleHeading({ level: 6 })
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -209,14 +209,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleHeading({ level: 6 })
|
.toggleHeading({ level: 6 })
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-paragraph",
|
selector: ".tiptap-paragraph",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().clearNodes().run();
|
return cmsEditor.getEditor().chain().focus().clearNodes().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -224,11 +224,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.clearNodes()
|
.clearNodes()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-blockquote",
|
selector: ".tiptap-blockquote",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -236,7 +236,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleBlockquote()
|
.toggleBlockquote()
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -244,11 +244,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleBlockquote()
|
.toggleBlockquote()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-codeblock",
|
selector: ".tiptap-codeblock",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -256,7 +256,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleCodeBlock()
|
.toggleCodeBlock()
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -264,11 +264,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleCodeBlock()
|
.toggleCodeBlock()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-ul",
|
selector: ".tiptap-ul",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -276,7 +276,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleBulletList()
|
.toggleBulletList()
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -284,11 +284,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleBulletList()
|
.toggleBulletList()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-ol",
|
selector: ".tiptap-ol",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -296,7 +296,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleOrderedList()
|
.toggleOrderedList()
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -304,14 +304,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleOrderedList()
|
.toggleOrderedList()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".cms-editor-insert-table-dialog",
|
selector: ".cms-editor-insert-table-dialog",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -319,11 +319,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.insertTable()
|
.insertTable()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".cms-editor-insert-table-dialog .btn-success",
|
selector: ".cms-editor-insert-table-dialog .btn-success",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
const dialog = cmsEditor
|
const dialog = cmsEditor
|
||||||
.getEditorElem()
|
.getEditorElem()
|
||||||
.querySelector(".cms-editor-insert-table-dialog");
|
.querySelector(".cms-editor-insert-table-dialog");
|
||||||
|
|
@ -342,8 +342,8 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
console.log(`rowsInput = ${rowsInput}`);
|
console.log(`rowsInput = ${rowsInput}`);
|
||||||
console.log(`colsInput = ${colsInput}`);
|
console.log(`colsInput = ${colsInput}`);
|
||||||
console.log(`headerRowInput = ${headerRowInput}`);
|
console.log(`headerRowInput = ${headerRowInput}`);
|
||||||
const rows = rowsInput.value;
|
const rows = parseInt(rowsInput.value, 10);
|
||||||
const cols = colsInput.value;
|
const cols = parseInt(colsInput.value, 10);
|
||||||
const headerRow = JSON.parse(headerRowInput.value) as Boolean;
|
const headerRow = JSON.parse(headerRowInput.value) as Boolean;
|
||||||
const insertTableDialog = $("#insert-table-dialog") as any;
|
const insertTableDialog = $("#insert-table-dialog") as any;
|
||||||
insertTableDialog.modal("hide");
|
insertTableDialog.modal("hide");
|
||||||
|
|
@ -352,25 +352,25 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.chain()
|
.chain()
|
||||||
.focus()
|
.focus()
|
||||||
.insertTable({
|
.insertTable({
|
||||||
allowTableNodeSelection: true,
|
// allowTableNodeSelection: true,
|
||||||
cellMinWidth: 150,
|
// cellMinWidth: 150,
|
||||||
cols: cols,
|
cols: cols,
|
||||||
headerRow: headerRow,
|
// headerRow: headerRow,
|
||||||
resizable: true,
|
// resizable: true,
|
||||||
rows: rows,
|
rows: rows
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return true;
|
return true;
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-insert-table-row-before",
|
selector: ".tiptap-insert-table-row-before",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().addRowBefore().run();
|
return cmsEditor.getEditor().chain().focus().addRowBefore().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -378,14 +378,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.addRowBefore()
|
.addRowBefore()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-insert-table-row-after",
|
selector: ".tiptap-insert-table-row-after",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().addRowAfter().run();
|
return cmsEditor.getEditor().chain().focus().addRowAfter().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -393,11 +393,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.addRowAfter()
|
.addRowAfter()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-insert-table-column-before",
|
selector: ".tiptap-insert-table-column-before",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -405,7 +405,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.addColumnBefore()
|
.addColumnBefore()
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -413,14 +413,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.addColumnBefore()
|
.addColumnBefore()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-insert-table-column-after",
|
selector: ".tiptap-insert-table-column-after",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().addColumnAfter().run();
|
return cmsEditor.getEditor().chain().focus().addColumnAfter().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -428,14 +428,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.addColumnAfter()
|
.addColumnAfter()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-remove-table-row",
|
selector: ".tiptap-remove-table-row",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().deleteRow().run();
|
return cmsEditor.getEditor().chain().focus().deleteRow().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -443,14 +443,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.deleteRow()
|
.deleteRow()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-remove-table-column",
|
selector: ".tiptap-remove-table-column",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().deleteColumn().run();
|
return cmsEditor.getEditor().chain().focus().deleteColumn().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -458,14 +458,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.deleteColumn()
|
.deleteColumn()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-remove-table",
|
selector: ".tiptap-remove-table",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().deleteTable().run();
|
return cmsEditor.getEditor().chain().focus().deleteTable().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -473,11 +473,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.deleteTable()
|
.deleteTable()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-toggle-table-header-row",
|
selector: ".tiptap-toggle-table-header-row",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -485,7 +485,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleHeaderRow()
|
.toggleHeaderRow()
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -493,11 +493,11 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleHeaderRow()
|
.toggleHeaderRow()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-toggle-table-header-column",
|
selector: ".tiptap-toggle-table-header-column",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -505,7 +505,7 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.toggleHeaderColumn()
|
.toggleHeaderColumn()
|
||||||
.run();
|
.run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -513,14 +513,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.toggleHeaderColumn()
|
.toggleHeaderColumn()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-merge-table-cells",
|
selector: ".tiptap-merge-table-cells",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().mergeCells().run();
|
return cmsEditor.getEditor().chain().focus().mergeCells().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -528,14 +528,14 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.mergeCells()
|
.mergeCells()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
selector: ".tiptap-split-table-cell",
|
selector: ".tiptap-split-table-cell",
|
||||||
command: (cmsEditor) => {
|
command: cmsEditor => {
|
||||||
return cmsEditor.getEditor().chain().focus().splitCell().run();
|
return cmsEditor.getEditor().chain().focus().splitCell().run();
|
||||||
},
|
},
|
||||||
can: (cmsEditor) => {
|
can: cmsEditor => {
|
||||||
return cmsEditor
|
return cmsEditor
|
||||||
.getEditor()
|
.getEditor()
|
||||||
.can()
|
.can()
|
||||||
|
|
@ -543,8 +543,8 @@ const BUTTONS: CmsEditorButton[] = [
|
||||||
.focus()
|
.focus()
|
||||||
.splitCell()
|
.splitCell()
|
||||||
.run();
|
.run();
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
// {
|
// {
|
||||||
// selector: "",
|
// selector: "",
|
||||||
// command: cmsEditor => {},
|
// command: cmsEditor => {},
|
||||||
|
|
@ -589,7 +589,7 @@ class CmsEditor {
|
||||||
for (const button of BUTTONS) {
|
for (const button of BUTTONS) {
|
||||||
const buttonElem = buttonsElem.querySelector(button.selector);
|
const buttonElem = buttonsElem.querySelector(button.selector);
|
||||||
if (buttonElem) {
|
if (buttonElem) {
|
||||||
buttonElem.addEventListener("click", (event) => {
|
buttonElem.addEventListener("click", event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
button.command(this);
|
button.command(this);
|
||||||
});
|
});
|
||||||
|
|
@ -628,7 +628,7 @@ class CmsEditor {
|
||||||
console.log(`editorElem = ${editorElem}`);
|
console.log(`editorElem = ${editorElem}`);
|
||||||
|
|
||||||
const saveButton = editorElem.querySelector(".cms-editor-save-button");
|
const saveButton = editorElem.querySelector(".cms-editor-save-button");
|
||||||
saveButton?.addEventListener("click", (event) => this.save(event));
|
saveButton?.addEventListener("click", event => this.save(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async save(event: Event) {
|
protected async save(event: Event) {
|
||||||
|
|
@ -642,9 +642,9 @@ class CmsEditor {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
},
|
},
|
||||||
body: params,
|
body: params
|
||||||
});
|
});
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -654,7 +654,7 @@ class CmsEditor {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.showSaveFailedErrMessage(error);
|
this.showSaveFailedErrMessage(error as string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -717,12 +717,17 @@ class CmsEditorBuilder {
|
||||||
StarterKit,
|
StarterKit,
|
||||||
Subscript,
|
Subscript,
|
||||||
Superscript,
|
Superscript,
|
||||||
Table.configure({ resizable: true }),
|
Table.configure({
|
||||||
|
allowTableNodeSelection: true,
|
||||||
|
cellMinWidth: 100,
|
||||||
|
handleWidth: 25,
|
||||||
|
resizable: true
|
||||||
|
}),
|
||||||
TableRow,
|
TableRow,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableCell,
|
TableCell
|
||||||
],
|
],
|
||||||
content: variant,
|
content: variant
|
||||||
});
|
});
|
||||||
|
|
||||||
return new CmsEditor(editor, this.editorElem, this.saveUrl);
|
return new CmsEditor(editor, this.editorElem, this.saveUrl);
|
||||||
|
|
@ -732,7 +737,7 @@ class CmsEditorBuilder {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(variantUrl, {
|
const response = await fetch(variantUrl, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
credentials: "include",
|
credentials: "include"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
|
@ -745,7 +750,7 @@ class CmsEditorBuilder {
|
||||||
throw `Failed to load variant. Status: ${response.status}, Status Text: ${response.statusText}`;
|
throw `Failed to load variant. Status: ${response.status}, Status Text: ${response.statusText}`;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.showLoadVariantFailedErrorMessage(error);
|
this.showLoadVariantFailedErrorMessage(error as string);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue