angular-pagedown
A pagedown editor for AngularJS. View this Plunker for demo.
Instructions
bower install angular-pagedown --save
- This will install also pagedown dependencies.
- Import these files in your HTML
- pagedown/Markdown.Converter.js
- pagedown/Markdown.Sanitizer.js
- pagedown/Markdown.Extra.js
- pagedown/Markdown.Editor.js
- angular-pagedown/angular-pagedown.js
- angular-pagedown/angular-pagedown.css
- If you're using a build tool like grunt/gulp's main-bower-files, you don't need to import the files manually.
- But add this in your bower.json
"overrides": {
"pagedown": {
"main": [
"Markdown.Converter.js",
"Markdown.Sanitizer.js",
"Markdown.Extra.js",
"Markdown.Editor.js",
"wmd-buttons.png"
]
}
}
- Include dependency in your app
angular.module("yourApp", ["ui.pagedown"]);
This package comes with 2 directives:
Editor
<pagedown-editor content="data.content"></pagedown-editor>
Options:
content
- An expression.
- Expression: Mandatory
- Example:
<pagedown-editor content="data.content"></pagedown-editor>
- Example:
<pagedown-editor content="'**some** _markdown_ text'"></pagedown-editor>
show-preview
- Should a live preview be displayed.
- Boolean: Default to true
help
- An expression to invoke upon clicking the help (?) button.
- Expression: Default to open http://daringfireball.net/projects/markdown/syntax in new window
- Example:
<pagedown-editor content="data.content" help="showSomeHelp()"></pagedown-editor>
insert-image
- An expression to invoke upon clicking the "Insert Image" button.
- Expression: Default to
noop
- Example:
<pagedown-editor content="data.content" insert-image="promptImageUrl()"></pagedown-editor>
- The parent scope function
promptImageUrl
must return either:
- A string of image URL.
- A promise resolved with a string of image URL.
placeholder
- An expression.
- Expression: Default to empty string
- Example:
<pagedown-editor content="data.content" placeholder="{{data.placeholder}} or anything"></pagedown-editor>
editor-class
- An expression to use as ngClass.
- Expression: Default to
wmd-input
- Example:
<pagedown-editor content="data.content" editorClass="{'a-class': true}"></pagedown-editor>
- Example:
<pagedown-editor content="data.content" editorClass="'a-class another-class'"></pagedown-editor>
- Example:
<pagedown-editor content="data.content" editorClass="aScopeVariable"></pagedown-editor>
editor-rows
- Number of rows for the
<textarea>
element
- Number: default to 10
preview-class
- An expression to use as ngClass.
- Expression: Default to
wmd-panel wmd-preview
- See
editor-class
preview-content
- An expression, will be updated with converted HTML when the editor content changes. Can be coupled with
show-preview="false"
and a custom previewer.
- Optional
Viewer
<pagedown-viewer content="data.content"></pagedown-viewer>
TODO
- Grunt setup to minify files.
- Extend PageDown editor to allow override of hyper link insertion.