rich-markdown-editor icon indicating copy to clipboard operation
rich-markdown-editor copied to clipboard

Higher versions [prosemirror-] packages with the [transform] dependency will make the pattern of the new line to override the row above it.

Open NagiaME opened this issue 3 years ago • 7 comments

To Reproduce Steps to reproduce the behavior:

  1. Add the editor into a new project.
  2. Or delete the yarn lock file.
  3. Or upgrade the packages.
  4. Then using the '/' to create a new row, the new row's pattern will override the row above the new one. If the patterns are the same of these two row, the old one's pattern will be removed as a normal world line.

Expected behavior The cause of this exception may is the newer [prosemirror-] packages are using the newer [prosemirror-transform] (upper than 1.2.5). The way I could only find to solve it is to change the lines about the inner dependencies in the yarn.lock file of the project which is using the editor manually, like:

prosemirror-transform@^1.0.0, prosemirror-transform@^1.1.0, prosemirror-transform@^1.2.1:
  version "1.2.12"
  resolved "https://registry.yarnpkg.com/prosemirror-transform/-/prosemirror-transform-1.2.12.tgz#4398b568faf75a1540fbf5c659ca436a8657ed6f"
  integrity sha512-S73syqLcGBq6QiPaF7vriB8kpvK/aIFsnErrriKaFLSiE/GxMgBc62TPhNQAeGQr7/9GCDApIReTsJFcMt4o2w==
  dependencies:
    prosemirror-model "^1.0.0"

to

prosemirror-transform@^1.0.0, prosemirror-transform@^1.1.0, prosemirror-transform@^1.2.1:
  version "1.2.5"
  resolved "https://registry.yarnpkg.com/prosemirror-transform/-/prosemirror-transform-1.2.5.tgz#7a3e2c61fcdbaf1d0844a2a3bc34fc3524e9809c"
  integrity sha512-eqeIaxWtUfOnpA1ERrXCuSIMzqIJtL9Qrs5uJMCjY5RMSaH5o4pc390SAjn/IDPeIlw6auh0hCCXs3wRvGnQug==
  dependencies:
    prosemirror-model "^1.0.0"

Version <=11.6.2

Screenshots

image

image

(Don't care about the styles)

NagiaME avatar Apr 02 '21 10:04 NagiaME

This has been brought up several times, and is the reason that the package.json explicitly specificies 1.2.5 as the required dependency :(

https://github.com/outline/rich-markdown-editor/blob/main/package.json#L43

tommoor avatar Apr 02 '21 15:04 tommoor

Same problem here. I am getting prosemirror-transform: 1.3.2 in a fresh install.

The below changes in the yarn.lock file helped. Thanks @NagiaME !

I've changed this:

prosemirror-transform@^1.0.0, prosemirror-transform@^1.1.0, prosemirror-transform@^1.2.1:
  version "1.3.2"
  resolved "https://registry.yarnpkg.com/prosemirror-transform/-/prosemirror-transform-1.3.2.tgz#5620ebe7379e6fae4f34ecc881886cb22ce96579"
  integrity sha512-/G6d/u9Mf6Bv3H1XR8VxhpjmUO75LYmnvj+s3ZfZpakU1hnQbsvCEybml1B3f2IWUAAQRFkbO1PnsbFhLZsYsw==
  dependencies:
    prosemirror-model "^1.0.0"

to this:

prosemirror-transform@^1.0.0, prosemirror-transform@^1.1.0, prosemirror-transform@^1.2.1:
  version "1.2.5"
  resolved "https://registry.yarnpkg.com/prosemirror-transform/-/prosemirror-transform-1.2.5.tgz#7a3e2c61fcdbaf1d0844a2a3bc34fc3524e9809c"
  integrity sha512-eqeIaxWtUfOnpA1ERrXCuSIMzqIJtL9Qrs5uJMCjY5RMSaH5o4pc390SAjn/IDPeIlw6auh0hCCXs3wRvGnQug==
  dependencies:
    prosemirror-model "^1.0.0"

mzalevski avatar Apr 07 '21 13:04 mzalevski

@mzalevski Since yarn.lock is auto-generated and changes can be easily overwritten, you might want to add to resolutions in your package.json

  ...
  "resolutions": {
    "prosemirror-transform": "1.2.5"
  },

amazingmarvin avatar Jun 22 '21 14:06 amazingmarvin

I came into this problem when I delete node_modules and reinstall. when using npm v7, u can also use the yarn "resolutions": { "prosemirror-transform": "1.2.5" }, with https://github.com/rogeriochaves/npm-force-resolutions.

uptonking avatar Jun 23 '21 14:06 uptonking

As mentioned before the package json explicitly specifics 1.2.5 as the required dependency, I don't know why package managers keep ignoring it 🤷

tommoor avatar Jun 23 '21 15:06 tommoor

@tommoor 1.2.5 gets correctly installed, but some of the other packages are requesting other versions of it. prosemirror-commands, prosemirror-history, prosemirror-inputrules, etc. ask for ^1.0.0, prosemirror-dropcursor asks for ^1.1.0, prosemirror-tables asks for ^1.2.1.

So a fresh project that just does yarn add rich-markdown-editor gets two versions installed:

[email protected]:
  version "1.2.5"
  resolved "https://registry.yarnpkg.com/prosemirror-transform/-/prosemirror-transform-1.2.5.tgz#7a3e2c61fcdbaf1d0844a2a3bc34fc3524e9809c"
  integrity sha512-eqeIaxWtUfOnpA1ERrXCuSIMzqIJtL9Qrs5uJMCjY5RMSaH5o4pc390SAjn/IDPeIlw6auh0hCCXs3wRvGnQug==
  dependencies:
    prosemirror-model "^1.0.0"

prosemirror-transform@^1.0.0, prosemirror-transform@^1.1.0, prosemirror-transform@^1.2.1:
  version "1.3.2"
  resolved "https://registry.yarnpkg.com/prosemirror-transform/-/prosemirror-transform-1.3.2.tgz#5620ebe7379e6fae4f34ecc881886cb22ce96579"
  integrity sha512-/G6d/u9Mf6Bv3H1XR8VxhpjmUO75LYmnvj+s3ZfZpakU1hnQbsvCEybml1B3f2IWUAAQRFkbO1PnsbFhLZsYsw==
  dependencies:
    prosemirror-model "^1.0.0"

I'm not sure what the best way to handle this is! But for an end-user, using "resolutions" in package.json seems to work. Unfortunately it doesn't work if you install rich-markdown-editor locally from the file system which makes hacking more difficult.

amazingmarvin avatar Jun 24 '21 07:06 amazingmarvin

Yea, I still feel like this is a problem in the package manager though - it should optimize for least installed duplicate packages IMO. There's not much that can be done about it though other than what you've described.

tommoor avatar Jun 24 '21 07:06 tommoor