Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lib/Editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@
background-color: var(--input);
}

.pm-editor :global(.code-wrap .CodeMirror-gutters) {
background-color: transparent;
}

.pm-editor :global(.code-wrap.no-toolbar .CodeMirror) {
border-radius: 20px;
}
Expand Down
26 changes: 13 additions & 13 deletions src/lib/plugins/marks-tooltip/LinkSelector/LinkSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
import { Modal, TabNav, TabNavItem } from '@hyvor/design/components';
import IconHash from '@hyvor/icons/IconHash';
import IconLink45deg from '@hyvor/icons/IconLink45deg';
import IconSearch from '@hyvor/icons/IconSearch';

import Paste from './Paste.svelte';
import SearchPosts from './SearchPosts.svelte';
import type { EditorView } from 'prosemirror-view';
import { toggleMark } from 'prosemirror-commands';
import { TextSelection } from 'prosemirror-state';
Expand All @@ -14,24 +11,27 @@
interface Props {
show: boolean;
view: EditorView;
edit?: null | string;
edit?: string;
}

let { show = $bindable(), view, edit = null }: Props = $props();
let { show = $bindable(), view, edit }: Props = $props();

let inputValue = $state(edit ?? '');
let isEditing = !!edit;

let activeTab: 'paste' | 'anchors' | 'posts' = $state('paste');

function handleAdd(e: CustomEvent<string>) {
if (edit) {
if (isEditing) {
// remove the link
toggleMark(view.state.schema.marks.link!)(view.state, view.dispatch);
}

toggleMark(view.state.schema.marks.link!, { href: e.detail })(view.state, view.dispatch);
show = false;
view.focus();

if (!edit) focusAtLinkEnd();
0
if (!isEditing) focusAtLinkEnd();
}

function focusAtLinkEnd() {
Expand All @@ -57,20 +57,20 @@
{/snippet}
Anchors
</TabNavItem>
<TabNavItem name="posts">
<!-- <TabNavItem name="posts">
{#snippet start()}
<IconSearch size={13} />
{/snippet}
Posts
</TabNavItem>
</TabNavItem> -->
</TabNav>
{/snippet}

{#if activeTab === 'paste'}
<Paste on:add={handleAdd} input={edit || ''} />
<Paste on:add={handleAdd} bind:input={inputValue} />
{:else if activeTab === 'anchors'}
<Anchors on:add={handleAdd} />
{:else if activeTab === 'posts'}
<SearchPosts on:add={handleAdd} />
<!-- {:else if activeTab === 'posts'}
<SearchPosts on:add={handleAdd} /> -->
{/if}
</Modal>
2 changes: 1 addition & 1 deletion src/lib/plugins/marks-tooltip/MarksTooltip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
{/key}

{#if linkSelectorOpen}
<LinkSelector bind:show={linkSelectorOpen} {view} edit={link ? link.attrs.href : null} />
<LinkSelector bind:show={linkSelectorOpen} {view} edit={link ? link.attrs.href : undefined} />
{/if}

<style>
Expand Down