1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-13 23:41:50 +03:00

Settings toggle to disable Composer Markdown (#8358)

This commit is contained in:
Janne Mareike Koschinski
2022-04-19 15:53:59 +02:00
committed by GitHub
parent f4d935d88d
commit bca9caa98e
12 changed files with 260 additions and 98 deletions

View File

@ -17,6 +17,7 @@ limitations under the License.
import { AllHtmlEntities } from 'html-entities';
import cheerio from 'cheerio';
import escapeHtml from "escape-html";
import Markdown from '../Markdown';
import { makeGenericPermalink } from "../utils/permalinks/Permalinks";
@ -48,7 +49,19 @@ export function mdSerialize(model: EditorModel): string {
}, "");
}
export function htmlSerializeIfNeeded(model: EditorModel, { forceHTML = false } = {}): string {
interface ISerializeOpts {
forceHTML?: boolean;
useMarkdown?: boolean;
}
export function htmlSerializeIfNeeded(
model: EditorModel,
{ forceHTML = false, useMarkdown = true }: ISerializeOpts = {},
): string {
if (!useMarkdown) {
return escapeHtml(textSerialize(model)).replace(/\n/g, '<br/>');
}
let md = mdSerialize(model);
// copy of raw input to remove unwanted math later
const orig = md;