ForgeComponenti
it

Componenti

j-CloudEditor

jComponent 20 · jcomponent@20 component Esempio caricato con jComponent 20
  • 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 il function(name, value)
    • click
    • errors
    • shortcut
    • cursor contiene la posizione del cursore
    • change contiene modifiche parziali per la collaborazione in tempo reale (config.realtime deve essere true)
  • contextmenu {String} un cammino verso il function(opt)
  • realtime {Boolean} consente di inviare cambiamenti in tempo reale al metodo event (nome dell'evento è change)
  • keywords {String} Le parole chiave in forma di e.g. ID,PATH
  • minheight {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 (con from) e rimuove (senza argomento from)
  • component.change(changes) per la collaborazione in tempo reale (changes può essere generato nella funzione config.event)
  • component.clear() chiarisce tutti i cambiamenti
  • component.replaceselections(selections)
  • component.replaceselection(selection)
  • component.replacerange(value, from, [to])
  • Il metodo component.command(cmd) esegue il metodo codemirror.execCommand()
  • Il metodo component.exec(a, [b], [c]) esegue il metodo document.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.

example.html
<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>