Skip to content

Getting Started

Leo Balter edited this page Mar 2, 2015 · 8 revisions

With:

<div class="editor"></div>

and:

var arte = new Arte('.editor');

then it doesn't create a internal element, but morphs the given element:

<div class="editor arte-editor" contenteditable="true">
    <span class="arte-placeholder">Start something...</span>
</div>

If the element contains content instead of just whitespace, use it instead of the placeholder.

Example:

<div class="editor">
  <h1>Hello, World!</h1>
  <p>Lorem ipsum</p>
</div>

<!-- becomes -->

<div class="editor arte-editor" contenteditable="true">
  <h1>Hello, World!</h1>
  <p>Lorem ipsum</p>
</div>
  • After the initialization, the cursor should be placed at the end of the content.
  • If the placeholder element is present, it should be cleaned after inserting anything else
  • If the content is empty, show the placeholder again (same given at the options or default).

Available options (with default options)

You can set custom options by passing an object with your options. Available options are listed at the Options page.

arte = new Arte('.editor', {
  placeholder: "Start something..."
});

Calling methods

Core methods

  • arte.html(): Returns the html content of the current selection
  • arte.text(): Returns the text content of the current selection
  • arte.destroy(): Destroys the arte object and makes the element content non-editable

Events

All events are editor wide and doesn't relate to the element current selection.

Specific events

You can find the following available events on ArteJS:

====

State methods

Specific state methods


All content related methods

You can call methods related to the entire Arte content, regardless of the current selection using the all property.

arte.all.text(); // returns the text value of the entire content regardless of the selected text

Available methods