j-CloudEditor
- A to funguje v Iframu.
- Podporuje více kurzorů (
shift + cmd + arrow-down/up) - Podporuje nalezení vybraného textu (
cmd + d) - Podporuje custom scrollbars
- Podporuje diff tracker
- Podporuje jednoduchý emmet plugin
- Podporuje spolupráci v reálném čase
- zdrojový kód: https://github.com/totaljs/editor
- Používá se redakce: Kódový zrcadlo
- Velmi malý kód
Konfigurace:
parent {String}Výběr hlavního kontejneru (default):auto)autosave {Boolean}automaticky přidává hodnotu z editoru na cestu komponentu (podmínkou:true)event {String}je cesta kfunction(name, value)clickerrorsshortcutcursorobsahuje kurzorovou pozicichangeobsahuje částečné změny pro spolupráci v reálném čase (config.realtimemusí býttrue)
contextmenu {String}je cesta kfunction(opt)realtime {Boolean}umožňuje v reálném čase odesílání změn na metoduevent(jméno události jechange)- Klíčové slovo
keywords {String}ve formě např.ID,PATH minheight {Number}volitelné, minimální výška (default:0)margin {Number}volitelný, vertikální (default:0)- NEW:
url {String}volitelné, odkaz na editor (podmínkou://cdn.componentator.com/editor/1.min.html)
Metoda:
component.insert('some text')component.replace('text', 'newvalue')component.search('text', callback(output))component.select(from, [to])component.goto(pos)component.focus()component.save(callback(value))component.marker(name, [from], [to], [color])přidává + modifikuje (sfrom) a odstraňuje (bez argumentufrom)component.change(changes)pro spolupráci v reálném čase (changesmůže být generován ve funkciconfig.event)component.clear()vyčistí všechny změnycomponent.replaceselections(selections)component.replaceselection(selection)component.replacerange(value, from, [to])component.command(cmd)Exekucecodemirror.execCommand()Metodacomponent.exec(a, [b], [c])Exekucedocument.execCommand(a, b, c)Metoda
Důležité:
Argumenty from, to, pos musí být ve formě: { line: Number, ch: Number }.
Použijte ji s <ui-component name="cloudeditor">Pokud je součástka ještě nezačleněna, jComponent Stáhnout ji na první použití z adresy DEF.fallback a) The Componentator CDN dle předvolby. autor: Peter Širka. zdroj: Componentator Výrobce je autorizován, MIT licence.
<ui-component name="LAZY menu"></ui-component>
<div style="width:600px;height:200px;border:1px solid #E0E0E0">
<ui-component name="cloudeditor" path="editormodel" config="contextmenu:editor_contextmenu;event:editor_event;realtime:1"></ui-component>
</div>
<br />
<div style="width:600px;height:200px;border:1px solid #E0E0E0">
<ui-component name="cloudeditor" path="editormirrored" config="readonly:1;$id:mirrored"></ui-component>
</div>
<div class="clearfix"></div>
<script>
var editorbody = '\n\n<h1>HELLO WORLD</h1>\n\n';
var editormodel = { mode: 'clientside', body: editorbody, keywords: 'WORLD' };
var editormirrored = { mode: 'clientside', body: editorbody };
function editor_event(type, value) {
switch (type) {
case 'change':
SETTER('#mirrored/change', value);
break;
case 'cursor':
SETTER('#mirrored/marker', 'Peter', value.from);
break;
}
SETTER('!menu/hide');
}
function editor_contextmenu(obj) {
var opt = {};
opt.x = obj.x;
opt.y = obj.y;
opt.items = [];
opt.items.push({ id: '1', name: 'Test item 1' });
opt.items.push({ id: '2', name: 'Test item 2' });
opt.items.push({ id: '3', name: 'Test item 3' });
opt.items.push({ id: '4', name: 'Test item 4' });
opt.callback = function(selected) {
console.log(selected);
};
SETTER('menu/show', opt);
}
</script>