我目前正在构建一个类似于 medium.com 上使用的编辑器。对于每个unstyled块,我渲染一个自定义组件,其中包含编辑按钮以更改该部分的块类型。
但是,例如,当我将部分更改为 aheader-one并点击返回按钮时,新块也是一个header-one块。我喜欢看到新块unstyled而不是前一个块的相同类型。
关于如何做到这一点的任何想法?
编辑
经过更多的搜索和尝试,我自己找到了解决方案!似乎最好的方法是在split-blockkeyCommand 被触发时插入一个新块。示例代码如下:
createEmptyBlock(editorState: Draft.EditorState) {
const newBlock = new Draft.ContentBlock({
key: Draft.genKey(),
type: "unstyled",
text: "",
characterList: Immutable.List()
})
const contentState = editorState.getCurrentContent()
const newBlockMap = contentState.getBlockMap().set(newBlock.getKey(), newBlock)
return Draft.EditorState.push(
editorState,
Draft.ContentState
.createFromBlockArray(newBlockMap.toArray())
.set('selectionAfter', contentState.getSelectionAfter().merge({
anchorKey: newBlock.getKey(),
anchorOffset: 0,
focusKey: newBlock.getKey(),
focusOffset: 0,
isBackward: false,
})) as Draft.ContentState,
"split-block"
)
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个在开发过程中托管 NodeJS 项目的 docker 镜像。它只是使用 nodemon 执行 NodeJS 应用程序,因此每次我进行更改时它都会重新启动。
我还使用 TypeScript 来开发应用程序。TypeScript 必须有权访问已安装的@types模块。但是,应该显示node_modules文件夹的已安装卷是空的。所以 TypeScript 找不到模块,也无法编译。我的 IDE 也在抱怨(显然)
有没有办法让node_modulesTypeScript 可见?
这是我的 Dockerfile:
FROM node:alpine
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json .
RUN npm install
# Bundle app source
COPY . .
# Run app
CMD [ "npm", "start" ]
Run Code Online (Sandbox Code Playgroud)
这是我的 docker-compose.yml:
version: "3"
services:
server:
build: .
environment:
- NODE_ENV=development
command: npm run debug
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules …Run Code Online (Sandbox Code Playgroud)