Update editor, workspace, Git services, appearance, and project guides
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import Icon from '$lib/ui/Icon.svelte';
|
||||
import WebData from './WebData.svelte';
|
||||
import { state as browserState, request } from './client';
|
||||
let selected = $state('user'), name = $state(''), message = $state('');
|
||||
let search = $state('duckduckgo'), adblock = $state(true), internalLinks = $state(true), rules = $state('');
|
||||
let homepage = $state(''), filterLists = $state(''), ready = $state(false), busy = $state(false);
|
||||
onMount(() => { void request('state').then(value => {
|
||||
selected = value.profiles[0].id; search = value.settings.search; adblock = value.settings.adblock;
|
||||
internalLinks = value.settings.linkDestination === 'internal'; rules = value.settings.personalRules;
|
||||
homepage = value.settings.homepage || ''; filterLists = (value.settings.filterLists || []).join('\n'); ready = true;
|
||||
}).catch(error => message = String(error)); });
|
||||
async function act(command: string, args: Record<string, unknown>) {
|
||||
try { const next = await request(command, args); message = 'Changes saved.'; return next; } catch (error) { message = String(error); return null; }
|
||||
}
|
||||
async function create(duplicate: boolean) {
|
||||
if (!name.trim()) { message = 'Enter a profile name.'; return; }
|
||||
const result = await act(duplicate ? 'duplicateProfile' : 'createProfile', duplicate ? { profileId: selected, name } : { name });
|
||||
if (result) { selected = result.profiles.at(-1)!.id; name = ''; }
|
||||
}
|
||||
async function save() {
|
||||
busy = true; message = 'Saving browser settings…';
|
||||
try {
|
||||
await act('settings', { search, adblock, linkDestination: internalLinks ? 'internal' : 'external', personalRules: rules,
|
||||
homepage, filterLists: filterLists.split(/\r?\n/).map(value => value.trim()).filter(Boolean) });
|
||||
} finally { busy = false; }
|
||||
}
|
||||
</script>
|
||||
<div class="settings">
|
||||
<h2>Browser</h2><p>Choose how you browse within RuneStone.</p>
|
||||
<h3>General</h3>
|
||||
<form onsubmit={event => { event.preventDefault(); if (ready && !busy) void save(); }}>
|
||||
<fieldset disabled={!ready || busy}>
|
||||
<div class="card">
|
||||
<label class="row"><span>Open web links in RuneStone<small>Turn this off to use your system browser.</small></span><input class="switch" type="checkbox" role="switch" aria-label="Open web links in RuneStone" bind:checked={internalLinks}></label>
|
||||
<label class="row"><span>Homepage<small>The page to open in each new browser tab. Leave blank for an empty page.</small></span><input class="address" type="url" aria-label="Homepage" placeholder="https://example.com" maxlength="8192" bind:value={homepage}></label>
|
||||
<label class="row"><span>Search engine</span><select bind:value={search}><option value="duckduckgo">DuckDuckGo</option><option value="google">Google</option><option value="bing">Bing</option></select></label>
|
||||
<label class="row"><span>Block ads and trackers<small>Apply the filter lists and personal rules to all browser tabs.</small></span><input class="switch" type="checkbox" role="switch" aria-label="Block ads and trackers" bind:checked={adblock}></label>
|
||||
<label class="row list-row"><span>Ad blocking lists<small>One HTTPS filter list URL per line, up to eight lists. New lists download when you save.</small></span><textarea aria-label="Ad blocking lists" rows="4" maxlength="66000" placeholder="https://easylist.to/easylist/easylist.txt" bind:value={filterLists}></textarea></label>
|
||||
</div>
|
||||
<label class="rules">Personal filter rules<small>Optional rules to add to the selected lists.</small><textarea rows="4" maxlength="100000" bind:value={rules}></textarea></label>
|
||||
<button type="submit"><Icon icon="save" />{busy ? 'Saving…' : 'Save browser settings'}</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<h3>Profiles</h3><p>New profiles start blank. Duplicate a profile to copy its stored browsing data and bookmarks.</p>
|
||||
<div class="card profiles">
|
||||
<label>Profile<select aria-label="Profile" bind:value={selected}>{#each $browserState?.profiles || [] as profile}<option value={profile.id}>{profile.name}</option>{/each}</select></label>
|
||||
<label>New profile name<input bind:value={name} maxlength="60" placeholder="Profile name"></label>
|
||||
<div class="actions"><button onclick={() => void create(false)}><Icon icon="plus" />New blank profile</button><button onclick={() => void create(true)}><Icon icon="copy" />Duplicate profile</button></div>
|
||||
<p class="note">Duplication briefly restarts browser tabs. The copies remain separate. Agent permissions are not copied.</p>
|
||||
</div>
|
||||
<h3>Web data</h3><p>Clear data for the selected profile. Its browser tabs will close. Bookmarks remain.</p>
|
||||
<div class="actions"><button onclick={() => void act('clearData', { profileId: selected, kind: 'cache' })}>Clear cache</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'cookies' })}>Clear cookies</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'history' })}>Clear history</button></div>
|
||||
<p role="status">{message}</p>
|
||||
{#if ready}<WebData profileId={selected} />{/if}
|
||||
</div>
|
||||
<style>
|
||||
.settings{color:var(--rs-text);font-family:var(--rs-font-ui)}h2{margin:0;font-size:var(--rs-settings-heading-size);font-weight:500;color:var(--rs-text-strong)}h3{margin:var(--rs-settings-section-gap) 0 var(--rs-settings-gap);font-size:14px;font-weight:500}
|
||||
p{color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.6}.card{padding:0 var(--rs-settings-row-padding);background:var(--rs-bg-elevated);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius)}
|
||||
.row{display:flex;justify-content:space-between;align-items:center;gap:var(--rs-settings-gap);padding:var(--rs-settings-row-padding) 0}.row+.row{border-top:1px solid var(--rs-border)}
|
||||
input,select,textarea,button{border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg);color:var(--rs-text);font:inherit;box-sizing:border-box;min-height:var(--rs-settings-control-height);padding:4px 8px}
|
||||
button{display:inline-flex;align-items:center;gap:7px;background:var(--rs-bg-elevated);cursor:pointer}button:hover{background:var(--rs-bg-active)}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:2px solid var(--rs-accent);outline-offset:1px}
|
||||
.rules{display:flex;flex-direction:column;gap:7px;margin:16px 0}.profiles{padding-top:16px;padding-bottom:8px}.profiles label{display:flex;flex-direction:column;gap:7px;margin-bottom:14px}
|
||||
.actions{display:flex;flex-wrap:wrap;gap:8px}.note{margin-bottom:0}
|
||||
fieldset{border:0;margin:0;padding:0;min-width:0}small{display:block;color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.5;margin-top:5px}
|
||||
.row>span{flex:1}.address,.list-row textarea{width:260px;max-width:48%;box-sizing:border-box}.list-row{align-items:flex-start}textarea{resize:vertical}
|
||||
.switch{appearance:none;position:relative;flex:none;width:44px;height:26px;border:0;border-radius:999px;background:var(--rs-text-dim);padding:0;cursor:pointer;transition:background .15s}
|
||||
.switch::before{content:'';position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:var(--rs-bg);box-shadow:0 1px 3px #0004;transition:transform .15s}
|
||||
.switch:checked{background:var(--rs-accent)}.switch:checked::before{transform:translateX(18px)}:disabled{opacity:.6;cursor:wait}
|
||||
@media(prefers-reduced-motion:reduce){.switch,.switch::before{transition:none}}
|
||||
@media(max-width:600px){.row{flex-wrap:wrap}.address,.list-row textarea{width:100%;max-width:100%}}
|
||||
</style>
|
||||
Reference in New Issue
Block a user