"Enabling image uploads in Vue.js with TinyMCE: A step-by-step guide

I have integrated tinymce into my Vue.js application, but I am experiencing issues with uploading images.

I have included the following package in my project:

import Editor from '@tinymce/tinymce-vue'
. I believe I might be missing a necessary plugin or toolbar.

component

  

     <editor
                      apiKey="API_KEY"
    
                      :init="{
                       height: 200,
                       menubar: true,
                       plugins: [
                         'advlist autolink lists link image charmap print preview anchor',
                         'searchreplace visualblocks code fullscreen',
                         'insertdatetime media table paste code help wordcount '
                       ],
                        file_picker_types: 'image',
                       toolbar:
                         'undo redo | formatselect | bold italic backcolor| link image| \
                         alignleft aligncenter alignright alignjustify | \
                         bullist numlist outdent indent | removeformat | help | image code'
                     }"
    
                    />

Answer №1

In order to implement image uploading, you need to include an option in the initialization object such as image_upload_url or image_upload_handler.

For detailed instructions, refer to the documentation: tinymce image upload options

Start by creating an API endpoint that responds with a JSON object containing the image path under the location key, for example:

{ location: 'path/to/filename.jpg' }

Next steps include:

  1. If you opt for the URL option, provide the endpoint string like

    http://example.com/api/image_upload
    and create the necessary route handler. (I can demonstrate this using express)

  2. If you choose the handler option, refer to this function which should return the same JSON object type, allowing advanced modifications before returning.

For simplicity, consider utilizing the image_upload_url option.

In my projects, I integrate tinymce with express for seamless functionality.

Please let me know your backend setup so I can provide further assistance.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Squashing the `require()` method in nwJS using emberJS

I am facing an issue with my nwjs application that connects to a web address hosting an ember application. I need to access the node context within the ember application to determine the user's operating system for updating purposes. I attempted to do ...

Why doesn't express.js throw an error when the variable 'app' is used within its own definition?

When working with express.js, I find it puzzling that createApplication() does not throw an error. This is because it uses app.handle(...) within an anonymous function that defines the same variable 'app'. I attempted to replicate this in jsFidd ...

Having difficulty coming back from a promise catch block

I'm struggling to populate a menu list from my PouchDB database because I am unable to retrieve anything within the promise that is executed after calling get on the db. Below is the code in question: <MenuList> {this.populateSavedClues()} ...

Unintended consequences within computed properties

I'm struggling to eliminate side effects in my code. Can anyone offer some guidance? computed: { sumVegetables(){ this.totalVegetables = 0; for( const vegetable of this.vegetables){ this.totalVegetables ...

Steps to activate an event when Windows is loaded

Every time windows load, I want to run $('select[name="order_id"]').change(), but it's not working as expected. After debugging in the browser console, I can see that the script $('select[name="order_id"]').cha ...

Using ng-options with the Add New feature is not compatible with the select statement

Hello everyone, I have some JSON values that look like this: [{"Employee":{"Emp_id":"EF00001","First_name":"Aruna","Last_name":"Jayalath"}}] Unfortunately, I am having trouble retrieving the values within the select statement when running this function i ...

Using Jquery to create interactive and dynamic webpage elements

I am struggling with a paragraph containing words in a span that are editable upon clicking. The content needs to be dynamically called, but my current approach is not effective. Can anyone provide a solution or a better way to achieve this? Feel free to ...

Invoke a router inside Node.js once a route has been triggered

I am working with ExpressJS and integrating the Auth0 API for authentication, along with ReactJS on the client side. Due to some limitations of the Auth0 API that I discussed with their team, I have implemented a workaround where I send updated user detail ...

Handling null values in the share middleware is crucial for managing inertia

function manageDarkMode(Request $request) { return array_merge(parent::manageDarkMode($request), [ 'darkMode' => !!$request->session()->get('dark_mode', false), ]); } The above logic is instructing to enab ...

What occurs when Render() is called during animation in React?

Curious about how React handles rendering during a component's animation? Let's explore an example where a component is re-rendered due to a state change triggered during its animation. Imagine a scenario where a component's animation lasts ...

Synchronous: Establishing a connection to MongoDB once the server has successfully launched

I am curious to understand the interaction between Node.js asynchronous functions and MongoDB. If the server initializes before establishing a connection, and if my templates or Ajax requests rely on database data, will the serving of the HTML fail or will ...

Ways to retrieve information from a specific key

I'm currently facing a challenge accessing specific data objects that are referenced by keys. In this particular scenario, the "applicant" data is nested within an Event object. My goal is to extract this data and create a new object from it. While I ...

Creating a click-away listener feature in your Next js application

I have a reusable component called DropDown and a custom hook called useClickOutside. I am utilizing the context API to manage multiple dropdowns with unique ids. Code for useClickOutside import { useEffect, useRef } from "react"; import { toUSV ...

Fill a Bootstrap Table with information obtained from a JSON file source

My journey into the world of bootstrap and json files has hit a roadblock, and I need some help with the following issue: Here is a snippet of my code: <div class="container"> <h1 class="text text-success text-center ">Kontoauszug</ ...

Converting JSON object settings to a string causes an error as it is not a valid function

For my project, I have been provided with a JSON object that contains various settings, some being strings and others booleans. One thing I am struggling with is adding an animation name from the object that is stored in a variable. aniFx.move(inner, { ...

Sending markdown files to Vue components via router

Using VueJS, I have externally generated markdown files that I want to convert into static pages using a vue component. To achieve this, I am utilizing the vite-plugin-md to transform imported md files into components. Example in Action Configuration (vit ...

Encountering error "An import path cannot end with a '.ts' extension." when importing TypeScript file in Vue Single File Component (SFC) within VS Code

Currently, I am in the process of transitioning my .vue components from using JavaScript to TypeScript. As a result, my single file components are structured as follows: <template> ...something... </template> <script lang="ts"> import ...

I'm having trouble retrieving my variable within the socketcluster's socket.on function

How can I store the value of msg in the variable sample when sample is not accessible inside the callback function? import { Injectable } from '@angular/core'; import * as socketCluster from 'socketcluster-client'; @Injectable({ pro ...

Discovering elements with Selenium

While using selenium, I stumbled upon this web element: <td style="padding-right: 10px; " **onclick="javascript:show_me('CarDetails.php?CarID=2358912&SubCatID=1**', '2358912', 560, 'ActiveLinkVisited');stat( '../& ...

Recording the $index value of dynamically included inputs

Check out my Plunker demo: http://plnkr.co/edit/sm3r4waKZkhd6Wvh0JdB?p=preview I have a dynamic set of form elements that users can add and remove. I am looking to include an 'id' property for each object in the form elements, corresponding to ...