forked from jenkinsci/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a17f0f6
commit 22ee9c7
Showing
9 changed files
with
338 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {EditorView, basicSetup } from "codemirror" | ||
import {EditorState} from "@codemirror/state" | ||
import {groovy} from "@codemirror/legacy-modes/mode/groovy" | ||
import {StreamLanguage} from "@codemirror/language" | ||
import { oneDark } from "@/components/textarea/theme"; | ||
|
||
function editorFromTextArea(textarea, extensions) { | ||
let view = new EditorView({ | ||
state: EditorState.create({doc: textarea.value, extensions: [basicSetup, StreamLanguage.define(groovy), oneDark]}), | ||
}); | ||
textarea.parentNode.insertBefore(view.dom, textarea) | ||
textarea.style.display = "none" | ||
if (textarea.form) { | ||
textarea.form.addEventListener("submit", () => { | ||
textarea.value = view.state.doc.toString() | ||
}) | ||
} | ||
return view | ||
} | ||
|
||
function init() { | ||
const textareas = document.querySelectorAll(".script"); | ||
textareas.forEach((textarea) => { | ||
const view = editorFromTextArea(textarea) | ||
}); | ||
} | ||
|
||
export default { init }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import {EditorView} from "@codemirror/view" | ||
import {HighlightStyle, syntaxHighlighting} from "@codemirror/language" | ||
import {tags as t} from "@lezer/highlight" | ||
|
||
const chalky = "#e5c07b", | ||
coral = "var(--red)", | ||
cyan = "var(--cyan)", | ||
invalid = "#ffffff", | ||
ivory = "#abb2bf", | ||
stone = "var(--text-color-secondary)", | ||
malibu = "var(--blue)", | ||
sage = "var(--green)", | ||
whiskey = "var(--orange)", | ||
violet = "var(--purple)", | ||
darkBackground = "#21252b", | ||
highlightBackground = "#2c313a", | ||
background = "var(--input-color)", | ||
tooltipBackground = "#353a42", | ||
selection = "var(--selection-color)", | ||
cursor = "var(--text-color)" | ||
|
||
/// The editor theme styles for One Dark. | ||
export const oneDarkTheme = EditorView.theme({ | ||
"&": { | ||
color: ivory, | ||
backgroundColor: background, | ||
borderRadius: "10px", | ||
border: "2px solid var(--input-border)", | ||
padding: "6px", | ||
boxShadow: 'var(--form-input-glow)', | ||
transition: 'var(--standard-transition)', | ||
}, | ||
"&:hover": { | ||
borderColor: 'var(--input-border-hover)', | ||
}, | ||
"&:focus-within": { | ||
borderColor: 'var(--focus-input-border)', | ||
boxShadow: 'var(--form-input-glow--focus)' | ||
}, | ||
".cm-content": { | ||
caretColor: cursor | ||
}, | ||
".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor }, | ||
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection }, | ||
".cm-panels": { backgroundColor: darkBackground, color: ivory }, | ||
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" }, | ||
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" }, | ||
".cm-searchMatch": { | ||
backgroundColor: "#72a1ff59", | ||
outline: "1px solid #457dff" | ||
}, | ||
".cm-searchMatch.cm-searchMatch-selected": { | ||
backgroundColor: "#6199ff2f" | ||
}, | ||
".cm-scroller": { | ||
fontFamily: 'var(--font-family-mono)' | ||
}, | ||
".cm-activeLine": { backgroundColor: "#6699ff0b" }, | ||
".cm-selectionMatch": { backgroundColor: "#aafe661a" }, | ||
"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": { | ||
backgroundColor: "#bad0f847" | ||
}, | ||
"&.cm-focused": { | ||
outline: "none", | ||
}, | ||
".cm-gutters": { | ||
backgroundColor: "transparent", | ||
color: stone, | ||
border: "none" | ||
}, | ||
".cm-activeLineGutter": { | ||
backgroundColor: "transparent" | ||
}, | ||
".cm-line": { | ||
backgroundColor: "transparent", | ||
}, | ||
".cm-foldPlaceholder": { | ||
backgroundColor: "transparent", | ||
border: "none", | ||
color: "#ddd" | ||
}, | ||
".cm-tooltip": { | ||
border: "none", | ||
backgroundColor: tooltipBackground | ||
}, | ||
".cm-tooltip .cm-tooltip-arrow:before": { | ||
borderTopColor: "transparent", | ||
borderBottomColor: "transparent" | ||
}, | ||
".cm-tooltip .cm-tooltip-arrow:after": { | ||
borderTopColor: tooltipBackground, | ||
borderBottomColor: tooltipBackground | ||
}, | ||
".cm-tooltip-autocomplete": { | ||
"& > ul > li[aria-selected]": { | ||
backgroundColor: highlightBackground, | ||
color: ivory | ||
} | ||
} | ||
}) | ||
|
||
/// The highlighting style for code in the One Dark theme. | ||
export const oneDarkHighlightStyle = HighlightStyle.define([ | ||
{tag: t.keyword, | ||
color: violet}, | ||
{tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName], | ||
color: coral}, | ||
{tag: [t.function(t.variableName), t.labelName], | ||
color: malibu}, | ||
{tag: [t.color, t.constant(t.name), t.standard(t.name)], | ||
color: whiskey}, | ||
{tag: [t.definition(t.name), t.separator], | ||
color: ivory}, | ||
{tag: [t.typeName, t.className, t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], | ||
color: chalky}, | ||
{tag: [t.operator, t.operatorKeyword, t.url, t.escape, t.regexp, t.link, t.special(t.string)], | ||
color: cyan}, | ||
{tag: [t.meta, t.comment], | ||
color: stone}, | ||
{tag: t.strong, | ||
fontWeight: "bold"}, | ||
{tag: t.emphasis, | ||
fontStyle: "italic"}, | ||
{tag: t.strikethrough, | ||
textDecoration: "line-through"}, | ||
{tag: t.link, | ||
color: stone, | ||
textDecoration: "underline"}, | ||
{tag: t.heading, | ||
fontWeight: "bold", | ||
color: coral}, | ||
{tag: [t.atom, t.bool, t.special(t.variableName)], | ||
color: whiskey }, | ||
{tag: [t.processingInstruction, t.string, t.inserted], | ||
color: sage}, | ||
{tag: t.invalid, | ||
color: invalid}, | ||
]) | ||
|
||
export const oneDark = [oneDarkTheme, syntaxHighlighting(oneDarkHighlightStyle)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +0,0 @@ | ||
.CodeMirror { | ||
display: block; | ||
background: var(--input-color); | ||
border: 2px solid var(--input-border); | ||
border-radius: var(--form-input-border-radius); | ||
width: 100%; | ||
box-shadow: var(--form-input-glow); | ||
transition: | ||
var(--standard-transition), | ||
height 0s; | ||
cursor: text; | ||
margin-bottom: var(--section-padding); | ||
|
||
// Override the defaults of codemirror.css | ||
pre { | ||
font-family: var(--font-family-mono) !important; | ||
font-weight: 500 !important; | ||
line-height: 1.66 !important; | ||
} | ||
|
||
&:hover { | ||
border-color: var(--input-border-hover); | ||
} | ||
|
||
&:active, | ||
&:focus-within { | ||
outline: none; | ||
border-color: var(--focus-input-border); | ||
box-shadow: var(--form-input-glow--focus); | ||
} | ||
|
||
textarea { | ||
background: transparent; | ||
border: none; | ||
outline: none; | ||
} | ||
|
||
.cm-variable { | ||
color: var(--text-color) !important; | ||
} | ||
|
||
.CodeMirror-selected { | ||
background-color: var(--selection-color) !important; | ||
} | ||
} | ||
|
||
.jenkins-codemirror-resizer { | ||
position: relative; | ||
width: 10px; | ||
height: 10px; | ||
margin: calc(-2rem - 11px) 3px 2rem auto; | ||
z-index: 10; | ||
cursor: ns-resize; | ||
background: currentColor; | ||
mask-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='20px' height='20px' viewBox='0 0 20 20' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cline x1='19' y1='12' x2='12' y2='19' id='Path' stroke='%23979797' stroke-width='2'%3E%3C/line%3E%3Cline x1='1' y1='18' x2='17.9705627' y2='1.02943725' id='Path-2' stroke='%23979797' stroke-width='2'%3E%3C/line%3E%3C/g%3E%3C/svg%3E"); | ||
mask-size: 7px 7px; | ||
mask-position: 3px 3px; | ||
mask-repeat: no-repeat; | ||
opacity: 0.75; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.