2018-02-27 06:50:03 +01:00
|
|
|
<div class="compose-box-toolbar">
|
2018-03-25 03:04:54 +02:00
|
|
|
<div class="compose-box-toolbar-items">
|
|
|
|
<IconButton
|
2019-05-29 07:24:22 +02:00
|
|
|
className="compose-toolbar-button"
|
2020-11-29 23:13:27 +01:00
|
|
|
label="{intl.addEmoji}"
|
2018-03-25 03:04:54 +02:00
|
|
|
href="#fa-smile"
|
|
|
|
on:click="onEmojiClick()"
|
|
|
|
/>
|
|
|
|
<IconButton
|
2019-05-29 07:24:22 +02:00
|
|
|
className="compose-toolbar-button"
|
2018-05-02 02:05:36 +02:00
|
|
|
svgClassName={$uploadingMedia ? 'spin' : ''}
|
2020-11-29 23:13:27 +01:00
|
|
|
label="{intl.addMedia}"
|
2018-05-02 02:05:36 +02:00
|
|
|
href={$uploadingMedia ? '#fa-spinner' : '#fa-camera'}
|
2018-03-25 03:04:54 +02:00
|
|
|
on:click="onMediaClick()"
|
2018-05-02 02:05:36 +02:00
|
|
|
disabled={$uploadingMedia || (media.length === 4)}
|
2018-03-25 03:04:54 +02:00
|
|
|
/>
|
2019-05-27 09:24:47 +02:00
|
|
|
<IconButton
|
2019-05-29 07:24:22 +02:00
|
|
|
className="compose-toolbar-button"
|
2020-11-29 23:13:27 +01:00
|
|
|
label="{intl.addPoll}"
|
|
|
|
pressedLabel="{intl.removePoll}"
|
2019-05-27 09:24:47 +02:00
|
|
|
href="#fa-bar-chart"
|
|
|
|
on:click="onPollClick()"
|
2019-11-23 20:25:36 +01:00
|
|
|
pressable={true}
|
2019-05-27 09:24:47 +02:00
|
|
|
pressed={poll && poll.options && poll.options.length}
|
|
|
|
/>
|
2018-03-25 03:04:54 +02:00
|
|
|
<IconButton
|
2019-05-29 07:24:22 +02:00
|
|
|
className="compose-toolbar-button"
|
2020-11-29 23:13:27 +01:00
|
|
|
label={postPrivacyLabel}
|
2018-05-02 02:05:36 +02:00
|
|
|
href={postPrivacy.icon}
|
2018-03-25 03:04:54 +02:00
|
|
|
on:click="onPostPrivacyClick()"
|
|
|
|
/>
|
|
|
|
<IconButton
|
2019-05-29 07:24:22 +02:00
|
|
|
className="compose-toolbar-button"
|
2020-11-29 23:13:27 +01:00
|
|
|
label="{intl.addContentWarning}"
|
|
|
|
pressedLabel="{intl.removeContentWarning}"
|
2018-03-25 03:04:54 +02:00
|
|
|
href="#fa-exclamation-triangle"
|
|
|
|
on:click="onContentWarningClick()"
|
2019-11-23 20:25:36 +01:00
|
|
|
pressable={true}
|
2018-05-02 02:05:36 +02:00
|
|
|
pressed={contentWarningShown}
|
2018-03-25 03:04:54 +02:00
|
|
|
/>
|
|
|
|
</div>
|
2018-03-01 18:02:42 +01:00
|
|
|
<input ref:input
|
2018-03-01 18:29:11 +01:00
|
|
|
on:change="onFileChange(event)"
|
2018-03-01 18:02:42 +01:00
|
|
|
style="display: none;"
|
|
|
|
type="file"
|
2019-09-08 20:07:20 +02:00
|
|
|
multiple
|
2018-12-15 11:06:12 +01:00
|
|
|
accept={mediaAccept} >
|
2018-02-27 06:50:03 +01:00
|
|
|
</div>
|
|
|
|
<style>
|
|
|
|
.compose-box-toolbar {
|
|
|
|
grid-area: toolbar;
|
|
|
|
align-self: center;
|
2018-03-25 03:04:54 +02:00
|
|
|
}
|
|
|
|
.compose-box-toolbar-items {
|
2018-02-27 06:50:03 +01:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
2019-05-29 07:24:22 +02:00
|
|
|
|
|
|
|
@media (max-width: 320px) {
|
|
|
|
:global(button.icon-button.compose-toolbar-button) {
|
2019-06-01 23:27:50 +02:00
|
|
|
padding-left: 5px;
|
|
|
|
padding-right: 5px;
|
2019-05-29 07:24:22 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-21 22:45:48 +02:00
|
|
|
@media (max-width: 240px) {
|
|
|
|
:global(button.icon-button.compose-toolbar-button .icon-button-svg) {
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
}
|
|
|
|
}
|
2018-02-27 06:50:03 +01:00
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
import IconButton from '../IconButton.html'
|
2021-07-05 05:19:04 +02:00
|
|
|
import { store } from '../../_store/store.js'
|
|
|
|
import { importShowEmojiDialog } from '../dialog/asyncDialogs/importShowEmojiDialog.js'
|
|
|
|
import { importShowPostPrivacyDialog } from '../dialog/asyncDialogs/importShowPostPrivacyDialog.js'
|
|
|
|
import { doMediaUpload } from '../../_actions/media.js'
|
|
|
|
import { toggleContentWarningShown } from '../../_actions/contentWarnings.js'
|
|
|
|
import { mediaAccept } from '../../_static/media.js'
|
|
|
|
import { enablePoll, disablePoll } from '../../_actions/composePoll.js'
|
|
|
|
import { updateCustomEmojiForInstance } from '../../_actions/emoji.js'
|
|
|
|
import { formatIntl } from '../../_utils/formatIntl.js'
|
2018-02-28 08:18:07 +01:00
|
|
|
|
2018-02-27 06:50:03 +01:00
|
|
|
export default {
|
|
|
|
components: {
|
2019-05-06 17:34:03 +02:00
|
|
|
IconButton
|
2018-02-28 08:18:07 +01:00
|
|
|
},
|
2018-12-15 11:06:12 +01:00
|
|
|
data: () => ({
|
|
|
|
mediaAccept
|
|
|
|
}),
|
2020-11-29 23:13:27 +01:00
|
|
|
computed: {
|
|
|
|
postPrivacyLabel: ({ postPrivacy }) => (
|
|
|
|
formatIntl('intl.postPrivacyLabel', { label: postPrivacy.label })
|
|
|
|
)
|
|
|
|
},
|
2018-02-28 08:18:07 +01:00
|
|
|
store: () => store,
|
|
|
|
methods: {
|
2018-04-20 06:38:01 +02:00
|
|
|
async onEmojiClick () {
|
2019-08-03 22:49:37 +02:00
|
|
|
const { realm } = this.get()
|
2019-08-30 04:15:30 +02:00
|
|
|
const { currentInstance } = this.store.get()
|
|
|
|
const [showEmojiDialog] = await Promise.all([
|
|
|
|
importShowEmojiDialog(),
|
|
|
|
updateCustomEmojiForInstance(currentInstance)
|
|
|
|
])
|
2018-04-21 18:56:53 +02:00
|
|
|
showEmojiDialog(realm)
|
2018-03-01 18:02:42 +01:00
|
|
|
},
|
2018-04-20 06:38:01 +02:00
|
|
|
onMediaClick () {
|
2018-03-01 18:02:42 +01:00
|
|
|
this.refs.input.click()
|
2018-03-01 18:29:11 +01:00
|
|
|
},
|
2019-09-08 20:07:20 +02:00
|
|
|
async onFileChange (e) {
|
|
|
|
const { files } = e.target
|
2019-08-03 22:49:37 +02:00
|
|
|
const { realm } = this.get()
|
2019-09-08 20:07:20 +02:00
|
|
|
for (const file of files) {
|
|
|
|
await doMediaUpload(realm, file)
|
|
|
|
}
|
2018-03-03 22:23:26 +01:00
|
|
|
},
|
2018-04-20 06:38:01 +02:00
|
|
|
async onPostPrivacyClick () {
|
2019-08-03 22:49:37 +02:00
|
|
|
const { realm } = this.get()
|
|
|
|
const showPostPrivacyDialog = await importShowPostPrivacyDialog()
|
2018-04-21 18:56:53 +02:00
|
|
|
showPostPrivacyDialog(realm)
|
2018-03-04 00:44:43 +01:00
|
|
|
},
|
2018-04-20 06:38:01 +02:00
|
|
|
onContentWarningClick () {
|
2019-08-03 22:49:37 +02:00
|
|
|
const { realm } = this.get()
|
2018-04-19 18:37:05 +02:00
|
|
|
toggleContentWarningShown(realm)
|
2019-05-27 09:24:47 +02:00
|
|
|
},
|
|
|
|
onPollClick () {
|
2019-08-03 22:49:37 +02:00
|
|
|
const { poll, realm } = this.get()
|
2019-05-27 09:24:47 +02:00
|
|
|
if (poll && poll.options && poll.options.length) {
|
|
|
|
disablePoll(realm)
|
|
|
|
} else {
|
|
|
|
enablePoll(realm)
|
|
|
|
}
|
2018-02-28 08:18:07 +01:00
|
|
|
}
|
2018-02-27 06:50:03 +01:00
|
|
|
}
|
|
|
|
}
|
2018-12-15 11:06:12 +01:00
|
|
|
</script>
|