tiddly-gittly / slate-write

A WYSIWYG editor for TiddlyWiki. (WIP)
https://tiddly-gittly.github.io/slate-write/
MIT License
39 stars 4 forks source link

Uncaught TypeError: Cannot read properties of undefined (reading 'attach') #54

Open linonetwo opened 1 year ago

linonetwo commented 1 year ago
react-dom:4 Uncaught TypeError: Cannot read properties of undefined (reading 'attach')
    at Object.eval [as keyMap] (codemirror.js:4:156330)
    at new ul (codemirror.js:4:133292)
    at ul (codemirror.js:4:129471)
    at ul.fromTextArea (codemirror.js:4:168807)
    at eval (index.js:41214:44)
    at Tr (react-dom:4:73687)
    at pl (react-dom:4:93859)
    at eval (react-dom:4:92602)
    at dl (react-dom:4:92667)
    at el (react-dom:4:86419)
    at xn (react-dom:4:32646)
    at pl (react-dom:4:94001)
    at eval (react-dom:4:90457)
    at v (react:4:3374)
    at Array.ce (react:4:5514)
    at eval (echarts-wordcloud.min.js:5:2655)

在打了三个 ` ,尝试插入代码块时报错

之后会导致默认编辑模式也进不去,因为 codemirror 崩了

linonetwo commented 1 year ago
* 在服务端可以正常加载模块并拿到导出的内容
* 需要验证在浏览器端是否可以加载,及经过其他打包工具打包后的前端项目是否能够加载
** fetch 远端的 mjd 需要服务端开启 cors,但是我[ext[常用的 serve 这个功能有毛病|https://github.com/vercel/serve/issues/771]]
*** 先手动复制到 storybook 的 asset 里解决
** 但 storybook 加载静态资源的方式只有 import 这一种,实际找不到带有 `/static` 的 URL 路径
*** 其实是类似 `/src/stories/assets/comments.svg` 这样的路径,`GET http://localhost:6006/src/stories/assets/comments.svg` 即可
** 点按钮会运行加载的逻辑,打了log但火狐开发者工具里怎么也看不到log
*** storybook在火狐里有问题,可能一直加载的是缓存的旧版。改为用Edge浏览器开发就好了
** 的确能够加载
* 但是openai的sdk打包后引用了crypto库,导致在前端导入后报错 `TypeError: Failed to resolve module specifier "/@id/__vite-browser-external:crypto". Invalid relative url or base scheme isn't hierarchical.` 因为里面的 `import{randomFillSync as a}from"crypto";`
** 得试试不带node依赖的,或分为前后端程序,带后端依赖的程序只有在有nodejs后端Provider时才加载
*** 来自 npm 的依赖 `import e from"ajv";` 也会导致 `TypeError: Failed to resolve module specifier "/node_modules/.cache/.vite-storybook/deps/ajv.js?v=5dd5b90d".`,因为 rollup 在打包插件时如果没有开 `json(),     commonjs(),     nodeResolve({ preferBuiltins: true }),`,就会默认作为 external dependency,使用 import/require 的方式引入:

[[在这里尝试插入代码块]]
king0billy commented 6 months ago

插眼