Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding starter text - how do I make custom 'default' text editable? #840

Open
2arch opened this issue May 30, 2023 · 0 comments
Open

Adding starter text - how do I make custom 'default' text editable? #840

2arch opened this issue May 30, 2023 · 0 comments

Comments

@2arch
Copy link

2arch commented May 30, 2023

I have another query; I have a bunch of texts loaded up under a node.json

Which looks like this:

node: [{"id": "some id",
"content": "long text here"}, ... ]

I have this script that takes the content of the node and loads it as the default text for the code editor.

        const codeMirrorLine = document.querySelector('.CodeMirror-code');

        if (lastNode) {
          codeMirrorLine.innerHTML = '';

          const editorLine = document.createElement('pre');
          editorLine.className = 'CodeMirror-line';

          const editorContent = document.createElement('span');
          editorContent.style.paddingRight = '0.1px';
          editorContent.textContent = lastNode.content;

          codeMirrorLine.appendChild(editorLine);
          editorLine.appendChild(editorContent);
        } else {
          codeMirrorLine.textContent = '';
        }

However, the text is uneditable, and when I enter a new text it replaces whatever default text was loaded.

What part of the cursor / editor element should I edit in addition to creating the custom 'pre' elements in order to load the node Contents by default, and also make them a part of the editable text?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant