Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: Patching Overlay Mode #603

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions example/index_customOverlay.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!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 / sideBySideFullscreen : false</title>
<link rel="stylesheet" href="../dist/easymde.min.css">
<script src="../dist/easymde.min.js"></script>
<style type="text/css">.cm-a-char { color: #00F !important; }</style>
</head>

<body>
<textarea># Good day to you Ionaru !

Every "A" character will be colored in blue !

## Awesome Markdown Editor

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ut pretium lorem. Proin fringilla eros sit amet ex aliquet interdum. Sed fermentum facilisis neque at commodo. Sed ornare dictum nisl quis bibendum. Sed venenatis eros turpis, imperdiet luctus mauris efficitur ut. Nunc eget orci orci. Nunc eu dolor tincidunt, porta odio vitae, rhoncus elit. Suspendisse at nisl dui. Aenean purus magna, convallis sit amet varius in, tincidunt eu libero.

## Super Action Letters

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ut pretium lorem. Proin fringilla eros sit amet ex aliquet interdum. Sed fermentum facilisis neque at commodo. Sed ornare dictum nisl quis bibendum. Sed venenatis eros turpis, imperdiet luctus mauris efficitur ut. Nunc eget orci orci. Nunc eu dolor tincidunt, porta odio vitae, rhoncus elit. Suspendisse at nisl dui. Aenean purus magna, convallis sit amet varius in, tincidunt eu libero.</textarea>
<script>
const easyMDE = new EasyMDE({
sideBySideFullscreen: false,
overlayMode: {
mode: {
name: 'test-mode',
token: function(stream) {
if ('A' === (stream.peek() || '')) {
stream.next();
return 'a-char';
}
stream.next();
return null;
}
}
}
});
easyMDE.codemirror.focus();
easyMDE.codemirror.doc.replaceRange(' ', {line: 2, ch: 47}, {line: 2, ch: 48});
easyMDE.codemirror.doc.setCursor({line: 2, ch: 48});
</script>
</body>

</html>
12 changes: 6 additions & 6 deletions src/js/easymde.js
Original file line number Diff line number Diff line change
Expand Up @@ -2123,21 +2123,21 @@ EasyMDE.prototype.render = function (el) {
CodeMirror.defineMode('overlay-mode', function (config) {
return CodeMirror.overlayMode(CodeMirror.getMode(config, options.spellChecker !== false ? 'spell-checker' : 'gfm'), options.overlayMode.mode, options.overlayMode.combine);
});

mode = 'overlay-mode';
backdrop = options.parsingConfig;
backdrop.name = 'gfm';
backdrop.gitHubSpice = false;
} else if (options.spellChecker !== false) {
mode = 'spell-checker';
backdrop = options.parsingConfig;
backdrop.name = 'gfm';
backdrop.gitHubSpice = false;
} else {
mode = options.parsingConfig;
mode.name = 'gfm';
mode.gitHubSpice = false;
}
if (options.spellChecker !== false) {
mode = 'spell-checker';
backdrop = options.parsingConfig;
backdrop.name = 'gfm';
backdrop.gitHubSpice = false;

if (typeof options.spellChecker === 'function') {
options.spellChecker({
codeMirrorInstance: CodeMirror,
Expand Down