Skip to content

Commit

Permalink
chore: 🏰 2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
rojer95 committed Aug 9, 2023
1 parent 2275856 commit e7fcc11
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 37 deletions.
61 changes: 55 additions & 6 deletions docs/demos/math.tsx

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions docs/getting-started/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ nav: 文档

基于 DSlate 的 Antd 风格包,支持 html 渲染与小程序 RichNode 渲染模式

> 小程序请手动引入 katex-mini 包的 css ,具体请看链接:https://github.com/rojer95/katex-mini
> Antd 版本要求:antd >= 5.0
> !!!重要提示!!!<br/>
> 1、小程序请手动引入 katex-mini 包的 css ,具体请看链接:https://github.com/rojer95/katex-mini <br/>
> 2、Latex 插件 从 DSlate V2.0.7 开始支持 <br/>
> 3、DSlate 2.0 起对 Antd 版本要求 >= 5.0
## Demo

Expand Down
4 changes: 3 additions & 1 deletion docs/getting-started/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type DSlatePlugin = {
locale?: Locale[];
props?: Record<string, any>;
serialize?: (element: any, pluginProps: any, children: any[]) => string;
serializeWeapp?: (element: any, pluginProps: any, children: any[]) => any;
};
```

Expand All @@ -65,7 +66,8 @@ type DSlatePlugin = {
| isDefaultElement | `boolean` | 是否为默认渲染组件 |
| locale | `Locale[]` | 国际化语言文案, 用法见 [国际化](/docs/locale#插件国际化) |
| props | `Record<string, any>` | 插件预设参数 [详见下方](#插件-props) |
| serialize | `(element: any, pluginProps: any, children: any[]) => string` | 转 HTML 方法 |
| serialize | `(element: any, pluginProps: any, children: any[]) => any` | 转 HTML 方法 |
| serializeWeapp | `(element: any, pluginProps: any, children: any[]) => string` | 转 小程序 RichNode 方法 |

### nodeType

Expand Down
10 changes: 10 additions & 0 deletions packages/antd/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @dslate/antd

## 2.0.7

### Patch Changes

- 支持 latex & 支持导出小程序 RichNode &题目编排 demo
- Updated dependencies
- @dslate/component@2.0.7
- @dslate/core@2.0.7
- @dslate/plugin@2.0.7

## 2.0.6

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/antd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dslate/antd",
"version": "2.0.6",
"version": "2.0.7",
"description": "一个Antd Design风格的富文本编辑器 - A Antd Design style rich editor based on Slate",
"keywords": [
"antd",
Expand All @@ -25,9 +25,9 @@
"build": "tsc && vite build"
},
"dependencies": {
"@dslate/component": "workspace:2.0.6",
"@dslate/core": "workspace:2.0.6",
"@dslate/plugin": "workspace:2.0.6",
"@dslate/component": "workspace:2.0.7",
"@dslate/core": "workspace:2.0.7",
"@dslate/plugin": "workspace:2.0.7",
"classnames": "^2.3.2",
"styled-components": "^5.3.6"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/component/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @dslate/component

## 2.0.7

### Patch Changes

- 支持 latex & 支持导出小程序 RichNode &题目编排 demo
- Updated dependencies
- @dslate/core@2.0.7

## 2.0.6

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/component/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dslate/component",
"version": "2.0.6",
"version": "2.0.7",
"description": "DSlate组件 - Component of DSlate",
"keywords": [
"antd",
Expand Down Expand Up @@ -30,7 +30,7 @@
"dev": "tsc && vite build --watch"
},
"devDependencies": {
"@dslate/core": "workspace:2.0.6",
"@dslate/core": "workspace:2.0.7",
"@types/node": "^14.18.36",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
Expand All @@ -40,7 +40,7 @@
"vite-plugin-dts": "^1.7.2"
},
"peerDependencies": {
"@dslate/core": ">=2.0.6",
"@dslate/core": ">=2.0.7",
"react": ">=16.9.0",
"react-dom": ">=16.9.0",
"slate": ">=0.90.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @dslate/core

## 2.0.7

### Patch Changes

- 支持 latex & 支持导出小程序 RichNode &题目编排 demo

## 2.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dslate/core",
"version": "2.0.6",
"version": "2.0.7",
"description": "一个Ant Design风格的富文本编辑器 - An Ant Design style rich editor based on Slate",
"keywords": [
"wysiwyg",
Expand Down
9 changes: 9 additions & 0 deletions packages/plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @dslate/plugin

## 2.0.7

### Patch Changes

- 支持 latex & 支持导出小程序 RichNode &题目编排 demo
- Updated dependencies
- @dslate/component@2.0.7
- @dslate/core@2.0.7

## 2.0.6

### Patch Changes
Expand Down
22 changes: 21 additions & 1 deletion packages/plugin/lib/plugins/latex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import parseKatexWeapp from '@rojer/katex-mini';
import katex from 'katex';
import 'katex/dist/katex.min.css';
import { useMemo } from 'react';
import { Editor, Text, Transforms } from 'slate';
import { Editor, Range, Text, Transforms } from 'slate';
import { ReactEditor, useSelected, useSlate } from 'slate-react';
const TYPE = 'latex';

Expand All @@ -25,6 +25,26 @@ const remove = (editor: Editor) => {

const add = (editor: Editor) => {
if (!editor.selection) return;
if (Range.isCollapsed(editor.selection)) {
Transforms.insertNodes(editor, {
type: TYPE,
children: [{ text: '' }],
});
} else {
Transforms.wrapNodes(
editor,
{
type: TYPE,
children: [],
},
{
at: editor.selection,
match: (n) => Text.isText(n),
split: true,
},
);
}

Transforms.wrapNodes(
editor,
{
Expand Down
10 changes: 1 addition & 9 deletions packages/plugin/lib/plugins/paragraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ const ParagraphPlugin: DSlatePlugin = {
}</${tag}>`;
},
serializeWeapp: (element, props, children) => {
const isEmpty = Node.string(element) === '';
let tag = 'div';

if (element?.[PROPS_KEY] === 'h1') {
Expand All @@ -241,14 +240,7 @@ const ParagraphPlugin: DSlatePlugin = {
return {
type: 'node',
name: tag,
children: isEmpty
? [
{
type: 'text',
text: '&nbsp;',
},
]
: children,
children,
};
},
};
Expand Down
10 changes: 5 additions & 5 deletions packages/plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dslate/plugin",
"version": "2.0.6",
"version": "2.0.7",
"description": "DSlate预设插件 - Preset plugin of DSlate",
"keywords": [
"wysiwyg",
Expand Down Expand Up @@ -39,8 +39,8 @@
"styled-components": "^5.3.6"
},
"devDependencies": {
"@dslate/component": "workspace:2.0.6",
"@dslate/core": "workspace:2.0.6",
"@dslate/component": "workspace:2.0.7",
"@dslate/core": "workspace:2.0.7",
"@types/is-hotkey": "^0.1.7",
"@types/katex": "^0.16.2",
"@types/node": "^14.18.36",
Expand All @@ -54,8 +54,8 @@
"vite-plugin-dts": "^1.7.2"
},
"peerDependencies": {
"@dslate/component": ">=2.0.6",
"@dslate/core": ">=2.0.6",
"@dslate/component": ">=2.0.7",
"@dslate/core": ">=2.0.7",
"react": ">=16.9.0",
"react-dom": ">=16.9.0",
"slate": ">=0.90.0",
Expand Down
10 changes: 10 additions & 0 deletions packages/semi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @dslate/semi

## 2.0.7

### Patch Changes

- 支持 latex & 支持导出小程序 RichNode &题目编排 demo
- Updated dependencies
- @dslate/component@2.0.7
- @dslate/core@2.0.7
- @dslate/plugin@2.0.7

## 2.0.6

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/semi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dslate/semi",
"version": "2.0.6",
"version": "2.0.7",
"description": "一个Semi Design风格的富文本编辑器 - A Semi Design style rich editor based on Slate",
"keywords": [
"antd",
Expand All @@ -25,9 +25,9 @@
"build": "tsc && vite build"
},
"dependencies": {
"@dslate/component": "workspace:2.0.6",
"@dslate/core": "workspace:2.0.6",
"@dslate/plugin": "workspace:2.0.6",
"@dslate/component": "workspace:2.0.7",
"@dslate/core": "workspace:2.0.7",
"@dslate/plugin": "workspace:2.0.7",
"classnames": "^2.3.2",
"styled-components": "^5.3.6"
},
Expand Down

0 comments on commit e7fcc11

Please sign in to comment.