easy-markdown-editor
easy-markdown-editor copied to clipboard
Method `isPreviewActive()` is not working properly
Describe the bug
The isPreviewActive() method is returning false, whether the preview mode is active or not.
Steps to reproduce the behavior:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Example / Preview</title>
<link rel="stylesheet" href="../dist/easymde.min.css">
<script src="../dist/easymde.min.js"></script>
</head>
<body>
<textarea></textarea>
<script>
const easyMDE = new EasyMDE({
toolbar: [
{
className: 'fa fa-eye',
default: true,
name: 'preview',
noDisable: true,
title: 'Toggle Preview',
action: handleTogglePreview
},
'|',
'heading', 'bold', 'italic', 'strikethrough',
'|', 'quote', 'code',
'|', 'unordered-list', 'ordered-list',
'|', 'clean-block',
'|', 'link', 'image',
'|', 'table'
],
});
function handleTogglePreview() {
easyMDE.togglePreview();
// easyMDE.isPreviewActive() is always false.
if (easyMDE.isPreviewActive()) {
console.log('Preview is active.');
} else {
console.log('Preview is NOT active.');
}
}
</script>
</body>
</html>
- Copy the code above into an HTML file (update paths to
easymde.min.jsandeasymde.min.cssaccordingly) - Open the HTML file in a browser
- Click the
Toggle previewbutton -
easyMDE.isPreviewActive()returnsfalse - Click the
Toggle previewbutton -
easyMDE.isPreviewActive()returnsfalseagain
Expected behavior
easyMDE.isPreviewActive() should return true when preview mode is active. Else, false.
Version information
- OS: Ubuntu 20.04.1 LTS
- Browser: 89.0.4389.114
- EasyMDE version: 2.15.0 (latest)
Additional context
- https://github.com/Ionaru/easy-markdown-editor/blob/dbab7e95e7777d353b1600729709f01b876565f9/src/js/easymde.js#L2859
-
easyNDE.isSideBySideActive()has the same issue.