mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	MkCodeにコピーボタンを追加 (#12999)
* Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update MkCode.vue * Update CHANGELOG.md --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
		
							parent
							
								
									945d6a2b09
								
							
						
					
					
						commit
						9a40b366a3
					
				
					 2 changed files with 43 additions and 14 deletions
				
			
		| 
						 | 
					@ -24,6 +24,7 @@
 | 
				
			||||||
- Feat: 絵文字の詳細ダイアログを追加
 | 
					- Feat: 絵文字の詳細ダイアログを追加
 | 
				
			||||||
- Feat: 枠線をつけるMFM`$[border.width=1,style=solid,color=fff,radius=0 ...]`を追加
 | 
					- Feat: 枠線をつけるMFM`$[border.width=1,style=solid,color=fff,radius=0 ...]`を追加
 | 
				
			||||||
  - デフォルトで枠線からはみ出る部分が隠されるようにしました。初期と同じ挙動にするには`$[border.noclip`が必要です
 | 
					  - デフォルトで枠線からはみ出る部分が隠されるようにしました。初期と同じ挙動にするには`$[border.noclip`が必要です
 | 
				
			||||||
 | 
					- Enhance: MFM等のコードブロックに全文コピー用のボタンを追加
 | 
				
			||||||
- Enhance: ハッシュタグ入力時に、本文の末尾の行に何も書かれていない場合は新たにスペースを追加しないように
 | 
					- Enhance: ハッシュタグ入力時に、本文の末尾の行に何も書かれていない場合は新たにスペースを追加しないように
 | 
				
			||||||
- Enhance: チャンネルノートのピン留めをノートのメニューからできるように
 | 
					- Enhance: チャンネルノートのピン留めをノートのメニューからできるように
 | 
				
			||||||
- Enhance: 管理者の場合はAPI tokenの発行画面で管理機能に関する権限を付与できるように
 | 
					- Enhance: 管理者の場合はAPI tokenの発行画面で管理機能に関する権限を付与できるように
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,12 +4,16 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
				
			||||||
-->
 | 
					-->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
<Suspense>
 | 
					<code v-if="inline" :class="$style.codeInlineRoot">{{ code }}</code>
 | 
				
			||||||
 | 
					<div v-else :class="$style.codeBlockRoot">
 | 
				
			||||||
 | 
						<button :class="$style.codeBlockCopyButton" class="_button" @click="copy">
 | 
				
			||||||
 | 
							<i class="ti ti-copy"></i>
 | 
				
			||||||
 | 
						</button>
 | 
				
			||||||
 | 
						<Suspense>
 | 
				
			||||||
		<template #fallback>
 | 
							<template #fallback>
 | 
				
			||||||
		<MkLoading v-if="!inline ?? true"/>
 | 
								<MkLoading />
 | 
				
			||||||
		</template>
 | 
							</template>
 | 
				
			||||||
	<code v-if="inline" :class="$style.codeInlineRoot">{{ code }}</code>
 | 
							<XCode v-if="show && lang" :code="code" :lang="lang"/>
 | 
				
			||||||
	<XCode v-else-if="show && lang" :code="code" :lang="lang"/>
 | 
					 | 
				
			||||||
		<pre v-else-if="show" :class="$style.codeBlockFallbackRoot"><code :class="$style.codeBlockFallbackCode">{{ code }}</code></pre>
 | 
							<pre v-else-if="show" :class="$style.codeBlockFallbackRoot"><code :class="$style.codeBlockFallbackCode">{{ code }}</code></pre>
 | 
				
			||||||
		<button v-else :class="$style.codePlaceholderRoot" @click="show = true">
 | 
							<button v-else :class="$style.codePlaceholderRoot" @click="show = true">
 | 
				
			||||||
			<div :class="$style.codePlaceholderContainer">
 | 
								<div :class="$style.codePlaceholderContainer">
 | 
				
			||||||
| 
						 | 
					@ -17,16 +21,19 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
				
			||||||
				<div>{{ i18n.ts.clickToShow }}</div>
 | 
									<div>{{ i18n.ts.clickToShow }}</div>
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
		</button>
 | 
							</button>
 | 
				
			||||||
</Suspense>
 | 
						</Suspense>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script lang="ts" setup>
 | 
					<script lang="ts" setup>
 | 
				
			||||||
import { defineAsyncComponent, ref } from 'vue';
 | 
					import { defineAsyncComponent, ref } from 'vue';
 | 
				
			||||||
 | 
					import * as os from '@/os.js';
 | 
				
			||||||
import MkLoading from '@/components/global/MkLoading.vue';
 | 
					import MkLoading from '@/components/global/MkLoading.vue';
 | 
				
			||||||
import { defaultStore } from '@/store.js';
 | 
					import { defaultStore } from '@/store.js';
 | 
				
			||||||
import { i18n } from '@/i18n.js';
 | 
					import { i18n } from '@/i18n.js';
 | 
				
			||||||
 | 
					import copyToClipboard from '@/scripts/copy-to-clipboard.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
defineProps<{
 | 
					const props = defineProps<{
 | 
				
			||||||
	code: string;
 | 
						code: string;
 | 
				
			||||||
	lang?: string;
 | 
						lang?: string;
 | 
				
			||||||
	inline?: boolean;
 | 
						inline?: boolean;
 | 
				
			||||||
| 
						 | 
					@ -35,9 +42,30 @@ defineProps<{
 | 
				
			||||||
const show = ref(!defaultStore.state.dataSaver.code);
 | 
					const show = ref(!defaultStore.state.dataSaver.code);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const XCode = defineAsyncComponent(() => import('@/components/MkCode.core.vue'));
 | 
					const XCode = defineAsyncComponent(() => import('@/components/MkCode.core.vue'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function copy() {
 | 
				
			||||||
 | 
						copyToClipboard(props.code);
 | 
				
			||||||
 | 
						os.success();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<style module lang="scss">
 | 
					<style module lang="scss">
 | 
				
			||||||
 | 
					.codeBlockRoot {
 | 
				
			||||||
 | 
						position: relative;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.codeBlockCopyButton {
 | 
				
			||||||
 | 
						color: #D4D4D4;
 | 
				
			||||||
 | 
						position: absolute;
 | 
				
			||||||
 | 
						top: 8px;
 | 
				
			||||||
 | 
						right: 8px;
 | 
				
			||||||
 | 
						opacity: 0.5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						&:hover {
 | 
				
			||||||
 | 
							opacity: 0.8;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.codeInlineRoot {
 | 
					.codeInlineRoot {
 | 
				
			||||||
	display: inline-block;
 | 
						display: inline-block;
 | 
				
			||||||
	font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;
 | 
						font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue