Open evd opened 11 years ago
Could you explain the utility of this tv type? May be you can describe some use cases..
What about handling richtext tv's when use_editor system setting is disabled ? Can it replace the use of codetext
tv ?
For example you can create TV for edit html markup and snippets call with highlight for sidebar. Handling richtext tvs is also solution, but I think Custom TV is more flexible, you can leave richtext for content field and text editor with highlight for sidebar TV.
Например, я пытался добавить TV, в котором хранится код, сгенерированный конструктором яндекс карт. Ричтекст вообще не выводил этот код, текстовая область оставляла только тег "<"/script">", а вот Ace-область здесь была бы очень кстати.
:+1: Love this! Miss this feature from CodeMirror integration and MODX Evo... This brings it back with Ace and Revo!
I am curious if codetext
TV type is technically required? Would be nice to see a compatible version that does not require re-mapping TV types. Would be great to have the option to work with "textarea" TV input types, and not limited to "Rich Text."
Why is this still not merged? It works great and is absolutely useful. I don't think that it's good if we use ACE for all "textarea" TVs - they might be used for non-code content. So the new TV type makes absolutely sense.
Who still need ace editor for some TVs can use this plugin:
<?php
//Apply ace editor to TV with id 5 and 7
$tvs = array(
array(
'id' => 5,
'height' => '600px',
'mimeType' => 'application/json'
),
array(
'id' => 7,
'height' => '300px',
'mimeType' => 'text/html'
)
);
if ($modx->event->name != 'OnDocFormRender') {
return;
}
if ($modx->getOption('which_element_editor', null, 'Ace') !== 'Ace') {
return;
}
$script = '';
foreach ($tvs as $tv) {
$id = is_array($tv) ? $tv['id'] : $tv;
$height = isset($tv['height']) ? $tv['height'] : '';
$mimeType = isset($tv['mimeType']) ? $tv['mimeType'] : '';
$tvId = '#tv' . $id;
$setHeightScript = !empty($height) ? 'this.style.height="' . $height . '";' : '';
$aceScript = 'MODx.ux.Ace.replaceTextAreas([this], "' . $mimeType . '");';
$script .= 'Ext.each(Ext.query("' . $tvId . '"), function() { ' . $setHeightScript . $aceScript . '});' . PHP_EOL;
}
if ($script) {
$modx->controller->addHtml('<script>Ext.onReady(function() {' . $script . '});</script>');
}
Plugin listen OnDocFormRender event and must be execute after Ace plugin, so set priority something like 10 or higher. TV type must be textarea.
In my MODX install when I use this plugin, the required theming assets for ACE do get the correct path
THIS. IS. AWESOME. @evd !!!
Works like a charm (I use priotity 99
)!
My ACE rows have a height of "18.5px" so I use a multiple of it, like 296px
to get 16 rows. And with the fullscreen option of ACE, coding "inside of MODX" is fun again! :-D
THANKS!!!
I would still like to see the new TV-type merged into ACE. ;-)
Maybe "Textarea ACE" would be a "better" name for the new TV-type? Would sort just below "Textarea" and would make it clear, that this is "ACE only".
Did anybody find a solution for <textarea class="ace_text-input" ...</textarea>
not having the correct width? This makes first time editing no real fun, because the cursor stays on the far left side, in column 1.
After going fullscreen mode everything is fine, even when leaving fullscreen mode again. Seems to be an "init" problem.
Is there a cure?
Yes we need to get this fixed. Bookmarked and will report back if I find a fix
Duh! Changing theme from tomorrow_night_eighties to textmate removed the issue!
Wow, that was easy! Now let's make "textmate" the default template instead of "chrome". :-D
The settings array $tvs
should be generated automagically by grabbing all TVs with the right input type and getting the options from the TV definition.
Looks like an new TV-type Textarea ACE
is needed. My skills are to limited to do this. :-(
Anybody?
Looks like an new TV-type
Textarea ACE
is needed. My skills are to limited to do this. :-( Anybody?
YES!!!!!!! I have used winmerge to compare files and css line by line. I can't figure this one out!
Strange. Seem's like a job for the masters with write access.
Btw: Besides textmate
, the themes solarized_dark
and solarized_light
also work fine.
Add new input TV type 'codetext' with ACE Editor.