outline / rich-markdown-editor

The open source React and Prosemirror based markdown editor that powers Outline. Want to try it out? Create an account:
https://www.getoutline.com
BSD 3-Clause "New" or "Revised" License
2.87k stars 588 forks source link

Disabling code_block may cause crash #528

Open Benjamsk opened 3 years ago

Benjamsk commented 3 years ago

To Reproduce Steps to reproduce the behavior:

  1. Disable code_block and code_fence extensions
  2. Open an existing document (value) in editor that has a line starting with 4 consecutive spaces (" ")
  3. Editor will crash
  4. See error

Expected behavior Should not crash. Should probably handle trailing spaces beginning of newline as nothing.

I am simply opening an editor with value I created in editor.

Console Sample: Error: Token type code_block not supported by Markdown parser at MarkdownParseState.parseTokens (from_markdown.js:55) at MarkdownParser.parse (from_markdown.js:219) at RichMarkdownEditor.createDocument (index.tsx:485) at RichMarkdownEditor.createState (index.tsx:466) at RichMarkdownEditor.createView (index.tsx:502) at RichMarkdownEditor.init (index.tsx:290) at RichMarkdownEditor.componentDidMount (index.tsx:208) at commitLifeCycles (react-dom.development.js:20663) at commitLayoutEffects (react-dom.development.js:23426) at HTMLUnknownElement.callCallback (react-dom.development.js:3945) at Object.invokeGuardedCallbackDev (react-dom.development.js:3994) at invokeGuardedCallback (react-dom.development.js:4056) at commitRootImpl (react-dom.development.js:23151) at unstable_runWithPriority (scheduler.development.js:468) at runWithPriority$1 (react-dom.development.js:11276) at commitRoot (react-dom.development.js:22990) at performSyncWorkOnRoot (react-dom.development.js:22329) at react-dom.development.js:11327 at unstable_runWithPriority (scheduler.development.js:468) at runWithPriority$1 (react-dom.development.js:11276) at flushSyncCallbackQueueImpl (react-dom.development.js:11322) at flushSyncCallbackQueue (react-dom.development.js:11309) at batchedUpdates$1 (react-dom.development.js:22387) at reactionScheduler (reaction.ts:261) at runReactions (reaction.ts:229) at endBatch (observable.ts:111) at _endAction (action.ts:138) at executeAction (action.ts:70) at bound openMyTasksPage (action.ts:46) at runMiddleWares (mobx-state-tree.module.js:3234) at runWithActionContext (mobx-state-tree.module.js:3078) at Proxy.res (mobx-state-tree.module.js:3105) at NewTaskStore.js:80

Similar Error message for code_fence, when multiple places with 4 trailing spaces (in middle of line).