Scheiß Line Separator

This commit is contained in:
2023-11-28 12:00:06 +01:00
parent 3996376381
commit 2abe554059
16 changed files with 1113 additions and 466 deletions

View File

@@ -1,12 +1,12 @@
<script lang="ts">
import {Spinner, Toolbar, ToolbarButton, ToolbarGroup, Tooltip} from "flowbite-svelte";
import {markdown} from "@codemirror/lang-markdown";
import {json} from "@codemirror/lang-json";
import CodeMirror from "svelte-codemirror-editor";
import {pageRepo} from "../../../repo/repo.ts";
import {base64ToBytes} from "../../util.ts";
import type {Page} from "../../../types/page.ts";
import {materialDark} from '@ddietr/codemirror-themes/material-dark.js'
import {EditOutline} from "flowbite-svelte-icons";
import {createEventDispatcher} from "svelte";
export let pageId: number;
@@ -56,7 +56,7 @@
</ToolbarGroup>
</Toolbar>
</div>
<CodeMirror bind:value={pageContent} lang={markdown()} theme={materialDark} />
<CodeMirror bind:value={pageContent} lang={page?.name.endsWith("md") ? markdown() : json()} theme={materialDark} />
</div>
{:catch error}
<p>{error.message}</p>

View File

@@ -4,7 +4,7 @@ import type {ListPage, PageList} from "../types/page.ts";
export const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);
export const nameRegex = new RegExp("(?!.*\/).+(?=\\.md)");
export const nameRegex = new RegExp("(?!.*\/).+(?=\\.(md|json))");
export function mapToMap(pages: PageList): Map<string, ListPage[]> {
const map = new Map();