Merge branch 'develop' into pr/9021

This commit is contained in:
syuilo 2022-07-19 23:53:08 +09:00
commit 2497499d63
43 changed files with 1245 additions and 941 deletions

View file

@ -9,6 +9,33 @@
You should also include the user name that made the change. You should also include the user name that made the change.
--> -->
## 12.x.x (unreleased)
### Improvements
### Bugfixes
- Client: 一度作ったwebhookの設定画面を開こうとするとページがフリーズする @syuilo
## 12.117.1 (2022/07/19)
### Improvements
- Client: UIのブラッシュアップ @syuilo
### Bugfixes
- Server: ファイルのアップロードに失敗することがある問題を修正 @acid-chicken
- Client: リアクションピッカーがアプリ内ウィンドウの後ろに表示されてしまう問題を修正 @syuilo
- Client: ユーザー情報の取得の再試行を修正 @xianonn
- Client: MFMチートシートの挙動を修正 @syuilo
- Client: 「インスタンスからのお知らせを受け取る」の設定を変更できない問題を修正 @syuilo
## 12.117.0 (2022/07/18)
### Improvements
- Client: ウィンドウを最大化できるように @syuilo
- Client: Shiftキーを押した状態でリンクをクリックするとアプリ内ウィンドウで開くように @syuilo
- Client: デッキを使用している際、Ctrlキーを押した状態でリンクをクリックするとページ遷移を強制できるように @syuilo
- Client: UIのブラッシュアップ @syuilo
## 12.116.1 (2022/07/17) ## 12.116.1 (2022/07/17)
### Bugfixes ### Bugfixes

View file

@ -1645,6 +1645,7 @@ _deck:
alwaysShowMainColumn: "সর্বদা মেইন কলাম দেখান" alwaysShowMainColumn: "সর্বদা মেইন কলাম দেখান"
columnAlign: "কলাম সাজান" columnAlign: "কলাম সাজান"
addColumn: "কলাম যুক্ত করুন" addColumn: "কলাম যুক্ত করুন"
configureColumn: "কলাম সেটিংস"
swapLeft: "বামে সরান" swapLeft: "বামে সরান"
swapRight: "ডানে সরান" swapRight: "ডানে সরান"
swapUp: "উপরে উঠান" swapUp: "উপরে উঠান"

View file

@ -890,6 +890,7 @@ activeEmailValidationDescription: "Aktivert strengere Überprüfung von E-Mail-A
navbar: "Navigationsleiste" navbar: "Navigationsleiste"
shuffle: "Mischen" shuffle: "Mischen"
account: "Benutzerkonto" account: "Benutzerkonto"
move: "Verschieben"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "Ermöglicht eine Erleichterung der Servermoderation durch die automatische Erkennungen von NSFW-Medien unter Verwendung von Machine Learning. Hierdurch wird die Serverlast etwas erhöht." description: "Ermöglicht eine Erleichterung der Servermoderation durch die automatische Erkennungen von NSFW-Medien unter Verwendung von Machine Learning. Hierdurch wird die Serverlast etwas erhöht."
sensitivity: "Erkennungssensitivität" sensitivity: "Erkennungssensitivität"
@ -1696,6 +1697,7 @@ _deck:
alwaysShowMainColumn: "Hauptspalte immer zeigen" alwaysShowMainColumn: "Hauptspalte immer zeigen"
columnAlign: "Spaltenausrichtung" columnAlign: "Spaltenausrichtung"
addColumn: "Spalte hinzufügen" addColumn: "Spalte hinzufügen"
configureColumn: "Spalteneinstellungen"
swapLeft: "Mit linker Spalte tauschen" swapLeft: "Mit linker Spalte tauschen"
swapRight: "Mit rechter Spalte tauschen" swapRight: "Mit rechter Spalte tauschen"
swapUp: "Mit oberer Spalte tauschen" swapUp: "Mit oberer Spalte tauschen"

View file

@ -890,6 +890,7 @@ activeEmailValidationDescription: "Enables stricter validation of email addresse
navbar: "Navigation bar" navbar: "Navigation bar"
shuffle: "Shuffle" shuffle: "Shuffle"
account: "Account" account: "Account"
move: "Move"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "Reduces the effort of server moderation through automatically recognizing NSFW media via Machine Learning. This will slightly increase the load on the server." description: "Reduces the effort of server moderation through automatically recognizing NSFW media via Machine Learning. This will slightly increase the load on the server."
sensitivity: "Detection sensitivity" sensitivity: "Detection sensitivity"
@ -1696,6 +1697,7 @@ _deck:
alwaysShowMainColumn: "Always show main column" alwaysShowMainColumn: "Always show main column"
columnAlign: "Align columns" columnAlign: "Align columns"
addColumn: "Add column" addColumn: "Add column"
configureColumn: "Column settings"
swapLeft: "Swap with the left column" swapLeft: "Swap with the left column"
swapRight: "Swap with the right column" swapRight: "Swap with the right column"
swapUp: "Swap with the above column" swapUp: "Swap with the above column"

View file

@ -890,6 +890,7 @@ activeEmailValidationDescription: "ユーザーのメールアドレスのバリ
navbar: "ナビゲーションバー" navbar: "ナビゲーションバー"
shuffle: "シャッフル" shuffle: "シャッフル"
account: "アカウント" account: "アカウント"
move: "移動"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。" description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。"
@ -1037,6 +1038,8 @@ _mfm:
sparkleDescription: "キラキラしたパーティクルのエフェクトを追加します。" sparkleDescription: "キラキラしたパーティクルのエフェクトを追加します。"
rotate: "回転" rotate: "回転"
rotateDescription: "指定した角度で回転させます。" rotateDescription: "指定した角度で回転させます。"
plain: "プレーン"
plainDescription: "内側の構文を全て無効にします。"
_instanceTicker: _instanceTicker:
none: "表示しない" none: "表示しない"

View file

@ -886,6 +886,8 @@ beta: "베타"
enableAutoSensitive: "자동 NSFW 탐지" enableAutoSensitive: "자동 NSFW 탐지"
enableAutoSensitiveDescription: "이용 가능할 경우 기계학습을 통해 자동으로 미디어 NSFW를 설정합니다. 이 기능을 해제하더라도, 인스턴스 정책에 따라 자동으로 설정될 수 있습니다." enableAutoSensitiveDescription: "이용 가능할 경우 기계학습을 통해 자동으로 미디어 NSFW를 설정합니다. 이 기능을 해제하더라도, 인스턴스 정책에 따라 자동으로 설정될 수 있습니다."
activeEmailValidationDescription: "유저가 입력한 메일 주소가 일회용 메일인지, 실제로 통신할 수 있는 지 엄격하게 검사합니다. 해제할 경우 이메일 형식에 대해서만 검사합니다." activeEmailValidationDescription: "유저가 입력한 메일 주소가 일회용 메일인지, 실제로 통신할 수 있는 지 엄격하게 검사합니다. 해제할 경우 이메일 형식에 대해서만 검사합니다."
navbar: "네비게이션 바"
shuffle: "셔플"
account: "계정" account: "계정"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "기계학습을 통해 자동으로 민감한 미디어를 탐지하여, 모더레이션에 참고할 수 있도록 합니다. 서버의 부하를 약간 증가시킵니다." description: "기계학습을 통해 자동으로 민감한 미디어를 탐지하여, 모더레이션에 참고할 수 있도록 합니다. 서버의 부하를 약간 증가시킵니다."
@ -1692,6 +1694,7 @@ _deck:
alwaysShowMainColumn: "메인 칼럼 항상 표시" alwaysShowMainColumn: "메인 칼럼 항상 표시"
columnAlign: "칼럼 정렬" columnAlign: "칼럼 정렬"
addColumn: "칼럼 추가" addColumn: "칼럼 추가"
configureColumn: "칼럼 설정"
swapLeft: "왼쪽으로 이동" swapLeft: "왼쪽으로 이동"
swapRight: "오른쪽으로 이동" swapRight: "오른쪽으로 이동"
swapUp: "위로 이동" swapUp: "위로 이동"
@ -1699,6 +1702,8 @@ _deck:
stackLeft: "왼쪽에 쌓기" stackLeft: "왼쪽에 쌓기"
popRight: "오른쪽으로 빼기" popRight: "오른쪽으로 빼기"
profile: "프로파일" profile: "프로파일"
newProfile: "새 프로파일"
deleteProfile: "프로파일 삭제"
introduction: "칼럼을 조합해서 나만의 인터페이스를 구성해 보아요!" introduction: "칼럼을 조합해서 나만의 인터페이스를 구성해 보아요!"
introduction2: "나중에라도 화면 우측의 + 버튼을 눌러 새 칼럼을 추가할 수 있습니다." introduction2: "나중에라도 화면 우측의 + 버튼을 눌러 새 칼럼을 추가할 수 있습니다."
widgetsIntroduction: "칼럼 메뉴의 \"위젯 편집\"에서 위젯을 추가해 주세요" widgetsIntroduction: "칼럼 메뉴의 \"위젯 편집\"에서 위젯을 추가해 주세요"

View file

@ -1637,6 +1637,7 @@ _deck:
alwaysShowMainColumn: "Всегда показывать главную колонку" alwaysShowMainColumn: "Всегда показывать главную колонку"
columnAlign: "Выравнивание колонок" columnAlign: "Выравнивание колонок"
addColumn: "Добавить колонку" addColumn: "Добавить колонку"
configureColumn: "Настройки колонок"
swapLeft: "Переставить левее" swapLeft: "Переставить левее"
swapRight: "Переставить правее" swapRight: "Переставить правее"
swapUp: "Переставить выше" swapUp: "Переставить выше"

View file

@ -885,6 +885,7 @@ enableAutoSensitiveDescription: "Ak je zapnuté, príznak NSFW sa na médiách a
activeEmailValidationDescription: "Dôkladnejšie overí e-mailovú adresu používateľa tým, že zistí, či ide o vyradenú e-mailovú adresu a či sa s ňou dá skutočne komunikovať. Ak nie je začiarknuté, e-mailová adresa sa kontroluje len ako text." activeEmailValidationDescription: "Dôkladnejšie overí e-mailovú adresu používateľa tým, že zistí, či ide o vyradenú e-mailovú adresu a či sa s ňou dá skutočne komunikovať. Ak nie je začiarknuté, e-mailová adresa sa kontroluje len ako text."
navbar: "Navigačný panel" navbar: "Navigačný panel"
account: "Účty" account: "Účty"
move: "Pohyb"
_sensitiveMediaDetection: _sensitiveMediaDetection:
description: "Strojové učenie sa použije na automatickú detekciu citlivých médií na účely ich moderovania. Mierne sa zvýši zaťaženie servera." description: "Strojové učenie sa použije na automatickú detekciu citlivých médií na účely ich moderovania. Mierne sa zvýši zaťaženie servera."
sensitivity: "Citlivosť detekcie" sensitivity: "Citlivosť detekcie"
@ -1691,6 +1692,7 @@ _deck:
alwaysShowMainColumn: "Vždy zobraziť v hlavnom stĺpci" alwaysShowMainColumn: "Vždy zobraziť v hlavnom stĺpci"
columnAlign: "Zarovnať stĺpce" columnAlign: "Zarovnať stĺpce"
addColumn: "Pridať stĺpec" addColumn: "Pridať stĺpec"
configureColumn: "Nastavenie stĺpcov"
swapLeft: "Vymeniť vľavo" swapLeft: "Vymeniť vľavo"
swapRight: "Vymeniť vpravo" swapRight: "Vymeniť vpravo"
swapUp: "Vymeniť hore" swapUp: "Vymeniť hore"

View file

@ -1696,6 +1696,7 @@ _deck:
alwaysShowMainColumn: "Luôn hiện cột chính" alwaysShowMainColumn: "Luôn hiện cột chính"
columnAlign: "Căn cột" columnAlign: "Căn cột"
addColumn: "Thêm cột" addColumn: "Thêm cột"
configureColumn: "Cài đặt cột"
swapLeft: "Hoán đổi với cột bên trái" swapLeft: "Hoán đổi với cột bên trái"
swapRight: "Hoán đổi với cột bên phải" swapRight: "Hoán đổi với cột bên phải"
swapUp: "Hoán đổi với cột trên" swapUp: "Hoán đổi với cột trên"

View file

@ -862,7 +862,7 @@ typeToConfirm: "输入 {x} 以确认操作。"
deleteAccount: "删除账户" deleteAccount: "删除账户"
document: "文档" document: "文档"
numberOfPageCache: "缓存页数" numberOfPageCache: "缓存页数"
numberOfPageCacheDescription: "设置较高的值会更方便用户,但服务器负载和内存使用量会增加。" numberOfPageCacheDescription: "设置较高的值会更方便用户,但设备的负载和内存使用量会增加。"
logoutConfirm: "是否确认登出?" logoutConfirm: "是否确认登出?"
lastActiveDate: "最后活跃时间" lastActiveDate: "最后活跃时间"
statusbar: "状态栏" statusbar: "状态栏"
@ -1691,13 +1691,16 @@ _deck:
alwaysShowMainColumn: "总是显示主列" alwaysShowMainColumn: "总是显示主列"
columnAlign: "列对齐" columnAlign: "列对齐"
addColumn: "添加列" addColumn: "添加列"
configureColumn: "列设置"
swapLeft: "向左移动" swapLeft: "向左移动"
swapRight: "向右移动" swapRight: "向右移动"
swapUp: "向上移动" swapUp: "向上移动"
swapDown: "向下移动" swapDown: "向下移动"
stackLeft: "向左折叠" stackLeft: "向左折叠"
popRight: "向右弹出" popRight: "向右弹出"
profile: "个人资料" profile: "配置文件"
newProfile: "新建配置文件"
deleteProfile: "删除配置文件"
_columns: _columns:
main: "主列" main: "主列"
widgets: "小工具" widgets: "小工具"

View file

@ -155,7 +155,7 @@ searchWith: "搜尋: {q}"
youHaveNoLists: "你沒有任何清單" youHaveNoLists: "你沒有任何清單"
followConfirm: "你真的要追隨{name}嗎?" followConfirm: "你真的要追隨{name}嗎?"
proxyAccount: "代理帳戶" proxyAccount: "代理帳戶"
proxyAccountDescription: "代理帳戶是在某些情況下充當其他伺服器用戶的帳戶。例如,當使用者將一個來自其他伺服器的帳戶放在列表中時,由於沒有其他使用者關注該帳戶,該指令不會傳送到該伺服器上,因此會由代理帳戶關注。" proxyAccountDescription: "代理帳戶是在某些情況下充當其他伺服器用戶的帳戶。例如,當使用者將一個來自其他伺服器的帳戶放在列表中時,由於沒有其他使用者追蹤該帳戶,該指令不會傳送到該伺服器上,因此會由代理帳戶追蹤。"
host: "主機" host: "主機"
selectUser: "選取使用者" selectUser: "選取使用者"
recipient: "收件人" recipient: "收件人"
@ -1695,6 +1695,7 @@ _deck:
alwaysShowMainColumn: "總是顯示主欄" alwaysShowMainColumn: "總是顯示主欄"
columnAlign: "對齊欄位" columnAlign: "對齊欄位"
addColumn: "新增欄位" addColumn: "新增欄位"
configureColumn: "欄位的設定"
swapLeft: "向左移動" swapLeft: "向左移動"
swapRight: "向右移動" swapRight: "向右移動"
swapUp: "往上移動" swapUp: "往上移動"

View file

@ -1,6 +1,6 @@
{ {
"name": "misskey", "name": "misskey",
"version": "12.116.1", "version": "12.117.1",
"codename": "indigo", "codename": "indigo",
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -101,13 +101,17 @@ export async function getFileInfo(path: string, opts: {
let porn = false; let porn = false;
if (!opts.skipSensitiveDetection) { if (!opts.skipSensitiveDetection) {
[sensitive, porn] = await detectSensitivity( await detectSensitivity(
path, path,
type.mime, type.mime,
opts.sensitiveThreshold ?? 0.5, opts.sensitiveThreshold ?? 0.5,
opts.sensitiveThresholdForPorn ?? 0.75, opts.sensitiveThresholdForPorn ?? 0.75,
opts.enableSensitiveMediaDetectionForVideos ?? false, opts.enableSensitiveMediaDetectionForVideos ?? false,
); ).then(value => {
[sensitive, porn] = value;
}, error => {
warnings.push(`detectSensitivity failed: ${error}`);
});
} }
return { return {

View file

@ -15,7 +15,7 @@
"@rollup/plugin-alias": "3.1.9", "@rollup/plugin-alias": "3.1.9",
"@rollup/plugin-json": "4.1.0", "@rollup/plugin-json": "4.1.0",
"@syuilo/aiscript": "0.11.1", "@syuilo/aiscript": "0.11.1",
"@vitejs/plugin-vue": "3.0.0", "@vitejs/plugin-vue": "3.0.1",
"@vue/compiler-sfc": "3.2.37", "@vue/compiler-sfc": "3.2.37",
"abort-controller": "3.0.0", "abort-controller": "3.0.0",
"autobind-decorator": "2.4.0", "autobind-decorator": "2.4.0",
@ -73,7 +73,7 @@
"uuid": "8.3.2", "uuid": "8.3.2",
"v-debounce": "0.1.2", "v-debounce": "0.1.2",
"vanilla-tilt": "1.7.2", "vanilla-tilt": "1.7.2",
"vite": "3.0.0", "vite": "3.0.2",
"vue": "3.2.37", "vue": "3.2.37",
"vue-prism-editor": "2.0.0-alpha.2", "vue-prism-editor": "2.0.0-alpha.2",
"vuedraggable": "4.0.1", "vuedraggable": "4.0.1",

View file

@ -206,17 +206,16 @@ export async function openAccountMenu(opts: {
to: `/@${ $i.username }`, to: `/@${ $i.username }`,
avatar: $i, avatar: $i,
}, null, ...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises, { }, null, ...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises, {
type: 'parent',
icon: 'fas fa-plus', icon: 'fas fa-plus',
text: i18n.ts.addAccount, text: i18n.ts.addAccount,
action: () => { children: [{
popupMenu([{ text: i18n.ts.existingAccount,
text: i18n.ts.existingAccount, action: () => { showSigninDialog(); },
action: () => { showSigninDialog(); }, }, {
}, { text: i18n.ts.createAccount,
text: i18n.ts.createAccount, action: () => { createAccount(); },
action: () => { createAccount(); }, }],
}], ev.currentTarget ?? ev.target);
},
}, { }, {
type: 'link', type: 'link',
icon: 'fas fa-users', icon: 'fas fa-users',

View file

@ -50,7 +50,7 @@ function onContextmenu(ev) {
icon: 'fas fa-expand-alt', icon: 'fas fa-expand-alt',
text: i18n.ts.showInPage, text: i18n.ts.showInPage,
action: () => { action: () => {
router.push(props.to); router.push(props.to, 'forcePage');
}, },
}, null, { }, null, {
icon: 'fas fa-external-link-alt', icon: 'fas fa-external-link-alt',
@ -79,7 +79,7 @@ function popout() {
popout_(props.to); popout_(props.to);
} }
function nav() { function nav(ev: MouseEvent) {
if (props.behavior === 'browser') { if (props.behavior === 'browser') {
location.href = props.to; location.href = props.to;
return; return;
@ -93,6 +93,10 @@ function nav() {
} }
} }
router.push(props.to); if (ev.shiftKey) {
return openWindow();
}
router.push(props.to, ev.ctrlKey ? 'forcePage' : null);
} }
</script> </script>

View file

@ -1,6 +1,12 @@
<template> <template>
<KeepAlive :max="defaultStore.state.numberOfPageCache"> <KeepAlive :max="defaultStore.state.numberOfPageCache">
<component :is="currentPageComponent" :key="key" v-bind="Object.fromEntries(currentPageProps)"/> <Suspense>
<component :is="currentPageComponent" :key="key" v-bind="Object.fromEntries(currentPageProps)"/>
<template #fallback>
Loading...
</template>
</Suspense>
</KeepAlive> </KeepAlive>
</template> </template>

View file

@ -8,6 +8,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { } from 'vue'; import { } from 'vue';
import { instanceName } from '@/config'; import { instanceName } from '@/config';
import { instance as Instance } from '@/instance';
const props = defineProps<{ const props = defineProps<{
instance?: { instance?: {
@ -19,7 +20,7 @@ const props = defineProps<{
// if no instance data is given, this is for the local instance // if no instance data is given, this is for the local instance
const instance = props.instance ?? { const instance = props.instance ?? {
faviconUrl: '/favicon.ico', faviconUrl: Instance.iconUrl || Instance.faviconUrl || '/favicon.ico',
name: instanceName, name: instanceName,
themeColor: (document.querySelector('meta[name="theme-color-orig"]') as HTMLMetaElement)?.content themeColor: (document.querySelector('meta[name="theme-color-orig"]') as HTMLMetaElement)?.content
}; };

View file

@ -15,20 +15,6 @@
</MkA> </MkA>
</template> </template>
</div> </div>
<div class="sub">
<button v-click-anime class="_button" @click="help">
<i class="fas fa-question-circle icon"></i>
<div class="text">{{ $ts.help }}</div>
</button>
<MkA v-click-anime to="/about" @click.passive="close()">
<i class="fas fa-info-circle icon"></i>
<div class="text">{{ $ts.instanceInfo }}</div>
</MkA>
<MkA v-click-anime to="/about-misskey" @click.passive="close()">
<img src="/static-assets/favicon.png" class="icon"/>
<div class="text">{{ $ts.aboutMisskey }}</div>
</MkA>
</div>
</div> </div>
</MkModal> </MkModal>
</template> </template>
@ -74,28 +60,6 @@ const items = Object.keys(navbarItemDef).filter(k => !menu.includes(k)).map(k =>
function close() { function close() {
modal.close(); modal.close();
} }
function help(ev: MouseEvent) {
os.popupMenu([{
type: 'link',
to: '/mfm-cheat-sheet',
text: i18n.ts._mfm.cheatSheet,
icon: 'fas fa-code',
}, {
type: 'link',
to: '/scratchpad',
text: i18n.ts.scratchpad,
icon: 'fas fa-terminal',
}, null, {
text: i18n.ts.document,
icon: 'fas fa-question-circle',
action: () => {
window.open('https://misskey-hub.net/help.html', '_blank');
},
}], ev.currentTarget ?? ev.target);
close();
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View file

@ -50,14 +50,14 @@ const emit = defineEmits<{
} }
> .name { > .name {
font-size: 0.9em; font-size: 1em;
} }
} }
> .users { > .users {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
font-size: 0.9em; font-size: 0.95em;
border-left: solid 0.5px var(--divider); border-left: solid 0.5px var(--divider);
padding-left: 10px; padding-left: 10px;
margin-left: 10px; margin-left: 10px;

View file

@ -46,7 +46,7 @@ export default defineComponent({
rounded: { rounded: {
type: Boolean, type: Boolean,
required: false, required: false,
default: false, default: true,
}, },
inline: { inline: {
type: Boolean, type: Boolean,

View file

@ -1,16 +1,16 @@
<template> <template>
<transition :name="$store.state.animation ? 'fade' : ''" appear> <transition :name="$store.state.animation ? 'fade' : ''" appear>
<div ref="rootEl" class="nvlagfpb" :style="{ zIndex }" @contextmenu.prevent.stop="() => {}"> <div ref="rootEl" class="nvlagfpb" :style="{ zIndex }" @contextmenu.prevent.stop="() => {}">
<MkMenu :items="items" class="_popup _shadow" :align="'left'" @close="$emit('closed')"/> <MkMenu :items="items" :align="'left'" @close="$emit('closed')"/>
</div> </div>
</transition> </transition>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, onBeforeUnmount } from 'vue'; import { onMounted, onBeforeUnmount } from 'vue';
import contains from '@/scripts/contains';
import MkMenu from './menu.vue'; import MkMenu from './menu.vue';
import { MenuItem } from './types/menu.vue'; import { MenuItem } from './types/menu.vue';
import contains from '@/scripts/contains';
import * as os from '@/os'; import * as os from '@/os';
const props = defineProps<{ const props = defineProps<{

View file

@ -0,0 +1,65 @@
<template>
<div ref="el" class="sfhdhdhr">
<MkMenu ref="menu" :items="items" :align="align" :width="width" :as-drawer="false" @close="onChildClosed"/>
</div>
</template>
<script lang="ts" setup>
import { on } from 'events';
import { nextTick, onBeforeUnmount, onMounted, onUnmounted, ref, watch } from 'vue';
import MkMenu from './menu.vue';
import { MenuItem } from '@/types/menu';
import * as os from '@/os';
const props = defineProps<{
items: MenuItem[];
targetElement: HTMLElement;
rootElement: HTMLElement;
width?: number;
viaKeyboard?: boolean;
}>();
const emit = defineEmits<{
(ev: 'closed'): void;
(ev: 'actioned'): void;
}>();
const el = ref<HTMLElement>();
const align = 'left';
function setPosition() {
const rootRect = props.rootElement.getBoundingClientRect();
const rect = props.targetElement.getBoundingClientRect();
const left = props.targetElement.offsetWidth;
const top = (rect.top - rootRect.top) - 8;
el.value.style.left = left + 'px';
el.value.style.top = top + 'px';
}
function onChildClosed(actioned?: boolean) {
if (actioned) {
emit('actioned');
} else {
emit('closed');
}
}
onMounted(() => {
setPosition();
nextTick(() => {
setPosition();
});
});
defineExpose({
checkHit: (ev: MouseEvent) => {
return (ev.target === el.value || el.value.contains(ev.target));
},
});
</script>
<style lang="scss" scoped>
.sfhdhdhr {
position: absolute;
}
</style>

View file

@ -1,55 +1,67 @@
<template> <template>
<div <div>
ref="itemsEl" v-hotkey="keymap" <div
class="rrevdjwt" ref="itemsEl" v-hotkey="keymap"
:class="{ center: align === 'center', asDrawer }" class="rrevdjwt _popup _shadow"
:style="{ width: (width && !asDrawer) ? width + 'px' : '', maxHeight: maxHeight ? maxHeight + 'px' : '' }" :class="{ center: align === 'center', asDrawer }"
@contextmenu.self="e => e.preventDefault()" :style="{ width: (width && !asDrawer) ? width + 'px' : '', maxHeight: maxHeight ? maxHeight + 'px' : '' }"
> @contextmenu.self="e => e.preventDefault()"
<template v-for="(item, i) in items2"> >
<div v-if="item === null" class="divider"></div> <template v-for="(item, i) in items2">
<span v-else-if="item.type === 'label'" class="label item"> <div v-if="item === null" class="divider"></div>
<span>{{ item.text }}</span> <span v-else-if="item.type === 'label'" class="label item">
<span>{{ item.text }}</span>
</span>
<span v-else-if="item.type === 'pending'" :tabindex="i" class="pending item">
<span><MkEllipsis/></span>
</span>
<MkA v-else-if="item.type === 'link'" :to="item.to" :tabindex="i" class="_button item" @click.passive="close(true)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/>
<span>{{ item.text }}</span>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</MkA>
<a v-else-if="item.type === 'a'" :href="item.href" :target="item.target" :download="item.download" :tabindex="i" class="_button item" @click="close(true)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<span>{{ item.text }}</span>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</a>
<button v-else-if="item.type === 'user'" :tabindex="i" class="_button item" :class="{ active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<MkAvatar :user="item.user" class="avatar"/><MkUserName :user="item.user"/>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</button>
<span v-else-if="item.type === 'switch'" :tabindex="i" class="item" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<FormSwitch v-model="item.ref" :disabled="item.disabled" class="form-switch">{{ item.text }}</FormSwitch>
</span>
<button v-else-if="item.type === 'parent'" :tabindex="i" class="_button item parent" :class="{ childShowing: childShowingItem === item }" @mouseenter="showChildren(item, $event)">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<span>{{ item.text }}</span>
<span class="caret"><i class="fas fa-caret-right fa-fw"></i></span>
</button>
<button v-else :tabindex="i" class="_button item" :class="{ danger: item.danger, active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/>
<span>{{ item.text }}</span>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</button>
</template>
<span v-if="items2.length === 0" class="none item">
<span>{{ $ts.none }}</span>
</span> </span>
<span v-else-if="item.type === 'pending'" :tabindex="i" class="pending item"> </div>
<span><MkEllipsis/></span> <div v-if="childMenu" class="child">
</span> <XChild ref="child" :items="childMenu" :target-element="childTarget" :root-element="itemsEl" showing @actioned="childActioned"/>
<MkA v-else-if="item.type === 'link'" :to="item.to" :tabindex="i" class="_button item" @click.passive="close()"> </div>
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/>
<span>{{ item.text }}</span>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</MkA>
<a v-else-if="item.type === 'a'" :href="item.href" :target="item.target" :download="item.download" :tabindex="i" class="_button item" @click="close()">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<span>{{ item.text }}</span>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</a>
<button v-else-if="item.type === 'user'" :tabindex="i" class="_button item" :class="{ active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)">
<MkAvatar :user="item.user" class="avatar"/><MkUserName :user="item.user"/>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</button>
<span v-else-if="item.type === 'switch'" :tabindex="i" class="item">
<FormSwitch v-model="item.ref" :disabled="item.disabled" class="form-switch">{{ item.text }}</FormSwitch>
</span>
<button v-else :tabindex="i" class="_button item" :class="{ danger: item.danger, active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)">
<i v-if="item.icon" class="fa-fw" :class="item.icon"></i>
<MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/>
<span>{{ item.text }}</span>
<span v-if="item.indicate" class="indicator"><i class="fas fa-circle"></i></span>
</button>
</template>
<span v-if="items2.length === 0" class="none item">
<span>{{ $ts.none }}</span>
</span>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { nextTick, onMounted, watch } from 'vue'; import { defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, onUnmounted, Ref, ref, watch } from 'vue';
import { focusPrev, focusNext } from '@/scripts/focus'; import { focusPrev, focusNext } from '@/scripts/focus';
import FormSwitch from '@/components/form/switch.vue'; import FormSwitch from '@/components/form/switch.vue';
import { MenuItem, InnerMenuItem, MenuPending, MenuAction } from '@/types/menu'; import { MenuItem, InnerMenuItem, MenuPending, MenuAction } from '@/types/menu';
import * as os from '@/os';
const XChild = defineAsyncComponent(() => import('./menu.child.vue'));
const props = defineProps<{ const props = defineProps<{
items: MenuItem[]; items: MenuItem[];
@ -61,19 +73,23 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(ev: 'close'): void; (ev: 'close', actioned?: boolean): void;
}>(); }>();
let itemsEl = $ref<HTMLDivElement>(); let itemsEl = $ref<HTMLDivElement>();
let items2: InnerMenuItem[] = $ref([]); let items2: InnerMenuItem[] = $ref([]);
let child = $ref<InstanceType<typeof XChild>>();
let keymap = $computed(() => ({ let keymap = $computed(() => ({
'up|k|shift+tab': focusUp, 'up|k|shift+tab': focusUp,
'down|j|tab': focusDown, 'down|j|tab': focusDown,
'esc': close, 'esc': close,
})); }));
let childShowingItem = $ref<MenuItem | null>();
watch(() => props.items, () => { watch(() => props.items, () => {
const items: (MenuItem | MenuPending)[] = [...props.items].filter(item => item !== undefined); const items: (MenuItem | MenuPending)[] = [...props.items].filter(item => item !== undefined);
@ -93,21 +109,53 @@ watch(() => props.items, () => {
immediate: true, immediate: true,
}); });
onMounted(() => { let childMenu = $ref<MenuItem[] | null>();
if (props.viaKeyboard) { let childTarget = $ref<HTMLElement | null>();
nextTick(() => {
focusNext(itemsEl.children[0], true, false); function closeChild() {
}); childMenu = null;
childShowingItem = null;
}
function childActioned() {
closeChild();
close(true);
}
function onGlobalMousedown(event: MouseEvent) {
if (childTarget && (event.target === childTarget || childTarget.contains(event.target))) return;
if (child && child.checkHit(event)) return;
closeChild();
}
let childCloseTimer: null | number = null;
function onItemMouseEnter(item) {
childCloseTimer = window.setTimeout(() => {
closeChild();
}, 300);
}
function onItemMouseLeave(item) {
if (childCloseTimer) window.clearTimeout(childCloseTimer);
}
async function showChildren(item: MenuItem, ev: MouseEvent) {
if (props.asDrawer) {
os.popupMenu(item.children, ev.currentTarget ?? ev.target);
close();
} else {
childTarget = ev.currentTarget ?? ev.target;
childMenu = item.children;
childShowingItem = item;
} }
}); }
function clicked(fn: MenuAction, ev: MouseEvent) { function clicked(fn: MenuAction, ev: MouseEvent) {
fn(ev); fn(ev);
close(); close(true);
} }
function close() { function close(actioned = false) {
emit('close'); emit('close', actioned);
} }
function focusUp() { function focusUp() {
@ -117,6 +165,20 @@ function focusUp() {
function focusDown() { function focusDown() {
focusNext(document.activeElement); focusNext(document.activeElement);
} }
onMounted(() => {
if (props.viaKeyboard) {
nextTick(() => {
focusNext(itemsEl.children[0], true, false);
});
}
document.addEventListener('mousedown', onGlobalMousedown, { passive: true });
});
onBeforeUnmount(() => {
document.removeEventListener('mousedown', onGlobalMousedown);
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -225,6 +287,25 @@ function focusDown() {
opacity: 0.7; opacity: 0.7;
} }
&.parent {
display: flex;
align-items: center;
cursor: default;
> .caret {
margin-left: auto;
}
&.childShowing {
color: var(--accent);
text-decoration: none;
&:before {
background: var(--accentedBg);
}
}
}
> i { > i {
margin-right: 5px; margin-right: 5px;
width: 20px; width: 20px;

View file

@ -1,6 +1,6 @@
<template> <template>
<MkModal ref="modal" v-slot="{ type, maxHeight }" :z-priority="'high'" :src="src" :transparent-bg="true" @click="modal.close()" @closed="emit('closed')"> <MkModal ref="modal" v-slot="{ type, maxHeight }" :z-priority="'high'" :src="src" :transparent-bg="true" @click="modal.close()" @closed="emit('closed')">
<MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :as-drawer="type === 'drawer'" class="sfhdhdhq _popup _shadow" :class="{ drawer: type === 'drawer' }" @close="modal.close()"/> <MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :as-drawer="type === 'drawer'" class="sfhdhdhq" :class="{ drawer: type === 'drawer' }" @close="modal.close()"/>
</MkModal> </MkModal>
</template> </template>

View file

@ -12,6 +12,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { nextTick, onMounted, onUnmounted, ref } from 'vue'; import { nextTick, onMounted, onUnmounted, ref } from 'vue';
import * as os from '@/os'; import * as os from '@/os';
import { calcPopupPosition } from '@/scripts/popup-position';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
showing: boolean; showing: boolean;
@ -36,151 +37,20 @@ const emit = defineEmits<{
const el = ref<HTMLElement>(); const el = ref<HTMLElement>();
const zIndex = os.claimZIndex('high'); const zIndex = os.claimZIndex('high');
const setPosition = () => { function setPosition() {
if (el.value == null) return; const data = calcPopupPosition(el.value, {
anchorElement: props.targetElement,
direction: props.direction,
align: 'center',
innerMargin: props.innerMargin,
x: props.x,
y: props.y,
});
const contentWidth = el.value.offsetWidth; el.value.style.transformOrigin = data.transformOrigin;
const contentHeight = el.value.offsetHeight; el.value.style.left = data.left + 'px';
el.value.style.top = data.top + 'px';
let rect: DOMRect; }
if (props.targetElement) {
rect = props.targetElement.getBoundingClientRect();
}
const calcPosWhenTop = () => {
let left: number;
let top: number;
if (props.targetElement) {
left = rect.left + window.pageXOffset + (props.targetElement.offsetWidth / 2);
top = (rect.top + window.pageYOffset - contentHeight) - props.innerMargin;
} else {
left = props.x;
top = (props.y - contentHeight) - props.innerMargin;
}
left -= (el.value.offsetWidth / 2);
if (left + contentWidth - window.pageXOffset > window.innerWidth) {
left = window.innerWidth - contentWidth + window.pageXOffset - 1;
}
return [left, top];
};
const calcPosWhenBottom = () => {
let left: number;
let top: number;
if (props.targetElement) {
left = rect.left + window.pageXOffset + (props.targetElement.offsetWidth / 2);
top = (rect.top + window.pageYOffset + props.targetElement.offsetHeight) + props.innerMargin;
} else {
left = props.x;
top = (props.y) + props.innerMargin;
}
left -= (el.value.offsetWidth / 2);
if (left + contentWidth - window.pageXOffset > window.innerWidth) {
left = window.innerWidth - contentWidth + window.pageXOffset - 1;
}
return [left, top];
};
const calcPosWhenLeft = () => {
let left: number;
let top: number;
if (props.targetElement) {
left = (rect.left + window.pageXOffset - contentWidth) - props.innerMargin;
top = rect.top + window.pageYOffset + (props.targetElement.offsetHeight / 2);
} else {
left = (props.x - contentWidth) - props.innerMargin;
top = props.y;
}
top -= (el.value.offsetHeight / 2);
if (top + contentHeight - window.pageYOffset > window.innerHeight) {
top = window.innerHeight - contentHeight + window.pageYOffset - 1;
}
return [left, top];
};
const calcPosWhenRight = () => {
let left: number;
let top: number;
if (props.targetElement) {
left = (rect.left + props.targetElement.offsetWidth + window.pageXOffset) + props.innerMargin;
top = rect.top + window.pageYOffset + (props.targetElement.offsetHeight / 2);
} else {
left = props.x + props.innerMargin;
top = props.y;
}
top -= (el.value.offsetHeight / 2);
if (top + contentHeight - window.pageYOffset > window.innerHeight) {
top = window.innerHeight - contentHeight + window.pageYOffset - 1;
}
return [left, top];
};
const calc = (): {
left: number;
top: number;
transformOrigin: string;
} => {
switch (props.direction) {
case 'top': {
const [left, top] = calcPosWhenTop();
//
if (top - window.pageYOffset < 0) {
const [left, top] = calcPosWhenBottom();
return { left, top, transformOrigin: 'center top' };
}
return { left, top, transformOrigin: 'center bottom' };
}
case 'bottom': {
const [left, top] = calcPosWhenBottom();
// TODO:
return { left, top, transformOrigin: 'center top' };
}
case 'left': {
const [left, top] = calcPosWhenLeft();
//
if (left - window.pageXOffset < 0) {
const [left, top] = calcPosWhenRight();
return { left, top, transformOrigin: 'left center' };
}
return { left, top, transformOrigin: 'right center' };
}
case 'right': {
const [left, top] = calcPosWhenRight();
// TODO:
return { left, top, transformOrigin: 'left center' };
}
}
};
const { left, top, transformOrigin } = calc();
el.value.style.transformOrigin = transformOrigin;
el.value.style.left = left + 'px';
el.value.style.top = top + 'px';
};
let loopHandler; let loopHandler;

View file

@ -1,6 +1,6 @@
<template> <template>
<transition :name="$store.state.animation ? 'window' : ''" appear @after-leave="$emit('closed')"> <transition :name="$store.state.animation ? 'window' : ''" appear @after-leave="$emit('closed')">
<div v-if="showing" class="ebkgocck"> <div v-if="showing" ref="rootEl" class="ebkgocck" :class="{ maximized }">
<div class="body _shadow _narrow_" @mousedown="onBodyMousedown" @keydown="onKeydown"> <div class="body _shadow _narrow_" @mousedown="onBodyMousedown" @keydown="onKeydown">
<div class="header" :class="{ mini }" @contextmenu.prevent.stop="onContextmenu"> <div class="header" :class="{ mini }" @contextmenu.prevent.stop="onContextmenu">
<span class="left"> <span class="left">
@ -11,6 +11,8 @@
</span> </span>
<span class="right"> <span class="right">
<button v-for="button in buttonsRight" v-tooltip="button.title" class="button _button" :class="{ highlighted: button.highlighted }" @click="button.onClick"><i :class="button.icon"></i></button> <button v-for="button in buttonsRight" v-tooltip="button.title" class="button _button" :class="{ highlighted: button.highlighted }" @click="button.onClick"><i :class="button.icon"></i></button>
<button v-if="canResize && maximized" class="button _button" @click="unMaximize()"><i class="fas fa-window-restore"></i></button>
<button v-else-if="canResize && !maximized" class="button _button" @click="maximize()"><i class="fas fa-window-maximize"></i></button>
<button v-if="closeButton" class="button _button" @click="close()"><i class="fas fa-times"></i></button> <button v-if="closeButton" class="button _button" @click="close()"><i class="fas fa-times"></i></button>
</span> </span>
</div> </div>
@ -32,15 +34,16 @@
</transition> </transition>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue'; import { onBeforeUnmount, onMounted, provide } from 'vue';
import contains from '@/scripts/contains'; import contains from '@/scripts/contains';
import * as os from '@/os'; import * as os from '@/os';
import { MenuItem } from '@/types/menu';
const minHeight = 50; const minHeight = 50;
const minWidth = 250; const minWidth = 250;
function dragListen(fn) { function dragListen(fn: (ev: MouseEvent) => void) {
window.addEventListener('mousemove', fn); window.addEventListener('mousemove', fn);
window.addEventListener('touchmove', fn); window.addEventListener('touchmove', fn);
window.addEventListener('mouseleave', dragClear.bind(null, fn)); window.addEventListener('mouseleave', dragClear.bind(null, fn));
@ -56,315 +59,342 @@ function dragClear(fn) {
window.removeEventListener('touchend', dragClear); window.removeEventListener('touchend', dragClear);
} }
export default defineComponent({ const props = withDefaults(defineProps<{
provide: { initialWidth?: number;
inWindow: true, initialHeight?: number | null;
}, canResize?: boolean;
closeButton?: boolean;
mini?: boolean;
front?: boolean;
contextmenu?: MenuItem[] | null;
buttonsLeft?: any[];
buttonsRight?: any[];
}>(), {
initialWidth: 400,
initialHeight: null,
canResize: false,
closeButton: true,
mini: false,
front: false,
contextmenu: null,
buttonsLeft: () => [],
buttonsRight: () => [],
});
props: { const emit = defineEmits<{
initialWidth: { (ev: 'closed'): void;
type: Number, }>();
required: false,
default: 400,
},
initialHeight: {
type: Number,
required: false,
default: null,
},
canResize: {
type: Boolean,
required: false,
default: false,
},
closeButton: {
type: Boolean,
required: false,
default: true,
},
mini: {
type: Boolean,
required: false,
default: false,
},
front: {
type: Boolean,
required: false,
default: false,
},
contextmenu: {
type: Array,
required: false,
},
buttonsLeft: {
type: Array,
required: false,
default: () => [],
},
buttonsRight: {
type: Array,
required: false,
default: () => [],
},
},
emits: ['closed'], provide('inWindow', true);
data() { let rootEl = $ref<HTMLElement | null>();
return { let showing = $ref(true);
showing: true, let beforeClickedAt = 0;
id: Math.random().toString(), // TODO: UUID let maximized = $ref(false);
}; let unMaximizedTop = '';
}, let unMaximizedLeft = '';
let unMaximizedWidth = '';
let unMaximizedHeight = '';
mounted() { function close() {
if (this.initialWidth) this.applyTransformWidth(this.initialWidth); showing = false;
if (this.initialHeight) this.applyTransformHeight(this.initialHeight); }
this.applyTransformTop((window.innerHeight / 2) - (this.$el.offsetHeight / 2)); function onKeydown(evt) {
this.applyTransformLeft((window.innerWidth / 2) - (this.$el.offsetWidth / 2)); if (evt.which === 27) { // Esc
evt.preventDefault();
evt.stopPropagation();
close();
}
}
// function onContextmenu(ev: MouseEvent) {
this.top(); if (props.contextmenu) {
os.contextMenu(props.contextmenu, ev);
}
}
window.addEventListener('resize', this.onBrowserResize); //
}, function top() {
if (rootEl) {
rootEl.style.zIndex = os.claimZIndex(props.front ? 'middle' : 'low');
}
}
unmounted() { function maximize() {
window.removeEventListener('resize', this.onBrowserResize); maximized = true;
}, unMaximizedTop = rootEl.style.top;
unMaximizedLeft = rootEl.style.left;
unMaximizedWidth = rootEl.style.width;
unMaximizedHeight = rootEl.style.height;
rootEl.style.top = '0';
rootEl.style.left = '0';
rootEl.style.width = '100%';
rootEl.style.height = '100%';
}
methods: { function unMaximize() {
close() { maximized = false;
this.showing = false; rootEl.style.top = unMaximizedTop;
}, rootEl.style.left = unMaximizedLeft;
rootEl.style.width = unMaximizedWidth;
rootEl.style.height = unMaximizedHeight;
}
onKeydown(evt) { function onBodyMousedown() {
if (evt.which === 27) { // Esc top();
evt.preventDefault(); }
evt.stopPropagation();
this.close(); function onDblClick() {
maximize();
}
function onHeaderMousedown(evt: MouseEvent) {
//
if (evt.button === 2) return;
let beforeMaximized = false;
if (maximized) {
beforeMaximized = true;
unMaximize();
}
//
if (Date.now() - beforeClickedAt < 300) {
beforeClickedAt = Date.now();
onDblClick();
return;
}
beforeClickedAt = Date.now();
const main = rootEl;
if (!contains(main, document.activeElement)) main.focus();
const position = main.getBoundingClientRect();
const clickX = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientX : evt.clientX;
const clickY = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientY : evt.clientY;
const moveBaseX = beforeMaximized ? parseInt(unMaximizedWidth, 10) / 2 : clickX - position.left; // TODO: parseInt
const moveBaseY = beforeMaximized ? 20 : clickY - position.top;
const browserWidth = window.innerWidth;
const browserHeight = window.innerHeight;
const windowWidth = main.offsetWidth;
const windowHeight = main.offsetHeight;
function move(x: number, y: number) {
let moveLeft = x - moveBaseX;
let moveTop = y - moveBaseY;
//
if (moveTop + windowHeight > browserHeight) moveTop = browserHeight - windowHeight;
//
if (moveLeft < 0) moveLeft = 0;
//
if (moveTop < 0) moveTop = 0;
//
if (moveLeft + windowWidth > browserWidth) moveLeft = browserWidth - windowWidth;
rootEl.style.left = moveLeft + 'px';
rootEl.style.top = moveTop + 'px';
}
if (beforeMaximized) {
move(clickX, clickY);
}
//
dragListen(me => {
const x = me.touches && me.touches.length > 0 ? me.touches[0].clientX : me.clientX;
const y = me.touches && me.touches.length > 0 ? me.touches[0].clientY : me.clientY;
move(x, y);
});
}
//
function onTopHandleMousedown(evt) {
const main = rootEl;
const base = evt.clientY;
const height = parseInt(getComputedStyle(main, '').height, 10);
const top = parseInt(getComputedStyle(main, '').top, 10);
//
dragListen(me => {
const move = me.clientY - base;
if (top + move > 0) {
if (height + -move > minHeight) {
applyTransformHeight(height + -move);
applyTransformTop(top + move);
} else { //
applyTransformHeight(minHeight);
applyTransformTop(top + (height - minHeight));
} }
}, } else { //
applyTransformHeight(top + height);
applyTransformTop(0);
}
});
}
onContextmenu(ev: MouseEvent) { //
if (this.contextmenu) { function onRightHandleMousedown(evt) {
os.contextMenu(this.contextmenu, ev); const main = rootEl;
const base = evt.clientX;
const width = parseInt(getComputedStyle(main, '').width, 10);
const left = parseInt(getComputedStyle(main, '').left, 10);
const browserWidth = window.innerWidth;
//
dragListen(me => {
const move = me.clientX - base;
if (left + width + move < browserWidth) {
if (width + move > minWidth) {
applyTransformWidth(width + move);
} else { //
applyTransformWidth(minWidth);
} }
}, } else { //
applyTransformWidth(browserWidth - left);
}
});
}
// //
top() { function onBottomHandleMousedown(evt) {
(this.$el as any).style.zIndex = os.claimZIndex(this.front ? 'middle' : 'low'); const main = rootEl;
},
onBodyMousedown() { const base = evt.clientY;
this.top(); const height = parseInt(getComputedStyle(main, '').height, 10);
}, const top = parseInt(getComputedStyle(main, '').top, 10);
const browserHeight = window.innerHeight;
onHeaderMousedown(evt: MouseEvent) { //
// dragListen(me => {
if (evt.button === 2) return; const move = me.clientY - base;
if (top + height + move < browserHeight) {
if (height + move > minHeight) {
applyTransformHeight(height + move);
} else { //
applyTransformHeight(minHeight);
}
} else { //
applyTransformHeight(browserHeight - top);
}
});
}
const main = this.$el as any; //
function onLeftHandleMousedown(evt) {
const main = rootEl;
if (!contains(main, document.activeElement)) main.focus(); const base = evt.clientX;
const width = parseInt(getComputedStyle(main, '').width, 10);
const left = parseInt(getComputedStyle(main, '').left, 10);
const position = main.getBoundingClientRect(); //
dragListen(me => {
const move = me.clientX - base;
if (left + move > 0) {
if (width + -move > minWidth) {
applyTransformWidth(width + -move);
applyTransformLeft(left + move);
} else { //
applyTransformWidth(minWidth);
applyTransformLeft(left + (width - minWidth));
}
} else { //
applyTransformWidth(left + width);
applyTransformLeft(0);
}
});
}
const clickX = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientX : evt.clientX; //
const clickY = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientY : evt.clientY; function onTopLeftHandleMousedown(evt) {
const moveBaseX = clickX - position.left; onTopHandleMousedown(evt);
const moveBaseY = clickY - position.top; onLeftHandleMousedown(evt);
const browserWidth = window.innerWidth; }
const browserHeight = window.innerHeight;
const windowWidth = main.offsetWidth;
const windowHeight = main.offsetHeight;
// //
dragListen(me => { function onTopRightHandleMousedown(evt) {
const x = me.touches && me.touches.length > 0 ? me.touches[0].clientX : me.clientX; onTopHandleMousedown(evt);
const y = me.touches && me.touches.length > 0 ? me.touches[0].clientY : me.clientY; onRightHandleMousedown(evt);
}
let moveLeft = x - moveBaseX; //
let moveTop = y - moveBaseY; function onBottomRightHandleMousedown(evt) {
onBottomHandleMousedown(evt);
onRightHandleMousedown(evt);
}
// //
if (moveTop + windowHeight > browserHeight) moveTop = browserHeight - windowHeight; function onBottomLeftHandleMousedown(evt) {
onBottomHandleMousedown(evt);
onLeftHandleMousedown(evt);
}
// //
if (moveLeft < 0) moveLeft = 0; function applyTransformHeight(height) {
if (height > window.innerHeight) height = window.innerHeight;
rootEl.style.height = height + 'px';
}
// //
if (moveTop < 0) moveTop = 0; function applyTransformWidth(width) {
if (width > window.innerWidth) width = window.innerWidth;
rootEl.style.width = width + 'px';
}
// // Y
if (moveLeft + windowWidth > browserWidth) moveLeft = browserWidth - windowWidth; function applyTransformTop(top) {
rootEl.style.top = top + 'px';
}
this.$el.style.left = moveLeft + 'px'; // X
this.$el.style.top = moveTop + 'px'; function applyTransformLeft(left) {
}); rootEl.style.left = left + 'px';
}, }
// function onBrowserResize() {
onTopHandleMousedown(evt) { const main = rootEl;
const main = this.$el as any; const position = main.getBoundingClientRect();
const browserWidth = window.innerWidth;
const browserHeight = window.innerHeight;
const windowWidth = main.offsetWidth;
const windowHeight = main.offsetHeight;
if (position.left < 0) main.style.left = '0'; //
if (position.top + windowHeight > browserHeight) main.style.top = browserHeight - windowHeight + 'px'; //
if (position.left + windowWidth > browserWidth) main.style.left = browserWidth - windowWidth + 'px'; //
if (position.top < 0) main.style.top = '0'; //
}
const base = evt.clientY; onMounted(() => {
const height = parseInt(getComputedStyle(main, '').height, 10); if (props.initialWidth) applyTransformWidth(props.initialWidth);
const top = parseInt(getComputedStyle(main, '').top, 10); if (props.initialHeight) applyTransformHeight(props.initialHeight);
// applyTransformTop((window.innerHeight / 2) - (rootEl.offsetHeight / 2));
dragListen(me => { applyTransformLeft((window.innerWidth / 2) - (rootEl.offsetWidth / 2));
const move = me.clientY - base;
if (top + move > 0) {
if (height + -move > minHeight) {
this.applyTransformHeight(height + -move);
this.applyTransformTop(top + move);
} else { //
this.applyTransformHeight(minHeight);
this.applyTransformTop(top + (height - minHeight));
}
} else { //
this.applyTransformHeight(top + height);
this.applyTransformTop(0);
}
});
},
// //
onRightHandleMousedown(evt) { top();
const main = this.$el as any;
const base = evt.clientX; window.addEventListener('resize', onBrowserResize);
const width = parseInt(getComputedStyle(main, '').width, 10); });
const left = parseInt(getComputedStyle(main, '').left, 10);
const browserWidth = window.innerWidth;
// onBeforeUnmount(() => {
dragListen(me => { window.removeEventListener('resize', onBrowserResize);
const move = me.clientX - base; });
if (left + width + move < browserWidth) {
if (width + move > minWidth) {
this.applyTransformWidth(width + move);
} else { //
this.applyTransformWidth(minWidth);
}
} else { //
this.applyTransformWidth(browserWidth - left);
}
});
},
// defineExpose({
onBottomHandleMousedown(evt) { close,
const main = this.$el as any;
const base = evt.clientY;
const height = parseInt(getComputedStyle(main, '').height, 10);
const top = parseInt(getComputedStyle(main, '').top, 10);
const browserHeight = window.innerHeight;
//
dragListen(me => {
const move = me.clientY - base;
if (top + height + move < browserHeight) {
if (height + move > minHeight) {
this.applyTransformHeight(height + move);
} else { //
this.applyTransformHeight(minHeight);
}
} else { //
this.applyTransformHeight(browserHeight - top);
}
});
},
//
onLeftHandleMousedown(evt) {
const main = this.$el as any;
const base = evt.clientX;
const width = parseInt(getComputedStyle(main, '').width, 10);
const left = parseInt(getComputedStyle(main, '').left, 10);
//
dragListen(me => {
const move = me.clientX - base;
if (left + move > 0) {
if (width + -move > minWidth) {
this.applyTransformWidth(width + -move);
this.applyTransformLeft(left + move);
} else { //
this.applyTransformWidth(minWidth);
this.applyTransformLeft(left + (width - minWidth));
}
} else { //
this.applyTransformWidth(left + width);
this.applyTransformLeft(0);
}
});
},
//
onTopLeftHandleMousedown(evt) {
this.onTopHandleMousedown(evt);
this.onLeftHandleMousedown(evt);
},
//
onTopRightHandleMousedown(evt) {
this.onTopHandleMousedown(evt);
this.onRightHandleMousedown(evt);
},
//
onBottomRightHandleMousedown(evt) {
this.onBottomHandleMousedown(evt);
this.onRightHandleMousedown(evt);
},
//
onBottomLeftHandleMousedown(evt) {
this.onBottomHandleMousedown(evt);
this.onLeftHandleMousedown(evt);
},
//
applyTransformHeight(height) {
if (height > window.innerHeight) height = window.innerHeight;
(this.$el as any).style.height = height + 'px';
},
//
applyTransformWidth(width) {
if (width > window.innerWidth) width = window.innerWidth;
(this.$el as any).style.width = width + 'px';
},
// Y
applyTransformTop(top) {
(this.$el as any).style.top = top + 'px';
},
// X
applyTransformLeft(left) {
(this.$el as any).style.left = left + 'px';
},
onBrowserResize() {
const main = this.$el as any;
const position = main.getBoundingClientRect();
const browserWidth = window.innerWidth;
const browserHeight = window.innerHeight;
const windowWidth = main.offsetWidth;
const windowHeight = main.offsetHeight;
if (position.left < 0) main.style.left = 0; //
if (position.top + windowHeight > browserHeight) main.style.top = browserHeight - windowHeight + 'px'; //
if (position.left + windowWidth > browserWidth) main.style.left = browserWidth - windowWidth + 'px'; //
if (position.top < 0) main.style.top = 0; //
},
},
}); });
</script> </script>
@ -384,7 +414,7 @@ export default defineComponent({
left: 0; left: 0;
> .body { > .body {
overflow: hidden; overflow: clip;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
contain: content; contain: content;
@ -522,5 +552,11 @@ export default defineComponent({
cursor: nesw-resize; cursor: nesw-resize;
} }
} }
&.maximized {
> .body {
border-radius: 0;
}
}
} }
</style> </style>

View file

@ -1,301 +1,313 @@
<template> <template>
<MkStickyContainer> <MkStickyContainer>
<template #header><MkPageHeader/></template> <template #header><MkPageHeader/></template>
<div class="mwysmxbg"> <MkSpacer :content-max="800">
<div>{{ $ts._mfm.intro }}</div> <div class="mwysmxbg">
<div>{{ $ts._mfm.intro }}</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.mention }}</div>
<div class="content">
<p>{{ $ts._mfm.mentionDescription }}</p>
<div class="preview">
<Mfm :text="preview_mention"/>
<MkTextarea v-model="preview_mention"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.hashtag }}</div>
<div class="content">
<p>{{ $ts._mfm.hashtagDescription }}</p>
<div class="preview">
<Mfm :text="preview_hashtag"/>
<MkTextarea v-model="preview_hashtag"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.url }}</div>
<div class="content">
<p>{{ $ts._mfm.urlDescription }}</p>
<div class="preview">
<Mfm :text="preview_url"/>
<MkTextarea v-model="preview_url"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.link }}</div>
<div class="content">
<p>{{ $ts._mfm.linkDescription }}</p>
<div class="preview">
<Mfm :text="preview_link"/>
<MkTextarea v-model="preview_link"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.emoji }}</div>
<div class="content">
<p>{{ $ts._mfm.emojiDescription }}</p>
<div class="preview">
<Mfm :text="preview_emoji"/>
<MkTextarea v-model="preview_emoji"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.bold }}</div>
<div class="content">
<p>{{ $ts._mfm.boldDescription }}</p>
<div class="preview">
<Mfm :text="preview_bold"/>
<MkTextarea v-model="preview_bold"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.small }}</div>
<div class="content">
<p>{{ $ts._mfm.smallDescription }}</p>
<div class="preview">
<Mfm :text="preview_small"/>
<MkTextarea v-model="preview_small"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.quote }}</div>
<div class="content">
<p>{{ $ts._mfm.quoteDescription }}</p>
<div class="preview">
<Mfm :text="preview_quote"/>
<MkTextarea v-model="preview_quote"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.center }}</div>
<div class="content">
<p>{{ $ts._mfm.centerDescription }}</p>
<div class="preview">
<Mfm :text="preview_center"/>
<MkTextarea v-model="preview_center"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.inlineCode }}</div>
<div class="content">
<p>{{ $ts._mfm.inlineCodeDescription }}</p>
<div class="preview">
<Mfm :text="preview_inlineCode"/>
<MkTextarea v-model="preview_inlineCode"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.blockCode }}</div>
<div class="content">
<p>{{ $ts._mfm.blockCodeDescription }}</p>
<div class="preview">
<Mfm :text="preview_blockCode"/>
<MkTextarea v-model="preview_blockCode"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.inlineMath }}</div>
<div class="content">
<p>{{ $ts._mfm.inlineMathDescription }}</p>
<div class="preview">
<Mfm :text="preview_inlineMath"/>
<MkTextarea v-model="preview_inlineMath"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<!-- deprecated
<div class="section _block"> <div class="section _block">
<div class="title">{{ $ts._mfm.mention }}</div> <div class="title">{{ $ts._mfm.search }}</div>
<div class="content"> <div class="content">
<p>{{ $ts._mfm.mentionDescription }}</p> <p>{{ $ts._mfm.searchDescription }}</p>
<div class="preview"> <div class="preview">
<Mfm :text="preview_mention"/> <Mfm :text="preview_search"/>
<MkTextarea v-model="preview_mention"><template #label>MFM</template></MkTextarea> <MkTextarea v-model="preview_search"><template #label>MFM</template></MkTextarea>
</div> </div>
</div> </div>
</div> </div>
<div class="section _block"> -->
<div class="title">{{ $ts._mfm.hashtag }}</div> <div class="section _block">
<div class="content"> <div class="title">{{ $ts._mfm.flip }}</div>
<p>{{ $ts._mfm.hashtagDescription }}</p> <div class="content">
<div class="preview"> <p>{{ $ts._mfm.flipDescription }}</p>
<Mfm :text="preview_hashtag"/> <div class="preview">
<MkTextarea v-model="preview_hashtag"><template #label>MFM</template></MkTextarea> <Mfm :text="preview_flip"/>
<MkTextarea v-model="preview_flip"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.font }}</div>
<div class="content">
<p>{{ $ts._mfm.fontDescription }}</p>
<div class="preview">
<Mfm :text="preview_font"/>
<MkTextarea v-model="preview_font"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.x2 }}</div>
<div class="content">
<p>{{ $ts._mfm.x2Description }}</p>
<div class="preview">
<Mfm :text="preview_x2"/>
<MkTextarea v-model="preview_x2"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.x3 }}</div>
<div class="content">
<p>{{ $ts._mfm.x3Description }}</p>
<div class="preview">
<Mfm :text="preview_x3"/>
<MkTextarea v-model="preview_x3"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.x4 }}</div>
<div class="content">
<p>{{ $ts._mfm.x4Description }}</p>
<div class="preview">
<Mfm :text="preview_x4"/>
<MkTextarea v-model="preview_x4"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.blur }}</div>
<div class="content">
<p>{{ $ts._mfm.blurDescription }}</p>
<div class="preview">
<Mfm :text="preview_blur"/>
<MkTextarea v-model="preview_blur"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.jelly }}</div>
<div class="content">
<p>{{ $ts._mfm.jellyDescription }}</p>
<div class="preview">
<Mfm :text="preview_jelly"/>
<MkTextarea v-model="preview_jelly"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.tada }}</div>
<div class="content">
<p>{{ $ts._mfm.tadaDescription }}</p>
<div class="preview">
<Mfm :text="preview_tada"/>
<MkTextarea v-model="preview_tada"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.jump }}</div>
<div class="content">
<p>{{ $ts._mfm.jumpDescription }}</p>
<div class="preview">
<Mfm :text="preview_jump"/>
<MkTextarea v-model="preview_jump"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.bounce }}</div>
<div class="content">
<p>{{ $ts._mfm.bounceDescription }}</p>
<div class="preview">
<Mfm :text="preview_bounce"/>
<MkTextarea v-model="preview_bounce"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.spin }}</div>
<div class="content">
<p>{{ $ts._mfm.spinDescription }}</p>
<div class="preview">
<Mfm :text="preview_spin"/>
<MkTextarea v-model="preview_spin"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.shake }}</div>
<div class="content">
<p>{{ $ts._mfm.shakeDescription }}</p>
<div class="preview">
<Mfm :text="preview_shake"/>
<MkTextarea v-model="preview_shake"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.twitch }}</div>
<div class="content">
<p>{{ $ts._mfm.twitchDescription }}</p>
<div class="preview">
<Mfm :text="preview_twitch"/>
<MkTextarea v-model="preview_twitch"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.rainbow }}</div>
<div class="content">
<p>{{ $ts._mfm.rainbowDescription }}</p>
<div class="preview">
<Mfm :text="preview_rainbow"/>
<MkTextarea v-model="preview_rainbow"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.sparkle }}</div>
<div class="content">
<p>{{ $ts._mfm.sparkleDescription }}</p>
<div class="preview">
<Mfm :text="preview_sparkle"/>
<MkTextarea v-model="preview_sparkle"><span>MFM</span></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.rotate }}</div>
<div class="content">
<p>{{ $ts._mfm.rotateDescription }}</p>
<div class="preview">
<Mfm :text="preview_rotate"/>
<MkTextarea v-model="preview_rotate"><span>MFM</span></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.plain }}</div>
<div class="content">
<p>{{ $ts._mfm.plainDescription }}</p>
<div class="preview">
<Mfm :text="preview_plain"/>
<MkTextarea v-model="preview_plain"><span>MFM</span></MkTextarea>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="section _block"> </MkSpacer>
<div class="title">{{ $ts._mfm.url }}</div>
<div class="content">
<p>{{ $ts._mfm.urlDescription }}</p>
<div class="preview">
<Mfm :text="preview_url"/>
<MkTextarea v-model="preview_url"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.link }}</div>
<div class="content">
<p>{{ $ts._mfm.linkDescription }}</p>
<div class="preview">
<Mfm :text="preview_link"/>
<MkTextarea v-model="preview_link"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.emoji }}</div>
<div class="content">
<p>{{ $ts._mfm.emojiDescription }}</p>
<div class="preview">
<Mfm :text="preview_emoji"/>
<MkTextarea v-model="preview_emoji"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.bold }}</div>
<div class="content">
<p>{{ $ts._mfm.boldDescription }}</p>
<div class="preview">
<Mfm :text="preview_bold"/>
<MkTextarea v-model="preview_bold"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.small }}</div>
<div class="content">
<p>{{ $ts._mfm.smallDescription }}</p>
<div class="preview">
<Mfm :text="preview_small"/>
<MkTextarea v-model="preview_small"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.quote }}</div>
<div class="content">
<p>{{ $ts._mfm.quoteDescription }}</p>
<div class="preview">
<Mfm :text="preview_quote"/>
<MkTextarea v-model="preview_quote"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.center }}</div>
<div class="content">
<p>{{ $ts._mfm.centerDescription }}</p>
<div class="preview">
<Mfm :text="preview_center"/>
<MkTextarea v-model="preview_center"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.inlineCode }}</div>
<div class="content">
<p>{{ $ts._mfm.inlineCodeDescription }}</p>
<div class="preview">
<Mfm :text="preview_inlineCode"/>
<MkTextarea v-model="preview_inlineCode"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.blockCode }}</div>
<div class="content">
<p>{{ $ts._mfm.blockCodeDescription }}</p>
<div class="preview">
<Mfm :text="preview_blockCode"/>
<MkTextarea v-model="preview_blockCode"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.inlineMath }}</div>
<div class="content">
<p>{{ $ts._mfm.inlineMathDescription }}</p>
<div class="preview">
<Mfm :text="preview_inlineMath"/>
<MkTextarea v-model="preview_inlineMath"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<!-- deprecated
<div class="section _block">
<div class="title">{{ $ts._mfm.search }}</div>
<div class="content">
<p>{{ $ts._mfm.searchDescription }}</p>
<div class="preview">
<Mfm :text="preview_search"/>
<MkTextarea v-model="preview_search"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
-->
<div class="section _block">
<div class="title">{{ $ts._mfm.flip }}</div>
<div class="content">
<p>{{ $ts._mfm.flipDescription }}</p>
<div class="preview">
<Mfm :text="preview_flip"/>
<MkTextarea v-model="preview_flip"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.font }}</div>
<div class="content">
<p>{{ $ts._mfm.fontDescription }}</p>
<div class="preview">
<Mfm :text="preview_font"/>
<MkTextarea v-model="preview_font"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.x2 }}</div>
<div class="content">
<p>{{ $ts._mfm.x2Description }}</p>
<div class="preview">
<Mfm :text="preview_x2"/>
<MkTextarea v-model="preview_x2"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.x3 }}</div>
<div class="content">
<p>{{ $ts._mfm.x3Description }}</p>
<div class="preview">
<Mfm :text="preview_x3"/>
<MkTextarea v-model="preview_x3"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.x4 }}</div>
<div class="content">
<p>{{ $ts._mfm.x4Description }}</p>
<div class="preview">
<Mfm :text="preview_x4"/>
<MkTextarea v-model="preview_x4"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.blur }}</div>
<div class="content">
<p>{{ $ts._mfm.blurDescription }}</p>
<div class="preview">
<Mfm :text="preview_blur"/>
<MkTextarea v-model="preview_blur"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.jelly }}</div>
<div class="content">
<p>{{ $ts._mfm.jellyDescription }}</p>
<div class="preview">
<Mfm :text="preview_jelly"/>
<MkTextarea v-model="preview_jelly"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.tada }}</div>
<div class="content">
<p>{{ $ts._mfm.tadaDescription }}</p>
<div class="preview">
<Mfm :text="preview_tada"/>
<MkTextarea v-model="preview_tada"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.jump }}</div>
<div class="content">
<p>{{ $ts._mfm.jumpDescription }}</p>
<div class="preview">
<Mfm :text="preview_jump"/>
<MkTextarea v-model="preview_jump"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.bounce }}</div>
<div class="content">
<p>{{ $ts._mfm.bounceDescription }}</p>
<div class="preview">
<Mfm :text="preview_bounce"/>
<MkTextarea v-model="preview_bounce"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.spin }}</div>
<div class="content">
<p>{{ $ts._mfm.spinDescription }}</p>
<div class="preview">
<Mfm :text="preview_spin"/>
<MkTextarea v-model="preview_spin"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.shake }}</div>
<div class="content">
<p>{{ $ts._mfm.shakeDescription }}</p>
<div class="preview">
<Mfm :text="preview_shake"/>
<MkTextarea v-model="preview_shake"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.twitch }}</div>
<div class="content">
<p>{{ $ts._mfm.twitchDescription }}</p>
<div class="preview">
<Mfm :text="preview_twitch"/>
<MkTextarea v-model="preview_twitch"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.rainbow }}</div>
<div class="content">
<p>{{ $ts._mfm.rainbowDescription }}</p>
<div class="preview">
<Mfm :text="preview_rainbow"/>
<MkTextarea v-model="preview_rainbow"><template #label>MFM</template></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.sparkle }}</div>
<div class="content">
<p>{{ $ts._mfm.sparkleDescription }}</p>
<div class="preview">
<Mfm :text="preview_sparkle"/>
<MkTextarea v-model="preview_sparkle"><span>MFM</span></MkTextarea>
</div>
</div>
</div>
<div class="section _block">
<div class="title">{{ $ts._mfm.rotate }}</div>
<div class="content">
<p>{{ $ts._mfm.rotateDescription }}</p>
<div class="preview">
<Mfm :text="preview_rotate"/>
<MkTextarea v-model="preview_rotate"><span>MFM</span></MkTextarea>
</div>
</div>
</div>
</div>
</MkStickyContainer> </MkStickyContainer>
</template> </template>
@ -306,35 +318,36 @@ import { definePageMetadata } from '@/scripts/page-metadata';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { instance } from '@/instance'; import { instance } from '@/instance';
const preview_mention = '@example'; let preview_mention = $ref('@example');
const preview_hashtag = '#test'; let preview_hashtag = $ref('#test');
const preview_url = 'https://example.com'; let preview_url = $ref('https://example.com');
const preview_link = `[${i18n.ts._mfm.dummy}](https://example.com)`; let preview_link = $ref(`[${i18n.ts._mfm.dummy}](https://example.com)`);
const preview_emoji = instance.emojis.length ? `:${instance.emojis[0].name}:` : ':emojiname:'; let preview_emoji = $ref(instance.emojis.length ? `:${instance.emojis[0].name}:` : ':emojiname:');
const preview_bold = `**${i18n.ts._mfm.dummy}**`; let preview_bold = $ref(`**${i18n.ts._mfm.dummy}**`);
const preview_small = `<small>${i18n.ts._mfm.dummy}</small>`; let preview_small = $ref(`<small>${i18n.ts._mfm.dummy}</small>`);
const preview_center = `<center>${i18n.ts._mfm.dummy}</center>`; let preview_center = $ref(`<center>${i18n.ts._mfm.dummy}</center>`);
const preview_inlineCode = '`<: "Hello, world!"`'; let preview_inlineCode = $ref('`<: "Hello, world!"`');
const preview_blockCode = '```\n~ (#i, 100) {\n\t<: ? ((i % 15) = 0) "FizzBuzz"\n\t\t.? ((i % 3) = 0) "Fizz"\n\t\t.? ((i % 5) = 0) "Buzz"\n\t\t. i\n}\n```'; let preview_blockCode = $ref('```\n~ (#i, 100) {\n\t<: ? ((i % 15) = 0) "FizzBuzz"\n\t\t.? ((i % 3) = 0) "Fizz"\n\t\t.? ((i % 5) = 0) "Buzz"\n\t\t. i\n}\n```');
const preview_inlineMath = '\\(x= \\frac{-b\' \\pm \\sqrt{(b\')^2-ac}}{a}\\)'; let preview_inlineMath = $ref('\\(x= \\frac{-b\' \\pm \\sqrt{(b\')^2-ac}}{a}\\)');
const preview_quote = `> ${i18n.ts._mfm.dummy}`; let preview_quote = $ref(`> ${i18n.ts._mfm.dummy}`);
const preview_search = `${i18n.ts._mfm.dummy} 検索`; let preview_search = $ref(`${i18n.ts._mfm.dummy} 検索`);
const preview_jelly = '$[jelly 🍮] $[jelly.speed=5s 🍮]'; let preview_jelly = $ref('$[jelly 🍮] $[jelly.speed=5s 🍮]');
const preview_tada = '$[tada 🍮] $[tada.speed=5s 🍮]'; let preview_tada = $ref('$[tada 🍮] $[tada.speed=5s 🍮]');
const preview_jump = '$[jump 🍮] $[jump.speed=5s 🍮]'; let preview_jump = $ref('$[jump 🍮] $[jump.speed=5s 🍮]');
const preview_bounce = '$[bounce 🍮] $[bounce.speed=5s 🍮]'; let preview_bounce = $ref('$[bounce 🍮] $[bounce.speed=5s 🍮]');
const preview_shake = '$[shake 🍮] $[shake.speed=5s 🍮]'; let preview_shake = $ref('$[shake 🍮] $[shake.speed=5s 🍮]');
const preview_twitch = '$[twitch 🍮] $[twitch.speed=5s 🍮]'; let preview_twitch = $ref('$[twitch 🍮] $[twitch.speed=5s 🍮]');
const preview_spin = '$[spin 🍮] $[spin.left 🍮] $[spin.alternate 🍮]\n$[spin.x 🍮] $[spin.x,left 🍮] $[spin.x,alternate 🍮]\n$[spin.y 🍮] $[spin.y,left 🍮] $[spin.y,alternate 🍮]\n\n$[spin.speed=5s 🍮]'; let preview_spin = $ref('$[spin 🍮] $[spin.left 🍮] $[spin.alternate 🍮]\n$[spin.x 🍮] $[spin.x,left 🍮] $[spin.x,alternate 🍮]\n$[spin.y 🍮] $[spin.y,left 🍮] $[spin.y,alternate 🍮]\n\n$[spin.speed=5s 🍮]');
const preview_flip = `$[flip ${i18n.ts._mfm.dummy}]\n$[flip.v ${i18n.ts._mfm.dummy}]\n$[flip.h,v ${i18n.ts._mfm.dummy}]`; let preview_flip = $ref(`$[flip ${i18n.ts._mfm.dummy}]\n$[flip.v ${i18n.ts._mfm.dummy}]\n$[flip.h,v ${i18n.ts._mfm.dummy}]`);
const preview_font = `$[font.serif ${i18n.ts._mfm.dummy}]\n$[font.monospace ${i18n.ts._mfm.dummy}]\n$[font.cursive ${i18n.ts._mfm.dummy}]\n$[font.fantasy ${i18n.ts._mfm.dummy}]`; let preview_font = $ref(`$[font.serif ${i18n.ts._mfm.dummy}]\n$[font.monospace ${i18n.ts._mfm.dummy}]\n$[font.cursive ${i18n.ts._mfm.dummy}]\n$[font.fantasy ${i18n.ts._mfm.dummy}]`);
const preview_x2 = '$[x2 🍮]'; let preview_x2 = $ref('$[x2 🍮]');
const preview_x3 = '$[x3 🍮]'; let preview_x3 = $ref('$[x3 🍮]');
const preview_x4 = '$[x4 🍮]'; let preview_x4 = $ref('$[x4 🍮]');
const preview_blur = `$[blur ${i18n.ts._mfm.dummy}]`; let preview_blur = $ref(`$[blur ${i18n.ts._mfm.dummy}]`);
const preview_rainbow = '$[rainbow 🍮] $[rainbow.speed=5s 🍮]'; let preview_rainbow = $ref('$[rainbow 🍮] $[rainbow.speed=5s 🍮]');
const preview_sparkle = '$[sparkle 🍮]'; let preview_sparkle = $ref('$[sparkle 🍮]');
const preview_rotate = '$[rotate 🍮]'; let preview_rotate = $ref('$[rotate 🍮]');
let preview_plain = $ref('<plain>**bold** @mention #hashtag `code` $[x2 🍮]</plain>');
definePageMetadata({ definePageMetadata({
title: i18n.ts._mfm.cheatSheet, title: i18n.ts._mfm.cheatSheet,

View file

@ -74,7 +74,7 @@ function fetchValue() {
async function save() { async function save() {
try { try {
JSON5.parse(valueForEditor); JSON5.parse(valueForEditor);
} catch (e) { } catch (err) {
os.alert({ os.alert({
type: 'error', type: 'error',
text: i18n.ts.invalidValue, text: i18n.ts.invalidValue,

View file

@ -10,7 +10,7 @@
</FormSection> </FormSection>
<FormSection> <FormSection>
<FormSwitch :value="$i.receiveAnnouncementEmail" @update:modelValue="onChangeReceiveAnnouncementEmail"> <FormSwitch :model-value="$i.receiveAnnouncementEmail" @update:modelValue="onChangeReceiveAnnouncementEmail">
{{ $ts.receiveAnnouncementFromInstance }} {{ $ts.receiveAnnouncementFromInstance }}
</FormSwitch> </FormSwitch>
</FormSection> </FormSection>

View file

@ -330,13 +330,11 @@ definePageMetadata(INFO);
width: 34%; width: 34%;
padding-right: 32px; padding-right: 32px;
box-sizing: border-box; box-sizing: border-box;
overflow: auto;
} }
> .main { > .main {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
overflow: auto;
} }
} }
} }

View file

@ -1,11 +1,11 @@
<template> <template>
<div class="_formRoot"> <div class="_formRoot">
<div class="llvierxe" :style="{ backgroundImage: $i.bannerUrl ? `url(${ $i.bannerUrl })` : null }"> <div class="llvierxe" :style="{ backgroundImage: $i.bannerUrl ? `url(${ $i.bannerUrl })` : null }">
<div class="avatar _acrylic"> <div class="avatar">
<MkAvatar class="avatar" :user="$i" :disable-link="true" @click="changeAvatar"/> <MkAvatar class="avatar" :user="$i" :disable-link="true" @click="changeAvatar"/>
<MkButton primary class="avatarEdit" @click="changeAvatar">{{ i18n.ts._profile.changeAvatar }}</MkButton> <MkButton primary rounded class="avatarEdit" @click="changeAvatar">{{ i18n.ts._profile.changeAvatar }}</MkButton>
</div> </div>
<MkButton primary class="bannerEdit" @click="changeBanner">{{ i18n.ts._profile.changeBanner }}</MkButton> <MkButton primary rounded class="bannerEdit" @click="changeBanner">{{ i18n.ts._profile.changeBanner }}</MkButton>
</div> </div>
<FormInput v-model="profile.name" :max="30" manual-save class="_formBlock"> <FormInput v-model="profile.name" :max="30" manual-save class="_formBlock">
@ -187,6 +187,7 @@ definePageMetadata({
position: relative; position: relative;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
border: solid 1px var(--divider);
border-radius: 10px; border-radius: 10px;
overflow: clip; overflow: clip;

View file

@ -6,7 +6,7 @@
<div v-if="user"> <div v-if="user">
<XFollowList :user="user" type="followers"/> <XFollowList :user="user" type="followers"/>
</div> </div>
<MkError v-else-if="error" @retry="fetch()"/> <MkError v-else-if="error" @retry="fetchUser()"/>
<MkLoading v-else/> <MkLoading v-else/>
</transition> </transition>
</MkSpacer> </MkSpacer>

View file

@ -6,7 +6,7 @@
<div v-if="user"> <div v-if="user">
<XFollowList :user="user" type="following"/> <XFollowList :user="user" type="following"/>
</div> </div>
<MkError v-else-if="error" @retry="fetch()"/> <MkError v-else-if="error" @retry="fetchUser()"/>
<MkLoading v-else/> <MkLoading v-else/>
</transition> </transition>
</MkSpacer> </MkSpacer>

View file

@ -10,7 +10,7 @@
<XPages v-else-if="tab === 'pages'" :user="user"/> <XPages v-else-if="tab === 'pages'" :user="user"/>
<XGallery v-else-if="tab === 'gallery'" :user="user"/> <XGallery v-else-if="tab === 'gallery'" :user="user"/>
</div> </div>
<MkError v-else-if="error" @retry="fetch()"/> <MkError v-else-if="error" @retry="fetchUser()"/>
<MkLoading v-else/> <MkLoading v-else/>
</transition> </transition>
</div> </div>

View file

@ -0,0 +1,158 @@
import { Ref } from 'vue';
export function calcPopupPosition(el: HTMLElement, props: {
anchorElement: HTMLElement | null;
innerMargin: number;
direction: 'top' | 'bottom' | 'left' | 'right';
align: 'top' | 'bottom' | 'left' | 'right' | 'center';
alignOffset?: number;
x?: number;
y?: number;
}): { top: number; left: number; transformOrigin: string; } {
const contentWidth = el.offsetWidth;
const contentHeight = el.offsetHeight;
let rect: DOMRect;
if (props.anchorElement) {
rect = props.anchorElement.getBoundingClientRect();
}
const calcPosWhenTop = () => {
let left: number;
let top: number;
if (props.anchorElement) {
left = rect.left + window.pageXOffset + (props.anchorElement.offsetWidth / 2);
top = (rect.top + window.pageYOffset - contentHeight) - props.innerMargin;
} else {
left = props.x;
top = (props.y - contentHeight) - props.innerMargin;
}
left -= (el.offsetWidth / 2);
if (left + contentWidth - window.pageXOffset > window.innerWidth) {
left = window.innerWidth - contentWidth + window.pageXOffset - 1;
}
return [left, top];
};
const calcPosWhenBottom = () => {
let left: number;
let top: number;
if (props.anchorElement) {
left = rect.left + window.pageXOffset + (props.anchorElement.offsetWidth / 2);
top = (rect.top + window.pageYOffset + props.anchorElement.offsetHeight) + props.innerMargin;
} else {
left = props.x;
top = (props.y) + props.innerMargin;
}
left -= (el.offsetWidth / 2);
if (left + contentWidth - window.pageXOffset > window.innerWidth) {
left = window.innerWidth - contentWidth + window.pageXOffset - 1;
}
return [left, top];
};
const calcPosWhenLeft = () => {
let left: number;
let top: number;
if (props.anchorElement) {
left = (rect.left + window.pageXOffset - contentWidth) - props.innerMargin;
top = rect.top + window.pageYOffset + (props.anchorElement.offsetHeight / 2);
} else {
left = (props.x - contentWidth) - props.innerMargin;
top = props.y;
}
top -= (el.offsetHeight / 2);
if (top + contentHeight - window.pageYOffset > window.innerHeight) {
top = window.innerHeight - contentHeight + window.pageYOffset - 1;
}
return [left, top];
};
const calcPosWhenRight = () => {
let left: number;
let top: number;
if (props.anchorElement) {
left = (rect.left + props.anchorElement.offsetWidth + window.pageXOffset) + props.innerMargin;
if (props.align === 'top') {
top = rect.top + window.pageYOffset;
if (props.alignOffset != null) top += props.alignOffset;
} else if (props.align === 'bottom') {
// TODO
} else { // center
top = rect.top + window.pageYOffset + (props.anchorElement.offsetHeight / 2);
top -= (el.offsetHeight / 2);
}
} else {
left = props.x + props.innerMargin;
top = props.y;
top -= (el.offsetHeight / 2);
}
if (top + contentHeight - window.pageYOffset > window.innerHeight) {
top = window.innerHeight - contentHeight + window.pageYOffset - 1;
}
return [left, top];
};
const calc = (): {
left: number;
top: number;
transformOrigin: string;
} => {
switch (props.direction) {
case 'top': {
const [left, top] = calcPosWhenTop();
// ツールチップを上に向かって表示するスペースがなければ下に向かって出す
if (top - window.pageYOffset < 0) {
const [left, top] = calcPosWhenBottom();
return { left, top, transformOrigin: 'center top' };
}
return { left, top, transformOrigin: 'center bottom' };
}
case 'bottom': {
const [left, top] = calcPosWhenBottom();
// TODO: ツールチップを下に向かって表示するスペースがなければ上に向かって出す
return { left, top, transformOrigin: 'center top' };
}
case 'left': {
const [left, top] = calcPosWhenLeft();
// ツールチップを左に向かって表示するスペースがなければ右に向かって出す
if (left - window.pageXOffset < 0) {
const [left, top] = calcPosWhenRight();
return { left, top, transformOrigin: 'left center' };
}
return { left, top, transformOrigin: 'right center' };
}
case 'right': {
const [left, top] = calcPosWhenRight();
// TODO: ツールチップを右に向かって表示するスペースがなければ左に向かって出す
return { left, top, transformOrigin: 'left center' };
}
}
};
return calc();
}

View file

@ -270,7 +270,7 @@ type Plugin = {
* () * ()
*/ */
import lightTheme from '@/themes/l-light.json5'; import lightTheme from '@/themes/l-light.json5';
import darkTheme from '@/themes/d-dark.json5'; import darkTheme from '@/themes/d-green-lime.json5';
export class ColdDeviceStorage { export class ColdDeviceStorage {
public static default = { public static default = {

View file

@ -11,10 +11,11 @@ export type MenuA = { type: 'a', href: string, target?: string, download?: strin
export type MenuUser = { type: 'user', user: Misskey.entities.User, active?: boolean, indicate?: boolean, action: MenuAction }; export type MenuUser = { type: 'user', user: Misskey.entities.User, active?: boolean, indicate?: boolean, action: MenuAction };
export type MenuSwitch = { type: 'switch', ref: Ref<boolean>, text: string, disabled?: boolean }; export type MenuSwitch = { type: 'switch', ref: Ref<boolean>, text: string, disabled?: boolean };
export type MenuButton = { type?: 'button', text: string, icon?: string, indicate?: boolean, danger?: boolean, active?: boolean, avatar?: Misskey.entities.User; action: MenuAction }; export type MenuButton = { type?: 'button', text: string, icon?: string, indicate?: boolean, danger?: boolean, active?: boolean, avatar?: Misskey.entities.User; action: MenuAction };
export type MenuParent = { type: 'parent', text: string, icon?: string, children: OuterMenuItem[] };
export type MenuPending = { type: 'pending' }; export type MenuPending = { type: 'pending' };
type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton; type OuterMenuItem = MenuDivider | MenuNull | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent;
type OuterPromiseMenuItem = Promise<MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton>; type OuterPromiseMenuItem = Promise<MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent>;
export type MenuItem = OuterMenuItem | OuterPromiseMenuItem; export type MenuItem = OuterMenuItem | OuterPromiseMenuItem;
export type InnerMenuItem = MenuDivider | MenuPending | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton; export type InnerMenuItem = MenuDivider | MenuPending | MenuLabel | MenuLink | MenuA | MenuUser | MenuSwitch | MenuButton | MenuParent;

View file

@ -1,5 +1,6 @@
<template> <template>
<component :is="popup.component" <component
:is="popup.component"
v-for="popup in popups" v-for="popup in popups"
:key="popup.id" :key="popup.id"
v-bind="popup.props" v-bind="popup.props"
@ -15,56 +16,45 @@
<div v-if="dev" id="devTicker"><span>DEV BUILD</span></div> <div v-if="dev" id="devTicker"><span>DEV BUILD</span></div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineAsyncComponent, defineComponent } from 'vue'; import { defineAsyncComponent } from 'vue';
import { swInject } from './sw-inject';
import { popup, popups, pendingApiRequestsCount } from '@/os'; import { popup, popups, pendingApiRequestsCount } from '@/os';
import { uploads } from '@/scripts/upload'; import { uploads } from '@/scripts/upload';
import * as sound from '@/scripts/sound'; import * as sound from '@/scripts/sound';
import { $i } from '@/account'; import { $i } from '@/account';
import { swInject } from './sw-inject';
import { stream } from '@/stream'; import { stream } from '@/stream';
export default defineComponent({ const XStreamIndicator = defineAsyncComponent(() => import('./stream-indicator.vue'));
components: { const XUpload = defineAsyncComponent(() => import('./upload.vue'));
XStreamIndicator: defineAsyncComponent(() => import('./stream-indicator.vue')),
XUpload: defineAsyncComponent(() => import('./upload.vue')),
},
setup() { const dev = _DEV_;
const onNotification = notification => {
if ($i.mutingNotificationTypes.includes(notification.type)) return;
if (document.visibilityState === 'visible') { const onNotification = notification => {
stream.send('readNotification', { if ($i.mutingNotificationTypes.includes(notification.type)) return;
id: notification.id
});
popup(defineAsyncComponent(() => import('@/components/notification-toast.vue')), { if (document.visibilityState === 'visible') {
notification stream.send('readNotification', {
}, {}, 'closed'); id: notification.id,
} });
sound.play('notification'); popup(defineAsyncComponent(() => import('@/components/notification-toast.vue')), {
}; notification,
}, {}, 'closed');
}
if ($i) { sound.play('notification');
const connection = stream.useChannel('main', null, 'UI'); };
connection.on('notification', onNotification);
//#region Listen message from SW if ($i) {
if ('serviceWorker' in navigator) { const connection = stream.useChannel('main', null, 'UI');
swInject(); connection.on('notification', onNotification);
}
}
return { //#region Listen message from SW
uploads, if ('serviceWorker' in navigator) {
popups, swInject();
pendingApiRequestsCount, }
dev: _DEV_, }
};
},
});
</script> </script>
<style lang="scss"> <style lang="scss">

View file

@ -87,6 +87,36 @@ function openInstanceMenu(ev: MouseEvent) {
text: i18n.ts.federation, text: i18n.ts.federation,
icon: 'fas fa-globe', icon: 'fas fa-globe',
to: '/about#federation', to: '/about#federation',
}, null, {
type: 'parent',
text: i18n.ts.help,
icon: 'fas fa-question-circle',
children: [{
type: 'link',
to: '/mfm-cheat-sheet',
text: i18n.ts._mfm.cheatSheet,
icon: 'fas fa-code',
}, {
type: 'link',
to: '/scratchpad',
text: i18n.ts.scratchpad,
icon: 'fas fa-terminal',
}, {
type: 'link',
to: '/api-console',
text: 'API Console',
icon: 'fas fa-terminal',
}, null, {
text: i18n.ts.document,
icon: 'fas fa-question-circle',
action: () => {
window.open('https://misskey-hub.net/help.html', '_blank');
},
}],
}, {
type: 'link',
text: i18n.ts.aboutMisskey,
to: '/about-misskey',
}], ev.currentTarget ?? ev.target, { }], ev.currentTarget ?? ev.target, {
align: 'left', align: 'left',
}); });

View file

@ -110,6 +110,36 @@ function openInstanceMenu(ev: MouseEvent) {
text: i18n.ts.federation, text: i18n.ts.federation,
icon: 'fas fa-globe', icon: 'fas fa-globe',
to: '/about#federation', to: '/about#federation',
}, null, {
type: 'parent',
text: i18n.ts.help,
icon: 'fas fa-question-circle',
children: [{
type: 'link',
to: '/mfm-cheat-sheet',
text: i18n.ts._mfm.cheatSheet,
icon: 'fas fa-code',
}, {
type: 'link',
to: '/scratchpad',
text: i18n.ts.scratchpad,
icon: 'fas fa-terminal',
}, {
type: 'link',
to: '/api-console',
text: 'API Console',
icon: 'fas fa-terminal',
}, null, {
text: i18n.ts.document,
icon: 'fas fa-question-circle',
action: () => {
window.open('https://misskey-hub.net/help.html', '_blank');
},
}],
}, {
type: 'link',
text: i18n.ts.aboutMisskey,
to: '/about-misskey',
}], ev.currentTarget ?? ev.target, { }], ev.currentTarget ?? ev.target, {
align: 'left', align: 'left',
}); });
@ -126,7 +156,7 @@ function more(ev: MouseEvent) {
<style lang="scss" scoped> <style lang="scss" scoped>
.mvcprjjd { .mvcprjjd {
$nav-width: 250px; $nav-width: 250px;
$nav-icon-only-width: 86px; $nav-icon-only-width: 80px;
flex: 0 0 $nav-width; flex: 0 0 $nav-width;
width: $nav-width; width: $nav-width;

View file

@ -128,31 +128,36 @@ function getMenu() {
if (canceled) return; if (canceled) return;
updateColumn(props.column.id, result); updateColumn(props.column.id, result);
}, },
}, null, {
icon: 'fas fa-arrow-left',
text: i18n.ts._deck.swapLeft,
action: () => {
swapLeftColumn(props.column.id);
},
}, { }, {
icon: 'fas fa-arrow-right', type: 'parent',
text: i18n.ts._deck.swapRight, text: i18n.ts.move + '...',
action: () => { icon: 'fas fa-arrows-up-down-left-right',
swapRightColumn(props.column.id); children: [{
}, icon: 'fas fa-arrow-left',
}, props.isStacked ? { text: i18n.ts._deck.swapLeft,
icon: 'fas fa-arrow-up', action: () => {
text: i18n.ts._deck.swapUp, swapLeftColumn(props.column.id);
action: () => { },
swapUpColumn(props.column.id); }, {
}, icon: 'fas fa-arrow-right',
} : undefined, props.isStacked ? { text: i18n.ts._deck.swapRight,
icon: 'fas fa-arrow-down', action: () => {
text: i18n.ts._deck.swapDown, swapRightColumn(props.column.id);
action: () => { },
swapDownColumn(props.column.id); }, props.isStacked ? {
}, icon: 'fas fa-arrow-up',
} : undefined, null, { text: i18n.ts._deck.swapUp,
action: () => {
swapUpColumn(props.column.id);
},
} : undefined, props.isStacked ? {
icon: 'fas fa-arrow-down',
text: i18n.ts._deck.swapDown,
action: () => {
swapDownColumn(props.column.id);
},
} : undefined],
}, {
icon: 'fas fa-window-restore', icon: 'fas fa-window-restore',
text: i18n.ts._deck.stackLeft, text: i18n.ts._deck.stackLeft,
action: () => { action: () => {

View file

@ -600,10 +600,10 @@
resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"
integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==
"@vitejs/plugin-vue@3.0.0": "@vitejs/plugin-vue@3.0.1":
version "3.0.0" version "3.0.1"
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-3.0.0.tgz#7081e2b3fbe04e291bb85107b9fb57a1fa5e6aeb" resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-3.0.1.tgz#b6af8f782485374bbb5fe09edf067a845bf4caae"
integrity sha512-yWP34ArFh/jAeNUDkkLz/kVRLjf5ppJiq4L36f64Cp6dIrMQeYZGDP9xxdemlXfZR9ylN9JgHUl3GzfqOtgYDg== integrity sha512-Ll9JgxG7ONIz/XZv3dssfoMUDu9qAnlJ+km+pBA0teYSXzwPCIzS/e1bmwNYl5dcQGs677D21amgfYAnzMl17A==
"@vue/compiler-core@3.2.37": "@vue/compiler-core@3.2.37":
version "3.2.37" version "3.2.37"
@ -4222,10 +4222,10 @@ verror@1.10.0:
core-util-is "1.0.2" core-util-is "1.0.2"
extsprintf "^1.2.0" extsprintf "^1.2.0"
vite@3.0.0: vite@3.0.2:
version "3.0.0" version "3.0.2"
resolved "https://registry.yarnpkg.com/vite/-/vite-3.0.0.tgz#b4675cb9ab83ec0803b9c952ffa6519bcce033a7" resolved "https://registry.yarnpkg.com/vite/-/vite-3.0.2.tgz#2a7b4642c53ae066cf724e7e581d6c1fd24e2c32"
integrity sha512-M7phQhY3+fRZa0H+1WzI6N+/onruwPTBTMvaj7TzgZ0v2TE+N2sdLKxJOfOv9CckDWt5C4HmyQP81xB4dwRKzA== integrity sha512-TAqydxW/w0U5AoL5AsD9DApTvGb2iNbGs3sN4u2VdT1GFkQVUfgUldt+t08TZgi23uIauh1TUOQJALduo9GXqw==
dependencies: dependencies:
esbuild "^0.14.47" esbuild "^0.14.47"
postcss "^8.4.14" postcss "^8.4.14"