Refactor svelte/legacy functions to svelte 5 syntax

This commit is contained in:
kwaroran
2024-10-23 21:03:34 +09:00
parent f078292843
commit 9add01cda2
24 changed files with 201 additions and 216 deletions

View File

@@ -1,6 +1,4 @@
<script lang="ts">
import { run, stopPropagation } from 'svelte/legacy';
import { ColorSchemeTypeStore } from "src/ts/gui/colorscheme";
import { ParseMarkdown } from "src/ts/parser";
import { parseMultilangString, toLangName } from "src/ts/util";
@@ -16,7 +14,7 @@
if(valueObject["en"] === undefined){
selectedLang = "xx"
}
run(() => {
$effect.pre(() => {
valueObject = parseMultilangString(value)
});
</script>
@@ -25,7 +23,8 @@
<div class="flex flex-wrap max-w-fit p-1 gap-2">
{#each Object.keys(valueObject) as lang}
{#if lang !== 'xx' || Object.keys(valueObject).length === 1}
<button class="bg-bgcolor py-2 rounded-lg px-4" class:ring-1={selectedLang === lang} onclick={stopPropagation(() => {
<button class="bg-bgcolor py-2 rounded-lg px-4" class:ring-1={selectedLang === lang} onclick={((e) => {
e.stopPropagation()
selectedLang = lang
})}>{toLangName(lang)}</button>
{/if}

View File

@@ -1,6 +1,4 @@
<script lang="ts">
import { run } from 'svelte/legacy';
import { encodeMultilangString, languageCodes, parseMultilangString, toLangName } from "src/ts/util";
import TextAreaInput from "./TextAreaInput.svelte";
let addingLang = $state(false)
@@ -33,7 +31,7 @@
delete valueObject["xx"]
updateValue()
}
run(() => {
$effect.pre(() => {
valueObject = parseMultilangString(value)
});
</script>

View File

@@ -114,8 +114,6 @@
</div>
</div>
<script lang="ts">
import { run } from 'svelte/legacy';
import { textAreaSize, textAreaTextSize } from 'src/ts/gui/guisize'
import { highlighter, getNewHighlightId, removeHighlight, AllCBS } from 'src/ts/gui/highlight'
import { isMobile } from 'src/ts/storage/globalApi';
@@ -311,10 +309,10 @@
} catch (error) {}
}
run(() => {
$effect.pre(() => {
optiValue = value
});
run(() => {
$effect.pre(() => {
highlightChange(value, highlightId)
});