diff --git a/website/demo/debug.html b/website/demo/debug.html index e91ec16e6..7e699aa59 100644 --- a/website/demo/debug.html +++ b/website/demo/debug.html @@ -4,7 +4,7 @@
Mobiledoc Kit (beta) is a framework-agnostic library for building WYSIWYG editors +
Mobiledoc Kit is a framework-agnostic library for building WYSIWYG editors supporting rich content via cards.
This repository hosts the core Mobiledoc-Kit library. If you want to use Mobiledoc-Kit to create a WYSIWYG editor you have the following options:
+This repository hosts the core Mobiledoc Kit library. If you want to use Mobiledoc Kit to create a WYSIWYG editor you have the following options:
ember-mobiledoc-dom-renderer | |
🔮 Render Mobiledoc as VDOM by passing React or React-like createElement function |
-mobiledoc-vdom-renderer | -
React Server and Browser Renderer | mobiledoc-react-renderer |
🔮 Render Mobiledoc as VDOM by passing React or React-like createElement function |
+mobiledoc-vdom-renderer | +
Mobiledoc is a deliberately simple and terse format, and you are encouraged to write your own renderer if you have other target output formats (e.g., a PDF renderer, an iOS Native Views Renderer, etc.).
@@ -147,7 +147,7 @@The Mobiledoc.Editor
class is invoked with an element to render into and
optionally a Mobiledoc to load. For example:
var simpleMobiledoc = {
+const simpleMobiledoc = {
version: "0.3.1",
markups: [],
atoms: [],
@@ -158,9 +158,9 @@ Usage
]]
]
};
-var element = document.querySelector('#editor');
-var options = { mobiledoc: simpleMobiledoc };
-var editor = new Mobiledoc.Editor(options);
+const element = document.querySelector('#editor');
+const options = { mobiledoc: simpleMobiledoc };
+const editor = new Mobiledoc.Editor(options);
editor.render(element);
options
is an object which may include the following properties:
@@ -300,7 +300,7 @@ Programmatic Post Editing
the run
and postEditor
API. This API allows the Mobiledoc editor to conserve
and better understand changes being made to the post.
editor.run(postEditor => {
- const mention = postEditor.builder.createAtom("mention", "John Doe", { id: 42 });
+ const mention = postEditor.builder.createAtom("mention", "Jane Doe", { id: 42 });
// insert at current cursor position:
// or should the user have to grab the current position from the editor first?
postEditor.insertMarkers(editor.range.head, [mention]);
@@ -313,7 +313,7 @@ Configuring hot keys
The Mobiledoc editor allows the configuration of hot keys and text expansions.
For instance, the hot-key command-B to make selected text bold, is registered
internally as:
-const boldKeyCommand = {
+const boldKeyCommand = {
str: 'META+B',
run(editor) {
editor.run(postEditor => postEditor.toggleMarkup('strong'));
@@ -329,7 +329,7 @@ Configuring hot keys
Overriding built-in keys
You can override built-in behavior by simply registering a hot key with the same name.
For example, to submit a form instead of entering a new line when enter
is pressed you could do the following:
-const enterKeyCommand = {
+const enterKeyCommand = {
str: 'enter',
run(editor) {
// submit the form
@@ -346,7 +346,7 @@ Responding to text input
The callback is called after the matching text has been inserted. It is passed
the editor
instance and an array of matches (either the result of match.exec
on the matching user-entered text, or an array containing only the text
).
-editor.onTextInput({
+editor.onTextInput({
text: 'X',
run(editor) {
// This callback is called after user types 'X'
@@ -363,7 +363,7 @@ Responding to text input
The editor has several default text input handlers that are defined in
src/js/editor/text-input-handlers.js
.
To remove default text input handlers call the unregister function.
-editor.unregisterAllTextInputHandlers();
+editor.unregisterAllTextInputHandlers();
\n
special-case match character
When writing a matching string it is common to use \s
at the end of a match
@@ -390,16 +390,16 @@
DOM Parsing hooks
if (node.nodeType !== 1 || node.tagName !== 'IMG') {
return;
}
- var payload = { src: node.src };
- var cardSection = builder.createCardSection('my-image', payload);
+ const payload = { src: node.src };
+ const cardSection = builder.createCardSection('my-image', payload);
addSection(cardSection);
nodeFinished();
}
-var options = {
+const options = {
parserPlugins: [imageToCardParser]
};
-var editor = new Mobiledoc.Editor(options);
-var element = document.querySelector('#editor');
+const editor = new Mobiledoc.Editor(options);
+const element = document.querySelector('#editor');
editor.render(element);
Parser hooks are called with three arguments:
@@ -417,7 +417,7 @@ DOM Parsing hooks
Note that you must call nodeFinished
to stop a DOM node from being
parsed by the next plugin or the default parser.
Caveats
-Mobiledoc-kit and the Grammarly extension
+Mobiledoc Kit and the Grammarly extension
mobiledoc-kit
and the Grammarly extension do not play well together (see issue 422). Until this is resolved, you can avoid any such problems by disabling Grammarly for the mobiledoc-kit
instances on your page. To do this, add the data-gramm="false"
attribute to the mobiledoc-kit
main DOM element.
Contributing
Fork the repo, write a test, make a change, open a PR.
@@ -430,18 +430,18 @@ Tests
Run tests via the built-in broccoli server:
npm start
yarn start
open http://localhost:4200/tests
Or run headless tests via testem:
npm test
yarn test
Tests in CI are run at Travis via Saucelabs (see the test:ci
npm script).
Tests in CI are run at Travis via Saucelabs (see the test:ci
yarn script).
To run the demo site locally:
npm start
yarn start
open http://localhost:4200/demo
The assets for the demo are in assets/demo
.
mobiledoc-kit
tag.
np
(npm install -g np
)np
(yarn install -g np
)np <version>
(e.g. np 0.12.0
)git push <origin> --tags
To publish a new version:
npm run build:website
- This builds the website into website/
and commits itnpm run deploy:website
- Pushes the website/
subtree to the gh-pages
+yarn run build:website
- This builds the website into website/
and commits ityarn run deploy:website
- Pushes the website/
subtree to the gh-pages
branch of your origin
at githubDevelopment of Mobiledoc and the supporting libraries was generously funded by Bustle Digital Group's engineering team.
+Development of Mobiledoc and the supporting libraries was generously funded by Bustle Digital Group.
@@ -484,7 +484,7 @@Text
Text
Text
Text
Text
Text
Text
Text
Text
Text