diff --git a/bin/svgs.js b/bin/svgs.js index 933d58fb..1f046974 100644 --- a/bin/svgs.js +++ b/bin/svgs.js @@ -52,5 +52,6 @@ module.exports = [ { id: 'fa-clock', src: 'src/thirdparty/font-awesome-svg-png/white/svg/clock-o.svg' }, { id: 'fa-refresh', src: 'src/thirdparty/font-awesome-svg-png/white/svg/refresh.svg' }, { id: 'fa-plus', src: 'src/thirdparty/font-awesome-svg-png/white/svg/plus.svg' }, - { id: 'fa-info-circle', src: 'src/thirdparty/font-awesome-svg-png/white/svg/info-circle.svg' } + { id: 'fa-info-circle', src: 'src/thirdparty/font-awesome-svg-png/white/svg/info-circle.svg' }, + { id: 'fa-crosshairs', src: 'src/thirdparty/font-awesome-svg-png/white/svg/crosshairs.svg' } ] diff --git a/package.json b/package.json index f3f484bb..f458a11e 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@babel/core": "^7.5.0", "@gamestdio/websocket": "^0.3.2", "@webcomponents/custom-elements": "^1.2.4", + "@wessberg/pointer-events": "^1.0.9", "babel-loader": "^8.0.6", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "cheerio": "^1.0.0-rc.2", diff --git a/src/routes/_actions/compose.js b/src/routes/_actions/compose.js index a97b8745..0dcd7fcb 100644 --- a/src/routes/_actions/compose.js +++ b/src/routes/_actions/compose.js @@ -4,7 +4,7 @@ import { postStatus as postStatusToServer } from '../_api/statuses' import { addStatusOrNotification } from './addStatusOrNotification' import { database } from '../_database/database' import { emit } from '../_utils/eventBus' -import { putMediaDescription } from '../_api/media' +import { putMediaMetadata } from '../_api/media' export async function insertHandleForReply (statusId) { let { currentInstance } = store.get() @@ -22,7 +22,7 @@ export async function insertHandleForReply (statusId) { export async function postStatus (realm, text, inReplyToId, mediaIds, sensitive, spoilerText, visibility, - mediaDescriptions, inReplyToUuid, poll) { + mediaDescriptions, inReplyToUuid, poll, mediaFocalPoints) { let { currentInstance, accessToken, online } = store.get() if (!online) { @@ -31,17 +31,27 @@ export async function postStatus (realm, text, inReplyToId, mediaIds, } text = text || '' - mediaDescriptions = mediaDescriptions || [] - store.set({ - postingStatus: true + let mediaMetadata = (mediaIds || []).map((mediaId, idx) => { + return { + description: mediaDescriptions && mediaDescriptions[idx], + focalPoint: mediaFocalPoints && mediaFocalPoints[idx] + } }) + + store.set({ postingStatus: true }) try { - await Promise.all(mediaDescriptions.map(async (description, i) => { - return description && putMediaDescription(currentInstance, accessToken, mediaIds[i], description) + await Promise.all(mediaMetadata.map(async ({ description, focalPoint }, i) => { + description = description || '' + focalPoint = focalPoint || [0, 0] + focalPoint[0] = focalPoint[0] || 0 + focalPoint[1] = focalPoint[1] || 0 + if (description || focalPoint[0] || focalPoint[1]) { + return putMediaMetadata(currentInstance, accessToken, mediaIds[i], description, focalPoint) + } })) let status = await postStatusToServer(currentInstance, accessToken, text, - inReplyToId, mediaIds, sensitive, spoilerText, visibility, poll) + inReplyToId, mediaIds, sensitive, spoilerText, visibility, poll, mediaFocalPoints) addStatusOrNotification(currentInstance, 'home', status) store.clearComposeData(realm) emit('postedStatus', realm, inReplyToUuid) diff --git a/src/routes/_api/media.js b/src/routes/_api/media.js index 370cd448..c06dd40a 100644 --- a/src/routes/_api/media.js +++ b/src/routes/_api/media.js @@ -11,7 +11,7 @@ export async function uploadMedia (instanceName, accessToken, file, description) return post(url, formData, auth(accessToken), { timeout: MEDIA_WRITE_TIMEOUT }) } -export async function putMediaDescription (instanceName, accessToken, mediaId, description) { +export async function putMediaMetadata (instanceName, accessToken, mediaId, description, focus) { let url = `${basename(instanceName)}/api/v1/media/${mediaId}` - return put(url, { description }, auth(accessToken), { timeout: WRITE_TIMEOUT }) + return put(url, { description, focus: (focus && focus.join(',')) }, auth(accessToken), { timeout: WRITE_TIMEOUT }) } diff --git a/src/routes/_components/Draggable.html b/src/routes/_components/Draggable.html new file mode 100644 index 00000000..56882678 --- /dev/null +++ b/src/routes/_components/Draggable.html @@ -0,0 +1,102 @@ +