-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add forward and backward deletion to PostEditor
fixes #36
- Loading branch information
Showing
8 changed files
with
325 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import PostNodeBuilder from 'content-kit-editor/models/post-node-builder'; | ||
import MobiledocRenderer from 'content-kit-editor/renderers/mobiledoc'; | ||
|
||
/* | ||
* usage: | ||
* makeMD(({post, section, marker, markup}) => | ||
* post([ | ||
* section('P', [ | ||
* marker('some text', [markup('B')]) | ||
* ]) | ||
* }) | ||
* ) | ||
*/ | ||
function build(treeFn) { | ||
let builder = new PostNodeBuilder(); | ||
|
||
const post = (...args) => builder.createPost(...args); | ||
const markupSection = (...args) => builder.createMarkupSection(...args); | ||
const markup = (...args) => builder.createMarkup(...args); | ||
const marker = (...args) => builder.createMarker(...args); | ||
|
||
let builtPost = treeFn({post, markupSection, markup, marker}); | ||
return MobiledocRenderer.render(builtPost); | ||
} | ||
|
||
export default { | ||
build | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.