Ionaru / Ionaru/easy-markdown-editor

Method `isPreviewActive()` is not working properly

Open
#332 0 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
JavaScript
Stars
3.1k
Forks
363
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
The `isPreviewActive()` method is returning `false`, whether the preview mode is active or not.

**Steps to reproduce the behavior:**
```html




Example / Preview



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.');
}
}

```

1. Copy the code above into an HTML file (update paths to `easymde.min.js` and `easymde.min.css` accordingly)
1. Open the HTML file in a browser
1. Click the `Toggle preview` button
1. `easyMDE.isPreviewActive()` returns `false`
1. Click the `Toggle preview` button
1. `easyMDE.isPreviewActive()` returns `false` again

**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.

Contributor guide

Open the contributing guide

Research direction

Start in src/js/easymde.js around line 2859 and reproduce the issue with the provided HTML example in a browser. Check the related isSideBySideActive() behavior as well. Done means isPreviewActive() returns true while preview mode is active and false after it is toggled off.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.