diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-08-16 22:56:09 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-08-16 22:56:09 +0200 |
| commit | bbd10eec6b8b46a7173d3be4dd7e05de212f8038 (patch) | |
| tree | 6250065034eb2cbf9569ca9f43fcf081bfa1dbc4 /public/javascripts/admin_interface.js | |
| parent | 9b6a6ff4f2a9f60d8c32dabd1e3d86921db7ba4d (diff) | |
Import Markdown into the editor
Use a vendored marked to import Markdown documents into tinymce.
Diffstat (limited to 'public/javascripts/admin_interface.js')
| -rw-r--r-- | public/javascripts/admin_interface.js | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index 8fe105a7..9b28eb06 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -16,7 +16,7 @@ $(document).ready(function () { | |||
| 16 | promotion: false, | 16 | promotion: false, |
| 17 | menubar: false, | 17 | menubar: false, |
| 18 | plugins: 'code link lists visualblocks', | 18 | plugins: 'code link lists visualblocks', |
| 19 | toolbar: 'bold italic underline | bullist numlist | link unlink | insertpageimage | blocks | code', | 19 | toolbar: 'bold italic underline | bullist numlist | link unlink | insertpageimage | importmarkdown | blocks | code', |
| 20 | extended_valid_elements: 'aggregate[children|tags|limit|order_by|order_direction|partial|conditions],a[href|title|target|rel|class|data-gallery],img[class|src|alt|title|width|height|style|border]', | 20 | extended_valid_elements: 'aggregate[children|tags|limit|order_by|order_direction|partial|conditions],a[href|title|target|rel|class|data-gallery],img[class|src|alt|title|width|height|style|border]', |
| 21 | relative_urls: false, | 21 | relative_urls: false, |
| 22 | entity_encoding: 'raw', | 22 | entity_encoding: 'raw', |
| @@ -39,6 +39,16 @@ $(document).ready(function () { | |||
| 39 | cccms.inline_images.open(editor); | 39 | cccms.inline_images.open(editor); |
| 40 | } | 40 | } |
| 41 | }); | 41 | }); |
| 42 | |||
| 43 | if (typeof marked !== 'undefined') { | ||
| 44 | editor.ui.registry.addButton('importmarkdown', { | ||
| 45 | text: ADMIN_STRINGS.import_markdown, | ||
| 46 | tooltip: ADMIN_STRINGS.import_markdown_tooltip, | ||
| 47 | onAction: function() { | ||
| 48 | cccms.markdown_import.open(editor); | ||
| 49 | } | ||
| 50 | }); | ||
| 51 | } | ||
| 42 | } | 52 | } |
| 43 | }); | 53 | }); |
| 44 | 54 | ||
| @@ -293,6 +303,33 @@ cccms = { | |||
| 293 | } | 303 | } |
| 294 | }, | 304 | }, |
| 295 | 305 | ||
| 306 | markdown_import : { | ||
| 307 | open : function(editor) { | ||
| 308 | editor.windowManager.open({ | ||
| 309 | title: ADMIN_STRINGS.import_markdown, | ||
| 310 | size: 'large', | ||
| 311 | body: { | ||
| 312 | type: 'panel', | ||
| 313 | items: [ | ||
| 314 | { type: 'textarea', name: 'source', maximized: true, | ||
| 315 | placeholder: ADMIN_STRINGS.import_markdown_placeholder } | ||
| 316 | ] | ||
| 317 | }, | ||
| 318 | buttons: [ | ||
| 319 | { type: 'cancel', text: ADMIN_STRINGS.cancel }, | ||
| 320 | { type: 'submit', text: ADMIN_STRINGS.insert, primary: true } | ||
| 321 | ], | ||
| 322 | onSubmit: function(api) { | ||
| 323 | var source = api.getData().source; | ||
| 324 | if (source.trim() !== '') { | ||
| 325 | editor.insertContent(marked.parse(source)); | ||
| 326 | } | ||
| 327 | api.close(); | ||
| 328 | } | ||
| 329 | }); | ||
| 330 | } | ||
| 331 | }, | ||
| 332 | |||
| 296 | inline_images: { | 333 | inline_images: { |
| 297 | ensure_overlay: function() { | 334 | ensure_overlay: function() { |
| 298 | if ($('#inline_image_picker').length) return; | 335 | if ($('#inline_image_picker').length) return; |
