mirror of
https://codeberg.org/Sevichecc/Seigwai.git
synced 2025-04-30 07:49:30 +08:00
Compare commits
4 commits
83df80eefc
...
d53c39aa9b
Author | SHA1 | Date | |
---|---|---|---|
d53c39aa9b | |||
2c7df8a212 | |||
edb4ec8212 | |||
4fe1c16dc4 |
7 changed files with 561 additions and 423 deletions
24
README.md
24
README.md
|
@ -1,18 +1,18 @@
|
|||
# Vue 3 + TypeScript + Vite
|
||||
# Introduction
|
||||
|
||||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
A Pleroma/Mastodon client, focus on editing experience (WIP 🏗️), developed by [@seviche@kongwoo.icu](https://kongwoo.icu/seviche)
|
||||
|
||||
## Recommended IDE Setup
|
||||
## Features
|
||||
|
||||
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
||||
- Markdown
|
||||
- drop and drag block
|
||||
|
||||
## Type Support For `.vue` Imports in TS
|
||||
## Development
|
||||
|
||||
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
|
||||
|
||||
1. Disable the built-in TypeScript Extension
|
||||
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
|
||||
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
|
||||
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + Vue + TS</title>
|
||||
<title>Seigwai</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
|
19
package.json
19
package.json
|
@ -27,18 +27,21 @@
|
|||
"@milkdown/transformer": "^7.1.0",
|
||||
"@milkdown/utils": "^7.1.0",
|
||||
"@milkdown/vue": "^7.1.0",
|
||||
"@prosemirror-adapter/vue": "^0.2.2",
|
||||
"@prosemirror-adapter/vue": "^0.2.3",
|
||||
"masto": "^5.10.0",
|
||||
"vue": "^3.2.45"
|
||||
"vue": "^3.2.47"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^0.35.2",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"daisyui": "^2.51.5",
|
||||
"postcss": "^8.4.21",
|
||||
"@antfu/eslint-config": "^0.37.0",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"@vitejs/plugin-vue": "^4.0.0",
|
||||
"eslint": "^8.34.0",
|
||||
"@vitejs/plugin-vue": "^4.1.0",
|
||||
"eslint": "^8.36.0",
|
||||
"tailwindcss": "^3.2.7",
|
||||
"typescript": "^4.9.5",
|
||||
"vite": "^4.1.0",
|
||||
"vue-tsc": "^1.0.24"
|
||||
"typescript": "^5.0.2",
|
||||
"vite": "^4.2.1",
|
||||
"vue-tsc": "^1.2.0"
|
||||
}
|
||||
}
|
758
pnpm-lock.yaml
758
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,35 @@
|
|||
<script setup lang="ts">
|
||||
import { SlashProvider } from '@milkdown/plugin-slash'
|
||||
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { useInstance } from '@milkdown/vue'
|
||||
import { usePluginViewContext } from '@prosemirror-adapter/vue'
|
||||
import type { VNodeRef } from 'vue'
|
||||
import { useCommands } from '../../composables/commands'
|
||||
import { editorViewCtx } from '@milkdown/core'
|
||||
import { SlashProvider } from '@milkdown/plugin-slash'
|
||||
import { callCommand } from '@milkdown/utils'
|
||||
|
||||
import type { VNodeRef } from 'vue'
|
||||
import type { CmdKey } from '@milkdown/core'
|
||||
import {
|
||||
createCodeBlockCommand,
|
||||
insertHrCommand,
|
||||
wrapInBlockquoteCommand,
|
||||
wrapInBulletListCommand,
|
||||
wrapInHeadingCommand,
|
||||
wrapInOrderedListCommand,
|
||||
} from '@milkdown/preset-commonmark'
|
||||
|
||||
const [loading, get] = useInstance()
|
||||
|
||||
const call = <T>(command: CmdKey<T>, payload?: T) => {
|
||||
return get()!.action((ctx) => {
|
||||
const view = ctx.get(editorViewCtx)
|
||||
const { dispatch, state } = view
|
||||
const { tr, selection } = state
|
||||
const { from } = selection
|
||||
dispatch(tr.deleteRange(from - 1, from))
|
||||
return callCommand(command, payload)(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
const { addCodeBlock, toggleBold } = useCommands()
|
||||
let tooltipProvider: SlashProvider
|
||||
|
||||
const { view, prevState } = usePluginViewContext()
|
||||
|
@ -29,18 +53,54 @@ onUnmounted(() => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="divRef">
|
||||
<div v-if="loading" ref="divRef">
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click="addCodeBlock"
|
||||
@click.prevent="call(createCodeBlockCommand.key)"
|
||||
>
|
||||
Code Block
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click="toggleBold"
|
||||
@click.prevent="call(wrapInHeadingCommand.key, 1)"
|
||||
>
|
||||
Bold
|
||||
Heading1
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click.prevent="call(wrapInHeadingCommand.key, 2)"
|
||||
>
|
||||
Heading2
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click.prevent="call(wrapInHeadingCommand.key, 3)"
|
||||
>
|
||||
Heading3
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click.prevent="call(wrapInBulletListCommand.key)"
|
||||
>
|
||||
BulletList
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click.prevent="call(wrapInOrderedListCommand.key)"
|
||||
>
|
||||
OrderList
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click.prevent="call(wrapInBlockquoteCommand.key)"
|
||||
>
|
||||
Quote
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click.prevent="call(insertHrCommand.key)"
|
||||
>
|
||||
Hr
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
<script setup lang="ts">
|
||||
import { useInstance } from '@milkdown/vue'
|
||||
import { TooltipProvider } from '@milkdown/plugin-tooltip'
|
||||
|
||||
import { usePluginViewContext } from '@prosemirror-adapter/vue'
|
||||
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
|
||||
import type { CmdKey } from '@milkdown/core'
|
||||
import type { VNodeRef } from 'vue'
|
||||
import { useCommands } from '../../composables/commands'
|
||||
import { callCommand } from '@milkdown/utils'
|
||||
|
||||
import {
|
||||
toggleEmphasisCommand,
|
||||
toggleInlineCodeCommand,
|
||||
toggleStrongCommand,
|
||||
wrapInBlockquoteCommand,
|
||||
} from '@milkdown/preset-commonmark'
|
||||
import { toggleStrikethroughCommand } from '@milkdown/preset-gfm'
|
||||
|
||||
const [loading, get] = useInstance()
|
||||
|
||||
const call = <T>(command: CmdKey<T>, payload?: T) => {
|
||||
return get()?.action(callCommand(command, payload))
|
||||
}
|
||||
|
||||
const {
|
||||
toggleBold,
|
||||
toggleInlineCode,
|
||||
toggleItalic,
|
||||
wrapInBlockQuote,
|
||||
toggleStrikeThrough,
|
||||
} = useCommands()
|
||||
const { view, prevState } = usePluginViewContext()
|
||||
|
||||
const divRef = ref<VNodeRef>()
|
||||
|
@ -38,34 +45,34 @@ onUnmounted(() => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="divRef">
|
||||
<div v-if="loading" ref="divRef">
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click="toggleBold"
|
||||
@click.prevent="call(toggleStrongCommand.key)"
|
||||
>
|
||||
Bold
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click="toggleInlineCode"
|
||||
@click.prevent="call(toggleInlineCodeCommand.key)"
|
||||
>
|
||||
Code
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click="toggleItalic"
|
||||
@click.prevent="call(toggleEmphasisCommand.key)"
|
||||
>
|
||||
Italic
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click="wrapInBlockQuote"
|
||||
@click.prevent="call(wrapInBlockquoteCommand.key)"
|
||||
>
|
||||
Quote
|
||||
</button>
|
||||
<button
|
||||
class="text-gray-600 bg-slate-200 px-2 py-1 rounded-lg hover:bg-slate-300 border hover:text-gray-900"
|
||||
@click="toggleStrikeThrough"
|
||||
@click.prevent="call(toggleStrikethroughCommand.key)"
|
||||
>
|
||||
StrikeThrough
|
||||
</button>
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/* eslint-disable antfu/if-newline */
|
||||
import { useInstance } from '@milkdown/vue'
|
||||
import {
|
||||
createCodeBlockCommand,
|
||||
toggleEmphasisCommand,
|
||||
toggleInlineCodeCommand,
|
||||
toggleStrongCommand,
|
||||
wrapInBlockquoteCommand,
|
||||
} from '@milkdown/preset-commonmark'
|
||||
import { toggleStrikethroughCommand } from '@milkdown/preset-gfm'
|
||||
import { callCommand } from '@milkdown/utils'
|
||||
import { editorViewCtx } from '@milkdown/core'
|
||||
|
||||
export const useCommands = () => {
|
||||
const [loading, get] = useInstance()
|
||||
|
||||
const toggleBold = (e: Event) => {
|
||||
if (loading.value) return
|
||||
e.preventDefault()
|
||||
get()!.action(callCommand(toggleStrongCommand.key))
|
||||
}
|
||||
|
||||
const toggleInlineCode = (e: Event) => {
|
||||
if (loading.value) return
|
||||
e.preventDefault()
|
||||
get()!.action(callCommand(toggleInlineCodeCommand.key))
|
||||
}
|
||||
|
||||
const toggleItalic = (e: Event) => {
|
||||
if (loading.value) return
|
||||
e.preventDefault()
|
||||
get()!.action(callCommand(toggleEmphasisCommand.key))
|
||||
}
|
||||
const toggleStrikeThrough = (e: Event) => {
|
||||
if (loading.value) return
|
||||
e.preventDefault()
|
||||
get()!.action(callCommand(toggleStrikethroughCommand.key))
|
||||
}
|
||||
|
||||
const wrapInBlockQuote = (e: Event) => {
|
||||
if (loading.value) return
|
||||
e.preventDefault()
|
||||
get()!.action(callCommand(wrapInBlockquoteCommand.key))
|
||||
}
|
||||
const addCodeBlock = (e: Event) => {
|
||||
if (loading.value) return
|
||||
e.preventDefault()
|
||||
get()!.action((ctx) => {
|
||||
const view = ctx.get(editorViewCtx)
|
||||
const { dispatch, state } = view
|
||||
const { tr, selection } = state
|
||||
const { from } = selection
|
||||
dispatch(tr.deleteRange(from - 1, from))
|
||||
return callCommand(createCodeBlockCommand.key)(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
toggleBold,
|
||||
toggleInlineCode,
|
||||
toggleItalic,
|
||||
toggleStrikeThrough,
|
||||
wrapInBlockQuote,
|
||||
addCodeBlock,
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue