What is the best way to connect a nested Vuex object to a Vue.js property within the Tiptap text editor?

I'm attempting to connect the nested Vuex state object to the editor property of the tiptap's editor-content component.

The structure of the state is as follows:

<template>
  <table
    :style="{ backgroundColor: element.options.backgroundColor }"
    class="main"
    width="100%"
    cellspacing="0"
    cellpadding="0"
    border="0"
    align="center"
    style="display: table;"
    data-type="title"
  >
    <tbody>
      <tr>
         <td>
             class="border-9/5 border-dashed border-transparent hover:border-blue-200"
            :class="{
              'border-builder-blue shadow border-dashed cursor-auto hover:border-builder-blue':
                element.active,
              'cursor-pointer': !element.active,
            }"
          >
            <div
              :align="element.options.align"
              :style="{
                paddingTop: element.options.padding[0],
                paddingRight: element.options.padding[1],
                paddingBottom: element.options.padding[2],
                paddingLeft: element.options.padding[3],
              }"
              style="color: #757575;"
              data-block-id="background"
            >
              <editor-content :editor="computedEditor" />
            </div>
          </div>
        </td>
      </tr>
    </tbody>
  </table>
</template>

<script>
import { EditorContent, Editor } from 'tiptap';

export default {
  components: {
    EditorContent,
  },
  props: ['element'],
  data() {
    return {
      content: null,
      options: {},
      id: '',
    };
  },
  computed: {
    computedEditor: {
      get() {
        return this.$store.state.email.editors[0].editor;
      },
      set(value) {
        this.$store.commit('email/testEditorUpdate', value);
      },
    },
  },
};
</script>

<style></style>

This Vuex object is part of the editors array in the Vuex store as shown below.

When I attempt this method, I encounter an error log from Vue. Previously, when using vue data properties, it worked smoothly but transitioning to Vuex has proven to be a challenge for me and the reason behind this issue is unclear.

Error message:

Error: [vuex] do not mutate vuex store state outside mutation handlers.
RangeError: Maximum call stack size exceeded

This error arises due to mutating the Vuex store state outside mutation handlers, causing an overflow in the call stack limit.

Answer №1

After much searching, I have discovered the answer to my problem. It turns out that Vuex was struggling to handle large object structures, especially when dealing with complex functions, nested configurations, and arrays in my object editor. I found two solutions to this issue.

  1. Reorganize the structure of the vuex object
  2. Implement a deep clone of the object within mutations in the Vuex store

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

Do we need to have the 'input type file' field as

I am currently working on a PHP form that includes mandatory fields for saving the data. For example: <td><input class="text_area required" type="text" name="new field" This form also has Javascript code with file upload functionality, which I ...

Injecting a controller into an AngularJS module within an anonymous function

As a newcomer to the world of javascript and just beginning to work with angular.js, I have a question. I'm wondering if there is a method for injecting a controller into a module that is declared within an anonymous function. This is how my code cu ...

The process of filtering and outputting JSON data in JavaScript or jQuery

There is JSON data available for review. var data = [{ "gender": "male", "name": { "first": "rubween", "last": "dean" } }, { "gender": "male", "name": { "first": "rubween", "last": "dean" } }, { ...

JavaScript | Determining the coordinates of where on the image X and Y were clicked

My goal is to determine the position of an x and y location when a user clicks on an image. This information will be used to add a spot to the image that displays relevant information. The content for the spot will be dynamically loaded from a SQL database ...

JavaScript tip: Finding the total sum of strings with time format (e.g. 00:00:00)

I have an array that contains time values: // hours, minutes, seconds let arr = ["00:00:30", "00:20:00", "01:00:10", "05:10:15"] Is there a way to calculate the total sum of these elements? output: "06:30:55" ...

Add JSON elements to an array

Looking for help! {"Task": [Hours per Day],"Work": [11],"Eat": [6],"Commute": [4],"Sleep": [3]} Need to add these items to a jQuery array. I've attempted using JSON.parse without success. Typically, I can push parameters as follows: MyArr.push([& ...

An effective way to eliminate or verify duplicate dates within an array in AngularJS1 is by employing the push() and indexOf() methods

I have successfully pulled EPOCH dates and converted them into strings, but my previous code did not check or remove duplicates. Does anyone have any suggestions on what I can add to accomplish this? The timestamp in this case is the EPOCH date that I re ...

JavaScript: Creating a Function that Returns an Object with an Undefined `this.variable`

While using javascript, I encountered an issue with instance variables. Declaring a variable as "this.variable" works fine until my function returns an object. However, if the function returns a String or Number, there are no issues. But when it returns ...

Utilizing Ajax in conjunction with Ruby on Rails

I have a question that may be quite basic (I am new to Rails 3). I am looking to implement Ajax functionality where once a user clicks on a link, it triggers a $.post call and initiates some server-side changes. Within the _share partial file, I currently ...

The initial rendering of components is not displayed by Vue Storybook

The functionality of the storybook is effective, but initially, it fails to "render" the component. By examining the screenshot, we can deduce that the component-template is being utilized in some way, as otherwise, the basic layout of the component would ...

API request was blocked due to the CORS policy

As I work on developing a web app using Vue.js, users must log in to receive an API key. My post request to the API through axios includes two parameters - a name and a password. However, upon form submission, persistent errors keep appearing: OPTIONS htt ...

When using the npm command, errors may occur that are directly related to the lifecycle and initialization

Currently, I am delving into the world of OpenLayers and JavaScript. I came across a helpful tutorial that provides step-by-step guidance on creating a simple OpenLayers project using JavaScript. I followed the instructions diligently but encountered an er ...

Link to the Vue Bootstrap Toast Message

I have integrated vue-bootstrap-toasts (demo) into my website to display Toasts. However, I am facing an issue with adding a link to the toast that should redirect to another page. this.$toast.success('Test is created', { href: "www.googl ...

AngularJS does not update values properly if there is a style applied to the parent container

I'm struggling to find the best approach to handle this situation. This is how my AngularJS code looks: <span class="something" ng-hide="onsomecondition"> {{value}} </span> .something{ text-align:left; padding:10px;} Issue: The value ...

Capturing and managing gulp-mocha error messages

For some reason, I just can't seem to get gulp-mocha to properly catch errors in my code. This issue is causing my gulp watch task to abruptly end whenever a test fails. My setup is incredibly basic: gulp.task("watch", ["build"], function () { gul ...

Generate text input fields dynamically and store their values in an array using the Backbone.js framework

Is there a way to dynamically create text boxes based on a number input field with type='number'? Essentially, every time a user increments the number input, a new text box should be added to the backbone.js view. Additionally, when values are en ...

Leverage jQuery to Retrieve Text and Modify

My Content Management System automatically generates a time stamp for when a page was last updated. However, the format it provides is not ideal for my needs. I would like the date to be displayed in the US Standard way - May 24, 2013, without including th ...

Ways to Toggle div Visibility for Elements with Identical Class Names on an Individual Basis

After searching for solutions on stackoverflow, I attempted to implement some answers provided by other users, but I'm still not achieving the desired outcome. In my website's about section, there are four different items. When a specific item&a ...

Want to learn how to display a description below a photo when you hover over it in a photo gallery?

I am currently creating a basic photo gallery where hovering over a thumbnail displays an enlarged photo below it. My goal is to also have text displayed inside a white text box when hovering over each thumbnail, with unique descriptions for each. I need ...

Converting an array into a string, transitioning from PHP to JavaScript

Hey everyone, I'm currently working on passing an array to a JavaScript file and encountering this error: An exception has been thrown during the rendering of a template ("Notice: Array to string conversion"). What I need is: data: ['2017/7&a ...