Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function mtodoc () {
self.content.editor = defaultMarkdownParser.parse(area.value)
self.content.markdown = area.value
self.$emit('_content-change-markdown')
}
// emulate v-model
serialize: ({ schema, content }) => {
const document = schema.nodeFromJSON(content);
const serializer = new ProseMirrorMarkdownSerializer(defaultMarkdownSerializer.nodes, {
...defaultMarkdownSerializer.marks,
bold: {
// creates a bold alias for the strong mark converter
...defaultMarkdownSerializer.marks.strong,
},
italic: { open: '_', close: '_', mixable: true, expelEnclosingWhitespace: true },
});
return serializer.serialize(document, {
tightLists: true,
});
},
};
serialize: ({ schema, content }) => {
const document = schema.nodeFromJSON(content);
const serializer = new ProseMirrorMarkdownSerializer(defaultMarkdownSerializer.nodes, {
...defaultMarkdownSerializer.marks,
bold: {
// creates a bold alias for the strong mark converter
...defaultMarkdownSerializer.marks.strong,
},
italic: { open: '_', close: '_', mixable: true, expelEnclosingWhitespace: true },
});
return serializer.serialize(document, {
tightLists: true,
});
},
};
serialize: ({ schema, content }) => {
const document = schema.nodeFromJSON(content);
const serializer = new ProseMirrorMarkdownSerializer(defaultMarkdownSerializer.nodes, {
...defaultMarkdownSerializer.marks,
bold: {
// creates a bold alias for the strong mark converter
...defaultMarkdownSerializer.marks.strong,
},
italic: { open: '_', close: '_', mixable: true, expelEnclosingWhitespace: true },
});
return serializer.serialize(document, {
tightLists: true,
});
},
};
import { MarkdownSerializer } from 'prosemirror-markdown';
import { generateBibTexString } from '../references/citationConversion';
// serialize to markdown and keep stack?
export const markdownSerializer = new MarkdownSerializer({
blockquote(state, node) {
state.wrapBlock('> ', null, node, () => state.renderContent(node));
},
code_block(state, node) {
if (node.attrs.params === null) {
state.wrapBlock(' ', null, node, () => state.text(node.textContent, false));
} else {
state.write('```' + node.attrs.params + '\n');
state.text(node.textContent, false);
state.ensureNewLine();
state.write('```');
state.closeBlock(node);
}
},
heading(state, node) {
state.write(state.repeat('#', node.attrs.level) + ' ');
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.markdownSerializer = undefined;
var _ref;
var _prosemirrorMarkdown = require('prosemirror-markdown');
var _citationConversion = require('../references/citationConversion');
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// serialize to markdown and keep stack?
var markdownSerializer = exports.markdownSerializer = new _prosemirrorMarkdown.MarkdownSerializer((_ref = {
blockquote: function blockquote(state, node) {
state.wrapBlock('> ', null, node, function () {
return state.renderContent(node);
});
},
code_block: function code_block(state, node) {
if (node.attrs.params === null) {
state.wrapBlock(' ', null, node, function () {
return state.text(node.textContent, false);
});
} else {
state.write('```' + node.attrs.params + '\n');
state.text(node.textContent, false);
state.ensureNewLine();
state.write('```');
state.closeBlock(node);
exports.createSimpleEditor = function (place, doc) {
var _require = require('../pubpubSetup'),
pubpubSetup = _require.pubpubSetup;
var _require2 = require('prosemirror-state'),
EditorState = _require2.EditorState;
var _require3 = require('prosemirror-view'),
EditorView = _require3.EditorView;
var _require4 = require("prosemirror-markdown"),
defaultMarkdownParser = _require4.defaultMarkdownParser,
defaultMarkdownSerializer = _require4.defaultMarkdownSerializer;
// const {clipboardParser, clipboardSerializer} = require('./proseEditor/clipboardSerializer');
/*
const state = EditorState.create({
// doc: pubSchema.nodeFromJSON(this.collab.doc.contents),
plugins: [pubpubSetup({schema: pubSchema})],
});
*/
var view = void 0;
try {
view = new EditorView(place, {
state: EditorState.create({ schema: _schema.schema }),
exports.createSimpleEditor = function (place, doc) {
var _require = require('../pubpubSetup'),
pubpubSetup = _require.pubpubSetup;
var _require2 = require('prosemirror-state'),
EditorState = _require2.EditorState;
var _require3 = require('prosemirror-view'),
EditorView = _require3.EditorView;
var _require4 = require("prosemirror-markdown"),
defaultMarkdownParser = _require4.defaultMarkdownParser,
defaultMarkdownSerializer = _require4.defaultMarkdownSerializer;
// const {clipboardParser, clipboardSerializer} = require('./proseEditor/clipboardSerializer');
/*
const state = EditorState.create({
// doc: pubSchema.nodeFromJSON(this.collab.doc.contents),
plugins: [pubpubSetup({schema: pubSchema})],
});
*/
var view = void 0;
try {
view = new EditorView(place, {
state: EditorState.create({ schema: _schema.schema }),
onAction: function onAction(action) {
'setupProseMirror': function (content, editor) {
const self = this
this.view = new MenuBarEditorView(editor, {
state: EditorState.create({
doc: defaultMarkdownParser.parse(content),
plugins: exampleSetup({schema})
}),
onAction: (action) => {
self.$emit('_content-change-editor', action)
self.content.editor = this.view.editor.state.doc
self.content.markdown = defaultMarkdownSerializer.serialize(this.view.editor.state.doc)
}
})
this.view.editor.focus()
},
'bindTextarea': function (area) {
this.$on('_content-change-markdown', () => {
if (this.mode === 'all') {
const state = EditorState.create({
doc: defaultMarkdownParser.parse(this.content.markdown),
plugins: exampleSetup({schema})
})
this.view.editor.updateState(state)
}
this.$emit('content-change-markdown')
})