ForgeKomponenty
cs

Komponenty

j-CloudEditor

jComponent 20 · jcomponent@20 component Příklad načten s jComponent 20
  • 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 k function(name, value)
    • click
    • errors
    • shortcut
    • cursor obsahuje kurzorovou pozici
    • change obsahuje částečné změny pro spolupráci v reálném čase (config.realtime musí být true)
  • contextmenu {String} je cesta k function(opt)
  • realtime {Boolean} umožňuje v reálném čase odesílání změn na metodu event (jméno události je change)
  • 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 (s from) a odstraňuje (bez argumentu from)
  • component.change(changes) pro spolupráci v reálném čase (changes může být generován ve funkci config.event)
  • component.clear() vyčistí všechny změny
  • component.replaceselections(selections)
  • component.replaceselection(selection)
  • component.replacerange(value, from, [to])
  • component.command(cmd) Exekuce codemirror.execCommand() Metoda
  • component.exec(a, [b], [c]) Exekuce document.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.

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>