From 600bb4726064a0658e0e62c56c7d016582c97757 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Mon, 23 Dec 2024 10:20:44 +0100 Subject: [PATCH] editor configuration --- src/helpers/grapesEditor.ts | 141 +++++++++++++++--- .../admin/settings/template/TemplateEdit.vue | 2 + 2 files changed, 120 insertions(+), 23 deletions(-) diff --git a/src/helpers/grapesEditor.ts b/src/helpers/grapesEditor.ts index f843d4f..66916bd 100644 --- a/src/helpers/grapesEditor.ts +++ b/src/helpers/grapesEditor.ts @@ -1,10 +1,11 @@ -import type { Editor } from "grapesjs"; +import type { AddComponentTypeOptions, BlockProperties, Editor } from "grapesjs"; export function configureEditor(editor: Editor): void { - editor.Panels.getPanel("devices-c")?.set("visible", false); + //editor.Panels.getPanel("devices-c")?.set("visible", false); editor.Panels.removeButton("devices-c", "set-device-mobile"); editor.Panels.removeButton("devices-c", "set-device-desktop"); editor.Panels.removeButton("views", "open-tm"); + editor.Panels.removeButton("views", "open-layers"); editor.Panels.removeButton("options", "export-template"); editor.Panels.removeButton("options", "preview"); // editor.Panels.removeButton("options", "fullscreen"); @@ -18,27 +19,6 @@ export function configureEditor(editor: Editor): void { editor.BlockManager.remove("sect37"); editor.BlockManager.remove("text-sect"); - editor.DomComponents.addType("heading", { - model: { - defaults: { - tagName: "h1", - content: "Heading", - }, - }, - isComponent(el) { - return el.tagName === "H1"; - }, - }); - editor.BlockManager.add("heading-block", { - label: "Heading", - content: { type: "heading" }, - category: "Text", - media: ` - - - - `, - }); editor.BlockManager.get("text").set("category", "Text"); editor.BlockManager.get("quote").set("category", "Text"); editor.BlockManager.get("link").set("category", "Text"); @@ -46,4 +26,119 @@ export function configureEditor(editor: Editor): void { editor.BlockManager.get("sect50").set("category", "Struktur"); editor.BlockManager.get("sect30").set("category", "Struktur"); editor.BlockManager.get("divider").set("category", "Struktur"); + editor.BlockManager.add("heading1-block", heading1_block); + editor.BlockManager.add("heading2-block", heading2_block); + editor.BlockManager.add("heading3-block", heading3_block); + editor.BlockManager.add("list_start", list_start_block); + editor.DomComponents.addType("list_end", list_end_block.type); + editor.BlockManager.add("list_end", list_end_block.block); + editor.BlockManager.add("list-block", list_block); + editor.BlockManager.add("list-inner-block", list_inner_block); } + +const heading1_block: BlockProperties = { + label: "Heading1", + category: "Text", + media: ` + + + + `, + content: ` +

Heading 1

+ `, +}; + +const heading2_block: BlockProperties = { + label: "Heading2", + category: "Text", + media: ` + + + + `, + content: ` +

Heading 2

+ `, +}; + +const heading3_block: BlockProperties = { + label: "Heading3", + category: "Text", + media: ` + + + + `, + content: ` +

Heading 3

+ `, +}; + +const list_start_block: BlockProperties = { + label: "Anfang WDH", + category: "Struktur", + media: ` + + + + `, + content: ` + + WDH Start: LISTENNAME + + `, +}; + +const list_end_block: { type: AddComponentTypeOptions; block: BlockProperties } = { + type: { + model: { + defaults: { + tagName: "listend", + content: "WDH ENDE", + editable: false, + }, + }, + isComponent(el) { + return el.tagName === "listend"; + }, + }, + block: { + label: "Ende WDH", + content: { type: "list_end" }, + category: "Struktur", + media: ` + + + + `, + }, +}; + +const list_block: BlockProperties = { + label: "Liste", + category: "Struktur", + media: ` + + + + `, + content: ` + + `, +}; + +const list_inner_block: BlockProperties = { + label: "Listenelement", + category: "Text", + media: ` + + + + `, + content: ` +
  • Element
  • + `, +}; diff --git a/src/views/admin/settings/template/TemplateEdit.vue b/src/views/admin/settings/template/TemplateEdit.vue index 108648f..573fa12 100644 --- a/src/views/admin/settings/template/TemplateEdit.vue +++ b/src/views/admin/settings/template/TemplateEdit.vue @@ -101,6 +101,8 @@ export default defineComponent({ height: "100%", width: "100%", fromElement: true, + telemetry: false, + showDevices: false, deviceManager: { devices: [ {