j-CloudEditor
- Funziona in iframe
- Supporta i multi-cursori (
shift + cmd + arrow-down/up) - Supporta la ricerca del testo selezionato (
cmd + d) - Supporto per scrollbars
- Supporto di diff tracker
- Supporta un semplice emmet plugin
- Supporta la collaborazione in tempo reale
- Codice di sorgente: https://github.com/totaljs/editor
- Utilizza l’editore: Il codice
- Il codice molto piccolo
Configurazione:
parent {String}un selettore per il contenitore principale (default:auto)autosave {Boolean}rimbone automaticamente il valore dall'editore al percorso del componente (default:true)event {String}un cammino verso ilfunction(name, value)clickerrorsshortcutcursorcontiene la posizione del cursorechangecontiene modifiche parziali per la collaborazione in tempo reale (config.realtimedeve esseretrue)
contextmenu {String}un cammino verso ilfunction(opt)realtime {Boolean}consente di inviare cambiamenti in tempo reale al metodoevent(nome dell'evento èchange)keywords {String}Le parole chiave in forma di e.g.ID,PATHminheight {Number}opzionale, altezza minima (default:0)margin {Number}opzionale, una margine verticale (default:0)- NEW:
url {String}opzionale, un link all'editore (default://cdn.componentator.com/editor/1.min.html)
Metodo:
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])aggiunge + modifiche (confrom) e rimuove (senza argomentofrom)component.change(changes)per la collaborazione in tempo reale (changespuò essere generato nella funzioneconfig.event)component.clear()chiarisce tutti i cambiamenticomponent.replaceselections(selections)component.replaceselection(selection)component.replacerange(value, from, [to])- Il metodo
component.command(cmd)esegue il metodocodemirror.execCommand() - Il metodo
component.exec(a, [b], [c])esegue il metododocument.execCommand(a, b, c)
Importante:
Gli argomenti from, to, pos devono essere nella forma: { line: Number, ch: Number }.
Utilizzare con <ui-component name="cloudeditor">Quando il componente non è ancora caricato, jComponent Scarica il codice in prima utilizzazione dall'indirizzo DEF.fallback (Il Componentator La storia di Peter Širka.Fonte: il Componentator Ristorante dei componenti, licenza MIT.
<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>