mirror of
https://github.com/outline/outline.git
synced 2026-11-27 16:08:58 +03:00
* fix: Do not escape plain URL link text in Markdown output * fix: Escape pipes in plain URL links inside table cells * fix: Escape table pipes in autolinks without a replace call
27 lines
680 B
TypeScript
27 lines
680 B
TypeScript
import type { Node as ProsemirrorNode, NodeSpec } from "prosemirror-model";
|
|
import type { MarkdownSerializerState } from "../lib/markdown/serializer";
|
|
import Node from "./Node";
|
|
|
|
export default class Text extends Node {
|
|
get name() {
|
|
return "text";
|
|
}
|
|
|
|
get schema(): NodeSpec {
|
|
return {
|
|
group: "inline",
|
|
};
|
|
}
|
|
|
|
toMarkdown(state: MarkdownSerializerState, node: ProsemirrorNode) {
|
|
const text = node.text || "";
|
|
if (!state.inAutolink) {
|
|
state.text(text, true);
|
|
return;
|
|
}
|
|
|
|
// Autolink text is not escaped, except pipes that would split a table cell.
|
|
state.text(state.inTable ? text.split("|").join("\\|") : text, false);
|
|
}
|
|
}
|