diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-11-14 13:02:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-14 05:02:11 +0000 |
commit | 3f9c3e7bc394c115ccc4818d6505f1f68de350d2 (patch) | |
tree | e07e4a3dc07ce80104f7949af5cb180b7fce449e /web_src | |
parent | 985e2a8af3d6468bac3ab178148c38bdbd8414f5 (diff) | |
download | gitea-3f9c3e7bc394c115ccc4818d6505f1f68de350d2.tar.gz gitea-3f9c3e7bc394c115ccc4818d6505f1f68de350d2.zip |
Refactor render system (#32492)
There were too many patches to the Render system, it's really difficult
to make further improvements.
This PR clears the legacy problems and fix TODOs.
1. Rename `RenderContext.Type` to `RenderContext.MarkupType` to clarify
its usage.
2. Use `ContentMode` to replace `meta["mode"]` and `IsWiki`, to clarify
the rendering behaviors.
3. Use "wiki" mode instead of "mode=gfm + wiki=true"
4. Merge `renderByType` and `renderByFile`
5. Add more comments
----
The problem of "mode=document": in many cases it is not set, so many
non-comment places use comment's hard line break incorrectly
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/features/comp/ComboMarkdownEditor.ts | 3 | ||||
-rw-r--r-- | web_src/js/features/repo-wiki.ts | 4 |
2 files changed, 1 insertions, 6 deletions
diff --git a/web_src/js/features/comp/ComboMarkdownEditor.ts b/web_src/js/features/comp/ComboMarkdownEditor.ts index 576c1bccd6..7117952fa3 100644 --- a/web_src/js/features/comp/ComboMarkdownEditor.ts +++ b/web_src/js/features/comp/ComboMarkdownEditor.ts @@ -74,7 +74,6 @@ export class ComboMarkdownEditor { previewUrl: string; previewContext: string; previewMode: string; - previewWiki: boolean; constructor(container, options = {}) { container._giteaComboMarkdownEditor = this; @@ -213,13 +212,11 @@ export class ComboMarkdownEditor { this.previewUrl = this.tabPreviewer.getAttribute('data-preview-url'); this.previewContext = this.tabPreviewer.getAttribute('data-preview-context'); this.previewMode = this.options.previewMode ?? 'comment'; - this.previewWiki = this.options.previewWiki ?? false; this.tabPreviewer.addEventListener('click', async () => { const formData = new FormData(); formData.append('mode', this.previewMode); formData.append('context', this.previewContext); formData.append('text', this.value()); - formData.append('wiki', String(this.previewWiki)); const response = await POST(this.previewUrl, {data: formData}); const data = await response.text(); renderPreviewPanelContent($(panelPreviewer), data); diff --git a/web_src/js/features/repo-wiki.ts b/web_src/js/features/repo-wiki.ts index 1a62427b73..0e72b87109 100644 --- a/web_src/js/features/repo-wiki.ts +++ b/web_src/js/features/repo-wiki.ts @@ -26,7 +26,6 @@ async function initRepoWikiFormEditor() { formData.append('mode', editor.previewMode); formData.append('context', editor.previewContext); formData.append('text', newContent); - formData.append('wiki', editor.previewWiki); try { const response = await POST(editor.previewUrl, {data: formData}); const data = await response.text(); @@ -51,8 +50,7 @@ async function initRepoWikiFormEditor() { // And another benefit is that we only need to write the style once for both editors. // TODO: Move height style to CSS after EasyMDE removal. editorHeights: {minHeight: '300px', height: 'calc(100vh - 600px)'}, - previewMode: 'gfm', - previewWiki: true, + previewMode: 'wiki', easyMDEOptions: { previewRender: (_content, previewTarget) => previewTarget.innerHTML, // disable builtin preview render toolbar: ['bold', 'italic', 'strikethrough', '|', |