modx-ace icon indicating copy to clipboard operation
modx-ace copied to clipboard

Custom input TV type

Open evd opened this issue 12 years ago • 15 comments

Add new input TV type 'codetext' with ACE Editor.

evd avatar Dec 01 '12 16:12 evd

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 ?

danyaPostfactum avatar Dec 26 '12 13:12 danyaPostfactum

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.

evd avatar Dec 26 '12 14:12 evd

Например, я пытался добавить TV, в котором хранится код, сгенерированный конструктором яндекс карт. Ричтекст вообще не выводил этот код, текстовая область оставляла только тег "<"/script">", а вот Ace-область здесь была бы очень кстати.

argnist avatar Jun 27 '13 07:06 argnist

:+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."

pixelchutes avatar May 22 '14 19:05 pixelchutes

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.

christianseel avatar Oct 03 '14 07:10 christianseel

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.

evd avatar Feb 27 '15 20:02 evd

In my MODX install when I use this plugin, the required theming assets for ACE do get the correct path screen shot 2016-02-04 at 10 23 54

sonicpunk avatar Feb 04 '16 09:02 sonicpunk

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!!!

mindeffects avatar Oct 26 '16 11:10 mindeffects

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".

mindeffects avatar Oct 26 '16 11:10 mindeffects

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?

mindeffects avatar Feb 23 '18 16:02 mindeffects

Yes we need to get this fixed. Bookmarked and will report back if I find a fix

mrhaw avatar Aug 19 '18 01:08 mrhaw

Duh! Changing theme from tomorrow_night_eighties to textmate removed the issue!

mrhaw avatar Aug 19 '18 03:08 mrhaw

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?

mindeffects avatar Sep 12 '18 12:09 mindeffects

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!

mrhaw avatar Sep 13 '18 03:09 mrhaw

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.

mindeffects avatar Sep 13 '18 20:09 mindeffects