mirror of
https://codeberg.org/Sevichecc/Seigwai.git
synced 2025-04-30 07:49:30 +08:00
feat: button status change with action
This commit is contained in:
parent
8adf00715b
commit
98837926fe
5 changed files with 57 additions and 712 deletions
|
@ -27,8 +27,6 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@antfu/eslint-config": "^0.37.0",
|
"@antfu/eslint-config": "^0.37.0",
|
||||||
"@commitlint/cli": "^17.5.1",
|
|
||||||
"@commitlint/config-conventional": "^17.4.4",
|
|
||||||
"@iconify-json/tabler": "^1.1.68",
|
"@iconify-json/tabler": "^1.1.68",
|
||||||
"@tailwindcss/typography": "^0.5.9",
|
"@tailwindcss/typography": "^0.5.9",
|
||||||
"@vitejs/plugin-vue": "^4.1.0",
|
"@vitejs/plugin-vue": "^4.1.0",
|
||||||
|
|
720
pnpm-lock.yaml
720
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -12,14 +12,16 @@ const inputUrl = ref<HTMLInputElement | null>(null)
|
||||||
|
|
||||||
const openLinkInput = () => {
|
const openLinkInput = () => {
|
||||||
showUrlInput.value = true
|
showUrlInput.value = true
|
||||||
nextTick(() => inputUrl.value?.focus())
|
nextTick(() =>
|
||||||
|
inputUrl.value?.focus(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const setLink = () => {
|
const setLink = () => {
|
||||||
const previousUrl = editor.getAttributes('link').href
|
const previousUrl = editor.getAttributes('link').href
|
||||||
|
|
||||||
if (previousUrl)
|
if (previousUrl)
|
||||||
placeholder.value = previousUrl
|
inputUrl.value = previousUrl
|
||||||
|
|
||||||
// cancelled
|
// cancelled
|
||||||
if (url.value === null)
|
if (url.value === null)
|
||||||
|
@ -36,8 +38,6 @@ const setLink = () => {
|
||||||
.extendMarkRange('link')
|
.extendMarkRange('link')
|
||||||
.setLink({ href: url.value })
|
.setLink({ href: url.value })
|
||||||
.run()
|
.run()
|
||||||
|
|
||||||
return (showUrlInput.value = false)
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -53,7 +53,11 @@ const setLink = () => {
|
||||||
:class="{ 'btn-active': editor.isActive('bold') }"
|
:class="{ 'btn-active': editor.isActive('bold') }"
|
||||||
@click="editor.chain().focus().toggleBold().run()"
|
@click="editor.chain().focus().toggleBold().run()"
|
||||||
>
|
>
|
||||||
<span class="i-tabler-bold" />
|
<span
|
||||||
|
:class="[
|
||||||
|
editor.isActive('bold') ? 'i-tabler-bold-off' : 'i-tabler-bold',
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="menu-btn"
|
class="menu-btn"
|
||||||
|
@ -74,21 +78,33 @@ const setLink = () => {
|
||||||
:class="{ 'btn-active': editor.isActive('code') }"
|
:class="{ 'btn-active': editor.isActive('code') }"
|
||||||
@click="editor.chain().focus().toggleCode().run()"
|
@click="editor.chain().focus().toggleCode().run()"
|
||||||
>
|
>
|
||||||
<span class="i-tabler-code" />
|
<span
|
||||||
|
:class="[
|
||||||
|
editor.isActive('code') ? 'i-tabler-code-off' : 'i-tabler-code',
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="menu-btn"
|
class="menu-btn"
|
||||||
:class="{ 'btn-active': editor.isActive('quote') }"
|
:class="{ 'btn-active': editor.isActive('blockquote') }"
|
||||||
@click="editor.chain().focus().toggleBlockquote().run()"
|
@click="editor.chain().focus().toggleBlockquote().run()"
|
||||||
>
|
>
|
||||||
<span class="i-tabler-quote" />
|
<span
|
||||||
|
:class="[
|
||||||
|
editor.isActive('blockquote') ? 'i-tabler-quote-off' : 'i-tabler-quote',
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
:class="{ 'btn-active': editor.isActive('link') }"
|
:class="{ 'btn-active': editor.isActive('link') }"
|
||||||
class="menu-btn"
|
class="menu-btn"
|
||||||
@click="openLinkInput"
|
@click="openLinkInput"
|
||||||
>
|
>
|
||||||
<span class="i-tabler-link" />
|
<span
|
||||||
|
:class="[
|
||||||
|
editor.isActive('link') ? 'i-tabler-unlink' : 'i-tabler-link',
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -6,7 +6,12 @@ import Link from '@tiptap/extension-link'
|
||||||
import BubbleMenu from './BubbleMenu.vue'
|
import BubbleMenu from './BubbleMenu.vue'
|
||||||
|
|
||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
content: '<p>I’m running Tiptap with Vue.js. 🎉</p>',
|
content: `<p>
|
||||||
|
Wow, this editor has support for links to the whole <a href="https://en.wikipedia.org/wiki/World_Wide_Web">world wide web</a>. We tested a lot of URLs and I think you can add *every URL* you want. Isn’t that cool? Let’s try <a href="https://statamic.com/">another one!</a> Yep, seems to work.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
By default every link will get a <code>rel="noopener noreferrer nofollow"</code> attribute. It’s configurable though.
|
||||||
|
</p>`,
|
||||||
extensions: [
|
extensions: [
|
||||||
StarterKit,
|
StarterKit,
|
||||||
Typography,
|
Typography,
|
||||||
|
|
|
@ -32,4 +32,8 @@
|
||||||
|
|
||||||
.input-group{
|
.input-group{
|
||||||
@apply h-4;
|
@apply h-4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #68CEF8;
|
||||||
|
}
|
Loading…
Reference in a new issue