[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] textareas: Add a new syntax option of "none" for disabling syntax parsing
"Jonny Bradley \(@jonnybradley\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <69a86fda1987c_3b1886342453@gitlab-sidekiq-low-urgency-cpu-bound-v2-6cc94ddffd-nmzdg.mail> |
Jonny Bradley pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
a98796ef by Jonny Bradley at 2026-03-04T17:37:59+00:00
[FIX] textareas: Add a new syntax option of "none" for disabling syntax parsing
---
* [DOC] Update textarea _syntax documentation
* [FIX] textareas: Rename the `syntax` param to `_syntax` (because parameters not starting with an underscore get added to the `<textarea>` html tag as attributes)
* [FIX] textareas: Add a new syntax option of "none" for disabling syntax parsing, and use this on tracker descriptions when descriptionIsParsed eq 'n'. An alternative to !9628 maybe?
See merge request tikiwiki/tiki!9675
- - - - -
5 changed files:
- lib/smarty_tiki/BlockHandler/TextArea.php
- lib/smarty_tiki/FunctionHandler/Toolbars.php
- templates/edit/post_editor_settings.tpl
- templates/tracker/replace.tpl
- templates/workspace/advanced_edit.tpl
Changes:
=====================================
lib/smarty_tiki/BlockHandler/TextArea.php
=====================================
@@ -26,6 +26,9 @@ use Exception;
* _wysiwyg: force wysiwyg editor
* _is_html: parse as html
* _preview: add a preview in a tab
+ * _syntax: Specify syntax to be used.
+ * If blank then \WikiParser_Parsable::guess_syntax is used.
+ * Use "none" to make a plain text area
*
* usage: {textarea id='my_area' name='my_area'}{tr}My Text{/tr}{/textarea}
*/
@@ -81,13 +84,13 @@ class TextArea extends Base
$smarty->assign('textarea_id', $params['id']);
- if (empty($params['syntax'])) { // work out if we have Tiki or Markdown syntax
+ if (empty($params['_syntax'])) { // work out if we have Tiki or Markdown syntax
$wikiParserParsable = new \WikiParser_Parsable($content);
$syntaxPluginResult = $wikiParserParsable->guess_syntax($content);// for the toolbars
if (isset($syntaxPluginResult['syntax'])) {
- $params['syntax'] = $syntaxPluginResult['syntax'];
+ $params['_syntax'] = $syntaxPluginResult['syntax'];
} else {
- $params['syntax'] = 'tiki';
+ $params['_syntax'] = 'tiki';
}// to pick the editor
if (isset($syntaxPluginResult['editor']) && empty($content) && empty($params['_wysiwyg'])) {
$params['_wysiwyg'] = $syntaxPluginResult['editor'] === 'wysiwyg' ? 'y' : 'n';
@@ -97,7 +100,7 @@ class TextArea extends Base
//codemirror integration
if ($prefs['feature_syntax_highlighter'] === 'y') {
$params['data-codemirror'] = $params['codemirror'] ?? '';
- $params['data-syntax'] = $params['syntax'];
+ $params['data-syntax'] = $params['_syntax'];
}
//keep params html5 friendly
unset($params['codemirror']);
@@ -113,7 +116,7 @@ class TextArea extends Base
}
$html = '';
$html .= '<input type="hidden" name="mode_wysiwyg" value="" /><input type="hidden" name="mode_normal" value="" />';
- $html .= '<input type="hidden" name="syntax" value="' . $params['syntax'] . '" />';
+ $html .= '<input type="hidden" name="syntax" value="' . $params['_syntax'] . '" />';
$auto_save_referrer = '';
$auto_save_warning = '';
@@ -180,7 +183,7 @@ class TextArea extends Base
$params['name'] = 'edit';
}
- if ($params['syntax'] === 'markdown') {
+ if ($params['_syntax'] === 'markdown') {
// markdown
$tuiOptions = $wysiwyglib->setUpMarkdownEditor($as_id, $content, $params, $auto_save_referrer);
@@ -217,7 +220,7 @@ class TextArea extends Base
if ($textarea_attributes != '') {
$smarty->assign('textarea_attributes', $textarea_attributes);
}
- $smarty->assign('textarea_syntax', $params['syntax']);
+ $smarty->assign('textarea_syntax', $params['_syntax']);
$smarty->assign('objectId', $params['objectId'] ?? null);
$smarty->assign_by_ref('textareadata', $content);
$html .= $smarty->fetch('wiki_edit.tpl');
@@ -422,7 +425,7 @@ class TextArea extends Base
$headerlib->add_jsfile('lib/jquery_tiki/edit_preview.js');
}
- if ($prefs['markdown_enabled'] === 'y' && ($params['syntax'] === 'tiki' || $params['syntax'] === 'markdown')) {
+ if ($prefs['markdown_enabled'] === 'y' && ($params['_syntax'] === 'tiki' || $params['_syntax'] === 'markdown')) {
$headerlib->add_js(/** @lang JavaScript */ '
function addSyntaxPlugin(domId, $form) {
const $textarea = $("#" + domId),
=====================================
lib/smarty_tiki/FunctionHandler/Toolbars.php
=====================================
@@ -26,6 +26,10 @@ class Toolbars extends Base
'syntax' => $prefs['markdown_default'],
];
$params = array_merge($default, $params);
+
+ if ($params['syntax'] == 'none') {
+ return '';
+ }
// filters some tools here depending on section
$hidden = [];
$switchableWysiwygSections = ['wiki page', 'blogs', 'newsletters', 'cms', 'webmail'];
=====================================
templates/edit/post_editor_settings.tpl
=====================================
@@ -1,5 +1,5 @@
{extends $global_extend_layout|default:'layout_view.tpl'}
{block name="content"}
- {textarea name=$domName id=$domId _wysiwyg=$wysiwyg syntax=$syntax}{$content}{/textarea}
+ {textarea name=$domName id=$domId _wysiwyg=$wysiwyg _syntax=$syntax}{$content}{/textarea}
{/block}
=====================================
templates/tracker/replace.tpl
=====================================
@@ -15,7 +15,9 @@
</div>
<div class="mb-3 mx-0">
<label for="description">{tr}Description{/tr}</label>
- {textarea class="form-control" name="description" id="description" cols="40"}{$info.description|escape}{/textarea}
+ {* if the _syntax param is empty, {textarea} will work out the best one, "none" forces a plain <textarea> to be created *}
+ {$descriptionSyntax = $info.descriptionIsParsed eq 'y' ? '' : 'none'}
+ {textarea class="form-control" name="description" id="description" cols="40" _syntax=$descriptionSyntax}{$info.description|escape}{/textarea}
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" name="descriptionIsParsed" id="descriptionIsParsed" {if $info.descriptionIsParsed eq 'y'}checked="checked"{/if} value="1">
=====================================
templates/workspace/advanced_edit.tpl
=====================================
@@ -30,7 +30,7 @@
</div>
<div class="mb-3 row">
<div class="col-sm-12">
- {textarea syntax='tiki' codemirror='true'}{$definition}{/textarea}
+ {textarea _syntax='tiki' codemirror='true'}{$definition}{/textarea}
</div>
</div>
<div class="submit text-center">
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a98796ef5c9aa8f08f008bf713f6ccbb673f5165
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a98796ef5c9aa8f08f008bf713f6ccbb673f5165
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs