Skip to content

TeemuKoivisto/prosemirror-weird-replace-step

Repository files navigation

When I replace '<i>p</i>o' text with a character, say 'm', it produces a quite convoluted ReplaceStep which, for some reason, defaults all marks's attributes to their default values.

To reproduce

  1. Go to https://teemukoivisto.github.io/prosemirror-weird-replace-step OR locally you can run node serve.js and go to http:https://localhost:4040/
  2. Follow the steps
  1. Go to https://teemukoivisto.github.io/prosemirror-weird-replace-step
  2. Click 'Restore example'
  3. Select po, press m
  4. The below JSON should be shown
{
  "stepType": "replace",
  "from": 5,
  "to": 38,
  "slice": {
    "content": [
      {
        "type": "text",
        "text": "m"
      },
      {
        "type": "text",
        "marks": [
          {
            "type": "italic",
            "attrs": {
              "color": null
            }
          }
        ],
        "text": "l"
      },
      {
        "type": "text",
        "text": "oo"
      },
      {
        "type": "text",
        "marks": [
          {
            "type": "bold",
            "attrs": {
              "color": null
            }
          }
        ],
        "text": "o"
      },
      {
        "type": "text",
        "text": "oooo"
      },
      {
        "type": "text",
        "marks": [
          {
            "type": "bold",
            "attrs": {
              "color": null
            }
          }
        ],
        "text": "o"
      },
      {
        "type": "text",
        "marks": [
          {
            "type": "italic",
            "attrs": {
              "color": null
            }
          }
        ],
        "text": "mm"
      },
      {
        "type": "text",
        "text": "oooo"
      },
      {
        "type": "text",
        "marks": [
          {
            "type": "bold",
            "attrs": {
              "color": null
            }
          }
        ],
        "text": "ooo"
      },
      {
        "type": "text",
        "text": " ooo"
      },
      {
        "type": "text",
        "marks": [
          {
            "type": "bold",
            "attrs": {
              "color": null
            }
          }
        ],
        "text": "o"
      },
      {
        "type": "text",
        "marks": [
          {
            "type": "italic",
            "attrs": {
              "color": null
            }
          }
        ],
        "text": "cb"
      },
      {
        "type": "text",
        "text": "ooo"
      },
      {
        "type": "text",
        "marks": [
          {
            "type": "italic",
            "attrs": {
              "color": null
            }
          }
        ],
        "text": "ocb"
      }
    ]
  }
}

How to install

  1. git submodule update --init --recursive
  2. yarn
  3. yarn pm
  4. yarn start