attempt prosemirror update, troubleshooting
This commit is contained in:
parent
e7ac3a7671
commit
49b3a62823
@ -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: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mma"}
|
||||||
- {label: "Cover Image", name: "image", widget: "image", required: false, tagname: ""}
|
- {label: "Cover Image", name: "image", widget: "image", required: false, tagname: ""}
|
||||||
- {label: "Body", name: "body", widget: "markdown"}
|
- {label: "Body", name: "body", widget: "markdown"}
|
||||||
|
- {label: "Body B", name: "bodyb", widget: "markdown"}
|
||||||
|
- {label: "Body C", name: "bodyc", widget: "markdown"}
|
||||||
meta:
|
meta:
|
||||||
- {label: "SEO Description", name: "description", widget: "text"}
|
- {label: "SEO Description", name: "description", widget: "text"}
|
||||||
|
|
||||||
|
24
package.json
24
package.json
@ -119,18 +119,18 @@
|
|||||||
"preliminaries-parser-toml": "1.1.0",
|
"preliminaries-parser-toml": "1.1.0",
|
||||||
"preliminaries-parser-yaml": "1.1.0",
|
"preliminaries-parser-yaml": "1.1.0",
|
||||||
"prismjs": "^1.5.1",
|
"prismjs": "^1.5.1",
|
||||||
"prosemirror-commands": "^0.16.0",
|
"prosemirror-commands": "^0.17.0",
|
||||||
"prosemirror-history": "^0.16.0",
|
"prosemirror-history": "^0.17.0",
|
||||||
"prosemirror-inputrules": "^0.16.0",
|
"prosemirror-inputrules": "^0.17.0",
|
||||||
"prosemirror-keymap": "^0.16.0",
|
"prosemirror-keymap": "^0.17.0",
|
||||||
"prosemirror-markdown": "^0.16.0",
|
"prosemirror-markdown": "^0.17.0",
|
||||||
"prosemirror-model": "^0.16.0",
|
"prosemirror-model": "^0.17.0",
|
||||||
"prosemirror-schema-basic": "^0.16.0",
|
"prosemirror-schema-basic": "^0.17.0",
|
||||||
"prosemirror-schema-list": "^0.16.0",
|
"prosemirror-schema-list": "^0.17.0",
|
||||||
"prosemirror-schema-table": "^0.16.0",
|
"prosemirror-schema-table": "^0.17.0",
|
||||||
"prosemirror-state": "^0.16.0",
|
"prosemirror-state": "^0.17.0",
|
||||||
"prosemirror-transform": "^0.16.0",
|
"prosemirror-transform": "^0.17.0",
|
||||||
"prosemirror-view": "^0.16.0",
|
"prosemirror-view": "^0.17.0",
|
||||||
"react": "^15.1.0",
|
"react": "^15.1.0",
|
||||||
"react-addons-css-transition-group": "^15.3.1",
|
"react-addons-css-transition-group": "^15.3.1",
|
||||||
"react-autosuggest": "^7.0.1",
|
"react-autosuggest": "^7.0.1",
|
||||||
|
@ -4,8 +4,8 @@ import { schema } from "prosemirror-markdown";
|
|||||||
import makeParser from '../parser';
|
import makeParser from '../parser';
|
||||||
|
|
||||||
const testSchema = new Schema({
|
const testSchema = new Schema({
|
||||||
nodes: schema.nodeSpec,
|
nodes: schema.spec.nodes,
|
||||||
marks: schema.markSpec,
|
marks: schema.spec.marks,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Temporary plugins test, uses preloaded plugins from ../parser
|
// Temporary plugins test, uses preloaded plugins from ../parser
|
||||||
|
@ -48,9 +48,9 @@ function buildInputRules(schema) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function markActive(state, type) {
|
function markActive(state, type) {
|
||||||
const { from, to, empty } = state.selection;
|
const { from, to, empty, $from } = state.selection;
|
||||||
if (empty) {
|
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);
|
return state.doc.rangeHasMark(from, to, type);
|
||||||
}
|
}
|
||||||
@ -111,6 +111,7 @@ export default class Editor extends Component {
|
|||||||
this.view = new EditorView(this.ref, {
|
this.view = new EditorView(this.ref, {
|
||||||
state: this.createEditorState(),
|
state: this.createEditorState(),
|
||||||
onAction: this.handleAction,
|
onAction: this.handleAction,
|
||||||
|
dispatchTransaction: this.handleTransaction,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,18 +122,6 @@ export default class Editor extends Component {
|
|||||||
return EditorState.create({
|
return EditorState.create({
|
||||||
doc,
|
doc,
|
||||||
schema,
|
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 { serializer } = this.state;
|
||||||
const newState = this.view.state.applyAction(action);
|
const newState = this.view.state.apply(transaction);
|
||||||
const md = serializer.serialize(newState.doc);
|
const md = serializer.serialize(newState.doc);
|
||||||
console.log(md);
|
|
||||||
const processedMarkdown = unified()
|
const processedMarkdown = unified()
|
||||||
.use(markdownToRemark)
|
.use(markdownToRemark)
|
||||||
.use(remarkToMarkdown, { fences: true, commonmark: true, footnotes: true, pedantic: true })
|
.use(remarkToMarkdown, { fences: true, commonmark: true, footnotes: true, pedantic: true })
|
||||||
.processSync(md);
|
.processSync(md);
|
||||||
console.log(processedMarkdown.contents);
|
|
||||||
this.props.onChange(processedMarkdown.contents);
|
this.props.onChange(processedMarkdown.contents);
|
||||||
this.view.updateState(newState);
|
this.view.updateState(newState);
|
||||||
if (newState.selection !== this.state.selection) {
|
if (newState.selection !== this.state.selection) {
|
||||||
|
@ -14,7 +14,12 @@ export default function markdownToProseMirror({ state }) {
|
|||||||
// on the state object.
|
// on the state object.
|
||||||
const { schema, plugins } = state;
|
const { schema, plugins } = state;
|
||||||
|
|
||||||
return transform;
|
// return transform;
|
||||||
|
|
||||||
|
return node => {
|
||||||
|
const result = transform(node);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The MDAST transformer function.
|
* The MDAST transformer function.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user