Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions GUI/src/services/service-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ import {

import api from '../services/api-dev';

const htmlToMarkdown = new NodeHtmlMarkdown({
textReplace: [
[/\\_/g, '_'],
[/\\\[/g, '['],
[/\\\]/g, ']'],
],
});

/**
* Normalises MCQ button payloads on all MultiChoiceQuestion nodes.
*
Expand Down Expand Up @@ -706,14 +714,6 @@ function handleTextField(
parentNode: Node,
childNode: Node<NodeDataProps> | undefined,
) {
const htmlToMarkdown = new NodeHtmlMarkdown({
textReplace: [
[/\\_/g, '_'],
[/\\\[/g, '['],
[/\\\]/g, ']'],
],
});

const spacePlaceholder = '___SPACE___';
const rawMessage = typeof parentNode.data.message === 'string' ? decodeHtmlEntities(parentNode.data.message) : '';
const rawMessageWithSpaceholders = replaceSpacesOutsideTags(
Expand Down Expand Up @@ -884,11 +884,14 @@ function handleMultiChoiceQuestion(
b.payload = b.payload.replace(/\/[^/]*_mcq_/, `/${rootServiceName}_mcq_`);
});

const rawQuestion = decodeHtmlEntities(parentNode?.data?.multiChoiceQuestion?.question ?? '');
const markdownQuestion = htmlToMarkdown.translate(rawQuestion);

return finishedFlow.set(parentStepName, {
assign: {
buttons: parentNode?.data?.multiChoiceQuestion?.buttons ?? [],
res: {
result: parentNode?.data?.multiChoiceQuestion?.question ?? '',
result: markdownQuestion,
},
},
next: childNode ? toSnakeCase(childNode.data.label ?? 'format_messages') : 'format_messages',
Expand Down
Loading