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