Cannot read properties of undefined (reading 'localsInner')

未关闭
#665 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
markdown, react, typescript, webpack

调研方向

Start with webpack.config.js, the dependency versions in package.json, and App.tsx to reproduce the localsInner failure in a minimal React application. Compare the module versions and imports used in issue #409, then run the development build to confirm the runtime error is gone. Also verify how the default preset enables the table toolbar command in WYSIWYG mode.

由索引模型根据 Issue 内容生成。

描述

I have the same problem that was described here earlier. But nothing changed for me after switching package managers (npm, yarn, pnpm, etc.).
I changed the versions of your package, used your examples to create a React application, but this error always remains.

there're my configs:

webpack.config.js

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

module.exports = {
  mode: "development",
  entry: "./src/index.tsx",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.js",
  },
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        loader: "esbuild-loader",
          options: {
            loader: 'jsx',
            target: 'es2020',
            format: "cjs",
        },
      },
      {
         test: /\.(ts|tsx)$/,
         loader: "esbuild-loader",
         options: {
           loader: "tsx",
           target: "esnext",
           format: "cjs",
         },
         exclude: /node_modules/,
       },
      {
         test: /\.css$/,
         use: ["style-loader", "css-loader"],
       },
    ],
  },
  resolve: {
   fallback: {
      http: false,
      https: false,
      stream: false,
      fs: false,
      process: false,
      path: false,
      url: false,
      punycode: false,
      buffer: false,
    },
    extensions: [".js",".jsx",".ts",".tsx"],
  },
  plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      template: "./public/index.html",
    }),
  ],
  devServer: {
    static: path.join(__dirname, "dist"),
    compress: true,
    port: 3001,
  },
};

tsconfig.json

{
   "compilerOptions": {
     "target": "ESNext",
     "module": "ESNext",
     "jsx": "react-jsx",
     "strict": true,
     "esModuleInterop": true,
     "skipLibCheck": true,
     "forceConsistentCasingInFileNames": true,
     "moduleResolution": "bundler"
   },
   "include": ["src"]
}

dependencies in package.json

"@diplodoc/transform": "^4.47.2",
    "@gravity-ui/markdown-editor": "^15.1.0",
    "@gravity-ui/uikit": "^7.4.0",
    "highlight.js": "^11.11.1",
    "lodash": "^4.17.21",
    "lowlight": "^3.3.0",
    "patch-package": "^8.0.0",
    "postinstall-postinstall": "^2.1.0",
    "react": "^18.0.2",
    "react-dom": "^18.0.2"

and my App.tsx

import React from 'react';
import { ThemeProvider, ToasterProvider, configure } from '@gravity-ui/uikit';
import { toaster } from '@gravity-ui/uikit/toaster-singleton';
import { useMarkdownEditor, MarkdownEditorView } from '@gravity-ui/markdown-editor';
import '@gravity-ui/uikit/styles/styles.css';

function Editor({ onSubmit }: any) {

  const editor = useMarkdownEditor({
    preset: "default",
    md: {
      html: false,
    },
    initial: {
      markup: content,
      mode: "wysiwyg",
      toolbarVisible: true,
      splitModeEnabled: true
    }
  });
  
  React.useEffect(() => {
    function submitHandler() {
      // Serialize current content to markdown markup
      const value = editor.getValue();
      onSubmit(value);
    }

    editor.on('submit', submitHandler);
    return () => {
      editor.off('submit', submitHandler);
    };
  }, [onSubmit]);

  return  <MarkdownEditorView stickyToolbar autofocus editor={editor} />;
}

export default function App() {
  return (
        <ThemeProvider>
        <ToasterProvider toaster={toaster}>
          <Editor onSubmit={(value: any) => console.log(value)} />
        </ToasterProvider>
      </ThemeProvider>
  );
}

To better understand the situation, I can create a repository with the project.

And additionally, I would like to ask. You have a preset for working with pure Markdown, specifically the "default" preset, which should also include a table, but it's not in the toolbar and it's unclear how to create it in WYSIWYG mode?

主要语言
TypeScript
星标
428
派生
48
平均合并
5 天 15 小时
30 天内合并 PR
47

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

gravity-ui/markdown-editor 的其他 Issue

查看 gravity-ui/markdown-editor 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。