codemirror
Advanced tools
Comparing version
@@ -201,4 +201,6 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var widget = this, cm = completion.cm; | ||
var ownerDocument = cm.getInputField().ownerDocument; | ||
var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow; | ||
var hints = this.hints = document.createElement("ul"); | ||
var hints = this.hints = ownerDocument.createElement("ul"); | ||
var theme = completion.cm.options.theme; | ||
@@ -210,3 +212,3 @@ hints.className = "CodeMirror-hints " + theme; | ||
for (var i = 0; i < completions.length; ++i) { | ||
var elt = hints.appendChild(document.createElement("li")), cur = completions[i]; | ||
var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i]; | ||
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS); | ||
@@ -216,3 +218,3 @@ if (cur.className != null) className = cur.className + " " + className; | ||
if (cur.render) cur.render(elt, data, cur); | ||
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur))); | ||
else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur))); | ||
elt.hintId = i; | ||
@@ -226,5 +228,5 @@ } | ||
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor. | ||
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth); | ||
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight); | ||
(completion.options.container || document.body).appendChild(hints); | ||
var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth); | ||
var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight); | ||
(completion.options.container || ownerDocument.body).appendChild(hints); | ||
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH; | ||
@@ -280,3 +282,3 @@ var scrolls = hints.scrollHeight > hints.clientHeight + 1 | ||
var newTop = top + startScroll.top - curScroll.top; | ||
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop); | ||
var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop); | ||
if (!below) point += hints.offsetHeight; | ||
@@ -283,0 +285,0 @@ if (point <= editor.top || point >= editor.bottom) return completion.close(); |
@@ -423,12 +423,14 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
name: "clike", | ||
keywords: words(cKeywords + " dynamic_cast namespace reinterpret_cast try explicit new " + | ||
"static_cast typeid catch operator template typename class friend private " + | ||
"this using const_cast public throw virtual delete mutable protected " + | ||
"alignas alignof constexpr decltype nullptr noexcept thread_local final " + | ||
"static_assert override"), | ||
// Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20. | ||
keywords: words(cKeywords + "alignas alignof and and_eq audit axiom bitand bitor catch " + | ||
"class compl concept constexpr const_cast decltype delete dynamic_cast " + | ||
"explicit export final friend import module mutable namespace new noexcept " + | ||
"not not_eq operator or or_eq override private protected public " + | ||
"reinterpret_cast requires static_assert static_cast template this " + | ||
"thread_local throw try typeid typename using virtual xor xor_eq"), | ||
types: cTypes, | ||
blockKeywords: words(cBlockKeywords +" class try catch finally"), | ||
blockKeywords: words(cBlockKeywords + " class try catch"), | ||
defKeywords: words(cDefKeywords + " class namespace"), | ||
typeFirstDefinitions: true, | ||
atoms: words("true false NULL"), | ||
atoms: words("true false NULL nullptr"), | ||
dontIndentStatements: /^template$/, | ||
@@ -671,2 +673,5 @@ isIdentifierChar: /[\w\$_~\xa1-\uffff]/, | ||
}, | ||
'*': function(_stream, state) { | ||
return state.prevToken == '.' ? 'variable' : 'operator'; | ||
}, | ||
'"': function(stream, state) { | ||
@@ -673,0 +678,0 @@ state.tokenize = tokenKotlinString(stream.match('""')); |
@@ -658,2 +658,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
if (type == "}") return pass(); | ||
if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern); | ||
return cont(expect(":"), pattern, maybeAssign); | ||
@@ -660,0 +661,0 @@ } |
@@ -54,3 +54,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
{name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]}, | ||
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]}, | ||
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90", "f95"]}, | ||
{name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]}, | ||
@@ -57,0 +57,0 @@ {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]}, |
@@ -147,3 +147,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
if (!isFmtString) { | ||
state.tokenize = tokenStringFactory(stream.current()); | ||
state.tokenize = tokenStringFactory(stream.current(), state.tokenize); | ||
return state.tokenize(stream, state); | ||
@@ -255,3 +255,3 @@ } else { | ||
function tokenStringFactory(delimiter) { | ||
function tokenStringFactory(delimiter, tokenOuter) { | ||
while ("rubf".indexOf(delimiter.charAt(0).toLowerCase()) >= 0) | ||
@@ -271,3 +271,3 @@ delimiter = delimiter.substr(1); | ||
} else if (stream.match(delimiter)) { | ||
state.tokenize = tokenBase; | ||
state.tokenize = tokenOuter; | ||
return OUTCLASS; | ||
@@ -282,3 +282,3 @@ } else { | ||
else | ||
state.tokenize = tokenBase; | ||
state.tokenize = tokenOuter; | ||
} | ||
@@ -285,0 +285,0 @@ return OUTCLASS; |
@@ -76,5 +76,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
} | ||
if (ch == '"' || ch == "'") { | ||
stream.next() | ||
var tokenize = tokenString(ch) | ||
if (ch = stream.match(/("{3}|"|')/)) { | ||
var tokenize = tokenString(ch[0]) | ||
state.tokenize.push(tokenize) | ||
@@ -121,2 +120,3 @@ return tokenize(stream, state) | ||
function tokenString(quote) { | ||
var singleLine = quote.length == 1 | ||
return function(stream, state) { | ||
@@ -131,4 +131,5 @@ var ch, escaped = false | ||
escaped = false | ||
} else if (ch == quote) { | ||
break | ||
} else if (stream.match(quote)) { | ||
state.tokenize.pop() | ||
return "string" | ||
} else { | ||
@@ -138,3 +139,5 @@ escaped = ch == "\\" | ||
} | ||
state.tokenize.pop() | ||
if (singleLine) { | ||
state.tokenize.pop() | ||
} | ||
return "string" | ||
@@ -141,0 +144,0 @@ } |
{ | ||
"name": "codemirror", | ||
"version": "5.41.0", | ||
"version": "5.42.0", | ||
"main": "lib/codemirror.js", | ||
@@ -5,0 +5,0 @@ "style": "lib/codemirror.css", |
@@ -6,3 +6,2 @@ # CodeMirror | ||
[](https://gitter.im/codemirror/CodeMirror) | ||
[Funding status: ](https://marijnhaverbeke.nl/fund/) | ||
@@ -9,0 +8,0 @@ CodeMirror is a versatile text editor implemented in JavaScript for |
import { heightAtLine } from "../line/spans.js" | ||
import { getLine, lineAtHeight, updateLineHeight } from "../line/utils_line.js" | ||
import { paddingTop, textHeight } from "../measurement/position_measurement.js" | ||
import { paddingTop, textHeight, charWidth } from "../measurement/position_measurement.js" | ||
import { ie, ie_version } from "../util/browser.js" | ||
@@ -12,3 +12,4 @@ | ||
for (let i = 0; i < display.view.length; i++) { | ||
let cur = display.view[i], height | ||
let cur = display.view[i], wrapping = cm.options.lineWrapping | ||
let height, width = 0 | ||
if (cur.hidden) continue | ||
@@ -22,2 +23,6 @@ if (ie && ie_version < 8) { | ||
height = box.bottom - box.top | ||
// Check that lines don't extend past the right of the current | ||
// editor width | ||
if (!wrapping && cur.text.firstChild) | ||
width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1 | ||
} | ||
@@ -32,2 +37,10 @@ let diff = cur.line.height - height | ||
} | ||
if (width > cm.display.sizerWidth) { | ||
let chWidth = Math.ceil(width / charWidth(cm.display)) | ||
if (chWidth > cm.display.maxLineLength) { | ||
cm.display.maxLineLength = chWidth | ||
cm.display.maxLine = cur.line | ||
cm.display.maxLineChanged = true | ||
} | ||
} | ||
} | ||
@@ -34,0 +47,0 @@ } |
@@ -10,7 +10,10 @@ import { onBlur } from "../display/focus.js" | ||
if (!document.getElementsByClassName) return | ||
let byClass = document.getElementsByClassName("CodeMirror") | ||
let byClass = document.getElementsByClassName("CodeMirror"), editors = [] | ||
for (let i = 0; i < byClass.length; i++) { | ||
let cm = byClass[i].CodeMirror | ||
if (cm) f(cm) | ||
if (cm) editors.push(cm) | ||
} | ||
if (editors.length) editors[0].operation(() => { | ||
for (let i = 0; i < editors.length; i++) f(editors[i]) | ||
}) | ||
} | ||
@@ -17,0 +20,0 @@ |
@@ -69,2 +69,2 @@ // EDITOR CONSTRUCTOR | ||
CodeMirror.version = "5.41.0" | ||
CodeMirror.version = "5.42.0" |
@@ -130,3 +130,3 @@ import { getOrder } from "../util/bidi.js" | ||
// the line map. Takes care to render special characters separately. | ||
function buildToken(builder, text, style, startStyle, endStyle, title, css) { | ||
function buildToken(builder, text, style, startStyle, endStyle, css, attributes) { | ||
if (!text) return | ||
@@ -187,3 +187,6 @@ let displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text | ||
let token = elt("span", [content], fullStyle, css) | ||
if (title) token.title = title | ||
if (attributes) { | ||
for (let attr in attributes) if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class") | ||
token.setAttribute(attr, attributes[attr]) | ||
} | ||
return builder.content.appendChild(token) | ||
@@ -212,3 +215,3 @@ } | ||
function buildTokenBadBidi(inner, order) { | ||
return (builder, text, style, startStyle, endStyle, title, css) => { | ||
return (builder, text, style, startStyle, endStyle, css, attributes) => { | ||
style = style ? style + " cm-force-border" : "cm-force-border" | ||
@@ -223,4 +226,4 @@ let start = builder.pos, end = start + text.length | ||
} | ||
if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css) | ||
inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css) | ||
if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, css, attributes) | ||
inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes) | ||
startStyle = null | ||
@@ -260,6 +263,7 @@ text = text.slice(part.to - start) | ||
let len = allText.length, pos = 0, i = 1, text = "", style, css | ||
let nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed | ||
let nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes | ||
for (;;) { | ||
if (nextChange == pos) { // Update current marker set | ||
spanStyle = spanEndStyle = spanStartStyle = title = css = "" | ||
spanStyle = spanEndStyle = spanStartStyle = css = "" | ||
attributes = null | ||
collapsed = null; nextChange = Infinity | ||
@@ -280,3 +284,9 @@ let foundBookmarks = [], endStyles | ||
if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to) | ||
if (m.title && !title) title = m.title | ||
// support for the old title property | ||
// https://github.com/codemirror/CodeMirror/pull/5673 | ||
if (m.title) (attributes || (attributes = {})).title = m.title | ||
if (m.attributes) { | ||
for (let attr in m.attributes) | ||
(attributes || (attributes = {}))[attr] = m.attributes[attr] | ||
} | ||
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) | ||
@@ -309,3 +319,3 @@ collapsed = sp | ||
builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, | ||
spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css) | ||
spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes) | ||
} | ||
@@ -312,0 +322,0 @@ if (end >= upto) {text = text.slice(upto - pos); pos = upto; break} |
@@ -214,3 +214,4 @@ import { eltP } from "../util/dom.js" | ||
regChange(cm, from.line, to.line + 1) | ||
else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css) | ||
else if (marker.className || marker.startStyle || marker.endStyle || marker.css || | ||
marker.attributes || marker.title) | ||
for (let i = from.line; i <= to.line; i++) regLineChange(cm, i, "text") | ||
@@ -217,0 +218,0 @@ if (marker.atomic) reCheckSelection(cm.doc) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2775923
0.17%62876
0.12%49
-2%