# Custom node with ace/monaco editor is removing newlines from content

**URL:** <https://discourse.nodered.org/t/custom-node-with-ace-monaco-editor-is-removing-newlines-from-content/94715>\
**Category:** Developing Nodes\
**Created:** [18 January 2025 16:45 UTC](https://discourse.nodered.org/t/custom-node-with-ace-monaco-editor-is-removing-newlines-from-content/94715 "2025-01-18T16:45:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 January 2025 16:45 UTC](https://discourse.nodered.org/t/custom-node-with-ace-monaco-editor-is-removing-newlines-from-content/94715/1 "2025-01-18T16:45:06Z")

</div>

Hi, I'm creating a new node that has a `RED.editor` in it set to `ace/mode/html` mode.

I copied the code from the core template node but annoyingly, while everything is otherwise working, the resulting saved code keeps removing newlines.

Does anyone know what I've done wrong?

This is where the editor is created:

```js
const stateId = RED.editor.generateViewStateId('node', node, '')
node.editor = RED.editor.createEditor({
    id: 'node-input-editor',
    mode: 'ace/mode/html',
    stateId: stateId,
    value: node.html
})

```

And this is the `oneditsave` function:

```js
function onEditSave(node) {
    const html = node.editor.getValue()
    $('#node-input-html').val(html)

    updateTab(html)

    node.editor.destroy()
    delete node.editor
}

```

Everything works correctly except for the HTML code being flattened each time. ☹

In case it matters, I'm using Monaco for the editor.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 January 2025 16:55 UTC](https://discourse.nodered.org/t/custom-node-with-ace-monaco-editor-is-removing-newlines-from-content/94715/2 "2025-01-18T16:55:51Z")

</div>

Never mind, answering my own question! 🙂

The hidden input to hold the html was marked as `type="text"`. Changing to `type="hidden"` fixed the issue.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 February 2025 16:56 UTC](https://discourse.nodered.org/t/custom-node-with-ace-monaco-editor-is-removing-newlines-from-content/94715/3 "2025-02-01T16:56:29Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
