@standardnotes/markdown-minimal 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +3 -0
- package/CHANGELOG.md +63 -0
- package/Gruntfile.js +125 -0
- package/README.md +26 -0
- package/dist/app.css +143 -0
- package/dist/app.css.map +1 -0
- package/dist/app.js +118 -0
- package/dist/app.js.map +1 -0
- package/dist/dist.css +490 -0
- package/dist/dist.js +11214 -0
- package/dist/lib.js +11096 -0
- package/dist/sn-codemirror-search/dialog/dialog.css +46 -0
- package/dist/sn-codemirror-search/dialog/dialog.js +161 -0
- package/dist/sn-codemirror-search/search.js +258 -0
- package/dist/sn-codemirror-search/searchcursor.js +293 -0
- package/ext.json +8 -0
- package/index.html +23 -0
- package/min-markdown.jpg +0 -0
- package/package.json +41 -0
- package/src/main.js +110 -0
- package/src/main.scss +151 -0
- package/vendor/addon/modes/overlay.js +90 -0
- package/vendor/mark-selection.js +119 -0
- package/vendor/modes/gfm/gfm.js +130 -0
- package/vendor/modes/markdown/markdown.js +884 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
3
|
+
|
|
4
|
+
// Utility function that allows modes to be combined. The mode given
|
|
5
|
+
// as the base argument takes care of most of the normal mode
|
|
6
|
+
// functionality, but a second (typically simple) mode is used, which
|
|
7
|
+
// can override the style of text. Both modes get to parse all of the
|
|
8
|
+
// text, but when both assign a non-null style to a piece of code, the
|
|
9
|
+
// overlay wins, unless the combine argument was true and not overridden,
|
|
10
|
+
// or state.overlay.combineTokens was true, in which case the styles are
|
|
11
|
+
// combined.
|
|
12
|
+
|
|
13
|
+
(function(mod) {
|
|
14
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
15
|
+
mod(require("../../lib/codemirror"));
|
|
16
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
17
|
+
define(["../../lib/codemirror"], mod);
|
|
18
|
+
else // Plain browser env
|
|
19
|
+
mod(CodeMirror);
|
|
20
|
+
})(function(CodeMirror) {
|
|
21
|
+
"use strict";
|
|
22
|
+
|
|
23
|
+
CodeMirror.overlayMode = function(base, overlay, combine) {
|
|
24
|
+
return {
|
|
25
|
+
startState: function() {
|
|
26
|
+
return {
|
|
27
|
+
base: CodeMirror.startState(base),
|
|
28
|
+
overlay: CodeMirror.startState(overlay),
|
|
29
|
+
basePos: 0, baseCur: null,
|
|
30
|
+
overlayPos: 0, overlayCur: null,
|
|
31
|
+
streamSeen: null
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
copyState: function(state) {
|
|
35
|
+
return {
|
|
36
|
+
base: CodeMirror.copyState(base, state.base),
|
|
37
|
+
overlay: CodeMirror.copyState(overlay, state.overlay),
|
|
38
|
+
basePos: state.basePos, baseCur: null,
|
|
39
|
+
overlayPos: state.overlayPos, overlayCur: null
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
token: function(stream, state) {
|
|
44
|
+
if (stream != state.streamSeen ||
|
|
45
|
+
Math.min(state.basePos, state.overlayPos) < stream.start) {
|
|
46
|
+
state.streamSeen = stream;
|
|
47
|
+
state.basePos = state.overlayPos = stream.start;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (stream.start == state.basePos) {
|
|
51
|
+
state.baseCur = base.token(stream, state.base);
|
|
52
|
+
state.basePos = stream.pos;
|
|
53
|
+
}
|
|
54
|
+
if (stream.start == state.overlayPos) {
|
|
55
|
+
stream.pos = stream.start;
|
|
56
|
+
state.overlayCur = overlay.token(stream, state.overlay);
|
|
57
|
+
state.overlayPos = stream.pos;
|
|
58
|
+
}
|
|
59
|
+
stream.pos = Math.min(state.basePos, state.overlayPos);
|
|
60
|
+
|
|
61
|
+
// state.overlay.combineTokens always takes precedence over combine,
|
|
62
|
+
// unless set to null
|
|
63
|
+
if (state.overlayCur == null) return state.baseCur;
|
|
64
|
+
else if (state.baseCur != null &&
|
|
65
|
+
state.overlay.combineTokens ||
|
|
66
|
+
combine && state.overlay.combineTokens == null)
|
|
67
|
+
return state.baseCur + " " + state.overlayCur;
|
|
68
|
+
else return state.overlayCur;
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
indent: base.indent && function(state, textAfter, line) {
|
|
72
|
+
return base.indent(state.base, textAfter, line);
|
|
73
|
+
},
|
|
74
|
+
electricChars: base.electricChars,
|
|
75
|
+
|
|
76
|
+
innerMode: function(state) { return {state: state.base, mode: base}; },
|
|
77
|
+
|
|
78
|
+
blankLine: function(state) {
|
|
79
|
+
var baseToken, overlayToken;
|
|
80
|
+
if (base.blankLine) baseToken = base.blankLine(state.base);
|
|
81
|
+
if (overlay.blankLine) overlayToken = overlay.blankLine(state.overlay);
|
|
82
|
+
|
|
83
|
+
return overlayToken == null ?
|
|
84
|
+
baseToken :
|
|
85
|
+
(combine && baseToken != null ? baseToken + " " + overlayToken : overlayToken);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
3
|
+
|
|
4
|
+
// Because sometimes you need to mark the selected *text*.
|
|
5
|
+
//
|
|
6
|
+
// Adds an option 'styleSelectedText' which, when enabled, gives
|
|
7
|
+
// selected text the CSS class given as option value, or
|
|
8
|
+
// "CodeMirror-selectedtext" when the value is not a string.
|
|
9
|
+
|
|
10
|
+
(function(mod) {
|
|
11
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
12
|
+
mod(require("../../lib/codemirror"));
|
|
13
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
14
|
+
define(["../../lib/codemirror"], mod);
|
|
15
|
+
else // Plain browser env
|
|
16
|
+
mod(CodeMirror);
|
|
17
|
+
})(function(CodeMirror) {
|
|
18
|
+
"use strict";
|
|
19
|
+
|
|
20
|
+
CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
|
|
21
|
+
var prev = old && old != CodeMirror.Init;
|
|
22
|
+
if (val && !prev) {
|
|
23
|
+
cm.state.markedSelection = [];
|
|
24
|
+
cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext";
|
|
25
|
+
reset(cm);
|
|
26
|
+
cm.on("cursorActivity", onCursorActivity);
|
|
27
|
+
cm.on("change", onChange);
|
|
28
|
+
} else if (!val && prev) {
|
|
29
|
+
cm.off("cursorActivity", onCursorActivity);
|
|
30
|
+
cm.off("change", onChange);
|
|
31
|
+
clear(cm);
|
|
32
|
+
cm.state.markedSelection = cm.state.markedSelectionStyle = null;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
function onCursorActivity(cm) {
|
|
37
|
+
if (cm.state.markedSelection)
|
|
38
|
+
cm.operation(function() { update(cm); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function onChange(cm) {
|
|
42
|
+
if (cm.state.markedSelection && cm.state.markedSelection.length)
|
|
43
|
+
cm.operation(function() { clear(cm); });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var CHUNK_SIZE = 8;
|
|
47
|
+
var Pos = CodeMirror.Pos;
|
|
48
|
+
var cmp = CodeMirror.cmpPos;
|
|
49
|
+
|
|
50
|
+
function coverRange(cm, from, to, addAt) {
|
|
51
|
+
if (cmp(from, to) == 0) return;
|
|
52
|
+
var array = cm.state.markedSelection;
|
|
53
|
+
var cls = cm.state.markedSelectionStyle;
|
|
54
|
+
for (var line = from.line;;) {
|
|
55
|
+
var start = line == from.line ? from : Pos(line, 0);
|
|
56
|
+
var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
|
|
57
|
+
var end = atEnd ? to : Pos(endLine, 0);
|
|
58
|
+
var mark = cm.markText(start, end, {className: cls});
|
|
59
|
+
if (addAt == null) array.push(mark);
|
|
60
|
+
else array.splice(addAt++, 0, mark);
|
|
61
|
+
if (atEnd) break;
|
|
62
|
+
line = endLine;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function clear(cm) {
|
|
67
|
+
var array = cm.state.markedSelection;
|
|
68
|
+
for (var i = 0; i < array.length; ++i) array[i].clear();
|
|
69
|
+
array.length = 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function reset(cm) {
|
|
73
|
+
clear(cm);
|
|
74
|
+
var ranges = cm.listSelections();
|
|
75
|
+
for (var i = 0; i < ranges.length; i++)
|
|
76
|
+
coverRange(cm, ranges[i].from(), ranges[i].to());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function update(cm) {
|
|
80
|
+
if (!cm.somethingSelected()) return clear(cm);
|
|
81
|
+
if (cm.listSelections().length > 1) return reset(cm);
|
|
82
|
+
|
|
83
|
+
var from = cm.getCursor("start"), to = cm.getCursor("end");
|
|
84
|
+
|
|
85
|
+
var array = cm.state.markedSelection;
|
|
86
|
+
if (!array.length) return coverRange(cm, from, to);
|
|
87
|
+
|
|
88
|
+
var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
|
|
89
|
+
if (!coverStart || !coverEnd || to.line - from.line <= CHUNK_SIZE ||
|
|
90
|
+
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
|
|
91
|
+
return reset(cm);
|
|
92
|
+
|
|
93
|
+
while (cmp(from, coverStart.from) > 0) {
|
|
94
|
+
array.shift().clear();
|
|
95
|
+
coverStart = array[0].find();
|
|
96
|
+
}
|
|
97
|
+
if (cmp(from, coverStart.from) < 0) {
|
|
98
|
+
if (coverStart.to.line - from.line < CHUNK_SIZE) {
|
|
99
|
+
array.shift().clear();
|
|
100
|
+
coverRange(cm, from, coverStart.to, 0);
|
|
101
|
+
} else {
|
|
102
|
+
coverRange(cm, from, coverStart.from, 0);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
while (cmp(to, coverEnd.to) < 0) {
|
|
107
|
+
array.pop().clear();
|
|
108
|
+
coverEnd = array[array.length - 1].find();
|
|
109
|
+
}
|
|
110
|
+
if (cmp(to, coverEnd.to) > 0) {
|
|
111
|
+
if (to.line - coverEnd.from.line < CHUNK_SIZE) {
|
|
112
|
+
array.pop().clear();
|
|
113
|
+
coverRange(cm, coverEnd.from, to);
|
|
114
|
+
} else {
|
|
115
|
+
coverRange(cm, coverEnd.to, to);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
|
3
|
+
|
|
4
|
+
(function(mod) {
|
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
6
|
+
mod(require("../../lib/codemirror"), require("../markdown/markdown"), require("../../addon/mode/overlay"));
|
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
8
|
+
define(["../../lib/codemirror", "../markdown/markdown", "../../addon/mode/overlay"], mod);
|
|
9
|
+
else // Plain browser env
|
|
10
|
+
mod(CodeMirror);
|
|
11
|
+
})(function(CodeMirror) {
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
|
|
15
|
+
|
|
16
|
+
CodeMirror.defineMode("gfm", function(config, modeConfig) {
|
|
17
|
+
var codeDepth = 0;
|
|
18
|
+
function blankLine(state) {
|
|
19
|
+
state.code = false;
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
var gfmOverlay = {
|
|
23
|
+
startState: function() {
|
|
24
|
+
return {
|
|
25
|
+
code: false,
|
|
26
|
+
codeBlock: false,
|
|
27
|
+
ateSpace: false
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
copyState: function(s) {
|
|
31
|
+
return {
|
|
32
|
+
code: s.code,
|
|
33
|
+
codeBlock: s.codeBlock,
|
|
34
|
+
ateSpace: s.ateSpace
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
token: function(stream, state) {
|
|
38
|
+
state.combineTokens = null;
|
|
39
|
+
|
|
40
|
+
// Hack to prevent formatting override inside code blocks (block and inline)
|
|
41
|
+
if (state.codeBlock) {
|
|
42
|
+
if (stream.match(/^```+/)) {
|
|
43
|
+
state.codeBlock = false;
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
stream.skipToEnd();
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (stream.sol()) {
|
|
50
|
+
state.code = false;
|
|
51
|
+
}
|
|
52
|
+
if (stream.sol() && stream.match(/^```+/)) {
|
|
53
|
+
stream.skipToEnd();
|
|
54
|
+
state.codeBlock = true;
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
// If this block is changed, it may need to be updated in Markdown mode
|
|
58
|
+
if (stream.peek() === '`') {
|
|
59
|
+
stream.next();
|
|
60
|
+
var before = stream.pos;
|
|
61
|
+
stream.eatWhile('`');
|
|
62
|
+
var difference = 1 + stream.pos - before;
|
|
63
|
+
if (!state.code) {
|
|
64
|
+
codeDepth = difference;
|
|
65
|
+
state.code = true;
|
|
66
|
+
} else {
|
|
67
|
+
if (difference === codeDepth) { // Must be exact
|
|
68
|
+
state.code = false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
} else if (state.code) {
|
|
73
|
+
stream.next();
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
// Check if space. If so, links can be formatted later on
|
|
77
|
+
if (stream.eatSpace()) {
|
|
78
|
+
state.ateSpace = true;
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
if (stream.sol() || state.ateSpace) {
|
|
82
|
+
state.ateSpace = false;
|
|
83
|
+
if (modeConfig.gitHubSpice !== false) {
|
|
84
|
+
if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
|
|
85
|
+
// User/Project@SHA
|
|
86
|
+
// User@SHA
|
|
87
|
+
// SHA
|
|
88
|
+
state.combineTokens = true;
|
|
89
|
+
return "link";
|
|
90
|
+
} else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
|
|
91
|
+
// User/Project#Num
|
|
92
|
+
// User#Num
|
|
93
|
+
// #Num
|
|
94
|
+
state.combineTokens = true;
|
|
95
|
+
return "link";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (stream.match(urlRE) &&
|
|
100
|
+
stream.string.slice(stream.start - 2, stream.start) != "](" &&
|
|
101
|
+
(stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
|
|
102
|
+
// URLs
|
|
103
|
+
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
|
104
|
+
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
|
|
105
|
+
// And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
|
|
106
|
+
state.combineTokens = true;
|
|
107
|
+
return "link";
|
|
108
|
+
}
|
|
109
|
+
stream.next();
|
|
110
|
+
return null;
|
|
111
|
+
},
|
|
112
|
+
blankLine: blankLine
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
var markdownConfig = {
|
|
116
|
+
underscoresBreakWords: false,
|
|
117
|
+
taskLists: true,
|
|
118
|
+
fencedCodeBlocks: '```',
|
|
119
|
+
strikethrough: true
|
|
120
|
+
};
|
|
121
|
+
for (var attr in modeConfig) {
|
|
122
|
+
markdownConfig[attr] = modeConfig[attr];
|
|
123
|
+
}
|
|
124
|
+
markdownConfig.name = "markdown";
|
|
125
|
+
return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
|
|
126
|
+
|
|
127
|
+
}, "markdown");
|
|
128
|
+
|
|
129
|
+
CodeMirror.defineMIME("text/x-gfm", "gfm");
|
|
130
|
+
});
|