-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 rich text editor to Slate backed by Unified #254
Merged
Merged
Changes from all commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
f3b7dc9
Update Jest to 0.19
KyleAMathews 24c0a1b
Replace markup-it with Remark for rendering markdown in the editor pr…
KyleAMathews 0eb109c
Convert markdown-prosemirror parser/compiler to Remark
KyleAMathews 8763666
Update parser to support remaining node types + add inline styled tex…
KyleAMathews f93aa34
fix rebase incongruencies
e401f7e
remove unrelated code style improvements
514fbb3
render plugins on visual editor load
erquhart adcb215
replace remark with unified for docs and extensibility
erquhart 5048c7c
convert editor component registry to Map
erquhart 8bb1845
implement initial unified/remark preview update
erquhart 361c3d5
improve prosemirror parser, fix new doc creation
erquhart b5e0be4
split off markdownToProseMirror plugin
erquhart b223232
handle raw editor html pastes with unified
erquhart bd76730
fix visual editor tests, parse/serialize consistency
erquhart b293b23
fix link creation in visual editor
erquhart e7ac3a7
switch remark options to use gfm, fences
erquhart 49b3a62
attempt prosemirror update, troubleshooting
erquhart 9c869be
migrate visual editor from prosemirror to slate
erquhart e01c077
fix empty initial state for rte
erquhart e682189
only render editor page controls/previews on change
erquhart 22a8da1
fix rte link serialization
erquhart bc72133
set rte focus after toolbar click
erquhart 1c0bb6a
implement widget data serialization for rte perf
erquhart ffbd8d2
expose widgetValueSerializer registry
erquhart 84ed450
add visual editor serializer source doc
erquhart 09e631d
allow nested widget previews to update
erquhart e0ca24c
add unified config module
erquhart faec38a
fix raw editor paste parsing
erquhart 54e77bd
fix raw editor formatting controls
erquhart 5cbc76d
improve rte pasting
erquhart cba631b
improve visual/raw editor consistency
erquhart 5a664f8
remove prosemirror, reuse unified pipelines
erquhart a8fe57e
pre-process visual editor pastes w/ unified
erquhart c49d84b
add empty node and Paper emoji unified plugins
erquhart 804ef3d
use true source maps
erquhart b08a9fc
improve Dropbox Paper paste handling
erquhart 719c105
remove logic from raw markdown editor
erquhart ae56ef6
convert raw editor to Slate
erquhart 24caead
add list and code toolbar buttons
erquhart 51cd8d3
remove prosemirror dependencies
erquhart fe3d04b
streamline raw editor pasting
erquhart f22d09b
add smart soft breaks for visual editor
erquhart 09751ef
allow raw html in markdown
erquhart 0e50210
close blocks on backspace
erquhart 31c9978
fix inline code serializing to blocks
erquhart 63e93d7
improve rte list handling
erquhart 469a50a
add idempotent markdown/html shortcode handling
erquhart 93687d9
add shortcodes through rte toolbar
erquhart 842c293
use mdast instead of html for rte local model
erquhart c95f061
fix soft break side effects
erquhart b7379b0
re-implement shortcode parsing to/from mdast
erquhart dbf14a8
re-enable shortcode insertion via toolbar
erquhart fbecc88
require images to be parsed as shortcodes
erquhart 6443f5d
allow enter key to make space around void nodes
erquhart 4ac6395
fix focus update on toolbar block click
erquhart 82d9bdd
port history shortcuts from Slate, force focus
erquhart ae7bd79
re-implement visual editor html paste
erquhart 7a744be
improve list handling
erquhart de1e361
allow yaml frontmatter parsing
erquhart 28ee67c
eliminate unnecessary editor renders
erquhart 750fbf5
re-implement visual editor link button
erquhart 336cab2
fix html whitespace truncation
erquhart 1f961d3
display images inserted through rte
erquhart 6377d8c
initial refactor, some bugfixes
erquhart be7385d
refactor remark-shortcodes plugin
erquhart 9174e56
refactor remarkToRehypeShortcodes
erquhart ca60a6b
update Slate shortcode handling to include paragraph
erquhart 1d65466
improve shortcode handling in visual editor
erquhart dd51f63
improve visual editor content styling
erquhart 9dcda7b
organize serializers
erquhart 406ae57
add blockquote rte button
erquhart cf2b7be
refactor and document rte serializers
erquhart d84b156
update existing serialization tests
erquhart 18b98fc
remove superfluous deps, update yarn.lock
erquhart 2bb6732
fix visual editor heading line height
erquhart 3d83325
add node type check to avoid errors in rte
erquhart 9c0b726
fix small code issues in RTE implementation
erquhart 317a876
fix html paste for visual editor
erquhart 0ea62e0
fix rte pasted links with leading/trailing spaces
erquhart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { List } from 'immutable'; | ||
import { actions as notifActions } from 'redux-notifications'; | ||
import { serializeValues } from '../lib/serializeEntryValues'; | ||
import { closeEntry } from './editor'; | ||
import { currentBackend } from '../backends/backend'; | ||
import { getIntegrationProvider } from '../integrations'; | ||
|
@@ -216,10 +217,11 @@ export function loadEntry(collection, slug) { | |
const backend = currentBackend(state.config); | ||
dispatch(entryLoading(collection, slug)); | ||
return backend.getEntry(collection, slug) | ||
.then(loadedEntry => ( | ||
dispatch(entryLoaded(collection, loadedEntry)) | ||
)) | ||
.then(loadedEntry => { | ||
return dispatch(entryLoaded(collection, loadedEntry)) | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately it provides no stack trace, and doesn't point to anything that's aware of source maps. But it's better than nothing. |
||
dispatch(notifSend({ | ||
message: `Failed to load entry: ${ error.message }`, | ||
kind: 'danger', | ||
|
@@ -265,28 +267,37 @@ export function persistEntry(collection) { | |
|
||
// Early return if draft contains validation errors | ||
if (!entryDraft.get('fieldsErrors').isEmpty()) return Promise.reject(); | ||
|
||
const backend = currentBackend(state.config); | ||
const assetProxies = entryDraft.get('mediaFiles').map(path => getAsset(state, path)); | ||
const entry = entryDraft.get('entry'); | ||
dispatch(entryPersisting(collection, entry)); | ||
|
||
/** | ||
* Serialize the values of any fields with registered serializers, and | ||
* update the entry and entryDraft with the serialized values. | ||
*/ | ||
const serializedData = serializeValues(entryDraft.getIn(['entry', 'data']), collection.get('fields')); | ||
const serializedEntry = entry.set('data', serializedData); | ||
const serializedEntryDraft = entryDraft.set('entry', serializedEntry); | ||
dispatch(entryPersisting(collection, serializedEntry)); | ||
return backend | ||
.persistEntry(state.config, collection, entryDraft, assetProxies.toJS()) | ||
.persistEntry(state.config, collection, serializedEntryDraft, assetProxies.toJS()) | ||
.then(() => { | ||
dispatch(notifSend({ | ||
message: 'Entry saved', | ||
kind: 'success', | ||
dismissAfter: 4000, | ||
})); | ||
return dispatch(entryPersisted(collection, entry)); | ||
return dispatch(entryPersisted(collection, serializedEntry)); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
dispatch(notifSend({ | ||
message: `Failed to persist entry: ${ error }`, | ||
kind: 'danger', | ||
dismissAfter: 8000, | ||
})); | ||
return dispatch(entryPersistFail(collection, entry, error)); | ||
return dispatch(entryPersistFail(collection, serializedEntry, error)); | ||
}); | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems more verbose to me, and doesn't pass our current
eslint
config (arrow functions with braces should have parens around the arguments). I prefer the old version, which is simply an expression (in fact, the old version has an extra set of parens that are unneeded).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why I did this, probably converted to run logs for debugging and forgot to switch back.