Milkdown / website

The official documentation website for milkdown.
https://milkdown.dev
MIT License
31 stars 101 forks source link

[Bug] MilkdownError: Context "editorViewOptions" not found after switching to `milkdown/kit` #45

Closed junchaw closed 2 months ago

junchaw commented 2 months ago

Hi I have been using milkdown for a while and it all work great, recently when making some changes I noticed you released a new kit package which includes all the basic stuff, then I tried to upgrade my dependency to use the latest, but I see the below error after switching from milkdown/core to milkdown/kit:

MilkdownError: Context "editorViewOptions" not found, do you forget to inject it?
    at d (index.ts:13:10)
    at G.get (container.ts:21:13)
    at L2.use (ctx.ts:87:28)
    at L2.update (ctx.ts:97:108)
    at c (index.ts:10:7)
    at editor.ts:75:55
    at Array.map (<anonymous>)
    at editor.ts:75:45
    at config.ts:18:13
    at editor.ts:142:29

Screenshot 2024-09-21 at 8 46 22 PM

It doesn't work in my use case and even if I copy the receipt https://milkdown.dev/docs/recipes/react I still get the same error, so I think there is no need to share my code, but this is my packages.json:

{
  "name": "app",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite --strictPort",
    "build": "tsc && vite build",
    "lint": "tsc && eslint . --ext ts,tsx --max-warnings 0",
    "preview": "vite preview",
    "trans:extract": "lingui extract",
    "trans:compile": "lingui compile"
  },
  "dependencies": {
    "react": "^18.3.1",
    "react-dom": "^18.3.1"
  },
  "devDependencies": {
    "@emotion/react": "^11.13.0",
    "@emotion/styled": "^11.13.0",
    "@fortawesome/fontawesome-svg-core": "^6.6.0",
    "@fortawesome/free-brands-svg-icons": "^6.6.0",
    "@fortawesome/free-solid-svg-icons": "^6.6.0",
    "@headlessui/react": "^2.1.1",
    "@lingui/cli": "^4.11.1",
    "@lingui/conf": "^4.11.1",
    "@lingui/core": "^4.11.1",
    "@lingui/react": "^4.11.1",
    "@lingui/vite-plugin": "^4.11.1",
    "@milkdown/kit": "^7.5.5",
    "@milkdown/react": "^7.5.0",
    "@milkdown/theme-nord": "^7.5.0",
    "@mui/base": "5.0.0-beta.40",
    "@mui/joy": "5.0.0-beta.48",
    "@tailwindcss/aspect-ratio": "^0.4.2",
    "@tailwindcss/container-queries": "^0.1.1",
    "@tailwindcss/forms": "^0.5.7",
    "@tailwindcss/typography": "^0.5.13",
    "@types/dompurify": "^3.0.5",
    "@types/luxon": "^3.4.2",
    "@types/node": "^20.14.9",
    "@types/react": "^18.3.3",
    "@types/react-dom": "^18.3.0",
    "@types/react-syntax-highlighter": "^15.5.13",
    "@typescript-eslint/eslint-plugin": "^7.14.1",
    "@typescript-eslint/parser": "^7.14.1",
    "@vitejs/plugin-react-swc": "^3.7.0",
    "autoprefixer": "^10.4.19",
    "axios": "^1.7.2",
    "clsx": "^2.1.1",
    "dnd-core": "^16.0.1",
    "dompurify": "^3.1.5",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "eslint-plugin-react-hooks": "^4.6.2",
    "eslint-plugin-react-refresh": "^0.4.7",
    "framer-motion": "^11.2.12",
    "immutability-helper": "^3.1.1",
    "lightgallery": "^2.7.2",
    "luxon": "^3.4.4",
    "marked": "^13.0.1",
    "postcss": "^8.4.39",
    "prettier": "3.3.3",
    "radash": "^12.1.0",
    "react-dnd": "^16.0.1",
    "react-dnd-html5-backend": "^16.0.1",
    "react-dnd-touch-backend": "^16.0.1",
    "react-icons": "^5.2.1",
    "react-idle-timer": "^5.7.2",
    "react-router-dom": "^6.24.0",
    "react-syntax-highlighter": "^15.5.0",
    "react-toastify": "^10.0.5",
    "react-tooltip": "^5.27.1",
    "react-use": "^17.5.0",
    "sass": "^1.77.6",
    "swr": "^2.2.5",
    "tailwindcss": "^3.4.4",
    "typescript": "^5.5.2",
    "usehooks-ts": "^3.1.0",
    "vite": "^5.3.2",
    "vite-tsconfig-paths": "^4.3.2"
  }
}

and now I have reverted my change to a working version, which is:

{
  "name": "app",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite --strictPort",
    "build": "tsc && vite build",
    "lint": "tsc && eslint . --ext ts,tsx --max-warnings 0",
    "preview": "vite preview",
    "trans:extract": "lingui extract",
    "trans:compile": "lingui compile"
  },
  "dependencies": {
    "react": "^18.3.1",
    "react-dom": "^18.3.1"
  },
  "devDependencies": {
    "@emotion/react": "^11.13.0",
    "@emotion/styled": "^11.13.0",
    "@fortawesome/fontawesome-svg-core": "^6.6.0",
    "@fortawesome/free-brands-svg-icons": "^6.6.0",
    "@fortawesome/free-solid-svg-icons": "^6.6.0",
    "@headlessui/react": "^2.1.1",
    "@lingui/cli": "^4.11.1",
    "@lingui/conf": "^4.11.1",
    "@lingui/core": "^4.11.1",
    "@lingui/react": "^4.11.1",
    "@lingui/vite-plugin": "^4.11.1",
    "@milkdown/core": "^7.4.0",
    "@milkdown/ctx": "^7.4.0",
    "@milkdown/preset-commonmark": "^7.4.0",
    "@milkdown/prose": "^7.4.0",
    "@milkdown/react": "^7.4.0",
    "@milkdown/theme-nord": "^7.4.0",
    "@milkdown/transformer": "^7.4.0",
    "@mui/base": "5.0.0-beta.40",
    "@mui/joy": "5.0.0-beta.48",
    "@tailwindcss/aspect-ratio": "^0.4.2",
    "@tailwindcss/container-queries": "^0.1.1",
    "@tailwindcss/forms": "^0.5.7",
    "@tailwindcss/typography": "^0.5.13",
    "@types/dompurify": "^3.0.5",
    "@types/luxon": "^3.4.2",
    "@types/node": "^20.14.9",
    "@types/react": "^18.3.3",
    "@types/react-dom": "^18.3.0",
    "@types/react-syntax-highlighter": "^15.5.13",
    "@typescript-eslint/eslint-plugin": "^7.14.1",
    "@typescript-eslint/parser": "^7.14.1",
    "@vitejs/plugin-react-swc": "^3.7.0",
    "autoprefixer": "^10.4.19",
    "axios": "^1.7.2",
    "clsx": "^2.1.1",
    "dnd-core": "^16.0.1",
    "dompurify": "^3.1.5",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "eslint-plugin-react-hooks": "^4.6.2",
    "eslint-plugin-react-refresh": "^0.4.7",
    "framer-motion": "^11.2.12",
    "immutability-helper": "^3.1.1",
    "lightgallery": "^2.7.2",
    "luxon": "^3.4.4",
    "marked": "^13.0.1",
    "postcss": "^8.4.39",
    "prettier": "3.3.3",
    "radash": "^12.1.0",
    "react-dnd": "^16.0.1",
    "react-dnd-html5-backend": "^16.0.1",
    "react-dnd-touch-backend": "^16.0.1",
    "react-icons": "^5.2.1",
    "react-idle-timer": "^5.7.2",
    "react-router-dom": "^6.24.0",
    "react-syntax-highlighter": "^15.5.0",
    "react-toastify": "^10.0.5",
    "react-tooltip": "^5.27.1",
    "react-use": "^17.5.0",
    "sass": "^1.77.6",
    "swr": "^2.2.5",
    "tailwindcss": "^3.4.4",
    "typescript": "^5.5.2",
    "usehooks-ts": "^3.1.0",
    "vite": "^5.3.2",
    "vite-tsconfig-paths": "^4.3.2"
  }
}
junchaw commented 2 months ago

Close in favor of https://github.com/Milkdown/milkdown/issues/1519

Saul-Mirone commented 2 months ago

maybe you have multiple versions of milkdown installed, have you tried to run pnpm/yarn dedupe?