mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-25 19:04:29 -06:00
added extractYaml to option ts and yaml-fm default
This commit is contained in:
parent
7dd3284398
commit
d3e357b826
@ -2011,8 +2011,8 @@ EasyMDE.prototype.updateStatusBar = function (itemName, content) {
|
|||||||
*/
|
*/
|
||||||
EasyMDE.prototype.markdown = function (text) {
|
EasyMDE.prototype.markdown = function (text) {
|
||||||
if (marked) {
|
if (marked) {
|
||||||
// When extractYaml is present we remove it from preview
|
// remove yaml-frontmatter from preview
|
||||||
if (typeof this.options.extractYaml === 'function' && text.indexOf('---') === 0) {
|
if (text.indexOf('---') === 0) {
|
||||||
var yaml = text.substring(3);
|
var yaml = text.substring(3);
|
||||||
var closeIdx = yaml.indexOf('---');
|
var closeIdx = yaml.indexOf('---');
|
||||||
if (closeIdx === -1) {
|
if (closeIdx === -1) {
|
||||||
@ -2025,7 +2025,9 @@ EasyMDE.prototype.markdown = function (text) {
|
|||||||
} else {
|
} else {
|
||||||
text = '';
|
text = '';
|
||||||
}
|
}
|
||||||
this.options.extractYaml(yaml);
|
if (this.options.extractYaml) {
|
||||||
|
this.options.extractYaml(yaml);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Initialize
|
// Initialize
|
||||||
var markedOptions;
|
var markedOptions;
|
||||||
@ -2132,7 +2134,7 @@ EasyMDE.prototype.render = function (el) {
|
|||||||
document.addEventListener('keydown', this.documentOnKeyDown, false);
|
document.addEventListener('keydown', this.documentOnKeyDown, false);
|
||||||
|
|
||||||
var mode, backdrop;
|
var mode, backdrop;
|
||||||
var defaultMode = typeof options.extractYaml === 'function' ? 'yaml-frontmatter' : 'gfm';
|
var defaultMode = 'yaml-frontmatter';
|
||||||
// CodeMirror overlay mode
|
// CodeMirror overlay mode
|
||||||
if (options.overlayMode) {
|
if (options.overlayMode) {
|
||||||
CodeMirror.defineMode('overlay-mode', function (config) {
|
CodeMirror.defineMode('overlay-mode', function (config) {
|
||||||
|
1
types/easymde.d.ts
vendored
1
types/easymde.d.ts
vendored
@ -182,6 +182,7 @@ declare namespace EasyMDE {
|
|||||||
autoRefresh?: boolean | { delay: number; };
|
autoRefresh?: boolean | { delay: number; };
|
||||||
blockStyles?: BlockStyleOptions;
|
blockStyles?: BlockStyleOptions;
|
||||||
element?: HTMLElement;
|
element?: HTMLElement;
|
||||||
|
extractYaml?: (yaml: string) => void;
|
||||||
forceSync?: boolean;
|
forceSync?: boolean;
|
||||||
hideIcons?: ReadonlyArray<ToolbarButton>;
|
hideIcons?: ReadonlyArray<ToolbarButton>;
|
||||||
indentWithTabs?: boolean;
|
indentWithTabs?: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user