Skip to content

Commit 98a62fa

Browse files
committed
feat: added initial toolbar keyboard navigation
1 parent 621840d commit 98a62fa

1 file changed

Lines changed: 10 additions & 35 deletions

File tree

packages/super-editor/src/components/toolbar/ToolbarButton.vue

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,11 @@ const caretIcon = computed(() => {
8282
</script>
8383
8484
<template>
85-
<div :class="['toolbar-item', attributes.className]" :style="getStyle">
86-
<div
87-
@click="handleClick"
88-
class="toolbar-button"
85+
<div :class="['toolbar-item', attributes.className]" :style="getStyle" @click="handleClick"
86+
@keydown.enter.stop="handleClick" tabindex="0" role="button">
87+
<div class="toolbar-button"
8988
:class="{ active, disabled, narrow: isNarrow, wide: isWide, 'has-inline-text-input': hasInlineTextInput }"
90-
:data-item="`btn-${name || ''}`"
91-
>
89+
:data-item="`btn-${name || ''}`">
9290
<ToolbarButtonIcon v-if="icon" :color="iconColor" class="toolbar-icon" :icon="icon" :name="name">
9391
</ToolbarButtonIcon>
9492
@@ -97,37 +95,14 @@ const caretIcon = computed(() => {
9795
</div>
9896
9997
<span v-if="inlineTextInputVisible">
100-
<input
101-
v-if="name === 'fontSize'"
102-
v-model="inlineTextInput"
103-
@input="onFontSizeInput"
104-
:placeholder="label"
105-
@keydown.enter.prevent="handleInputSubmit"
106-
type="text"
107-
class="button-text-input"
108-
:id="'inlineTextInput-' + name"
109-
autoccomplete="off"
110-
ref="inlineInput"
111-
/>
112-
<input
113-
v-else
114-
v-model="inlineTextInput"
115-
:placeholder="label"
116-
@keydown.enter.prevent="handleInputSubmit"
117-
type="text"
118-
class="button-text-input"
119-
:id="'inlineTextInput-' + name"
120-
autoccomplete="off"
121-
ref="inlineInput"
122-
/>
98+
<input v-if="name === 'fontSize'" v-model="inlineTextInput" @input="onFontSizeInput" :placeholder="label"
99+
@keydown.enter.prevent="handleInputSubmit" type="text" class="button-text-input"
100+
:id="'inlineTextInput-' + name" autoccomplete="off" ref="inlineInput" />
101+
<input v-else v-model="inlineTextInput" :placeholder="label" @keydown.enter.prevent="handleInputSubmit"
102+
type="text" class="button-text-input" :id="'inlineTextInput-' + name" autoccomplete="off" ref="inlineInput" />
123103
</span>
124104
125-
<div
126-
v-if="hasCaret"
127-
class="dropdown-caret"
128-
v-html="caretIcon"
129-
:style="{ opacity: disabled ? 0.6 : 1 }"
130-
>
105+
<div v-if="hasCaret" class="dropdown-caret" v-html="caretIcon" :style="{ opacity: disabled ? 0.6 : 1 }">
131106
</div>
132107
133108
</div>

0 commit comments

Comments
 (0)