Skip to content

Commit

Permalink
Allow the hiding of additional buttons on the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
codemwnci committed Sep 14, 2014
1 parent 05e26be commit d1e850e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,20 @@ The first example turns a normal textarea, which is bound to the `mydata` angula

The second example show how you can just do a preview of markdown data already available. So, not Live Preview this time, but a Markdown render. It displays the rendered markdown that is stored in a scope variable called `myMD`

<markdown bind-from='myMD'></markdown>
<markdown bind-from='myMD'></markdown>

Further customisation of the editor is also possible. To change which buttons are hidden, it is possible to pass in a list of buttons names to the `markdown-hidden-buttons` attribute. Example three shows the removal of the Code and Quote buttons.

<textarea ng-model="mydata" markdownedit markdown-hidden-buttons="cmdCode,cmdQuote"></textarea>
<markdown bind-from="mydata"></markdown>

The name of the buttons are as follows
- Bold = cmdBold
- Italic = cmdItalic
- Heading = cmdHeading
- URL/Link = cmdUrl
- Image = cmdImage
- Unordered List = cmdList
- Ordered List = cmdList0
- Code = cmdCode
- Quote = cmdQuote
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>Markdown Render Example</h1>
<hr />

<h1>Markdown Live Edit / Preview Example</h1>
<textarea ng-model="liveedit" markdownedit></textarea>
<textarea ng-model="liveedit" markdownedit markdown-hidden-buttons="cmdQuote"></textarea>
<markdown bind-from="liveedit"></markdown>

</body>
Expand Down
9 changes: 3 additions & 6 deletions lib/codemwnci/markdown-editpreview-ng.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@
restrict: 'A',
replace: false,
link: function(scope, element, attrs) {
<<<<<<< HEAD
element.markdown({hiddenButtons: 'cmdPreview'});
=======
attrs.$set('data-provide', 'markdown');
attrs.$set('data-hiddenButtons', 'cmdPreview');
>>>>>>> FETCH_HEAD
var hiddenButtons = attrs.markdownHiddenButtons.split(",");
hiddenButtons.push('cmdPreview');
element.markdown({hiddenButtons: hiddenButtons});
},
};
}])
Expand Down

0 comments on commit d1e850e

Please sign in to comment.