diff --git a/example/config.yml b/example/config.yml index 464d2c38..04a18dc0 100644 --- a/example/config.yml +++ b/example/config.yml @@ -15,6 +15,8 @@ collections: # A list of collections the CMS should be able to edit - {label: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mma"} - {label: "Cover Image", name: "image", widget: "image", required: false, tagname: ""} - {label: "Body", name: "body", widget: "markdown"} + - {label: "Body B", name: "bodyb", widget: "markdown"} + - {label: "Body C", name: "bodyc", widget: "markdown"} meta: - {label: "SEO Description", name: "description", widget: "text"} diff --git a/package.json b/package.json index b155b71b..e231f82c 100644 --- a/package.json +++ b/package.json @@ -119,18 +119,18 @@ "preliminaries-parser-toml": "1.1.0", "preliminaries-parser-yaml": "1.1.0", "prismjs": "^1.5.1", - "prosemirror-commands": "^0.16.0", - "prosemirror-history": "^0.16.0", - "prosemirror-inputrules": "^0.16.0", - "prosemirror-keymap": "^0.16.0", - "prosemirror-markdown": "^0.16.0", - "prosemirror-model": "^0.16.0", - "prosemirror-schema-basic": "^0.16.0", - "prosemirror-schema-list": "^0.16.0", - "prosemirror-schema-table": "^0.16.0", - "prosemirror-state": "^0.16.0", - "prosemirror-transform": "^0.16.0", - "prosemirror-view": "^0.16.0", + "prosemirror-commands": "^0.17.0", + "prosemirror-history": "^0.17.0", + "prosemirror-inputrules": "^0.17.0", + "prosemirror-keymap": "^0.17.0", + "prosemirror-markdown": "^0.17.0", + "prosemirror-model": "^0.17.0", + "prosemirror-schema-basic": "^0.17.0", + "prosemirror-schema-list": "^0.17.0", + "prosemirror-schema-table": "^0.17.0", + "prosemirror-state": "^0.17.0", + "prosemirror-transform": "^0.17.0", + "prosemirror-view": "^0.17.0", "react": "^15.1.0", "react-addons-css-transition-group": "^15.3.1", "react-autosuggest": "^7.0.1", diff --git a/src/components/Widgets/MarkdownControl/VisualEditor/__tests__/parser.spec.js b/src/components/Widgets/MarkdownControl/VisualEditor/__tests__/parser.spec.js index 594f2a32..5d35d45d 100644 --- a/src/components/Widgets/MarkdownControl/VisualEditor/__tests__/parser.spec.js +++ b/src/components/Widgets/MarkdownControl/VisualEditor/__tests__/parser.spec.js @@ -4,8 +4,8 @@ import { schema } from "prosemirror-markdown"; import makeParser from '../parser'; const testSchema = new Schema({ - nodes: schema.nodeSpec, - marks: schema.markSpec, + nodes: schema.spec.nodes, + marks: schema.spec.marks, }); // Temporary plugins test, uses preloaded plugins from ../parser diff --git a/src/components/Widgets/MarkdownControl/VisualEditor/index.js b/src/components/Widgets/MarkdownControl/VisualEditor/index.js index 6585442b..5adc913b 100644 --- a/src/components/Widgets/MarkdownControl/VisualEditor/index.js +++ b/src/components/Widgets/MarkdownControl/VisualEditor/index.js @@ -48,9 +48,9 @@ function buildInputRules(schema) { } function markActive(state, type) { - const { from, to, empty } = state.selection; + const { from, to, empty, $from } = state.selection; if (empty) { - return type.isInSet(state.storedMarks || state.doc.marksAt(from)); + return type.isInSet(state.storedMarks || $from.marks()); } return state.doc.rangeHasMark(from, to, type); } @@ -111,6 +111,7 @@ export default class Editor extends Component { this.view = new EditorView(this.ref, { state: this.createEditorState(), onAction: this.handleAction, + dispatchTransaction: this.handleTransaction, }); } @@ -121,18 +122,6 @@ export default class Editor extends Component { return EditorState.create({ doc, schema, - plugins: [ - inputRules({ - rules: allInputRules.concat(buildInputRules(schema)), - }), - keymap(buildKeymap(schema)), - keymap(baseKeymap), - history.history(), - keymap({ - 'Mod-z': history.undo, - 'Mod-y': history.redo, - }), - ], }); } @@ -146,16 +135,14 @@ export default class Editor extends Component { } } - handleAction = (action) => { + handleTransaction = (transaction) => { const { serializer } = this.state; - const newState = this.view.state.applyAction(action); + const newState = this.view.state.apply(transaction); const md = serializer.serialize(newState.doc); - console.log(md); const processedMarkdown = unified() .use(markdownToRemark) .use(remarkToMarkdown, { fences: true, commonmark: true, footnotes: true, pedantic: true }) .processSync(md); - console.log(processedMarkdown.contents); this.props.onChange(processedMarkdown.contents); this.view.updateState(newState); if (newState.selection !== this.state.selection) { diff --git a/src/components/Widgets/MarkdownControl/VisualEditor/markdownToProseMirror.js b/src/components/Widgets/MarkdownControl/VisualEditor/markdownToProseMirror.js index 911edd69..6f212121 100644 --- a/src/components/Widgets/MarkdownControl/VisualEditor/markdownToProseMirror.js +++ b/src/components/Widgets/MarkdownControl/VisualEditor/markdownToProseMirror.js @@ -14,7 +14,12 @@ export default function markdownToProseMirror({ state }) { // on the state object. const { schema, plugins } = state; - return transform; + // return transform; + + return node => { + const result = transform(node); + return result; + }; /** * The MDAST transformer function.