mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-08-27 19:12:45 -06:00
WIP: selective heading levels
This commit is contained in:
parent
a6b121f2e6
commit
72caf1bffd
@ -13,7 +13,11 @@
|
||||
<body>
|
||||
<textarea></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE();
|
||||
const easyMDE = new EasyMDE({
|
||||
parsingConfig: {
|
||||
headingLevels: [ 5, 2, 3, 4, 5 ]
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
@ -1822,7 +1822,15 @@ function EasyMDE(options) {
|
||||
options.parsingConfig = extend({
|
||||
highlightFormatting: true, // needed for toggleCodeBlock to detect types of code
|
||||
}, options.parsingConfig || {});
|
||||
|
||||
if ( options.parsingConfig.headingLevels ) {
|
||||
var headingLevels = [];
|
||||
for ( var l = 0, requestedLevels = options.parsingConfig.headingLevels; l < requestedLevels.length; l++ ) {
|
||||
if ( ! isNaN( requestedLevels[ l ] ) && headingLevels.indexOf( requestedLevels[ l ] ) === -1 ) {
|
||||
headingLevels[ l ] = parseInt( requestedLevels[ l ], 10 );
|
||||
}
|
||||
}
|
||||
options.parsingConfig.headingLevels = headingLevels;
|
||||
}
|
||||
|
||||
// Merging the insertTexts, with the given options
|
||||
options.insertTexts = extend({}, insertTexts, options.insertTexts || {});
|
||||
@ -2190,6 +2198,12 @@ EasyMDE.prototype.render = function (el) {
|
||||
cm.save();
|
||||
});
|
||||
}
|
||||
if (options.parsingConfig.headingLevels) {
|
||||
var cm = this.codemirror;
|
||||
cm.on('beforeChange', function (cm, obj) {
|
||||
console.log( obj );
|
||||
});
|
||||
}
|
||||
|
||||
this.gui = {};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user