Skip to content

Commit 8a234ba

Browse files
committed
DOC-3224: Support for uploading additional file types.
1 parent 7e98a33 commit 8a234ba

File tree

10 files changed

+355
-12
lines changed

10 files changed

+355
-12
lines changed

antora.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ asciidoc:
1010
companyurl: https://www.tiny.cloud
1111
cdnurl: https://cdn.tiny.cloud/1/no-api-key/tinymce/8/tinymce.min.js
1212
tdcdnurl: https://cdn.tiny.cloud/1/_your_api_key_/tinydrive/8/tinydrive.min.js
13-
tinymce_live_demo_url: https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/8/tinymce.min.js
13+
tinymce_live_demo_url: https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/8-testing/tinymce.min.js
1414
tinydrive_live_demo_url: https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinydrive/8/tinydrive.min.js
1515
webcomponent_url: https://cdn.jsdelivr.net/npm/@tinymce/tinymce-webcomponent/dist/tinymce-webcomponent.min.js
1616
jquery_url: https://cdn.jsdelivr.net/npm/@tinymce/tinymce-jquery@2/dist/tinymce-jquery.min.js

modules/ROOT/examples/live-demos/uploadcare-full-feature/example.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ tinymce.init({
2424
showLogo: false,
2525
fluid: true,
2626
},
27+
// File upload configuration - enables file uploads in the link dialog
28+
documents_file_types: [
29+
{ mimeType: 'application/msword', extensions: [ 'doc' ] },
30+
{ mimeType: 'application/vnd.ms-excel', extensions: [ 'xls' ] },
31+
{ mimeType: 'application/vnd.ms-powerpoint', extensions: [ 'ppt', 'pps' ] },
32+
{ mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', extensions: [ 'docx' ] },
33+
{ mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', extensions: [ 'xlsx' ] },
34+
{ mimeType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', extensions: [ 'pptx' ] },
35+
{ mimeType: 'application/pdf', extensions: [ 'pdf' ] },
36+
{ mimeType: 'application/rtf', extensions: [ 'rtf' ] },
37+
{ mimeType: 'text/plain', extensions: [ 'txt' ] }
38+
],
2739
a11y_advanced_options: true,
2840
toolbar: "undo redo | styles | bold italic underline | forecolor | bullist numlist| link uploadcare uploadcare-video | code preview",
2941
height: 700,

modules/ROOT/examples/live-demos/uploadcare-full-feature/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ tinymce.init({
2525
showLogo: false,
2626
fluid: true,
2727
},
28+
// File upload configuration - enables file uploads in the link dialog
29+
documents_file_types: [
30+
{ mimeType: 'application/msword', extensions: [ 'doc' ] },
31+
{ mimeType: 'application/vnd.ms-excel', extensions: [ 'xls' ] },
32+
{ mimeType: 'application/vnd.ms-powerpoint', extensions: [ 'ppt', 'pps' ] },
33+
{ mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', extensions: [ 'docx' ] },
34+
{ mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', extensions: [ 'xlsx' ] },
35+
{ mimeType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', extensions: [ 'pptx' ] },
36+
{ mimeType: 'application/pdf', extensions: [ 'pdf' ] },
37+
{ mimeType: 'application/rtf', extensions: [ 'rtf' ] },
38+
{ mimeType: 'text/plain', extensions: [ 'txt' ] }
39+
],
2840
a11y_advanced_options: true,
2941
toolbar: "undo redo | styles | bold italic underline | forecolor | bullist numlist | link uploadcare uploadcare-video | code preview",
3042
height: 700,

modules/ROOT/pages/8.3.0-release-notes.adoc

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@ include::partial$misc/admon-releasenotes-for-stable.adoc[]
2828

2929
The following premium plugin updates were released alongside {productname} {release-version}.
3030

31-
// === <Premium plugin name 1> <Premium plugin name 1 version>
31+
=== Media Optimizer
3232

33-
// The {productname} {release-version} release includes an accompanying release of the **<Premium plugin name 1>** premium plugin.
33+
The {productname} {release-version} release includes an accompanying release of the **Media Optimizer** premium plugin.
3434

35-
// **<Premium plugin name 1>** <Premium plugin name 1 version> includes the following <fixes, changes, improvements>.
35+
**Media Optimizer** includes the following improvements.
3636

37-
// ==== <Premium plugin name 1 change 1>
37+
==== Support for uploading additional file types
38+
// #TINY-13270
3839

39-
// // CCFR here.
40+
The Media Optimizer plugin now supports uploading many additional file types through the link dialog, including documents (PDF, Word, Excel, PowerPoint, RTF, plain text), iWork files (Keynote, Pages, Numbers), audio files (WAV, MP3, OGG), and archive files (ZIP, GZIP, TAR, 7Z, RAR). A full list of supported file types is available in the documentation.
4041

41-
// For information on the **<Premium plugin name 1>** plugin, see: xref:<plugincode>.adoc[<Premium plugin name 1>].
42+
The default list of supported file types can be customized using the xref:uploadcare.adoc#documents-file-types[`+documents_file_types+`] option.
43+
44+
For information on the **Media Optimizer** plugin, see: xref:uploadcare.adoc#documents-file-types[Media Optimizer].
4245

4346

4447
[[improvements]]
@@ -57,10 +60,16 @@ The following premium plugin updates were released alongside {productname} {rele
5760

5861
{productname} {release-version} also includes the following additions:
5962

60-
=== <TINY-vwxyz 1 changelog entry>
61-
// #TINY-vwxyz1
63+
=== New options `files_upload_handler`, `documents_file_types`, and `link_uploadtab`
64+
// #TINY-13278
6265

63-
// CCFR here.
66+
Added new configuration options to the Link plugin to support file uploads through the link dialog:
67+
68+
* xref:link.adoc#files_upload_handler[`+files_upload_handler+`] - Specifies a function that handles file uploads in the link dialog's upload tab
69+
* xref:link.adoc#documents_file_types[`+documents_file_types+`] - Specifies which file types (MIME types and extensions) are supported for file uploads
70+
* xref:link.adoc#link_uploadtab[`+link_uploadtab+`] - Controls whether the "Upload" tab is displayed in the link dialog
71+
72+
For more information, see xref:link.adoc#files_upload_handler[`+files_upload_handler+`], xref:link.adoc#documents_file_types[`+documents_file_types+`], and xref:link.adoc#link_uploadtab[`+link_uploadtab+`].
6473

6574

6675
[[changes]]

modules/ROOT/pages/file-image-upload.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ include::partial$configuration/images_upload_handler.adoc[leveloffset=+1]
2020

2121
include::partial$configuration/images_upload_url.adoc[leveloffset=+1]
2222

23+
include::partial$configuration/files_upload_handler.adoc[leveloffset=+1]
24+
25+
include::partial$configuration/documents_file_types.adoc[leveloffset=+1]
26+
2327
== Options for improving custom file handling
2428

2529
include::partial$configuration/automatic_uploads.adoc[leveloffset=+1]

modules/ROOT/pages/link.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ include::partial$configuration/link_target_list.adoc[leveloffset=+1]
4848

4949
include::partial$configuration/link_attributes_postprocess.adoc[leveloffset=+1]
5050

51+
include::partial$configuration/files_upload_handler.adoc[leveloffset=+1]
52+
53+
include::partial$configuration/documents_file_types.adoc[leveloffset=+1]
54+
55+
include::partial$configuration/link_uploadtab.adoc[leveloffset=+1]
56+
5157
include::partial$misc/plugin-toolbar-button-id-boilerplate.adoc[]
5258

5359
include::partial$misc/plugin-menu-item-id-boilerplate.adoc[]

modules/ROOT/pages/uploadcare.adoc

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
= Media Optimizer
22
:navtitle: Media Optimizer
3-
:description: The Media Optimizer plugin allows you to optimize images and videos in your content.
3+
:description: The Media Optimizer plugin optimizes images and videos in content.
44
:description_short: optimize images and videos in your content.
55
:plugincode: uploadcare
66
:pluginname: Media Optimizer
@@ -11,11 +11,12 @@ The {pluginname} plugin provides comprehensive media management capabilities for
1111

1212
== Overview
1313

14-
The {pluginname} plugin extends {productname} with powerful media handling features that allow users to upload, process, and embed both images and videos directly within the editor. The plugin leverages Uploadcare's infrastructure to provide real-time media processing, responsive delivery, and advanced optimization capabilities.
14+
The {pluginname} plugin extends {productname} with powerful media handling features that enable uploading, processing, and embedding both images and videos directly within the editor. The plugin also supports uploading and linking document files (PDF, Word, Excel, PowerPoint, and more) through the xref:link.adoc[Link] plugin's dialog. The plugin leverages Uploadcare's infrastructure to provide real-time media processing, responsive delivery, and advanced optimization capabilities.
1515

1616
== Key benefits
1717

1818
* Upload and optimize both images and videos directly within the editor
19+
* Upload and link document files (PDF, Word, Excel, PowerPoint, and more) through the xref:link.adoc[Link] plugin's dialog
1920
* Real-time media optimization and compression
2021
* Responsive media delivery with automatic format selection
2122
* Advanced image filtering and video player customization
@@ -86,6 +87,25 @@ include::partial$configuration/uploadcare_store_type.adoc[leveloffset=+1]
8687

8788
include::partial$configuration/uploadcare_resources.adoc[leveloffset=+1]
8889

90+
:includedSection: uploadcarePlugin
91+
include::partial$configuration/documents_file_types.adoc[leveloffset=+1]
92+
:!includedSection:
93+
94+
[NOTE]
95+
====
96+
**File Upload Support**
97+
98+
The Media Optimizer plugin supports file uploads for documents and other file types through the xref:link.adoc[Link] plugin's dialog. The `+link+` plugin must be enabled for file uploads via the Insert/Edit Link dialog to work.
99+
100+
When both the `+link+` plugin and the Media Optimizer plugin are enabled, the Media Optimizer plugin automatically configures the xref:link.adoc#files_upload_handler[`+files_upload_handler+`] and xref:uploadcare.adoc#documents-file-types[`+documents_file_types+`] options to enable file uploads in the link dialog.
101+
102+
By default, the Media Optimizer plugin supports a comprehensive list of file types including documents (PDF, Word, Excel, PowerPoint, RTF, plain text), iWork files (Keynote, Pages, Numbers), audio files (WAV, MP3, OGG), and archive files (ZIP, GZIP, TAR, 7Z, RAR). You can customize this list by setting the xref:uploadcare.adoc#documents-file-types[`+documents_file_types+`] option.
103+
104+
When the Media Optimizer plugin sets `+documents_file_types+`, this option acts as the source of truth for supported file types. Both the Link plugin and the Media Optimizer plugin will use this list, ensuring consistent file type validation across the editor.
105+
106+
These options are part of the xref:link.adoc[Link plugin] and can also be configured independently. If you set `+documents_file_types+` manually, both the Link plugin and Media Optimizer plugin will use your custom list. For more information about file upload configuration, see the xref:link.adoc[Link plugin] documentation.
107+
====
108+
89109
:includedSection: uploadcarePlugin
90110
include::partial$configuration/a11y_advanced_options.adoc[leveloffset=+1]
91111
:!includedSection:
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
[[documents-file-types]]
2+
== `+documents_file_types+`
3+
4+
ifeval::["{includedSection}" == "uploadcarePlugin"]
5+
This option specifies which file types (MIME types and extensions) are supported for file uploads in the link dialog when using the Media Optimizer plugin. When both the xref:link.adoc[Link] plugin and the Media Optimizer plugin are enabled, the Media Optimizer plugin automatically configures this option to enable file uploads in the link dialog.
6+
endif::[]
7+
ifndef::includedSection[]
8+
This option specifies which file types (MIME types and extensions) are supported for file uploads in the link dialog. When both the xref:link.adoc[Link] plugin and the xref:link.adoc#files_upload_handler[`+files_upload_handler+`] are configured, the link dialog displays an "Upload" tab that enables file uploads.
9+
endif::[]
10+
11+
ifeval::["{includedSection}" == "uploadcarePlugin"]
12+
The option should be a non-empty array of objects, where each object contains:
13+
endif::[]
14+
ifndef::includedSection[]
15+
The option should be an array of objects, where each object contains:
16+
endif::[]
17+
18+
* `+mimeType+` - A string representing the MIME type (e.g., `+'application/pdf'+`)
19+
* `+extensions+` - An array of strings representing the file extensions (e.g., `+['pdf']+`)
20+
21+
ifeval::["{includedSection}" == "uploadcarePlugin"]
22+
[IMPORTANT]
23+
====
24+
If `+documents_file_types+` is set to an empty array or is not a valid array of objects matching the configuration schema, the Media Optimizer plugin will throw an error: "Must be a non-empty array of objects matching the configuration schema."
25+
====
26+
27+
When the Media Optimizer plugin is enabled with the `+link+` plugin, it automatically sets a default list of supported file types. The default list includes:
28+
29+
* **Documents:** PDF, Word (doc, docx), Excel (xls, xlsx), PowerPoint (ppt, pps, pptx), RTF, plain text (txt)
30+
* **iWork files:** Keynote (key), Pages (pages), Numbers (numbers)
31+
* **Audio files:** WAV, MP3, OGG (with various extensions)
32+
* **Archive files:** ZIP, GZIP, TAR, 7Z, RAR
33+
34+
This list can be customized by setting `+documents_file_types+` manually in the editor configuration.
35+
36+
endif::[]
37+
38+
ifeval::["{includedSection}" == "uploadcarePlugin"]
39+
[NOTE]
40+
====
41+
**Priority Behavior**
42+
43+
When `+documents_file_types+` is set, it acts as the source of truth for supported file types throughout the editor. This means:
44+
45+
* The xref:link.adoc[Link] plugin uses this custom list instead of its default supported file types
46+
* The Media Optimizer plugin also uses this list to determine which `+mimeType+` values are allowed for file uploads when both the `+link+` plugin and the Media Optimizer plugin are enabled as they share the same list of supported file types via this option.
47+
** If a MIME type is blocked by the Uploadcare dashboard on the server side, the MIME type will also be blocked on the client side regardless of whether `+documents_file_types+` is set, resulting in an error message such as "File type not allowed" or "File type not supported".
48+
49+
If `+documents_file_types+` is not set:
50+
51+
* The xref:link.adoc[Link] plugin uses its default list of supported file types
52+
* The Media Optimizer plugin uses its own default list of supported file types (as listed above)
53+
====
54+
endif::[]
55+
ifndef::includedSection[]
56+
[NOTE]
57+
====
58+
**Priority Behavior**
59+
60+
When `+documents_file_types+` is set, it acts as the source of truth for supported file types throughout the editor. This means:
61+
62+
* The Link plugin uses this custom list instead of its default supported file types
63+
64+
If `+documents_file_types+` is not set:
65+
66+
* The Link plugin uses its default list of supported file types
67+
====
68+
69+
endif::[]
70+
71+
*Type:* `+Array+`
72+
73+
ifeval::["{includedSection}" == "uploadcarePlugin"]
74+
*Default value:* `+undefined+`. The Media Optimizer plugin automatically configures this option when both the `+link+` plugin and the Media Optimizer plugin are enabled. The automatically configured list includes documents, iWork files, audio files, and archive files.
75+
endif::[]
76+
ifndef::includedSection[]
77+
*Default value:* `+undefined+`
78+
endif::[]
79+
80+
ifeval::["{includedSection}" == "uploadcarePlugin"]
81+
=== Example: Using `documents_file_types` with Media Optimizer
82+
83+
This example shows how to customize the file types when using the Media Optimizer plugin with the xref:link.adoc[Link] plugin:
84+
85+
[source,js]
86+
----
87+
tinymce.init({
88+
selector: 'textarea',
89+
plugins: 'uploadcare link',
90+
toolbar: 'uploadcare link',
91+
uploadcare_public_key: '<your-public-key>',
92+
documents_file_types: [
93+
{ mimeType: 'application/msword', extensions: [ 'doc' ] },
94+
{ mimeType: 'application/vnd.ms-excel', extensions: [ 'xls' ] },
95+
{ mimeType: 'application/vnd.ms-powerpoint', extensions: [ 'ppt', 'pps' ] },
96+
{ mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', extensions: [ 'docx' ] },
97+
{ mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', extensions: [ 'xlsx' ] },
98+
{ mimeType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', extensions: [ 'pptx' ] },
99+
{ mimeType: 'application/pdf', extensions: [ 'pdf' ] },
100+
{ mimeType: 'application/rtf', extensions: [ 'rtf' ] },
101+
{ mimeType: 'text/plain', extensions: [ 'txt' ] },
102+
{ mimeType: 'application/x-iwork-keynote-sffkey', extensions: [ 'key' ] },
103+
{ mimeType: 'application/x-iwork-pages-sffpages', extensions: [ 'pages' ] },
104+
{ mimeType: 'application/x-iwork-numbers-sffnumbers', extensions: [ 'numbers' ] },
105+
{ mimeType: 'audio/wav', extensions: [ 'wav', 'wave' ] },
106+
{ mimeType: 'audio/mpeg', extensions: [ 'mp3' ] },
107+
{ mimeType: 'audio/ogg', extensions: [ 'ogg', 'oga', 'ogx', 'ogm', 'spx', 'opus' ] },
108+
{ mimeType: 'application/zip', extensions: [ 'zip' ] },
109+
{ mimeType: 'application/gzip', extensions: [ 'gz', 'gzip' ] },
110+
{ mimeType: 'application/x-tar', extensions: [ 'tar' ] },
111+
{ mimeType: 'application/x-gtar', extensions: [ 'tar.gz', 'tgz' ] },
112+
{ mimeType: 'application/x-7z-compressed', extensions: [ '7z' ] },
113+
{ mimeType: 'application/x-rar-compressed', extensions: [ 'rar' ] }
114+
]
115+
});
116+
----
117+
118+
This option is part of the xref:link.adoc[Link plugin] and can also be configured independently. For more information about file upload configuration, see xref:link.adoc#documents-file-types[`+documents_file_types+`] in the Link plugin documentation.
119+
120+
endif::[]
121+
ifndef::includedSection[]
122+
=== Example: using `+documents_file_types+`
123+
124+
[source,js]
125+
----
126+
tinymce.init({
127+
selector: 'textarea',
128+
plugins: 'link',
129+
toolbar: 'link',
130+
// Configure the file upload handler to handle the file uploads
131+
files_upload_handler: async (blobInfo, progress) => {
132+
return { url: 'https://example.com/file.pdf', fileName: 'file.pdf' };
133+
},
134+
// Configure the list of supported file types
135+
documents_file_types: [
136+
{ mimeType: 'application/msword', extensions: [ 'doc' ] },
137+
{ mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', extensions: [ 'docx' ] },
138+
{ mimeType: 'application/pdf', extensions: [ 'pdf' ] },
139+
{ mimeType: 'text/plain', extensions: [ 'txt' ] }
140+
]
141+
});
142+
----
143+
144+
endif::[]
145+

0 commit comments

Comments
 (0)