wip
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
*/
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import type { EmbedParams, EmbeddableEntity } from '@/scripts/embed-page.js';
|
||||
import { url } from '@/config.js';
|
||||
import * as os from '@/os.js';
|
||||
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
|
||||
import type { EmbedParams, EmbeddableEntity } from '@/scripts/embed-page.js';
|
||||
import { defaultEmbedParams, embedRouteWithScrollbar } from '@/scripts/embed-page.js';
|
||||
|
||||
const MOBILE_THRESHOLD = 500;
|
||||
@@ -64,7 +64,7 @@ export function getEmbedCode(path: string, params?: EmbedParams): string {
|
||||
*
|
||||
* カスタマイズ機能がいらない場合(事前にパラメータを指定する場合)は getEmbedCode を直接使ってください
|
||||
*/
|
||||
export function copyEmbedCode(entity: EmbeddableEntity, idOrUsername: string, params?: EmbedParams) {
|
||||
export function genEmbedCode(entity: EmbeddableEntity, id: string, params?: EmbedParams) {
|
||||
const _params = { ...params };
|
||||
|
||||
if (embedRouteWithScrollbar.includes(entity) && _params.maxHeight == null) {
|
||||
@@ -73,13 +73,12 @@ export function copyEmbedCode(entity: EmbeddableEntity, idOrUsername: string, pa
|
||||
|
||||
// PCじゃない場合はコードカスタマイズ画面を出さずにそのままコピー
|
||||
if (window.innerWidth < MOBILE_THRESHOLD) {
|
||||
const _idOrUsername = entity === 'user-timeline' ? `@${idOrUsername}` : idOrUsername;
|
||||
copyToClipboard(getEmbedCode(`/embed/${entity}/${_idOrUsername}`, _params));
|
||||
copyToClipboard(getEmbedCode(`/embed/${entity}/${id}`, _params));
|
||||
os.success();
|
||||
} else {
|
||||
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkEmbedCodeGenDialog.vue')), {
|
||||
entity,
|
||||
idOrUsername,
|
||||
id,
|
||||
params: _params,
|
||||
}, {
|
||||
closed: () => dispose(),
|
||||
|
@@ -21,7 +21,7 @@ import { MenuItem } from '@/types/menu.js';
|
||||
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
||||
import { isSupportShare } from '@/scripts/navigator.js';
|
||||
import { getAppearNote } from '@/scripts/get-appear-note.js';
|
||||
import { copyEmbedCode } from '@/scripts/get-embed-code.js';
|
||||
import { genEmbedCode } from '@/scripts/get-embed-code.js';
|
||||
|
||||
export async function getNoteClipMenu(props: {
|
||||
note: Misskey.entities.Note;
|
||||
@@ -165,7 +165,7 @@ function getNoteEmbedCodeMenu(note: Misskey.entities.Note, text: string): MenuIt
|
||||
icon: 'ti ti-code',
|
||||
text,
|
||||
action: (): void => {
|
||||
copyEmbedCode('notes', note.id);
|
||||
genEmbedCode('notes', note.id);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -324,7 +324,7 @@ export function getNoteMenu(props: {
|
||||
action: () => {
|
||||
window.open(appearNote.url ?? appearNote.uri, '_blank', 'noopener');
|
||||
},
|
||||
} : getNoteEmbedCodeMenu(appearNote, i18n.ts.copyEmbedCode),
|
||||
} : getNoteEmbedCodeMenu(appearNote, i18n.ts.genEmbedCode),
|
||||
...(isSupportShare() ? [{
|
||||
icon: 'ti ti-share',
|
||||
text: i18n.ts.share,
|
||||
@@ -464,7 +464,7 @@ export function getNoteMenu(props: {
|
||||
action: () => {
|
||||
window.open(appearNote.url ?? appearNote.uri, '_blank', 'noopener');
|
||||
},
|
||||
} : getNoteEmbedCodeMenu(appearNote, i18n.ts.copyEmbedCode)]
|
||||
} : getNoteEmbedCodeMenu(appearNote, i18n.ts.genEmbedCode)]
|
||||
.filter(x => x !== undefined);
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ import { notesSearchAvailable, canSearchNonLocalNotes } from '@/scripts/check-pe
|
||||
import { IRouter } from '@/nirax.js';
|
||||
import { antennasCache, rolesCache, userListsCache } from '@/cache.js';
|
||||
import { mainRouter } from '@/router/main.js';
|
||||
import { copyEmbedCode } from '@/scripts/get-embed-code.js';
|
||||
import { genEmbedCode } from '@/scripts/get-embed-code.js';
|
||||
import { MenuItem } from '@/types/menu.js';
|
||||
|
||||
export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter = mainRouter) {
|
||||
@@ -182,12 +182,12 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
|
||||
},
|
||||
}] : [{
|
||||
icon: 'ti ti-code',
|
||||
text: i18n.ts.copyEmbedCode,
|
||||
text: i18n.ts.genEmbedCode,
|
||||
type: 'parent' as const,
|
||||
children: [{
|
||||
text: i18n.ts.noteOfThisUser,
|
||||
action: () => {
|
||||
copyEmbedCode('user-timeline', user.username);
|
||||
genEmbedCode('user-timeline', user.id);
|
||||
},
|
||||
}], // TODO: ユーザーカードの埋め込みなど
|
||||
}]), {
|
||||
|
Reference in New Issue
Block a user