Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: codemirror/codemirror5
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: hackmdio/CodeMirror
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
Loading
Showing with 4,145 additions and 68 deletions.
  1. +2 −0 .github/workflows/ci.yml
  2. +2 −1 .gitignore
  3. +1 −0 addon/dialog/dialog.css
  4. +1 −1 addon/display/fullscreen.css
  5. +11 −4 addon/edit/continuelist.js
  6. +5 −0 addon/hint/show-hint.css
  7. +112 −12 addon/lint/lint.js
  8. +165 −23 addon/merge/merge.js
  9. +3 −1 addon/mode/simple.js
  10. +1 −1 addon/scroll/annotatescrollbar.js
  11. +8 −7 addon/scroll/simplescrollbars.css
  12. +1 −2 addon/search/matchesonscrollbar.css
  13. +18 −1 demo/lint.html
  14. +25 −0 keymap/vim.js
  15. +14 −0 lib/codemirror.css
  16. +29 −0 mode/csv/csv.js
  17. +48 −0 mode/csv/index.html
  18. +57 −0 mode/graphviz/graphviz.js
  19. +54 −0 mode/graphviz/index.html
  20. +4 −0 mode/index.html
  21. +930 −0 mode/markdown/markdown_math.js
  22. +16 −0 mode/mediawiki/README.salvus
  23. BIN mode/mediawiki/img/black4.png
  24. BIN mode/mediawiki/img/ext2.png
  25. BIN mode/mediawiki/img/ext4.png
  26. BIN mode/mediawiki/img/link4.png
  27. BIN mode/mediawiki/img/template4.png
  28. BIN mode/mediawiki/img/template8.png
  29. +110 −0 mode/mediawiki/mediawiki.css
  30. +791 −0 mode/mediawiki/mediawiki.js
  31. +52 −0 mode/mermaid/index.html
  32. +81 −0 mode/mermaid/mermaid.js
  33. +4 −0 mode/meta.js
  34. +58 −0 mode/plantuml/index.html
  35. +136 −0 mode/plantuml/plantuml.js
  36. +101 −0 mode/solidity/index.html
  37. +628 −0 mode/solidity/solidity.js
  38. +29 −0 mode/typescript/typescript.js
  39. +9 −9 package.json
  40. +6 −0 release
  41. +83 −0 release.cmd
  42. +92 −0 release.sh
  43. +2 −1 src/display/Display.js
  44. +15 −1 src/display/selection.js
  45. +2 −2 src/input/TextareaInput.js
  46. +1 −0 src/model/history.js
  47. +1 −1 src/util/browser.js
  48. +2 −1 test/run.js
  49. +221 −0 theme/one-dark.css
  50. +214 −0 theme/one-solarized.css
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -14,4 +14,6 @@ jobs:

- run: npm install

- run: npm run-script build

- run: npm test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
.idea
*.iml
/lib/codemirror.js
codemirror.min.js
/addon/runmode/runmode-standalone.js
/addon/runmode/runmode.node.js
**/.DS_Store
**/.DS_Store
1 change: 1 addition & 0 deletions addon/dialog/dialog.css
Original file line number Diff line number Diff line change
@@ -29,4 +29,5 @@

.CodeMirror-dialog button {
font-size: 70%;
color: black;
}
2 changes: 1 addition & 1 deletion addon/display/fullscreen.css
Original file line number Diff line number Diff line change
@@ -2,5 +2,5 @@
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
height: auto;
z-index: 9;
z-index: 2000;
}
15 changes: 11 additions & 4 deletions addon/edit/continuelist.js
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@
})(function(CodeMirror) {
"use strict";

var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,
emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,
var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\[\s\]\s|\[x\]\s|\s*)/,
emptyListRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)[.)])(\[\s\]\s*|\[x\]\s|\s*)$/,
unorderedListRE = /[*+-]\s/;

CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
@@ -50,12 +50,19 @@
});
replacements[i] = "\n";
} else {
var disableAutoIncrement = cm.getOption("disableAutoIncrementMarkdownListNumbers") || false
var indent = match[1], after = match[5];
var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
var bullet = numbered ? (parseInt(match[3], 10) + 1) + match[4] : match[2].replace("x", " ");
var bullet
if (numbered) {
bullet = (disableAutoIncrement ? 1 : (parseInt(match[3], 10) + 1)) + match[4];
} else {
bullet = match[2].replace("x", " ");
}
after = after.replace('[x]', '[ ]'); // make todo list default unchecked
replacements[i] = "\n" + indent + bullet + after;

if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
if (numbered && !disableAutoIncrement) incrementRemainingMarkdownListNumbers(cm, pos);
}
}

5 changes: 5 additions & 0 deletions addon/hint/show-hint.css
Original file line number Diff line number Diff line change
@@ -30,6 +30,11 @@
cursor: pointer;
}

.CodeMirror-hint:hover {
background: #08f;
color: white;
}

li.CodeMirror-hint-active {
background: #08f;
color: white;
124 changes: 112 additions & 12 deletions addon/lint/lint.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
var GUTTER_ID = "CodeMirror-lint-markers";
var LINT_LINE_ID = "CodeMirror-lint-line-";

function showTooltip(cm, e, content) {
function showTooltip(cm, e, content, node) {
var tt = document.createElement("div");
tt.className = "CodeMirror-lint-tooltip cm-s-" + cm.options.theme;
tt.appendChild(content.cloneNode(true));
@@ -22,13 +22,21 @@
else
document.body.appendChild(tt);

function position(e) {
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
tt.style.left = (e.clientX + 5) + "px";
if (cm.state.lint.options.fixedTooltip) {
const { top, left } = node.getBoundingClientRect()

tt.style.top = top - 5 + 'px'
tt.style.left = left + 20 + 'px'
} else {
function position(e) {
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
tt.style.left = (e.clientX + 5) + "px";
}
CodeMirror.on(document, "mousemove", position);
position(e);
}
CodeMirror.on(document, "mousemove", position);
position(e);

if (tt.style.opacity != null) tt.style.opacity = 1;
return tt;
}
@@ -43,11 +51,12 @@
}

function showTooltipFor(cm, e, content, node) {
var tooltip = showTooltip(cm, e, content);
var tooltip = showTooltip(cm, e, content, node);
function hide() {
CodeMirror.off(node, "mouseout", hide);
if (tooltip) { hideTooltip(tooltip); tooltip = null; }
}

var poll = setInterval(function() {
if (tooltip) for (var n = node;; n = n.parentNode) {
if (n && n.nodeType == 11) n = n.host;
@@ -56,8 +65,74 @@
}
if (!tooltip) return clearInterval(poll);
}, 400);

CodeMirror.on(node, "mouseout", hide);
}

/**
*
* @param {*} cm
* @param {Array<{ content: string, html: string, onClick: any }>} menus
* @param {*} e
*/
function showMenu (cm, menus, e) {
var target = e.target || e.srcElement;
var state = cm.state.lint

if (state.hints) {
remove(state.hints)
}

if (!menus && menus.length > 0) {
return
}

// build menu
var hints = document.createElement("ul");
var theme = cm.options.theme;
hints.className = "CodeMirror-hints " + theme;
hints.style.position = 'fixed'
hints.style.zIndex = '999'

for (let item of menus) {
const elt = hints.appendChild(document.createElement('li'))
elt.className = 'CodeMirror-hint'
if (item.content) {
elt.textContent = item.content
} else {
elt.innerHTML = item.html
}
const onClick = item.onClick
elt.addEventListener('click', (e) => {
if (typeof onClick === 'function') {
onClick(e)
}
remove(hints)
})
}

var removal = function () { setTimeout(function () { remove(hints) }, 100) }
function remove (hints) {
if (hints.parentNode) {
hints.parentNode.removeChild(hints)
}
state.hints = null

cm.off("mousedown", removal)
cm.off("scroll", removal)
}

state.hints = hints
document.body.appendChild(hints)
const { left, top } = target.getBoundingClientRect()

hints.style.top = top + 5 + 'px'
hints.style.left = left + 20 + 'px'


cm.on("mousedown", removal)
cm.on("scroll", removal)
}

function LintState(cm, conf, hasGutter) {
this.marked = [];
@@ -76,7 +151,10 @@
this.timeout = null;
this.hasGutter = hasGutter;
this.onMouseOver = function(e) { onMouseOver(cm, e); };
this.onClick = function(e) { onClick(cm, e); };
this.waitingFor = 0

this.contextMenuEnable = typeof this.linterOptions.contextmenu === 'function'
}

var defaults = {
@@ -107,7 +185,7 @@
})
}

function makeMarker(cm, labels, severity, multiple, tooltips) {
function makeMarker(cm, labels, severity, multiple, tooltips, annotations) {
var marker = document.createElement("div"), inner = marker;
marker.className = "CodeMirror-lint-marker CodeMirror-lint-marker-" + severity;
if (multiple) {
@@ -119,6 +197,13 @@
showTooltipFor(cm, e, labels, inner);
});

if (cm.state.lint.contextMenuEnable) {
marker.addEventListener('click', function (e) {
const menus = cm.state.lint.linterOptions.contextmenu(annotations)
showMenu(cm, menus, e)
})
}

return marker;
}

@@ -247,8 +332,8 @@
}
showTooltipFor(cm, e, tooltip, target);
}

function onMouseOver(cm, e) {
function handleMarkerAction (cm, e, cb) {
var target = e.target || e.srcElement;
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
@@ -259,7 +344,19 @@
var ann = spans[i].__annotation;
if (ann) annotations.push(ann);
}
if (annotations.length) popupTooltips(cm, annotations, e);

if (annotations.length) cb(cm, annotations, e)
}

function onMouseOver(cm, e) {
handleMarkerAction(cm, e, popupTooltips)
}

function onClick (cm, e) {
handleMarkerAction(cm, e, function (cm, annotations, e) {
const menus = cm.state.lint.linterOptions.contextmenu(annotations)
showMenu(cm, menus, e)
})
}

CodeMirror.defineOption("lint", false, function(cm, val, old) {
@@ -280,6 +377,9 @@
cm.on("change", onChange);
if (state.options.tooltips != false && state.options.tooltips != "gutter")
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
if (state.contextMenuEnable) {
CodeMirror.on(cm.getWrapperElement(), "click", state.onClick);
}

startLinting(cm);
}
Loading