aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features
diff options
context:
space:
mode:
authorNanguan Lin <70063547+lng2020@users.noreply.github.com>2023-11-22 17:14:16 +0800
committerGitHub <noreply@github.com>2023-11-22 09:14:16 +0000
commit37ed92d6fdb989fd5e56621f33b3e26369933ec2 (patch)
tree9c3de5211c793925cbac71534473b49361d457a8 /web_src/js/features
parent4d0eba8e0adf64de0bbef9ddb2f77277b1c5af5f (diff)
downloadgitea-37ed92d6fdb989fd5e56621f33b3e26369933ec2.tar.gz
gitea-37ed92d6fdb989fd5e56621f33b3e26369933ec2.zip
Revert "Fix EOL handling in web editor" (#28101)
Reverts go-gitea/gitea#27141 close #28097
Diffstat (limited to 'web_src/js/features')
-rw-r--r--web_src/js/features/codeeditor.js19
1 files changed, 2 insertions, 17 deletions
diff --git a/web_src/js/features/codeeditor.js b/web_src/js/features/codeeditor.js
index 5f924fd086..7dbbcd3dd6 100644
--- a/web_src/js/features/codeeditor.js
+++ b/web_src/js/features/codeeditor.js
@@ -62,7 +62,7 @@ export async function createMonaco(textarea, filename, editorOpts) {
const monaco = await import(/* webpackChunkName: "monaco" */'monaco-editor');
initLanguages(monaco);
- let {language, eol, ...other} = editorOpts;
+ let {language, ...other} = editorOpts;
if (!language) language = getLanguage(filename);
const container = document.createElement('div');
@@ -105,28 +105,14 @@ export async function createMonaco(textarea, filename, editorOpts) {
monaco.languages.register({id: 'vs.editor.nullLanguage'});
monaco.languages.setLanguageConfiguration('vs.editor.nullLanguage', {});
- // We encode the initial value in JSON on the backend to prevent browsers from
- // discarding the \r during HTML parsing:
- // https://html.spec.whatwg.org/multipage/parsing.html#preprocessing-the-input-stream
- const value = JSON.parse(textarea.getAttribute('data-initial-value') || '""');
- textarea.value = value;
- textarea.removeAttribute('data-initial-value');
-
const editor = monaco.editor.create(container, {
- value,
+ value: textarea.value,
theme: 'gitea',
language,
...other,
});
const model = editor.getModel();
-
- // Monaco performs auto-detection of dominant EOL in the file, biased towards LF for
- // empty files. If there is an editorconfig value, override this detected value.
- if (eol in monaco.editor.EndOfLineSequence) {
- model.setEOL(monaco.editor.EndOfLineSequence[eol]);
- }
-
model.onDidChangeContent(() => {
textarea.value = editor.getValue();
textarea.dispatchEvent(new Event('change')); // seems to be needed for jquery-are-you-sure
@@ -201,6 +187,5 @@ function getEditorConfigOptions(ec) {
opts.trimAutoWhitespace = ec.trim_trailing_whitespace === true;
opts.insertSpaces = ec.indent_style === 'space';
opts.useTabStops = ec.indent_style === 'tab';
- opts.eol = ec.end_of_line?.toUpperCase();
return opts;
}