# j-CloudEditor

> j-CloudEditor: funcționează în iframe; susține cursori multiple (schimb + cmd + arrow-down / up)

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: ro
Content-SHA256: bcc69c30ed477408d95be7b501fc55408c5dae0b79d1436728bfa0d75869c54b
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- Funcționează în iframe
- Suport pentru cursori multiple (`shift + cmd + arrow-down/up`)
- susține găsirea textului selectat (`cmd + d`)
- Suport pentru scrollbars
- Suport pentru dif tracker
- Suport pentru un plugin Emmet
- sprijină colaborarea în timp real
- Cod de sursa: <https://github.com/totaljs/editor>
- Folosește editorul: [Codul Mirrorului](https://codemirror.net/)
- Coduri foarte mici

__Configurarea__:

- `parent {String}` un selector pentru containerul principal (default: `auto`)
- `autosave {Boolean}` reunește automat valoarea de la editor la calea componentei (default: `true`)
- `event {String}` este o cale spre `function(name, value)`
	- `click`
	- `errors`
	- `shortcut`
	- `cursor` conține poziția cursorului
	- `change` conține modificări parțiale pentru colaborarea în timp real (`config.realtime` trebuie să fie `true`)
- `contextmenu {String}` este o cale spre `function(opt)`
- `realtime {Boolean}` permite trimiterea în timp real a modificărilor metodei `event` (numele evenimentului este `change`)
- `keywords {String}` Cuvinte cheie în formă e.g. `ID,PATH`
- `minheight {Number}` opțional, o înălțime minimă (default: `0`)
- `margin {Number}` opțional, o marjă verticală (default: `0`)
- __NEW__: `url {String}` opțional, un link la editor (default: `//cdn.componentator.com/editor/1.min.html`)

__Metodă__:

- `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])` adăuga + modifică (cu `from`) și îndepărtează (fără argumentul `from`)
- `component.change(changes)` pentru colaborarea în timp real (`changes` poate fi generat în funcția `config.event`)
- `component.clear()` clarifică toate modificările
- `component.replaceselections(selections)`
- `component.replaceselection(selection)`
- `component.replacerange(value, from, [to])`
- `component.command(cmd)` execută metoda `codemirror.execCommand()`
- `component.exec(a, [b], [c])` execută metoda `document.execCommand(a, b, c)`

__Importantă__:

Argumentele `from`, `to`, `pos` trebuie să fie în formă: `{ line: Number, ch: Number }`.

Utilizați-l cu `<ui-component name="cloudeditor">`Când componenta nu este încă încărcată, jComponent Descărcați-l la prima utilizare de la adresa `DEF.fallback` (în cazul Componentator Autor: Peter Širka. sursă: Componentator Componente de stocare, MIT licență.

```html 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>
```
