1.0.2 • Published 7 years ago

@abcum/ember-editables v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

ember-editables

A collection of inline editable text components for Ember.js for text, html, and code.

npm.io npm.io npm.io npm.io npm.io npm.io

Usage

Installation

ember install @abcum/ember-editables

Usage examples

editable-text

The editable-text component enables inline editing of a contenteditable div, while removing all additional html markup (e.g. bold, italics).

{{editable-text value=model.name on-change=(action (mut model.name)) placeholder="Enter your fullname..."}}

To display placeholder text inside the editable-text component add the following code to your css, less, or sass files.

[contentEditable="true"][placeholder]:empty:not(:focus):before {
    color:#B6B6B6; /* Specify your placeholder colour */
}

editable-html

The editable-html component enables inline editing of a contenteditable div, while keeping any additional html markup (e.g. bold, italics).

{{editable-html value=model.name on-change=(action (mut model.name)) placeholder="Enter your fullname..."}}

To display placeholder text inside the editable-html component add the following code to your css, less, or sass files.

[contentEditable="true"][placeholder]:empty:not(:focus):before {
    color:#B6B6B6; /* Specify your placeholder colour */
}

editable-code

The editable-code component provides an editable code area powered by Codemirror.

{{editable-code value=model.code on-change=(action (mut model.code))}}
Install options

The plugins, themes, and language modes that will be bundled with the application source code can be configured from the application environment file,

// config/environment.js
module.exports = function(environment) {
    return {
        editables: {
            codemirror: true,
            includeTags: true,
            includeComments: true,
            includeBrackets: true,
            includeWhitespace: true,
            modes: [ "htmlmixed", "css",  "sass",  "javascript",  "markdown",  "handlebars" ],
            themes: [ "base16-dark", "base16-light", "bespin", "dracula", "eclipse" ],
        },
    }
};
Editor options

Additional configuration options can be passed to the editable-code instance allowing for further customisation of the editor.

AttributeDefaultDescription
autoCloseBracketstrueWhether to automatically close brackets and quotes when typed.
autofocusfalseCan be used to make CodeMirror focus itself on initialization
commentBlankLinesfalseWhether to also comment empty lines when adding line comments.
cursorBlinkRate530Half-period in milliseconds used for cursor blinking.
electricCharstrueWhether the editor should re-indent when characters are changed.
firstLineNumber1At which number to start counting lines.
historyEventDelay1250How many milliseconds of inactivity until a new history event is started.
indentUnit4How many spaces a block should be indented.
indentWithTabsfalseWhether tabs or spaces should be used to indent.
lineNumberstrueWhether to show line numbers to the left of the editor.
lineWrappingfalseWhether CodeMirror should scroll or wrap for long lines.
matchBracketstrueWhether to highlight matching brackets when the cursor is next to them.
mode"htmlmixed"The language mode to use in the editor.
readOnlyfalseThis disables editing of the editor content by the user.
smartIndenttrueWhether to use the context-sensitive indentation that the mode provides.
tabSize4The width of a tab character.
theme"default"The name of the the css theme to use with the editor.
undoDepth200The maximum number of content or selection changes that are stored.
viewportMargin10How many lines are rendered above and below the visible lines.

Development

  • make install (install bower and ember-cli dependencies)
  • make upgrade (upgrade ember-cli to the specified version)
  • make tests (run all tests defined in the package)
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago