diff --git a/assets/app.js b/assets/app.js index e389a28..36ff758 100644 --- a/assets/app.js +++ b/assets/app.js @@ -55,9 +55,13 @@ import './styles/05-utilities/utilities.css'; console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉'); +import Prism from 'prismjs'; + import 'katex/dist/katex.min.css'; import renderMathInElement from 'katex/dist/contrib/auto-render.mjs'; +Prism.highlightAll(); + // Detect math blocks in text content while avoiding common currency patterns function hasRealMath(text) { if (!text) return false; diff --git a/assets/controllers/editor/layout_controller.js b/assets/controllers/editor/layout_controller.js index bdb1911..07c5e72 100644 --- a/assets/controllers/editor/layout_controller.js +++ b/assets/controllers/editor/layout_controller.js @@ -3,7 +3,7 @@ import {Controller} from '@hotwired/stimulus'; export default class extends Controller { static targets = [ - 'modeTab', 'editPane', 'markdownPane', 'previewPane', + 'modeTab', 'editPane', 'markdownPane', 'jsonPane', 'previewPane', 'previewBody', 'previewTitle', 'previewSummary', 'previewImage', 'previewImagePlaceholder', 'previewAuthor', 'previewDate', 'markdownEditor', 'markdownTitle', 'markdownCode', 'status' @@ -24,6 +24,23 @@ export default class extends Controller { imageInput.addEventListener('input', () => this.updatePreview()); imageInput.addEventListener('change', () => this.updatePreview()); } + + // If editing an existing article, load JSON event by default + if (this.element.dataset.articleId && this.hasJsonPaneTarget) { + // Find the JSON textarea in the pane and load the event + const jsonTextarea = this.jsonPaneTarget.querySelector('[data-editor--json-panel-target="jsonTextarea"]'); + if (jsonTextarea && !jsonTextarea.value.trim()) { + // Try to get the Nostr publish controller's JSON + const nostrController = this.application.getControllerForElementAndIdentifier( + this.element.querySelector('[data-controller*="nostr--nostr-publish"]'), + 'nostr--nostr-publish' + ); + if (nostrController && nostrController.hasJsonTextareaTarget) { + jsonTextarea.value = nostrController.jsonTextareaTarget.value; + // Optionally, trigger formatting/validation if needed + } + } + } } switchMode(event) { @@ -37,6 +54,7 @@ export default class extends Controller { // Toggle panes - hide all, then show the selected one this.editPaneTarget.classList.toggle('is-hidden', mode !== 'edit'); this.markdownPaneTarget.classList.toggle('is-hidden', mode !== 'markdown'); + this.jsonPaneTarget.classList.toggle('is-hidden', mode !== 'json'); this.previewPaneTarget.classList.toggle('is-hidden', mode !== 'preview'); // Update content when switching modes @@ -44,6 +62,8 @@ export default class extends Controller { this.updateMarkdown(); } else if (mode === 'preview') { this.updatePreview(); + } else if (mode === 'json') { + // Optionally, trigger JSON formatting/validation } } diff --git a/assets/controllers/editor--markdown-sync_controller.js b/assets/controllers/editor/markdown-sync_controller.js similarity index 100% rename from assets/controllers/editor--markdown-sync_controller.js rename to assets/controllers/editor/markdown-sync_controller.js diff --git a/importmap.php b/importmap.php index 83da80a..573fbc7 100644 --- a/importmap.php +++ b/importmap.php @@ -115,4 +115,53 @@ return [ 'katex/dist/katex.min.js' => [ 'version' => '0.16.25', ], + 'prism-react' => [ + 'version' => '1.0.2', + ], + 'prism-redux' => [ + 'version' => '1.0.2', + ], + 'react' => [ + 'version' => '15.5.4', + ], + 'recompose' => [ + 'version' => '0.22.0', + ], + 'object-assign' => [ + 'version' => '4.1.1', + ], + 'fbjs/lib/invariant' => [ + 'version' => '0.8.12', + ], + 'fbjs/lib/warning' => [ + 'version' => '0.8.12', + ], + 'fbjs/lib/emptyFunction' => [ + 'version' => '0.8.12', + ], + 'fbjs/lib/emptyObject' => [ + 'version' => '0.8.12', + ], + 'prop-types/factory' => [ + 'version' => '15.5.7', + ], + 'fbjs/lib/shallowEqual' => [ + 'version' => '0.8.8', + ], + 'hoist-non-react-statics' => [ + 'version' => '1.2.0', + ], + 'change-emitter' => [ + 'version' => '0.1.2', + ], + 'symbol-observable' => [ + 'version' => '1.0.4', + ], + 'prismjs' => [ + 'version' => '1.30.0', + ], + 'prismjs/themes/prism.min.css' => [ + 'version' => '1.30.0', + 'type' => 'css', + ], ]; diff --git a/templates/editor/layout.html.twig b/templates/editor/layout.html.twig index c7162e6..43a6c59 100644 --- a/templates/editor/layout.html.twig +++ b/templates/editor/layout.html.twig @@ -38,7 +38,7 @@ {% endblock %} {% block layout %} -
+
{# Insert the article list sidebar as the first grid column #}
+ +
@@ -319,14 +326,6 @@ {% include 'editor/panels/_media.html.twig' %} #} - -
@@ -354,8 +353,3 @@ {% block footer %} {% endblock %} - -{% block javascripts %} - {{ parent() }} - {# Removed inline script, now handled by Stimulus controller #} -{% endblock %} diff --git a/templates/editor/panels/_json.html.twig b/templates/editor/panels/_json.html.twig index af19f84..953700b 100644 --- a/templates/editor/panels/_json.html.twig +++ b/templates/editor/panels/_json.html.twig @@ -1,9 +1,4 @@
-

Raw Nostr Event

-

- View and edit the raw Nostr event JSON. Changes here will override form values when publishing. -

-
-