mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
Remove newline && runner plugins
This commit is contained in:
parent
cf60ae79c3
commit
bdd59de877
@ -1,35 +0,0 @@
|
|||||||
function getIndent(text) {
|
|
||||||
let offset = text.length - text.trimLeft().length;
|
|
||||||
if (offset) {
|
|
||||||
let indent = text[0];
|
|
||||||
while (--offset) {
|
|
||||||
indent += text[0];
|
|
||||||
}
|
|
||||||
return indent;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function NewlinePlugin() {
|
|
||||||
return {
|
|
||||||
onKeyDown(event, change) {
|
|
||||||
const { value } = change;
|
|
||||||
if (!value.isCollapsed) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.key === 'Enter' && !event.shiftKey) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
const { startBlock } = value;
|
|
||||||
const currentLineText = startBlock.text;
|
|
||||||
const indent = getIndent(currentLineText);
|
|
||||||
|
|
||||||
return change
|
|
||||||
.splitBlock()
|
|
||||||
.insertText(indent)
|
|
||||||
.focus();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
export default function RunnerPlugin({ handler }) {
|
|
||||||
return {
|
|
||||||
onKeyDown(event) {
|
|
||||||
// Handle enter
|
|
||||||
if (handler && event.key === 'Enter' && event.shiftKey) {
|
|
||||||
// Submit on Enter
|
|
||||||
event.preventDefault();
|
|
||||||
handler(event);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user