From 808f8b83304b1865e6c67685d1d29d86ff63bd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Thu, 28 Aug 2025 17:08:35 +0200 Subject: [PATCH] Editor styles --- assets/controllers/nostr_publish_controller.js | 13 +------------ assets/controllers/quill_controller.js | 6 +++--- assets/styles/form.css | 14 +++++++++++++- src/Form/EditorType.php | 10 +++++----- templates/pages/editor.html.twig | 3 --- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/assets/controllers/nostr_publish_controller.js b/assets/controllers/nostr_publish_controller.js index d78b6dd..c9dee6a 100644 --- a/assets/controllers/nostr_publish_controller.js +++ b/assets/controllers/nostr_publish_controller.js @@ -9,16 +9,10 @@ export default class extends Controller { connect() { console.log('Nostr publish controller connected'); - // Helpful debug to verify values are wired from Twig try { console.debug('[nostr-publish] publishUrl:', this.publishUrlValue || '(none)'); console.debug('[nostr-publish] has csrfToken:', Boolean(this.csrfTokenValue)); } catch (_) {} - - // Provide a sensible fallback if not passed via values - if (!this.hasPublishUrlValue || !this.publishUrlValue) { - this.publishUrlValue = '/api/article/publish'; - } } async publish(event) { @@ -87,11 +81,7 @@ export default class extends Controller { const formData = new FormData(form); - // Get content from Quill editor if available - const quillEditor = document.querySelector('.ql-editor'); let content = formData.get('editor[content]') || ''; - - // Convert HTML to markdown (basic conversion) content = this.htmlToMarkdown(content); const title = formData.get('editor[title]') || ''; @@ -124,7 +114,7 @@ export default class extends Controller { // Create tags array const tags = [ - ['d', formData.slug], // NIP-33 replaceable event identifier + ['d', formData.slug], ['title', formData.title], ['published_at', Math.floor(Date.now() / 1000).toString()] ]; @@ -191,7 +181,6 @@ export default class extends Controller { markdown = markdown.replace(/]*>(.*?)<\/b>/gi, '**$1**'); markdown = markdown.replace(/]*>(.*?)<\/em>/gi, '*$1*'); markdown = markdown.replace(/]*>(.*?)<\/i>/gi, '*$1*'); - markdown = markdown.replace(/]*>(.*?)<\/u>/gi, '_$1_'); // Convert links markdown = markdown.replace(/]*href="([^"]*)"[^>]*>(.*?)<\/a>/gi, '[$2]($1)'); diff --git a/assets/controllers/quill_controller.js b/assets/controllers/quill_controller.js index 60ba30b..173b4ec 100644 --- a/assets/controllers/quill_controller.js +++ b/assets/controllers/quill_controller.js @@ -9,9 +9,9 @@ export default class extends Controller { connect() { const toolbarOptions = [ - ['bold', 'italic', 'underline', 'strike'], + ['bold', 'italic', 'strike'], ['link', 'blockquote', 'code-block', 'image'], - [{ 'header': 1 }, { 'header': 2 }], + [{ 'header': 1 }, { 'header': 2 }, { 'header': 3 }], [{ list: 'ordered' }, { list: 'bullet' }], ]; @@ -36,4 +36,4 @@ export default class extends Controller { }); } -} \ No newline at end of file +} diff --git a/assets/styles/form.css b/assets/styles/form.css index 432c489..c4dde5b 100644 --- a/assets/styles/form.css +++ b/assets/styles/form.css @@ -54,4 +54,16 @@ input:focus, textarea:focus { .image-with-preview input { flex-grow: 1; -} \ No newline at end of file +} + +textarea, input { + font-family: var(--font-family), sans-serif; +} + +.quill { + border: 2px solid var(--color-border); +} + +#editor { + margin: 0; +} diff --git a/src/Form/EditorType.php b/src/Form/EditorType.php index 0091d3e..e90e968 100644 --- a/src/Form/EditorType.php +++ b/src/Form/EditorType.php @@ -22,16 +22,16 @@ class EditorType extends AbstractType // create a form with a title field, a QuillType content field and a submit button $builder ->add('title', TextType::class, [ - 'required' => false, + 'required' => true, 'sanitize_html' => true, - 'attr' => ['placeholder' => 'Awesome article', 'class' => 'form-control']]) + 'attr' => ['placeholder' => 'Awesome title', 'class' => 'form-control']]) ->add('summary', TextareaType::class, [ 'required' => false, 'sanitize_html' => true, 'attr' => ['class' => 'form-control']]) ->add('content', QuillType::class, [ - 'required' => false, - 'attr' => ['placeholder' => 'Enter content', 'class' => 'form-control']]) + 'required' => true, + 'attr' => ['placeholder' => 'Write content', 'class' => 'form-control']]) ->add('image', UrlType::class, [ 'required' => false, 'label' => 'Cover image URL', @@ -40,7 +40,7 @@ class EditorType extends AbstractType 'required' => false, 'sanitize_html' => true, 'help' => 'Separate tags with commas, skip #', - 'attr' => ['placeholder' => 'Enter tags', 'class' => 'form-control']]); + 'attr' => ['placeholder' => 'Add tags', 'class' => 'form-control']]); // Apply the custom transformer $builder->get('topics') diff --git a/templates/pages/editor.html.twig b/templates/pages/editor.html.twig index 4d8c749..bbb3185 100644 --- a/templates/pages/editor.html.twig +++ b/templates/pages/editor.html.twig @@ -23,16 +23,13 @@ {{ form_start(form) }} - {{ form_row(form.title) }} {{ form_row(form.summary) }} {{ form_row(form.content) }} {{ form_row(form.image) }} {{ form_row(form.topics) }} -
-