Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Slate 0.30.x #826

Merged
merged 9 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@
"remark-stringify": "^3.0.1",
"sanitize-filename": "^1.6.1",
"semaphore": "^1.0.5",
"slate": "^0.25.0",
"slate-edit-list": "^0.8.0",
"slate-edit-table": "^0.11.0",
"slate-plain-serializer": "^0.1.10",
"slate-react": "^0.1.10",
"slate-soft-break": "^0.4.0",
"slate": "^0.30.0",
"slate-edit-list": "^0.10.1",
"slate-edit-table": "^0.12.0",
"slate-plain-serializer": "^0.4.0",
"slate-react": "0.10.11",
"slate-soft-break": "^0.6.0",
"slug": "^0.9.1",
"toml-j0.4": "^1.1.1",
"tomlify-j0.4": "^3.0.0-alpha.0",
Expand Down
3 changes: 1 addition & 2 deletions src/components/ControlPanel/ControlPane.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

& input,
& textarea,
& select,
& div[contenteditable=true] {
& select {
@apply --input;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}

.nc-rawEditor-rawEditor {
@apply(--input);
position: relative;
overflow: hidden;
overflow-x: auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ export default class RawEditor extends React.Component {
constructor(props) {
super(props);
this.state = {
editorState: Plain.deserialize(this.props.value || ''),
value: Plain.deserialize(this.props.value || ''),
};
}

shouldComponentUpdate(nextProps, nextState) {
return !this.state.editorState.equals(nextState.editorState);
return !this.state.value.equals(nextState.value);
}

handleChange = change => {
if (!this.state.editorState.document.equals(change.state.document)) {
if (!this.state.value.document.equals(change.value.document)) {
this.handleDocumentChange(change);
}
this.setState({ editorState: change.state });
this.setState({ value: change.value });
};

/**
* When the document value changes, serialize from Slate's AST back to plain
* text (which is Markdown) and pass that up as the new value.
*/
handleDocumentChange = debounce(change => {
const value = Plain.serialize(change.state);
const value = Plain.serialize(change.value);
this.props.onChange(value);
}, 150);

Expand Down Expand Up @@ -62,7 +62,7 @@ export default class RawEditor extends React.Component {
</Sticky>
<Slate
className="nc-rawEditor-rawEditor"
state={this.state.editorState}
value={this.state.value}
onChange={this.handleChange}
onPaste={this.handlePaste}
/>
Expand Down
Loading