-
Notifications
You must be signed in to change notification settings - Fork 166
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
a67e586
commit 8c487a6
Showing
20 changed files
with
1,262 additions
and
755 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Support\Str; | ||
use Illuminate\View\Component; | ||
|
||
class Editor extends Component | ||
{ | ||
public string $id; | ||
|
||
public string $name; | ||
|
||
public ?string $value; | ||
|
||
public array $options; | ||
|
||
public function __construct( | ||
string $name, | ||
?string $value, | ||
public string $lang, | ||
public bool $readonly = false, | ||
public bool $lineNumbers = true, | ||
) { | ||
$this->id = $name.'-'.Str::random(8); | ||
$this->name = $name; | ||
$this->value = json_encode($value ?? ''); | ||
$this->options = $this->getOptions(); | ||
} | ||
|
||
private function getOptions(): array | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'name' => $this->name, | ||
'lang' => $this->lang, | ||
'value' => $this->value, | ||
]; | ||
} | ||
|
||
public function render(): View|Closure|string | ||
{ | ||
return view('components.editor'); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import ace from 'brace'; | ||
import 'brace/mode/javascript'; | ||
import 'brace/mode/plain_text'; | ||
import 'brace/mode/sh'; | ||
import 'brace/mode/ini'; | ||
import 'brace/ext/searchbox' | ||
import './theme-vito' | ||
import './mode-env'; | ||
import './mode-nginx'; | ||
|
||
window.initAceEditor = function (options = {}) { | ||
const editorValue = JSON.parse(options.value || ''); | ||
const editor = ace.edit(options.id); | ||
editor.setTheme("ace/theme/vito"); | ||
editor.getSession().setMode(`ace/mode/${options.lang || 'plain_text'}`); | ||
editor.setValue(editorValue, -1); | ||
editor.clearSelection(); | ||
editor.focus(); | ||
editor.setOptions({ | ||
enableBasicAutocompletion: true, | ||
enableSnippets: true, | ||
enableLiveAutocompletion: true, | ||
printMargin: false, | ||
}); | ||
|
||
editor.renderer.setScrollMargin(15, 15, 0, 0) | ||
editor.renderer.setPadding(15); | ||
|
||
editor.getSession().on('change', function () { | ||
document.getElementById(`textarea-${options.id}`).value = editor.getValue(); | ||
}); | ||
|
||
window.addEventListener('resize', function () { | ||
editor.resize(); | ||
}) | ||
|
||
document.getElementById(`textarea-${options.id}`).innerHTML = editorValue; | ||
|
||
return editor; | ||
} |
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,136 @@ | ||
ace.define("ace/mode/env", ["require", "exports", "module", "ace/lib/oop", "ace/mode/text", "ace/mode/env_highlight_rules", "ace/mode/folding/ini","ace/mode/behaviour"], function (require, exports) { | ||
var oop = require("../lib/oop"); | ||
var TextMode = require("./text").Mode; | ||
var Behaviour = require("./behaviour").Behaviour; | ||
var envHighlightRules = require("./env_highlight_rules").envHighlightRules; | ||
|
||
var Mode = function () { | ||
this.HighlightRules = envHighlightRules; | ||
this.$behaviour = new Behaviour | ||
}; | ||
|
||
oop.inherits(Mode, TextMode); | ||
|
||
(function() { | ||
this.lineCommentStart = "#", | ||
this.blockComment = null, | ||
this.$id = "ace/mode/env" | ||
}).call(Mode.prototype), | ||
|
||
exports.Mode = Mode; | ||
}) | ||
ace.define("ace/mode/env_highlight_rules", ["require", "exports", "module", "ace/lib/oop", "ace/mode/text_highlight_rules"], function (require, exports, module) { | ||
"use strict"; | ||
|
||
var oop = require("../lib/oop"); | ||
var TextHighlightRules = | ||
require("./text_highlight_rules").TextHighlightRules; | ||
|
||
var envHighlightRules = function () { | ||
this.$rules = { | ||
start: [ | ||
{ | ||
token: "punctuation.definition.comment.env", | ||
regex: "#.*", | ||
push_: [ | ||
{ | ||
token: "comment.line.number-sign.env", | ||
regex: "$|^", | ||
next: "pop", | ||
}, | ||
{ | ||
defaultToken: "comment.line.number-sign.env", | ||
}, | ||
], | ||
}, | ||
{ | ||
token: "punctuation.definition.comment.env", | ||
regex: "#.*", | ||
push_: [ | ||
{ | ||
token: "comment.line.semicolon.env", | ||
regex: "$|^", | ||
next: "pop", | ||
}, | ||
{ | ||
defaultToken: "comment.line.semicolon.env", | ||
}, | ||
], | ||
}, | ||
{ | ||
token: [ | ||
"keyword.other.definition.env", | ||
"text", | ||
"punctuation.separator.key-value.env", | ||
], | ||
regex: "\\b([a-zA-Z0-9_.-]+)\\b(\\s*)(=)", | ||
}, | ||
{ | ||
token: [ | ||
"punctuation.definition.entity.env", | ||
"constant.section.group-title.env", | ||
"punctuation.definition.entity.env", | ||
], | ||
regex: "^(\\[)(.*?)(\\])", | ||
}, | ||
{ | ||
token: "punctuation.definition.string.begin.env", | ||
regex: "'", | ||
push: [ | ||
{ | ||
token: "punctuation.definition.string.end.env", | ||
regex: "'", | ||
next: "pop", | ||
}, | ||
{ | ||
token: "constant.language.escape", | ||
regex: "\\\\(?:[\\\\0abtrn;#=:]|x[a-fA-F\\d]{4})", | ||
}, | ||
{ | ||
defaultToken: "string.quoted.single.env", | ||
}, | ||
], | ||
}, | ||
{ | ||
token: "punctuation.definition.string.begin.env", | ||
regex: '"', | ||
push: [ | ||
{ | ||
token: "constant.language.escape", | ||
regex: "\\\\(?:[\\\\0abtrn;#=:]|x[a-fA-F\\d]{4})", | ||
}, | ||
{ | ||
token: "support.constant.color", | ||
regex: /\${[\w]+}/, | ||
}, | ||
{ | ||
token: "punctuation.definition.string.end.env", | ||
regex: '"', | ||
next: "pop", | ||
}, | ||
{ | ||
defaultToken: "string.quoted.double.env", | ||
}, | ||
], | ||
}, | ||
{ | ||
token: "constant.language.boolean", | ||
regex: /(?:true|false)\b/, | ||
}, | ||
], | ||
}; | ||
this.normalizeRules(); | ||
}; | ||
|
||
envHighlightRules.metaData = { | ||
fileTypes: ["env"], | ||
keyEquivalent: "^~I", | ||
name: "Env", | ||
scopeName: "source.env", | ||
}; | ||
|
||
oop.inherits(envHighlightRules, TextHighlightRules); | ||
|
||
exports.envHighlightRules = envHighlightRules; | ||
}); | ||
|
Oops, something went wrong.