Issue #1309Opened July 23, 2018by jvillena0 reactions

How I can save dynamic text persistent on a component view?

Question

I was trying to insert dynamic text on a component view in the HTML but when I'm saving the html hasn't got my changes. I'll try the following things:

                  var text = editorRTE.getSelected().view.$el[0].innerHTML;

                   String.prototype.splice = function(idx, rem, str) {
                       return this.slice(0, idx) + str + this.slice(idx + Math.abs(rem));
                   };

                   value = text.splice(caret, 0, value);
                   editorRTE.getSelected().view.$el[0].innerHTML = value;
                   editorRTE.getSelected().view.$el[0].focus();
                   editorRTE.getSelected().set('content', value.trim());

With the code above I can inject the text in the caret position (cursor position) but the method when I save the content I'm receiving the value.trim() concat with the current text that it was in the DomDocument.

http://recordit.co/cjAUl37aGr

I tried as well to do: editorRTE.getSelected().view.render(); But it's showing me the same output: This week [email protected]@ This week Special

Answers (2)

jvillenaJuly 24, 20180 reactions

To insert the text in the highlight paragraph selected I did this because I was losing the focus after opening a popup modal dialog:

              var text = editor.getSelected().view.$el[0].innerHTML;

                String.prototype.splice = function(idx, rem, str) {
                    return this.slice(0, idx) + str + this.slice(idx + Math.abs(rem));
                };

                value = text.splice(caret, 0, value);
                const domComponents = editor.DomComponents;
                const component = domComponents.getWrapper().find('.gjs-comp-selected')[0];
                component.components(value.trim());
                editor.getSelected().view.$el[0].focus();
                domComponents.render();
lock[bot]September 17, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.