test: stabilize cold-start Playwright tests; fix editor bind:new_content fallback
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
|
||||
let {
|
||||
content = $bindable(''),
|
||||
new_content = $bindable(''),
|
||||
new_content = $bindable(),
|
||||
placeholder = 'Start typing...',
|
||||
theme_mode = 'light',
|
||||
language = 'markdown',
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
async function create_editor() {
|
||||
if (!browser) return;
|
||||
|
||||
|
||||
cm = await ensureCodeMirrorModules();
|
||||
if (!cm) return;
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
cm.crosshairCursor(),
|
||||
cm.highlightActiveLine(),
|
||||
cm.highlightActiveLineGutter(),
|
||||
|
||||
|
||||
// Keymaps
|
||||
cm.keymap.of([
|
||||
...cm.defaultKeymap,
|
||||
@@ -178,14 +178,14 @@
|
||||
const changes = state.changeByRange((range: any) => {
|
||||
const line = state.doc.lineAt(range.from);
|
||||
const has_list = line.text.startsWith('- ');
|
||||
|
||||
|
||||
if (has_list) {
|
||||
return {
|
||||
changes: [{ from: line.from, to: line.from + 2, insert: '' }],
|
||||
range: cm.EditorSelection.range(range.from - 2, range.to - 2)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
changes: [{ from: line.from, insert: '- ' }],
|
||||
range: cm.EditorSelection.range(range.from + 2, range.to + 2)
|
||||
@@ -211,15 +211,15 @@
|
||||
<button type="button" class="btn btn-sm variant-soft hover:variant-filled-primary" onclick={() => wrap_selection('`')} title="Inline Code">
|
||||
<Code size="14" />
|
||||
</button>
|
||||
|
||||
|
||||
<div class="ml-auto flex gap-1">
|
||||
<span class="text-[10px] opacity-50 self-center uppercase font-bold mr-2">{language}</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div
|
||||
bind:this={editor_container}
|
||||
<div
|
||||
bind:this={editor_container}
|
||||
class="grow overflow-auto bg-white dark:bg-black/20"
|
||||
style="min-height: 100px;"
|
||||
></div>
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
*/
|
||||
import { onMount, untrack } from 'svelte';
|
||||
import { browser } from '$app/environment';
|
||||
import {
|
||||
Bold, Italic, List, ListOrdered,
|
||||
import {
|
||||
Bold, Italic, List, ListOrdered,
|
||||
RemoveFormatting, Type, Code, AlignLeft
|
||||
} from 'lucide-svelte';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
let {
|
||||
content = $bindable(''),
|
||||
new_content = $bindable(''),
|
||||
new_content = $bindable(),
|
||||
placeholder = 'Start writing...',
|
||||
readonly = false,
|
||||
auto_format = true,
|
||||
@@ -102,7 +102,7 @@
|
||||
<button type="button" class="btn btn-sm variant-soft hover:variant-filled-error" onclick={() => exec('removeFormat')} title="Clear Formatting">
|
||||
<RemoveFormatting size="14" />
|
||||
</button>
|
||||
|
||||
|
||||
<button type="button" class="btn btn-sm variant-soft hover:variant-filled-success" onclick={handle_format} title="Format HTML Source">
|
||||
<AlignLeft size="14" />
|
||||
<span class="text-[10px] ml-1">Format</span>
|
||||
@@ -121,7 +121,7 @@
|
||||
{placeholder}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
<div
|
||||
bind:this={editor_element}
|
||||
contenteditable={!readonly}
|
||||
|
||||
Reference in New Issue
Block a user