Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
maybeEscape(unit, dir) {
let pos = this.cm.getCursor()
if (this.cm.somethingSelected() ||
pos.line != (dir < 0 ? this.cm.firstLine() : this.cm.lastLine()) ||
(unit == "char" &&
pos.ch != (dir < 0 ? 0 : this.cm.getLine(pos.line).length)))
return CodeMirror.Pass
this.view.focus()
let targetPos = this.getPos() + (dir < 0 ? 0 : this.node.nodeSize)
let selection = Selection.near(this.view.state.doc.resolve(targetPos), dir)
this.view.dispatch(this.view.state.tr.setSelection(selection).scrollIntoView())
this.view.focus()
}
// }
Tab: (cm, widget) => {
// Override default behavior and don't select hint on Tab
widget.close();
return CodeMirror.Pass;
}
}
onKeyTab(cm) {
let {activeSuggestion} = ReplActiveInputStore.getStore();
if(activeSuggestion && activeSuggestion.id === this.props.tag) {
let {suggestion} = activeSuggestion;
this.onSelectTabCompletion(suggestion.input, suggestion.expect);
return;
}
return CodeMirror.Pass;
}
indent: function(state) {
if (state.tokenize != tokenBase) return state.tokenize.isString ? CodeMirror.Pass : 0
return state.scopes[0].offset
},
function completeIfInVariableName (cm) {
completeAfter(cm, () => {
const cur = cm.getCursor();
const pos = CodeMirror.Pos(cur.line, cur.ch - MAX_HINT_LOOK_BACK);
const range = cm.getRange(pos, cur);
return range.match(COMPLETE_AFTER_WORD);
});
return CodeMirror.Pass;
}
export function newline(cm: cm_t) {
if (cm.getOption("disableInput")) return CodeMirror.Pass
const selections = cm.listSelections()
var replacements: string[] = repeat("\n", selections.length)
for (let i = 0; i < selections.length; i++) {
var range = selections[i]
var pos = range.head
const eolState = cm.getStateAfter(pos.line) as HyperMDState
if (eolState.list !== false) {
replacements[i] += repeatStr(" ", eolState.listStack.slice(-1)[0])
}
}
cm.replaceSelections(replacements)
}
completeAfter(cm, pred) {
var cur = cm.getCursor();
if (!pred || pred()) setTimeout(() => {
if (!cm.state.completionActive) {
cm.showHint({ completeSingle: false });
}
}, 100);
return CodeMirror.Pass;
},
completeIfInTag(cm) {
indent: function(state, textAfter) {
var cx = state.context;
if (!cx) return CodeMirror.Pass;
var closing = textAfter.charAt(0) == cx.type;
if (cx.align) return cx.col + (closing ? 0 : 1);
else return cx.indent + (closing ? 0 : config.indentUnit);
},
CodeMirror.commands.swapLineDown = (cm) =>
{
if(cm.isReadOnly())
{
return CodeMirror.Pass
}
const ranges = cm.listSelections()
const linesToMove = []
let at = cm.lastLine() + 1
for(let i = ranges.length - 1; i >= 0; i--)
{
const range = ranges[i]
let from = range.to().line + 1
const to = range.from().line
if(range.to().ch == 0 && !range.empty())
{
from--
}
CodeMirror.commands.indentLessOrderedList = cm => {
if (cm.getOption('disableInput')) {
return CodeMirror.Pass;
}
cm.execCommand('indentLess');
cm.execCommand('fixOrderedListNumber');
return null;
};