import api from "../api";
import codeSyntaxHighlight from "@toast-ui/editor-plugin-code-syntax-highlight/dist/toastui-editor-plugin-code-syntax-highlight-all.js";
+const customHTMLRenderer = {
+ heading( node, { entering, getChildrenText } ) {
+ const tagName = `h${node.level}`;
+
+ if (entering) {
+ return {
+ type: 'openTag',
+ tagName,
+ attributes: {
+ id: getChildrenText(node)
+ .toLowerCase()
+ .replace(/[^a-z0-9-\s]*/g, '')
+ .trim()
+ .replace(/\s/g, '-')
+ }
+ };
+ }
+ return { type: 'closeTag', tagName };
+ }
+};
+
export default {
components: {
Viewer,
},
data: function () {
+
return {
editMode: false,
draftSaveTimeout: null,
noteLoadFailedIcon: null,
noteLoadFailedMessage: "Failed to load Note",
viewerOptions: {
+ customHTMLRenderer: customHTMLRenderer,
plugins: [codeSyntaxHighlight],
extendedAutolinks: true,
},
- editorOptions: { plugins: [codeSyntaxHighlight] },
+ editorOptions: {
+ customHTMLRenderer: customHTMLRenderer,
+ plugins: [codeSyntaxHighlight] },
};
},