Add Turn into to the text toolbar, page icons from the sidebar, and steadier block handles
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
CI / desktop (ubuntu-latest) (push) Successful in 1h36m55s
CI / mobile (push) Failing after 1m47s
CI / go (Media) (push) Successful in 19m45s
CI / go (Server) (push) Failing after 26m1s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 8m49s
CI / docker (push) Failing after 37m4s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
CI / desktop (ubuntu-latest) (push) Successful in 1h36m55s
CI / mobile (push) Failing after 1m47s
CI / go (Media) (push) Successful in 19m45s
CI / go (Server) (push) Failing after 26m1s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 8m49s
CI / docker (push) Failing after 37m4s
Turn into: the selection toolbar starts with the block's kind ("Heading 1")
and opens the list of kinds it can become, with a tick on the current
one. In a list it turns the whole list, as the block menu did; the grip
menu no longer has it.
Page icons: an editor clicks a page's icon in the sidebar tree to pick an
emoji from groups, recent picks or a search by name (any pasted emoji
works too), or to remove it. The emoji now stands in for the page glyph
rather than sitting before the title. Strings in all five languages.
Block handles: the link and grip buttons stay on the block the cursor is
in, which is highlighted while the editor has focus, sit centred on the
block's height, and no longer vanish crossing the gap from the text.
The sidebar shows the Docwell logo above the workspace switcher.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c98b127f1e
commit
2a063a51be
16 files changed
+688
-60
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
|
||||
<script setup lang="ts">
|
||||
import { DwButton, DwCallout, DwIcon, useTheme, type IconName, type ThemeMode } from "@docwell/ui";
|
||||
import { DwButton, DwCallout, DwIcon, DwLogo, useTheme, type IconName, type ThemeMode } from "@docwell/ui";
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
@@ -237,7 +237,14 @@ function signOut() {
|
||||
:style="{ width: `${sidebar.width.value}px` }"
|
||||
data-testid="sidebar"
|
||||
>
|
||||
<div class="flex shrink-0 items-center gap-1 px-2 pt-2">
|
||||
<RouterLink
|
||||
to="/"
|
||||
class="flex h-11 shrink-0 items-center self-start rounded-sm px-4 pt-2"
|
||||
data-testid="sidebar-logo"
|
||||
>
|
||||
<DwLogo class="h-6" />
|
||||
</RouterLink>
|
||||
<div class="flex shrink-0 items-center gap-1 px-2 pt-1">
|
||||
<WorkspaceSwitcher />
|
||||
<DwButton
|
||||
variant="ghost"
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
|
||||
<script setup lang="ts">
|
||||
import { DwIcon } from "@docwell/ui";
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import {
|
||||
emojiByGroup,
|
||||
emojiGroups,
|
||||
recentEmoji,
|
||||
rememberEmoji,
|
||||
searchEmoji,
|
||||
typedEmoji,
|
||||
type EmojiGroup,
|
||||
} from "../lib/emoji";
|
||||
|
||||
// A page icon picker beside anchor: recent emoji, groups to scroll or jump to,
|
||||
// and a search that also takes any emoji typed or pasted. Escape or a click
|
||||
// elsewhere closes it.
|
||||
const props = defineProps<{ anchor: HTMLElement; current?: string }>();
|
||||
const emit = defineEmits<{ pick: [char: string]; remove: []; close: [] }>();
|
||||
|
||||
const box = ref<HTMLElement | null>(null);
|
||||
const list = ref<HTMLElement | null>(null);
|
||||
const input = ref<HTMLInputElement | null>(null);
|
||||
const query = ref("");
|
||||
const recent = ref(recentEmoji());
|
||||
const pos = ref({ top: 0, left: 0 });
|
||||
|
||||
const groupIcons: Record<EmojiGroup, string> = {
|
||||
smileys: "😀",
|
||||
people: "👋",
|
||||
nature: "🌿",
|
||||
food: "🍎",
|
||||
activity: "⚽",
|
||||
travel: "🚗",
|
||||
objects: "💡",
|
||||
symbols: "🔣",
|
||||
};
|
||||
|
||||
const results = computed(() => searchEmoji(query.value));
|
||||
const typed = computed(() => typedEmoji(query.value));
|
||||
|
||||
function place() {
|
||||
const r = props.anchor.getBoundingClientRect();
|
||||
const w = box.value?.offsetWidth ?? 320;
|
||||
const h = box.value?.offsetHeight ?? 380;
|
||||
const left = Math.max(8, Math.min(r.left, window.innerWidth - w - 8));
|
||||
const below = r.bottom + 4;
|
||||
const top = below + h > window.innerHeight - 8 ? Math.max(8, r.top - h - 4) : below;
|
||||
pos.value = { top, left };
|
||||
}
|
||||
|
||||
function pick(char: string) {
|
||||
rememberEmoji(char);
|
||||
emit("pick", char);
|
||||
}
|
||||
|
||||
function jump(g: EmojiGroup) {
|
||||
query.value = "";
|
||||
void nextTick(() => list.value?.querySelector(`[data-group="${g}"]`)?.scrollIntoView({ block: "start" }));
|
||||
}
|
||||
|
||||
function onKey(e: KeyboardEvent) {
|
||||
if (e.key === "Escape") {
|
||||
e.stopPropagation();
|
||||
emit("close");
|
||||
} else if (e.key === "Enter" && e.target === input.value) {
|
||||
const first = typed.value ?? results.value[0]?.char;
|
||||
if (first) pick(first);
|
||||
}
|
||||
}
|
||||
|
||||
function onPointer(e: PointerEvent) {
|
||||
const t = e.target as Node;
|
||||
if (!box.value?.contains(t) && !props.anchor.contains(t)) emit("close");
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
place();
|
||||
void nextTick(() => {
|
||||
place();
|
||||
input.value?.focus();
|
||||
});
|
||||
document.addEventListener("pointerdown", onPointer, true);
|
||||
window.addEventListener("resize", place);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener("pointerdown", onPointer, true);
|
||||
window.removeEventListener("resize", place);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
ref="box"
|
||||
class="fixed z-50 flex w-80 max-w-[calc(100vw-16px)] flex-col rounded-md border border-line bg-surface-raised shadow-menu"
|
||||
:style="{ top: `${pos.top}px`, left: `${pos.left}px` }"
|
||||
role="dialog"
|
||||
:aria-label="$t('emoji.title')"
|
||||
data-testid="emoji-picker"
|
||||
@keydown="onKey"
|
||||
>
|
||||
<div class="flex items-center gap-0.5 border-b border-line px-1.5 pt-1.5 pb-1" role="tablist">
|
||||
<button
|
||||
v-for="g in emojiGroups"
|
||||
:key="g"
|
||||
type="button"
|
||||
class="grid size-7 cursor-pointer place-items-center rounded-sm text-base hover:bg-surface-hover"
|
||||
:aria-label="$t(`emoji.groups.${g}`)"
|
||||
:title="$t(`emoji.groups.${g}`)"
|
||||
@click="jump(g)"
|
||||
>
|
||||
{{ groupIcons[g] }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5 px-2 pt-2">
|
||||
<label
|
||||
class="flex h-control-sm min-w-0 flex-1 items-center gap-1.5 rounded-sm border border-line bg-surface px-2"
|
||||
>
|
||||
<DwIcon name="search" :size="14" class="shrink-0 text-ink-muted" />
|
||||
<input
|
||||
ref="input"
|
||||
v-model="query"
|
||||
class="min-w-0 flex-1 bg-transparent text-ui-sm text-ink outline-none placeholder:text-ink-faint"
|
||||
:placeholder="$t('emoji.search')"
|
||||
:aria-label="$t('emoji.search')"
|
||||
data-testid="emoji-search"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
v-if="current"
|
||||
type="button"
|
||||
class="h-control-sm shrink-0 cursor-pointer rounded-sm border border-line px-2 text-ui-sm text-ink-muted hover:border-line-strong hover:text-ink"
|
||||
data-testid="emoji-remove"
|
||||
@click="emit('remove')"
|
||||
>
|
||||
{{ $t("emoji.remove") }}
|
||||
</button>
|
||||
</div>
|
||||
<div ref="list" class="h-72 overflow-y-auto px-2 pt-1 pb-2">
|
||||
<template v-if="query.trim()">
|
||||
<div class="grid grid-cols-8">
|
||||
<button
|
||||
v-if="typed && !results.some((r) => r.char === typed)"
|
||||
type="button"
|
||||
class="grid size-9 cursor-pointer place-items-center rounded-sm text-xl hover:bg-surface-hover"
|
||||
@click="pick(typed)"
|
||||
>
|
||||
{{ typed }}
|
||||
</button>
|
||||
<button
|
||||
v-for="e in results"
|
||||
:key="e.char"
|
||||
type="button"
|
||||
class="grid size-9 cursor-pointer place-items-center rounded-sm text-xl hover:bg-surface-hover"
|
||||
:title="e.words"
|
||||
:aria-label="e.words"
|
||||
@click="pick(e.char)"
|
||||
>
|
||||
{{ e.char }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="!typed && !results.length" class="px-1 py-6 text-center text-ui-sm text-ink-muted">
|
||||
{{ $t("emoji.none") }}
|
||||
</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-if="recent.length">
|
||||
<h3 class="sticky top-0 bg-surface-raised px-1 pt-1.5 pb-1 text-ui-xs font-semibold text-ink-muted">
|
||||
{{ $t("emoji.recent") }}
|
||||
</h3>
|
||||
<div class="grid grid-cols-8">
|
||||
<button
|
||||
v-for="c in recent"
|
||||
:key="c"
|
||||
type="button"
|
||||
class="grid size-9 cursor-pointer place-items-center rounded-sm text-xl hover:bg-surface-hover"
|
||||
@click="pick(c)"
|
||||
>
|
||||
{{ c }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<section v-for="g in emojiGroups" :key="g" :data-group="g">
|
||||
<h3 class="sticky top-0 bg-surface-raised px-1 pt-1.5 pb-1 text-ui-xs font-semibold text-ink-muted">
|
||||
{{ $t(`emoji.groups.${g}`) }}
|
||||
</h3>
|
||||
<div class="grid grid-cols-8">
|
||||
<button
|
||||
v-for="e in emojiByGroup[g]"
|
||||
:key="e.char"
|
||||
type="button"
|
||||
class="grid size-9 cursor-pointer place-items-center rounded-sm text-xl hover:bg-surface-hover"
|
||||
:class="{ 'bg-accent-soft': e.char === current }"
|
||||
:title="e.words"
|
||||
:aria-label="e.words"
|
||||
@click="pick(e.char)"
|
||||
>
|
||||
{{ e.char }}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -6,6 +6,7 @@ import { computed, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { dropPlacement, zoneAt, type DropZone } from "../lib/tree";
|
||||
import { useSpacesStore } from "../stores/spaces";
|
||||
import EmojiPicker from "./EmojiPicker.vue";
|
||||
|
||||
const props = defineProps<{ spaceId: string; node: PageNode; depth: number }>();
|
||||
const emit = defineEmits<{ error: [err: unknown] }>();
|
||||
@@ -18,6 +19,18 @@ const editable = computed(() => spaces.canEdit(props.spaceId));
|
||||
const active = computed(() => spaces.active.page === props.node.id);
|
||||
const zone = ref<DropZone | null>(null);
|
||||
|
||||
// The page's icon: an emoji, or the page glyph. Editors click it to pick another.
|
||||
const iconButton = ref<HTMLElement | null>(null);
|
||||
const picking = ref(false);
|
||||
async function setIcon(icon: string) {
|
||||
picking.value = false;
|
||||
try {
|
||||
await spaces.setIcon(props.spaceId, props.node.id, icon);
|
||||
} catch (e) {
|
||||
emit("error", e);
|
||||
}
|
||||
}
|
||||
|
||||
function onDragStart(e: DragEvent) {
|
||||
spaces.dragging = { spaceId: props.spaceId, id: props.node.id };
|
||||
e.dataTransfer?.setData("text/plain", props.node.id);
|
||||
@@ -102,14 +115,35 @@ const dropClass = computed(() => {
|
||||
@dragleave="zone = null"
|
||||
@drop.prevent="onDrop"
|
||||
>
|
||||
<template #icon>
|
||||
<button
|
||||
v-if="editable"
|
||||
ref="iconButton"
|
||||
type="button"
|
||||
class="grid size-5 shrink-0 cursor-pointer place-items-center rounded-xs hover:bg-line"
|
||||
:class="{ 'bg-line': picking }"
|
||||
:aria-label="$t('emoji.changeIcon')"
|
||||
:title="$t('emoji.changeIcon')"
|
||||
aria-haspopup="dialog"
|
||||
:aria-expanded="picking"
|
||||
data-testid="page-icon"
|
||||
@click.stop="picking = !picking"
|
||||
>
|
||||
<span v-if="node.icon" class="text-ui-md leading-none">{{ node.icon }}</span>
|
||||
<DwIcon v-else name="page" :size="16" />
|
||||
</button>
|
||||
<span v-else-if="node.icon" class="grid size-5 shrink-0 place-items-center text-ui-md leading-none">{{
|
||||
node.icon
|
||||
}}</span>
|
||||
<DwIcon v-else name="page" :size="16" />
|
||||
</template>
|
||||
<RouterLink
|
||||
:to="{ name: 'page', params: { id: node.id } }"
|
||||
class="block truncate rounded-xs"
|
||||
:class="active ? 'text-accent' : 'text-inherit'"
|
||||
:aria-current="active ? 'page' : undefined"
|
||||
>
|
||||
<span v-if="node.icon" class="mr-1">{{ node.icon }}</span
|
||||
>{{ node.title || $t("home.untitled") }}
|
||||
{{ node.title || $t("home.untitled") }}
|
||||
<DwIcon
|
||||
v-if="node.restricted"
|
||||
name="lock"
|
||||
@@ -139,6 +173,14 @@ const dropClass = computed(() => {
|
||||
/>
|
||||
</template>
|
||||
</DwTreeItem>
|
||||
<EmojiPicker
|
||||
v-if="picking && iconButton"
|
||||
:anchor="iconButton"
|
||||
:current="node.icon"
|
||||
@pick="setIcon"
|
||||
@remove="setIcon('')"
|
||||
@close="picking = false"
|
||||
/>
|
||||
<ul v-if="open && kids.length" role="group" class="mt-px flex flex-col gap-px">
|
||||
<PageTreeNode
|
||||
v-for="k in kids"
|
||||
|
||||
Reference in new issue
Block a user