diff --git a/editors/demo/src/Editoria/Editoria.js b/editors/demo/src/Editoria/Editoria.js
index 3a72be1e77c3730d05315f894139f42e27619975..9bda4b1134b3737b5871a9376d44bbe0f478a44d 100644
--- a/editors/demo/src/Editoria/Editoria.js
+++ b/editors/demo/src/Editoria/Editoria.js
@@ -53,9 +53,9 @@ const Editoria = () => {
           value={demo}
           // readonly
           layout={layout}
-          // onChange={debounce(source => {
-          //   console.log(JSON.stringify(source));
-          // }, 200)}
+          onChange={debounce(source => {
+            console.log(JSON.stringify(source));
+          }, 200)}
           user={user}
           scrollMargin={200}
           scrollThreshold={200}
diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js
index aa5d9607b8066939535cbbd0b45742c3f1847362..81440af1627bdceea4e5144c791151177adadc97 100644
--- a/editors/demo/src/Editoria/config/config.js
+++ b/editors/demo/src/Editoria/config/config.js
@@ -64,6 +64,41 @@ import CharactersList from './CharactersList';
 //   console.log(title);
 // };
 
+const text = `In the shroud of redundant noise, consectetur,
+A symphony sweeter than summer is discovered,
+In the hearty paws and gentle eyes of a dog, our protector,
+A tangible form of love, in fur is covered.
+
+Against every day's chaos, turmoil, and upset,
+A wagging tail carries, perhaps, the simplest antidote,
+A soothing balm to a soul, in life's whirling roulette,
+In each bark and paw, an unwritten heartfelt note.
+
+Faithful are they, standing unwavering by our side,
+Through the laughter, the struggles, and silent cries,
+In their hearts, a world where compassion and loyalty reside,
+Reflecting the truest emotions in their warm, gleaming eyes.
+
+From the grandeur of a golden retriever's gallop,
+To the charming chortle of a chihuahua's cheer,
+Each breed, each dog, narrates a touching tale,
+A saga of love, in their worlds, so clear.
+
+They are guardian angels sporting leathered noses,
+Draped in a cloak spun with devotion and trust,
+They chase not just toys, but away our woes,
+Their love, a precious gem, untouched by worldly rust.
+
+In every dog, there lies a universe obscure,
+A cosmos of gentleness veiled by playful veneer,
+Their paw prints leave indelible marks, so pure,
+Within us, they awaken a love, incredibly dear.
+
+So here's to these creatures, adorable, and fierce,
+The ones who teach us about love unfeigned,
+In the echoing cacophony of this life, so diverse,
+Semper fidelis - forever faithful, their love remains.`;
+
 async function DummyPromise(userInput) {
   return new Promise((resolve, reject) => {
     setTimeout(() => {
@@ -71,9 +106,7 @@ async function DummyPromise(userInput) {
       if (userInput === 'reject') {
         reject('Your request could not be processed for now');
       } else {
-        resolve(
-          'He made significant contributions to theoretical physics, including achievements in quantum mechanics',
-        );
+        resolve(text);
       }
     }, 4150);
   });
diff --git a/wax-prosemirror-services/src/AiService/InsertTextBelowSelection.js b/wax-prosemirror-services/src/AiService/InsertTextBelowSelection.js
index ac3e907c7805abf7afdfdcadea98971a36d6be95..5d14eea5b397180a53f8853b3cdc137fdaf26f35 100644
--- a/wax-prosemirror-services/src/AiService/InsertTextBelowSelection.js
+++ b/wax-prosemirror-services/src/AiService/InsertTextBelowSelection.js
@@ -1,13 +1,14 @@
 import { TextSelection } from 'prosemirror-state';
-export const insertTextBelowSelection = (view, transformedText) => {
-  let state = view.state;
-  let tr = state.tr;
+
+const insertTextBelowSelection = (view, transformedText) => {
+  let { state } = view;
+  let { tr } = state;
 
   const { to } = tr.selection;
 
   // Check if 'to' is within the document size
   if (to > state.doc.content.size) {
-    console.error("Position out of range");
+    console.error('Position out of range');
     return;
   }
 
@@ -37,3 +38,5 @@ export const insertTextBelowSelection = (view, transformedText) => {
   // Dispatch the final transaction to update the state
   view.dispatch(tr);
 };
+
+export default insertTextBelowSelection;
diff --git a/wax-prosemirror-services/src/AiService/ReplaceSelectedText.js b/wax-prosemirror-services/src/AiService/ReplaceSelectedText.js
index b0b5bb5eebf5d30359f8d64d6cd20ba2429d6d1d..315f96ea7fe209640739718bcc35bf64154f32a3 100644
--- a/wax-prosemirror-services/src/AiService/ReplaceSelectedText.js
+++ b/wax-prosemirror-services/src/AiService/ReplaceSelectedText.js
@@ -1,13 +1,22 @@
-import { TextSelection } from 'prosemirror-state';
-export const replaceSelectedText = (view, transformedText) => {
-  let state = view.state;
-  let tr = state.tr;
+import { DOMParser } from 'prosemirror-model';
+import { ReplaceStep, ReplaceAroundStep } from 'prosemirror-transform';
+import { Selection, TextSelection } from 'prosemirror-state';
+
+const elementFromString = string => {
+  const wrappedValue = `<body>${string}</body>`;
+
+  return new window.DOMParser().parseFromString(wrappedValue, 'text/html').body;
+};
+
+const replaceSelectedText = (view, transformedText) => {
+  let { state } = view;
+  let { tr } = state;
 
   const { from, to } = tr.selection;
 
   // Check if 'from' and 'to' are within the document size
   if (from > state.doc.content.size || to > state.doc.content.size) {
-    console.error("Position out of range");
+    console.error('Position out of range');
     return;
   }
 
@@ -19,11 +28,33 @@ export const replaceSelectedText = (view, transformedText) => {
   // Fetch the most recent state again
   state = view.state;
 
-  // Create a new text node with the transformed text
-  const newText = state.schema.text(transformedText);
+  const paragraphNodes = [];
+
+  if (transformedText.includes('\n\n')) {
+    transformedText.split('\n\n').forEach(element => {
+      paragraphNodes.push(
+        state.schema.nodes.paragraph.create(
+          {
+            preserveWhitespace: 'full',
+          },
+          state.schema.text(element),
+        ),
+      );
+    });
+  }
+
+  const newText = state.schema.nodes.paragraph.create(
+    {
+      preserveWhitespace: 'full',
+    },
+    state.schema.text(transformedText),
+  );
+
+  const finalReplacementText =
+    paragraphNodes.length !== 0 ? paragraphNodes : newText;
 
   // Replace the selected text with the new text
-  tr = tr.replaceWith(from, from, newText);  // Note: 'to' is replaced with 'from'
+  tr = tr.replaceWith(from, from, finalReplacementText); // Note: 'to' is replaced with 'from'
 
   // Dispatch the transaction to update the state
   view.dispatch(tr);
@@ -33,9 +64,12 @@ export const replaceSelectedText = (view, transformedText) => {
 
   // Update the selection to the end of the new text
   const newTo = from + transformedText.length;
-  const newSelection = TextSelection.create(state.doc, newTo, newTo);
+  const newSelection = TextSelection.create(state.doc, newTo + 2, newTo + 2);
   tr = state.tr.setSelection(newSelection);
 
   // Dispatch the final transaction to update the state
   view.dispatch(tr);
+  view.focus();
 };
+
+export default replaceSelectedText;
diff --git a/wax-prosemirror-services/src/AiService/components/AskAIOverlay.js b/wax-prosemirror-services/src/AiService/components/AskAIOverlay.js
index e33fa0a72fa05ddfe977eba00dd78248f4d5ae01..bf35643618d3ed83d3b9f6a00e2350575d5d3e47 100644
--- a/wax-prosemirror-services/src/AiService/components/AskAIOverlay.js
+++ b/wax-prosemirror-services/src/AiService/components/AskAIOverlay.js
@@ -2,8 +2,8 @@
 import React, { useRef, useLayoutEffect, useContext, useState } from 'react';
 import styled from 'styled-components';
 import { WaxContext, icons } from 'wax-prosemirror-core';
-import { replaceSelectedText } from '../ReplaceSelectedText';
-import { insertTextBelowSelection } from '../InsertTextBelowSelection';
+import replaceSelectedText from '../ReplaceSelectedText';
+import insertTextBelowSelection from '../InsertTextBelowSelection';
 
 const Wrapper = styled.div`
   display: flex;