From 7a5bf494df326e55d7843f26a437b3ffa9dc961c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Cebri=C3=A1n?= Date: Fri, 24 Jan 2020 23:47:10 +0100 Subject: [PATCH] [Highlight Plugin] Add line highlight via Prism Line Highlight plugin Extra: Add Spanish translation to the plugin --- plugins/highlight/trumbowyg.highlight.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/plugins/highlight/trumbowyg.highlight.js b/plugins/highlight/trumbowyg.highlight.js index 1ca737ca7..8fc83fcdf 100644 --- a/plugins/highlight/trumbowyg.highlight.js +++ b/plugins/highlight/trumbowyg.highlight.js @@ -5,9 +5,9 @@ // My plugin default options var defaultOptions = {}; - function highlightIt(text, language) { + function highlightIt(text, language, lineHighlight) { return [ - '
',
+            '
',
             '' + Prism.highlight(text, Prism.languages[language]) + '',
             '
', ].join(''); @@ -36,14 +36,20 @@ '
', ' ', '
', + '
', + ' ', + '
' ].join('\n')), $language = $modal.find('.language'), - $code = $modal.find('.code'); + $code = $modal.find('.code'), + $lineHighlight = $modal.find('.trumbowyg-line-highlight'); // Listen clicks on modal box buttons $modal.on('tbwconfirm', function () { trumbowyg.restoreRange(); - trumbowyg.execCmd('insertHTML', highlightIt($code.val(), $language.val())); + trumbowyg.execCmd('insertHTML', highlightIt($code.val(), $language.val(), $lineHighlight.val())); trumbowyg.execCmd('insertHTML', '


'); trumbowyg.closeModal(); @@ -61,8 +67,15 @@ langs: { // jshint camelcase:false en: { - highlight: 'Code syntax highlight' + highlight: 'Code syntax highlight', + highlight_line: 'Highlight lines, e.g.: 1,3-5', + prism_highlight_plugin_alert: 'You must have Prism Line Highlight plugin installed' }, + es: { + highlight: 'Resaltado de sintaxis de código', + highlight_line: 'Resaltar lineas, ej: 1,3-5', + prism_highlight_plugin_alert: 'Debes de tener el plugin Prism Line Highlight instalado' + } pt_br: { highlight: 'Realçar sintaxe de código' },