Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Commit 0454cbc

Browse files
committed
Pass renderMark as plugin to match renderNode
1 parent 84c8d20 commit 0454cbc

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as React from "react";
33
import { Value, Editor as TEditor, Schema, Node } from "slate";
44
import { Editor } from "slate-react";
55
import styled, { ThemeProvider } from "styled-components";
6-
import type { SlateNodeProps, Plugin, SearchResult } from "./types";
6+
import type { Plugin, SearchResult } from "./types";
77
import { light as lightTheme, dark as darkTheme } from "./theme";
88
import defaultSchema from "./schema";
99
import getDataTransferFiles from "./lib/getDataTransferFiles";
@@ -14,7 +14,6 @@ import BlockInsert from "./components/BlockInsert";
1414
import Contents from "./components/Contents";
1515
import Markdown from "./serializer";
1616
import createPlugins from "./plugins";
17-
import renderMark from "./marks";
1817
import commands from "./commands";
1918
import queries from "./queries";
2019

@@ -285,7 +284,6 @@ class RichMarkdownEditor extends React.PureComponent<Props, State> {
285284
commands={commands}
286285
queries={queries}
287286
placeholder={placeholder}
288-
renderMark={renderMark}
289287
schema={this.getSchema()}
290288
onKeyDown={this.handleKeyDown}
291289
onChange={this.handleChange}

src/marks.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ type Props = {
88
mark: Mark,
99
};
1010

11-
export default function renderMark(
12-
props: Props,
13-
editor: Editor,
14-
next: Function
15-
) {
11+
function renderMark(props: Props, editor: Editor, next: Function) {
1612
switch (props.mark.type) {
1713
case "bold":
1814
return <strong>{props.children}</strong>;
@@ -30,3 +26,5 @@ export default function renderMark(
3026
return next();
3127
}
3228
}
29+
30+
export default { renderMark };

src/plugins.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import MarkdownPaste from "./plugins/MarkdownPaste";
1717
import Ellipsis from "./plugins/Ellipsis";
1818
import Embeds from "./plugins/Embeds";
1919
import Nodes from "./nodes.js";
20+
import Marks from "./marks.js";
2021

2122
// additional language support based on the most popular programming languages
2223
import "prismjs/components/prism-ruby";
@@ -29,6 +30,7 @@ import "prismjs/components/prism-java";
2930
const createPlugins = ({ placeholder, getLinkComponent }: *) => {
3031
return [
3132
Nodes,
33+
Marks,
3234
PasteLinkify({
3335
type: "link",
3436
collapseTo: "end",

0 commit comments

Comments
 (0)