BeyondGrammar For ProseMirror[production]

by Craig Haywood

HTML

<link rel=stylesheet href="https://prosemirror.net/css/editor.css">
    
    
    <script src="https://prosemirror.net/examples/prosemirror.js"></script>
    <script src="https://prowriting.azureedge.net/beyondgrammar-prosemirror/1.0.38/dist/beyond-grammar-plugin.js"></script>
    
    <div style="display: none;" id="content">
    <h3>Hello ProseMirror</h3>

   <p>
    Novalk Djokovic is set to miss the US Open after one of his doctors made an announcement that he will need six to twelve weeks to recovers from a elbow injury.
  </p>

  <p>
    But Andy Murrey's chances of playing at Flushing Meadows would appear more positive, with the Scot continuing his rehabilitation from a hip problem.
  </p>

  <p>
    The last grandslam of the year starts in just under five weeks on August 28, meaning Djokovic will run out of time if the latest assessment is correct.
  </p>

  <p>
    <b>Injured Djokovic starting to consider a break away from tennis</b>
    <br />The 12-time major champion was forced to retire injured during his Wimbeldon quarter-final against Tomas Berdych earlier this month and said after the match that he had been feeling pain in his right elbow for over a year and a half. According to
    his physio its not doing very well. If he does return he will be more likely to injure it again.
  </p>

  <p>
    He has since been seeking advice from specialists, including Serbian doctor Zdenko Milinkovic, who said Djokovic is suffering from a "bruised bone due to excessive playing".
  </p>

  <p>"Nole must rest for six to 12 weeks," Milinkovic told Sportski Zurnal, a sports newspaper in Serbia.</p>

  <p>
    The next examination will know wether this asdsessment stays or changes. During this period, he is not going to train with a racket but he will run other sessions, such as fitness and the like.
  </p>
</div>

<div id="editor" spellcheck="true"></div>

CSS

#contenteditable-editor {
  border: 1px solid #cccaca;
  padding: 20px;
  height: 300px;
  overflow: auto;
  outline: none;
  background: white;
}

JavaScript

$(function() { (function (prosemirrorState, prosemirrorView, prosemirrorModel, prosemirrorSchemaBasic, prosemirrorSchemaList, prosemirrorExampleSetup) {
            'use strict';

            // init prosemirror
            // Mix the nodes from prosemirror-schema-list into the basic schema to
            // create a schema with list support.
            let mySchema = new prosemirrorModel.Schema({
                nodes: prosemirrorSchemaList.addListNodes(prosemirrorSchemaBasic.schema.spec.nodes, "paragraph block*", "block"),
                marks: prosemirrorSchemaBasic.schema.spec.marks
            });

            let createBeyondGrammarPluginSpec = window["BeyondGrammar"].createBeyondGrammarPluginSpec;

            let spec = createBeyondGrammarPluginSpec(PM, document.getElementById("editor"),{
                service : { apiKey : "E8FEF7AE-3F36-4EAF-A451-456D05E6F2A3", serviceUrl: "//rtg.prowritingaid.com" }, 
                grammar : {}
            });

            let plugin = new prosemirrorState.Plugin( spec );

            spec.editorView = new prosemirrorView.EditorView(document.getElementById("editor"), {
                state: prosemirrorState.EditorState.create({
                    doc: prosemirrorModel.DOMParser
                        .fromSchema(mySchema)
                        .parse(document.getElementById("content")),
                    plugins: prosemirrorExampleSetup
                        .exampleSetup({schema: mySchema })
                        .concat( plugin )
                })
            });

        }(PM.state, PM.view, PM.model, PM.schema_basic, PM.schema_list, PM.example_setup))});