1.0.40 • Published 2 months ago

@pingfe/editor v1.0.40

Weekly downloads
113
License
ISC
Repository
-
Last release
2 months ago

编辑器

注意

粘贴html时会自动过滤块级子元素属性,需要改源码
const toolTags = tags.reduce((result, tag) => {
  result[tag.toLowerCase()] = true;
  // result[tag.toLowerCase()] = {}; 将这一行修改成上边这行
  return result;
}, {});
源码文件地址:src/editorjs/components/modules/paste.ts#L569
粘贴figure图片时没有figcaption会无法粘贴
return {
  content,
  content: (content.tagName === 'FIGURE' && $.isNodeEmpty(n) && content.childNodes.length > 0) ? content.childNodes[0]: content// 修改,
  isBlock,
  tool,
  event,
};
源码文件地址:src/editorjs/components/modules/paste.ts#L582
将iframe设置为单标签
return tag.tagName && [
      ...
      'WBR',
      'IFRAME' // 新增
    ].includes(tag.tagName);
源码文件地址:src/editorjs/components/modules/dom.ts#L13
将\n br 换行转换block换行
nodes = nodes.reduce((res: any, node: any) => {
  if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
    const div = $.make('div')
    div.appendChild(node)
    console.log(div.innerHTML, 'div.innerHTML')
    const paragraph = div.innerHTML ? div.innerHTML.split(/(\n|<br\/>|<br>)/): []
    if (paragraph.length > 0) {
      paragraph.map(text => {
        const p = $.make('p')
        p.innerHTML = text
        res.push(p)
      })
    } else {
      res.push(node)
    }
  } else {
    res.push(node)
  }
  return res
}, [])

源码文件地址:src/editorjs/components/modules/paste.ts#L544
给编辑器增加header样式
if (contentNode.querySelector('h2') || contentNode.querySelector('h3')) {
  contentNode.style.marginTop = '22px'
  contentNode.style.marginBottom = '8px'
}
源码文件地址:src/editorjs/components/block/index.ts#L688

启动

npm run build 项目中配置 '@editor': require.resolve('项目地址/dist/editor')

1.0.40

2 months ago

1.0.39

2 months ago

1.0.38

2 months ago

1.0.37

2 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.29

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.34

3 years ago

1.0.28

3 years ago

1.0.26

3 years ago

1.0.27

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.22

3 years ago

1.0.23

3 years ago

1.0.19

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago