-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Showing
10 changed files
with
3,600 additions
and
680 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# How to Build? | ||
|
||
> npm install | ||
> npm start | ||
The builded editor will be bundled on `build/bundle.js`. |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { nodeResolve } from "@rollup/plugin-node-resolve"; | ||
import {nodeResolve} from "@rollup/plugin-node-resolve"; | ||
|
||
export default { | ||
input: "./source/editor.js", | ||
output: { | ||
file: "./build/bundle.js", | ||
format: "iife", | ||
}, | ||
plugins: [nodeResolve()], | ||
input: "./src/main.js", | ||
output: { | ||
file: "./build/bundle.js", | ||
format: "iife", | ||
}, | ||
plugins: [nodeResolve()], | ||
}; |
Submodule source
deleted from
ec8210
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,38 @@ | ||
import {HighlightStyle, tags} from '@codemirror/highlight'; | ||
|
||
export const myHighlightStyle = HighlightStyle.define( | ||
{tag: tags.link, textDecoration: 'underline'}, | ||
{fontWeight: 'bold', tag: tags.heading, textDecoration: 'underline'}, | ||
{fontStyle: 'italic', tag: tags.emphasis}, | ||
{fontWeight: 'bold', tag: tags.strong}, | ||
{color: '#a77b51', tag: tags.keyword}, | ||
{ | ||
color: '#219', | ||
tag: [ | ||
tags.atom, | ||
tags.bool, | ||
tags.url, | ||
tags.contentSeparator, | ||
tags.labelName, | ||
], | ||
}, | ||
{color: '#164', tag: [tags.literal, tags.inserted]}, | ||
{color: '#a11', tag: [tags.string, tags.deleted]}, | ||
{color: '#e40', tag: [tags.regexp, tags.escape, tags.special(tags.string)]}, | ||
{color: '#00f', tag: tags.definition(tags.variableName)}, | ||
{color: '#30a', tag: tags.local(tags.variableName)}, | ||
{color: '#085', tag: [tags.typeName, tags.namespace]}, | ||
{color: '#167', tag: tags.className}, | ||
{ | ||
color: '#256', | ||
tag: [ | ||
tags.special(tags.variableName), | ||
tags.macroName, | ||
tags.local(tags.variableName), | ||
], | ||
}, | ||
{color: '#00c', tag: tags.definition(tags.propertyName)}, | ||
{color: '#940', tag: tags.comment}, | ||
{color: '#7a757a', tag: tags.meta}, | ||
{color: '#f00', tag: tags.invalid}, | ||
); |
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,81 @@ | ||
<!DOCTYPE html> | ||
<html data-bs-theme="dark" lang="en"> | ||
<head> | ||
<meta charset="UTF-8"/> | ||
<meta content="width=device-width, initial-scale=1.0" name="viewport"/> | ||
<title>CodeMirror 6</title> | ||
<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" | ||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div data-language="properties" id="code-editor"></div> | ||
<script id="editor-content" type="text/plain">ServerName localhost | ||
DocumentRoot /etc/fruithost/placeholder | ||
DirectoryIndex index.php index.html | ||
AddDefaultCharset UTF-8 | ||
|
||
ErrorDocument 100 /errors/100.html | ||
ErrorDocument 101 /errors/101.html | ||
ErrorDocument 400 /errors/400.html | ||
ErrorDocument 401 /errors/401.html | ||
ErrorDocument 403 /errors/403.html | ||
ErrorDocument 404 /errors/404.html | ||
ErrorDocument 405 /errors/405.html | ||
ErrorDocument 408 /errors/408.html | ||
ErrorDocument 410 /errors/410.html | ||
ErrorDocument 411 /errors/411.html | ||
ErrorDocument 412 /errors/412.html | ||
ErrorDocument 413 /errors/413.html | ||
ErrorDocument 414 /errors/414.html | ||
ErrorDocument 415 /errors/415.html | ||
ErrorDocument 500 /errors/500.html | ||
ErrorDocument 501 /errors/501.html | ||
ErrorDocument 502 /errors/502.html | ||
ErrorDocument 503 /errors/503.html | ||
ErrorDocument 504 /errors/504.html | ||
ErrorDocument 505 /errors/505.html | ||
ErrorDocument 506 /errors/506.html | ||
|
||
<Directory /etc/fruithost/placeholder/errors> | ||
Order allow,deny | ||
Allow from all | ||
</Directory> | ||
|
||
<Directory /etc/fruithost/modules/*/hooks> | ||
Require all denied | ||
</Directory> | ||
<Directory /etc/fruithost/modules/*/www> | ||
Options +FollowSymLinks -Indexes | ||
AllowOverride None | ||
Require all granted | ||
</Directory> | ||
|
||
<Directory /etc/fruithost/placeholder> | ||
Options +FollowSymLinks -Indexes | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
|
||
<Directory /etc/fruithost/placeholder/errors> | ||
Options +FollowSymLinks -Indexes | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
|
||
<VirtualHost *:80> | ||
ServerAdmin info@fruithost.de | ||
DocumentRoot "/etc/fruithost/placeholder/" | ||
</VirtualHost> | ||
|
||
ServerSignature Off | ||
ServerTokens Prod | ||
Header set Server: "fruithost" | ||
|
||
Include /etc/fruithost/config/apache2/panel.conf | ||
IncludeOptional /etc/fruithost/config/apache2/vhosts/*.conf | ||
|
||
</script> | ||
<script src="../build/bundle.js"></script> | ||
</body> | ||
</html> |
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,87 @@ | ||
import {EditorView} from "@codemirror/view"; | ||
import {Compartment, EditorState} from "@codemirror/state"; | ||
import {basicSetup} from "codemirror"; | ||
import {html} from "@codemirror/lang-html"; | ||
import {javascript} from "@codemirror/lang-javascript"; | ||
import {StreamLanguage} from "@codemirror/language" | ||
import {properties} from "@codemirror/legacy-modes/mode/properties" | ||
import {myTheme} from "./theme.js"; | ||
import {json} from "@codemirror/lang-json"; | ||
|
||
class CodeEditor { | ||
constructor() { | ||
this._code = document.querySelector('#editor-content').innerHTML; | ||
this._container = document.querySelector('#code-editor'); | ||
this._language = new Compartment; | ||
this.init(); | ||
} | ||
|
||
getLanguage() { | ||
return this._container.dataset.language; | ||
} | ||
|
||
init() { | ||
this._state = EditorState.create({ | ||
doc: this._code, | ||
extensions: [ | ||
basicSetup, | ||
myTheme, | ||
this._language.of(this.findLanguage()), | ||
this.loadLanguage() | ||
], | ||
}); | ||
|
||
this._view = new EditorView({ | ||
state: this._state, | ||
parent: this._container | ||
}); | ||
} | ||
|
||
update() { | ||
this._view.dispatch({ | ||
effects: this._language.reconfigure(this.findLanguage()) | ||
}) | ||
} | ||
|
||
findLanguage() { | ||
let language = null; | ||
|
||
switch (this.getLanguage()) { | ||
case "html": | ||
language = html(); | ||
break; | ||
case "javascript": | ||
language = javascript(); | ||
break; | ||
case "json": | ||
language = json(); | ||
break; | ||
case "properties": | ||
language = StreamLanguage.define(properties); | ||
break; | ||
default: | ||
language = html(); | ||
break; | ||
} | ||
|
||
if (language === null) { | ||
return null | ||
} | ||
|
||
return language; | ||
} | ||
|
||
loadLanguage() { | ||
return EditorState.transactionExtender.of(tr => { | ||
if (!tr.docChanged) { | ||
return null | ||
} | ||
|
||
return { | ||
effects: this._language.reconfigure(this.findLanguage()) | ||
} | ||
}); | ||
} | ||
} | ||
|
||
window.addEventListener('DOMContentLoaded', () => new CodeEditor); |
Oops, something went wrong.