mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-21 16:55:25 +03:00
Merge pull request #735 from Steffo99/feature/paste-attach
Allow pasting attachments on Akkoma / Pleroma instances
This commit is contained in:
commit
29822cbf2d
3 changed files with 127 additions and 107 deletions
|
@ -197,6 +197,7 @@ function highlightText(text, { maxCharacters = Infinity }) {
|
|||
|
||||
// const rtf = new Intl.RelativeTimeFormat();
|
||||
const RTF = mem((locale) => new Intl.RelativeTimeFormat(locale || undefined));
|
||||
const LF = mem((locale) => new Intl.ListFormat(locale || undefined));
|
||||
|
||||
const CUSTOM_EMOJIS_COUNT = 100;
|
||||
|
||||
|
@ -210,6 +211,7 @@ function Compose({
|
|||
}) {
|
||||
const { i18n } = useLingui();
|
||||
const rtf = RTF(i18n.locale);
|
||||
const lf = LF(i18n.locale);
|
||||
|
||||
console.warn('RENDER COMPOSER');
|
||||
const { masto, instance } = api();
|
||||
|
@ -226,11 +228,11 @@ function Compose({
|
|||
const {
|
||||
statuses: {
|
||||
maxCharacters,
|
||||
maxMediaAttachments,
|
||||
maxMediaAttachments, // Beware: it can be undefined!
|
||||
charactersReservedPerUrl,
|
||||
} = {},
|
||||
mediaAttachments: {
|
||||
supportedMimeTypes = [],
|
||||
supportedMimeTypes,
|
||||
imageSizeLimit,
|
||||
imageMatrixLimit,
|
||||
videoSizeLimit,
|
||||
|
@ -600,15 +602,26 @@ function Compose({
|
|||
const handleItems = (e) => {
|
||||
const { items } = e.clipboardData || e.dataTransfer;
|
||||
const files = [];
|
||||
const unsupportedFiles = [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
if (item.kind === 'file') {
|
||||
const file = item.getAsFile();
|
||||
if (file && supportedMimeTypes.includes(file.type)) {
|
||||
if (supportedMimeTypes !== undefined && !supportedMimeTypes.includes(file.type)) {
|
||||
unsupportedFiles.push(file);
|
||||
} else {
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (unsupportedFiles.length > 0) {
|
||||
alert(
|
||||
plural(unsupportedFiles.length, {
|
||||
one: `File ${unsupportedFiles[0].name} is not supported.`,
|
||||
other: `Files ${lf.format(unsupportedFiles.map(f => f.name))} are not supported.`,
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (files.length > 0 && mediaAttachments.length >= maxMediaAttachments) {
|
||||
alert(
|
||||
plural(maxMediaAttachments, {
|
||||
|
@ -623,8 +636,10 @@ function Compose({
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// Auto-cut-off files to avoid exceeding maxMediaAttachments
|
||||
let allowedFiles = files;
|
||||
if(maxMediaAttachments !== undefined) {
|
||||
const max = maxMediaAttachments - mediaAttachments.length;
|
||||
const allowedFiles = files.slice(0, max);
|
||||
allowedFiles = allowedFiles.slice(0, max);
|
||||
if(allowedFiles.length <= 0) {
|
||||
alert(
|
||||
plural(maxMediaAttachments, {
|
||||
|
@ -634,6 +649,7 @@ function Compose({
|
|||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const mediaFiles = allowedFiles.map((file) => ({
|
||||
file,
|
||||
type: file.type,
|
||||
|
@ -1307,8 +1323,8 @@ function Compose({
|
|||
<label class="toolbar-button">
|
||||
<input
|
||||
type="file"
|
||||
accept={supportedMimeTypes.join(',')}
|
||||
multiple={mediaAttachments.length < maxMediaAttachments - 1}
|
||||
accept={supportedMimeTypes?.join(',')}
|
||||
multiple={(maxMediaAttachments === undefined) || (maxMediaAttachments - mediaAttachments >= 2)}
|
||||
disabled={
|
||||
uiState === 'loading' ||
|
||||
mediaAttachments.length >= maxMediaAttachments ||
|
||||
|
@ -1400,7 +1416,7 @@ function Compose({
|
|||
class="toolbar-button gif-picker-button"
|
||||
disabled={
|
||||
uiState === 'loading' ||
|
||||
mediaAttachments.length >= maxMediaAttachments ||
|
||||
(maxMediaAttachments !== undefined && mediaAttachments.length >= maxMediaAttachments) ||
|
||||
!!poll
|
||||
}
|
||||
onClick={() => {
|
||||
|
|
184
src/locales/en.po
generated
184
src/locales/en.po
generated
|
@ -105,7 +105,7 @@ msgstr ""
|
|||
|
||||
#: src/components/account-info.jsx:427
|
||||
#: src/components/account-info.jsx:1115
|
||||
#: src/components/compose.jsx:2463
|
||||
#: src/components/compose.jsx:2479
|
||||
#: src/components/media-alt-modal.jsx:45
|
||||
#: src/components/media-modal.jsx:283
|
||||
#: src/components/status.jsx:1703
|
||||
|
@ -400,11 +400,11 @@ msgstr ""
|
|||
#: src/components/account-info.jsx:1989
|
||||
#: src/components/account-info.jsx:2089
|
||||
#: src/components/account-sheet.jsx:37
|
||||
#: src/components/compose.jsx:797
|
||||
#: src/components/compose.jsx:2419
|
||||
#: src/components/compose.jsx:2892
|
||||
#: src/components/compose.jsx:3100
|
||||
#: src/components/compose.jsx:3330
|
||||
#: src/components/compose.jsx:813
|
||||
#: src/components/compose.jsx:2435
|
||||
#: src/components/compose.jsx:2908
|
||||
#: src/components/compose.jsx:3116
|
||||
#: src/components/compose.jsx:3346
|
||||
#: src/components/drafts.jsx:58
|
||||
#: src/components/embed-modal.jsx:12
|
||||
#: src/components/generic-accounts.jsx:142
|
||||
|
@ -541,135 +541,139 @@ msgstr ""
|
|||
msgid "Compose"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:392
|
||||
#: src/components/compose.jsx:394
|
||||
msgid "You have unsaved changes. Discard this post?"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:614
|
||||
#: src/components/compose.jsx:630
|
||||
#: src/components/compose.jsx:1337
|
||||
#: src/components/compose.jsx:1598
|
||||
#: src/components/compose.jsx:619
|
||||
msgid "{0, plural, one {File {1} is not supported.} other {Files {2} are not supported.}}"
|
||||
msgstr "{0, plural, one {File {1} is not supported.} other {Files {2} are not supported.}}"
|
||||
|
||||
#: src/components/compose.jsx:627
|
||||
#: src/components/compose.jsx:645
|
||||
#: src/components/compose.jsx:1353
|
||||
#: src/components/compose.jsx:1614
|
||||
msgid "{maxMediaAttachments, plural, one {You can only attach up to 1 file.} other {You can only attach up to # files.}}"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:778
|
||||
#: src/components/compose.jsx:794
|
||||
msgid "Pop out"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:785
|
||||
#: src/components/compose.jsx:801
|
||||
msgid "Minimize"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:821
|
||||
#: src/components/compose.jsx:837
|
||||
msgid "Looks like you closed the parent window."
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:828
|
||||
#: src/components/compose.jsx:844
|
||||
msgid "Looks like you already have a compose field open in the parent window and currently publishing. Please wait for it to be done and try again later."
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:833
|
||||
#: src/components/compose.jsx:849
|
||||
msgid "Looks like you already have a compose field open in the parent window. Popping in this window will discard the changes you made in the parent window. Continue?"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:875
|
||||
#: src/components/compose.jsx:891
|
||||
msgid "Pop in"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:885
|
||||
#: src/components/compose.jsx:901
|
||||
msgid "Replying to @{0}’s post (<0>{1}</0>)"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:895
|
||||
#: src/components/compose.jsx:911
|
||||
msgid "Replying to @{0}’s post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:908
|
||||
#: src/components/compose.jsx:924
|
||||
msgid "Editing source post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:955
|
||||
#: src/components/compose.jsx:971
|
||||
msgid "Poll must have at least 2 options"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:959
|
||||
#: src/components/compose.jsx:975
|
||||
msgid "Some poll choices are empty"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:972
|
||||
#: src/components/compose.jsx:988
|
||||
msgid "Some media have no descriptions. Continue?"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1024
|
||||
#: src/components/compose.jsx:1040
|
||||
msgid "Attachment #{i} failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1118
|
||||
#: src/components/compose.jsx:1134
|
||||
#: src/components/status.jsx:2029
|
||||
#: src/components/timeline.jsx:984
|
||||
msgid "Content warning"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1134
|
||||
#: src/components/compose.jsx:1150
|
||||
msgid "Content warning or sensitive media"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1170
|
||||
#: src/components/compose.jsx:1186
|
||||
#: src/components/status.jsx:93
|
||||
#: src/pages/settings.jsx:304
|
||||
msgid "Public"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1175
|
||||
#: src/components/compose.jsx:1191
|
||||
#: src/components/nav-menu.jsx:386
|
||||
#: src/components/shortcuts-settings.jsx:162
|
||||
#: src/components/status.jsx:94
|
||||
msgid "Local"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1179
|
||||
#: src/components/compose.jsx:1195
|
||||
#: src/components/status.jsx:95
|
||||
#: src/pages/settings.jsx:307
|
||||
msgid "Unlisted"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1182
|
||||
#: src/components/compose.jsx:1198
|
||||
#: src/components/status.jsx:96
|
||||
#: src/pages/settings.jsx:310
|
||||
msgid "Followers only"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1185
|
||||
#: src/components/compose.jsx:1201
|
||||
#: src/components/status.jsx:97
|
||||
#: src/components/status.jsx:1907
|
||||
msgid "Private mention"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1194
|
||||
#: src/components/compose.jsx:1210
|
||||
msgid "Post your reply"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1196
|
||||
#: src/components/compose.jsx:1212
|
||||
msgid "Edit your post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1197
|
||||
#: src/components/compose.jsx:1213
|
||||
msgid "What are you doing?"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1275
|
||||
#: src/components/compose.jsx:1291
|
||||
msgid "Mark media as sensitive"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1373
|
||||
#: src/components/compose.jsx:1389
|
||||
msgid "Add poll"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1395
|
||||
#: src/components/compose.jsx:1411
|
||||
msgid "Add custom emoji"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1479
|
||||
#: src/components/compose.jsx:1495
|
||||
#: src/components/keyboard-shortcuts-help.jsx:143
|
||||
#: src/components/status.jsx:895
|
||||
#: src/components/status.jsx:1683
|
||||
|
@ -678,195 +682,195 @@ msgstr ""
|
|||
msgid "Reply"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1481
|
||||
#: src/components/compose.jsx:1497
|
||||
msgid "Update"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1482
|
||||
#: src/components/compose.jsx:1498
|
||||
msgctxt "Submit button in composer"
|
||||
msgid "Post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1610
|
||||
#: src/components/compose.jsx:1626
|
||||
msgid "Downloading GIF…"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1638
|
||||
#: src/components/compose.jsx:1654
|
||||
msgid "Failed to download GIF"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:1750
|
||||
#: src/components/compose.jsx:1827
|
||||
#: src/components/compose.jsx:1766
|
||||
#: src/components/compose.jsx:1843
|
||||
#: src/components/nav-menu.jsx:287
|
||||
msgid "More…"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2232
|
||||
#: src/components/compose.jsx:2248
|
||||
msgid "Uploaded"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2245
|
||||
#: src/components/compose.jsx:2261
|
||||
msgid "Image description"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2246
|
||||
#: src/components/compose.jsx:2262
|
||||
msgid "Video description"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2247
|
||||
#: src/components/compose.jsx:2263
|
||||
msgid "Audio description"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2283
|
||||
#: src/components/compose.jsx:2303
|
||||
#: src/components/compose.jsx:2299
|
||||
#: src/components/compose.jsx:2319
|
||||
msgid "File size too large. Uploading might encounter issues. Try reduce the file size from {0} to {1} or lower."
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2295
|
||||
#: src/components/compose.jsx:2315
|
||||
#: src/components/compose.jsx:2311
|
||||
#: src/components/compose.jsx:2331
|
||||
msgid "Dimension too large. Uploading might encounter issues. Try reduce dimension from {0}×{1}px to {2}×{3}px."
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2323
|
||||
#: src/components/compose.jsx:2339
|
||||
msgid "Frame rate too high. Uploading might encounter issues."
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2383
|
||||
#: src/components/compose.jsx:2633
|
||||
#: src/components/compose.jsx:2399
|
||||
#: src/components/compose.jsx:2649
|
||||
#: src/components/shortcuts-settings.jsx:723
|
||||
#: src/pages/catchup.jsx:1074
|
||||
#: src/pages/filters.jsx:412
|
||||
msgid "Remove"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2400
|
||||
#: src/components/compose.jsx:2416
|
||||
#: src/compose.jsx:83
|
||||
msgid "Error"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2425
|
||||
#: src/components/compose.jsx:2441
|
||||
msgid "Edit image description"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2426
|
||||
#: src/components/compose.jsx:2442
|
||||
msgid "Edit video description"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2427
|
||||
#: src/components/compose.jsx:2443
|
||||
msgid "Edit audio description"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2472
|
||||
#: src/components/compose.jsx:2521
|
||||
#: src/components/compose.jsx:2488
|
||||
#: src/components/compose.jsx:2537
|
||||
msgid "Generating description. Please wait…"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2492
|
||||
#: src/components/compose.jsx:2508
|
||||
msgid "Failed to generate description: {0}"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2493
|
||||
#: src/components/compose.jsx:2509
|
||||
msgid "Failed to generate description"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2505
|
||||
#: src/components/compose.jsx:2511
|
||||
#: src/components/compose.jsx:2557
|
||||
#: src/components/compose.jsx:2521
|
||||
#: src/components/compose.jsx:2527
|
||||
#: src/components/compose.jsx:2573
|
||||
msgid "Generate description…"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2544
|
||||
#: src/components/compose.jsx:2560
|
||||
msgid "Failed to generate description{0}"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2559
|
||||
#: src/components/compose.jsx:2575
|
||||
msgid "({0}) <0>— experimental</0>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2578
|
||||
#: src/components/compose.jsx:2594
|
||||
msgid "Done"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2614
|
||||
#: src/components/compose.jsx:2630
|
||||
msgid "Choice {0}"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2661
|
||||
#: src/components/compose.jsx:2677
|
||||
msgid "Multiple choices"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2664
|
||||
#: src/components/compose.jsx:2680
|
||||
msgid "Duration"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2695
|
||||
#: src/components/compose.jsx:2711
|
||||
msgid "Remove poll"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2909
|
||||
#: src/components/compose.jsx:2925
|
||||
msgid "Search accounts"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2950
|
||||
#: src/components/compose.jsx:2966
|
||||
#: src/components/shortcuts-settings.jsx:712
|
||||
#: src/pages/list.jsx:359
|
||||
msgid "Add"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2963
|
||||
#: src/components/compose.jsx:2979
|
||||
#: src/components/generic-accounts.jsx:227
|
||||
msgid "Error loading accounts"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3106
|
||||
#: src/components/compose.jsx:3122
|
||||
msgid "Custom emojis"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3126
|
||||
#: src/components/compose.jsx:3142
|
||||
msgid "Search emoji"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3157
|
||||
#: src/components/compose.jsx:3173
|
||||
msgid "Error loading custom emojis"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3168
|
||||
#: src/components/compose.jsx:3184
|
||||
msgid "Recently used"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3169
|
||||
#: src/components/compose.jsx:3185
|
||||
msgid "Others"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3207
|
||||
#: src/components/compose.jsx:3223
|
||||
msgid "{0} more…"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3345
|
||||
#: src/components/compose.jsx:3361
|
||||
msgid "Search GIFs"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3360
|
||||
#: src/components/compose.jsx:3376
|
||||
msgid "Powered by GIPHY"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3368
|
||||
#: src/components/compose.jsx:3384
|
||||
msgid "Type to search GIFs"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3466
|
||||
#: src/components/compose.jsx:3482
|
||||
#: src/components/media-modal.jsx:387
|
||||
#: src/components/timeline.jsx:889
|
||||
msgid "Previous"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3484
|
||||
#: src/components/compose.jsx:3500
|
||||
#: src/components/media-modal.jsx:406
|
||||
#: src/components/timeline.jsx:906
|
||||
msgid "Next"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3501
|
||||
#: src/components/compose.jsx:3517
|
||||
msgid "Error loading GIFs"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2013,11 +2017,11 @@ msgstr ""
|
|||
|
||||
#: src/components/status.jsx:756
|
||||
msgid "Unliked @{0}'s post"
|
||||
msgstr "Unliked @{0}'s post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/status.jsx:757
|
||||
msgid "Liked @{0}'s post"
|
||||
msgstr "Liked @{0}'s post"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/status.jsx:796
|
||||
msgid "Unbookmarked @{0}'s post"
|
||||
|
|
|
@ -122,7 +122,6 @@ function getInstanceConfiguration(instance) {
|
|||
configuration,
|
||||
maxMediaAttachments,
|
||||
maxTootChars,
|
||||
pleroma,
|
||||
pollLimits,
|
||||
} = instance;
|
||||
|
||||
|
@ -130,6 +129,7 @@ function getInstanceConfiguration(instance) {
|
|||
if (maxMediaAttachments) {
|
||||
statuses.maxMediaAttachments ??= maxMediaAttachments;
|
||||
}
|
||||
|
||||
if (maxTootChars) {
|
||||
statuses.maxCharacters ??= maxTootChars;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue