Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cycleccc/wangEditor-next
Browse files Browse the repository at this point in the history
  • Loading branch information
cycleccc committed Feb 24, 2025
2 parents bb844ab + 4b56542 commit 37bd40c
Show file tree
Hide file tree
Showing 41 changed files with 987 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:

# 上传覆盖率报告到 Codecov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5.2.0
uses: codecov/codecov-action@v5.3.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
Expand Down
8 changes: 8 additions & 0 deletions packages/editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 5.6.31

### Patch Changes

- 3f6d567: fix(table): allow parsing for TH elements in table module
- Updated dependencies [3f6d567]
- @wangeditor-next/table-module@1.6.42

## 5.6.30

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wangeditor-next/editor",
"version": "5.6.30",
"version": "5.6.31",
"description": "Web rich text editor, Web 富文本编辑器",
"keywords": [
"wangeditor",
Expand Down Expand Up @@ -59,7 +59,7 @@
"@wangeditor-next/code-highlight": "~1.3.29",
"@wangeditor-next/core": "~1.7.32",
"@wangeditor-next/list-module": "~1.1.38",
"@wangeditor-next/table-module": "~1.6.41",
"@wangeditor-next/table-module": "~1.6.42",
"@wangeditor-next/upload-image-module": "~1.1.35",
"@wangeditor-next/video-module": "~1.3.38",
"dom7": "^4.0.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-float-image/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @wangeditor-next/plugin-float-image

## 1.0.16

### Patch Changes

- Updated dependencies [3f6d567]
- @wangeditor-next/editor@5.6.31

## 1.0.15

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-float-image/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wangeditor-next/plugin-float-image",
"version": "1.0.15",
"version": "1.0.16",
"description": "wangEditor float image plugin",
"author": "cycleccc <[email protected]>",
"type": "module",
Expand Down Expand Up @@ -41,7 +41,7 @@
"url": "https://github.com/wangeditor-next/wangeditor-next/issues"
},
"peerDependencies": {
"@wangeditor-next/editor": "5.6.30",
"@wangeditor-next/editor": "5.6.31",
"dom7": "^3.0.0 || ^4.0.0",
"slate": "^0.72.0",
"snabbdom": "^3.1.0"
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-formula/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @wangeditor-next/plugin-formula

## 1.0.16

### Patch Changes

- Updated dependencies [3f6d567]
- @wangeditor-next/editor@5.6.31

## 1.0.15

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-formula/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wangeditor-next/plugin-formula",
"version": "1.0.15",
"version": "1.0.16",
"description": "wangEditor next formula 公式",
"author": "cycleccc <[email protected]>",
"type": "module",
Expand Down Expand Up @@ -44,7 +44,7 @@
"katex": "^0.16.0"
},
"peerDependencies": {
"@wangeditor-next/editor": "5.6.30",
"@wangeditor-next/editor": "5.6.31",
"katex": "^0.16.0",
"snabbdom": "^3.1.0"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-link-card/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @wangeditor-next/plugin-link-card

## 1.0.16

### Patch Changes

- Updated dependencies [3f6d567]
- @wangeditor-next/editor@5.6.31

## 1.0.15

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-link-card/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wangeditor-next/plugin-link-card",
"version": "1.0.15",
"version": "1.0.16",
"description": "wangEditor link card plugin",
"author": "cycleccc <[email protected]>",
"type": "module",
Expand Down Expand Up @@ -41,7 +41,7 @@
"url": "https://github.com/wangeditor-next/wangeditor-next/issues"
},
"peerDependencies": {
"@wangeditor-next/editor": "5.6.30",
"@wangeditor-next/editor": "5.6.31",
"dom7": "^3.0.0 || ^4.0.0",
"slate": "^0.72.0",
"snabbdom": "^3.1.0"
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @wangeditor-next/plugin-markdown

## 1.0.16

### Patch Changes

- Updated dependencies [3f6d567]
- @wangeditor-next/editor@5.6.31

## 1.0.15

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wangeditor-next/plugin-markdown",
"version": "1.0.15",
"version": "1.0.16",
"description": "wangEditor markdown plugin",
"author": "cycleccc <[email protected]>",
"type": "module",
Expand Down Expand Up @@ -41,7 +41,7 @@
"url": "https://github.com/wangeditor-next/wangeditor-next/issues"
},
"peerDependencies": {
"@wangeditor-next/editor": "5.6.30",
"@wangeditor-next/editor": "5.6.31",
"dom7": "^3.0.0 || ^4.0.0",
"slate": "^0.72.0",
"snabbdom": "^3.1.0"
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-mention/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @wangeditor-next/plugin-mention

## 1.0.1

### Patch Changes

- 140d22c: feat(plugin-mention): add mention plugin
90 changes: 90 additions & 0 deletions packages/plugin-mention/README-en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# wangEditor mention plugin

[中文文档](./README.md)

## Introduction

[wangeditor-next](https://github.com/cycleccc/wangEditor-next) mention plugin, like `@James`.

![](./_img/demo.png)

## Installation

```shell
yarn add @wangeditor-next/plugin-mention
```

## Usage

[Vue demo source code](https://github.com/wangfupeng1988/vue2-wangeditor-demo/blob/master/src/components/MyEditorWithMention.vue)

### Use in editor

```ts
import { IDomEditor, Boot, IEditorConfig } from '@wangeditor-next/editor'
import mentionModule, { MentionElement } from '@wangeditor-next/plugin-mention'

// Register
// You should register this before create editor, and register only once (not repeatedly).
Boot.registerModule(mentionModule)

// Show your modal
function showModal(editor: IDomEditor) {
// Get cursor's position info, to set modal position
const domSelection = document.getSelection()
const domRange = domSelection.getRangeAt(0)
if (domRange == null) return
const selectionRect = domRange.getBoundingClientRect()

// Get editor container's position info, maybe help to get right modal position
const containerRect = editor.getEditableContainer().getBoundingClientRect()

// Show your modal, and set position
// PS: You must implement the modal yourself, use <div> or Vue React component


// Insert mention node when emit some event.
function insertMention() {
const mentionNode: MentionElement = {
type: 'mention', // must be 'mention'
value: 'James', // text
info: { x: 1, y: 2 }, // extended info
children: [{ text: '' }], // must have an empty text node in children
}

editor.restoreSelection()
editor.deleteBackward('character') // delete '@'
editor.insertNode(mentionNode)
editor.move(1) // move curser
}
}

// hide your modal
function hideModal(editor: IDomEditor) {
// hide your modal
}

// editor config
const editorConfig: Partial<IEditorConfig> = {
EXTEND_CONF: {
mentionConfig: {
showModal, // required
hideModal, // required
},
},

// others...
}

// Then create editor and toolbar, you will use `editorConfig`
```

### Render HTML

You will get a mention's HTML format like this. You need to `decodeURIComponent` the value of `data-info`.

```html
<span data-w-e-type="mention" data-w-e-is-void data-w-e-is-inline data-value="James" data-info="%7B%22x%22%3A10%7D">@James</span>
```


87 changes: 87 additions & 0 deletions packages/plugin-mention/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# wangEditor mention 插件

[English Documentation](./README-en.md)

## 介绍

[wangeditor-next](https://github.com/cycleccc/wangEditor-next) mention 插件,如 `@张三`

![](./_img/demo.png)

## 安装

```shell
yarn add @wangeditor-next/plugin-mention
```

## 使用

[Vue 示例源码](https://github.com/wangfupeng1988/vue2-wangeditor-demo/blob/master/src/components/MyEditorWithMention.vue)

### 注册到编辑器

```ts
import { IDomEditor, Boot, IEditorConfig } from '@wangeditor-next/editor'
import mentionModule, { MentionElement } from '@wangeditor-next/plugin-mention'

// 注册。要在创建编辑器之前注册,且只能注册一次,不可重复注册。
Boot.registerModule(mentionModule)

// 显示弹框
function showModal(editor: IDomEditor) {
// 获取光标位置,定位 modal
const domSelection = document.getSelection()
const domRange = domSelection.getRangeAt(0)
if (domRange == null) return
const selectionRect = domRange.getBoundingClientRect()

// 获取编辑区域 DOM 节点的位置,以辅助定位
const containerRect = editor.getEditableContainer().getBoundingClientRect()

// 显示 modal 弹框,并定位
// PS:modal 需要自定义,如 <div> 或 Vue React 组件


// 当触发某事件(如点击一个按钮)时,插入 mention 节点
function insertMention() {
const mentionNode: MentionElement = {
type: 'mention', // 必须是 'mention'
value: '张三', // 文本
info: { x: 1, y: 2 }, // 其他信息,自定义
children: [{ text: '' }], // 必须有一个空 text 作为 children
}

editor.restoreSelection() // 恢复选区
editor.deleteBackward('character') // 删除 '@'
editor.insertNode(mentionNode) // 插入 mention
editor.move(1) // 移动光标
}
}

// 隐藏弹框
function hideModal(editor: IDomEditor) {
// 隐藏 modal
}

// 编辑器配置
const editorConfig: Partial<IEditorConfig> = {
EXTEND_CONF: {
mentionConfig: {
showModal, // 必须
hideModal, // 必须
},
},

// 其他...
}

// 创建创建和工具栏,会用到 editorConfig 。具体查看 wangEditor 文档
```

### 显示 HTML

mention 节点返回的 HTML 格式如下,其中 `data-info` 的值需要 `decodeURIComponent` 解析。

```html
<span data-w-e-type="mention" data-w-e-is-void data-w-e-is-inline data-value="张三" data-info="%7B%22x%22%3A10%7D">@张三</span>
```
Binary file added packages/plugin-mention/_img/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions packages/plugin-mention/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@wangeditor-next/plugin-mention",
"version": "1.0.1",
"description": "wangEditor mention plugin",
"author": "cycleccc <[email protected]>",
"type": "module",
"homepage": "https://github.com/wangeditor-next/wangEditor-next#readme",
"license": "MIT",
"types": "dist/plugin-mention/src/index.d.ts",
"main": "dist/index.js",
"module": "dist/index.mjs",
"exports": {
".": {
"types": "./dist/plugin-mention/src/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./dist/css/style.css": "./dist/css/style.css"
},
"directories": {
"lib": "dist"
},
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/wangeditor-next/wangEditor-next.git"
},
"scripts": {
"dev": "cross-env NODE_ENV=development rollup -c rollup.config.js",
"dev-watch": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
"build": "cross-env NODE_ENV=production rollup -c rollup.config.js",
"dev-size-stats": "cross-env NODE_ENV=development:size_stats rollup -c rollup.config.js",
"size-stats": "cross-env NODE_ENV=production:size_stats rollup -c rollup.config.js"
},
"bugs": {
"url": "https://github.com/wangeditor-next/wangeditor-next/issues"
},
"peerDependencies": {
"@wangeditor-next/editor": "5.6.31",
"snabbdom": "^3.1.0"
}
}
Loading

0 comments on commit 37bd40c

Please sign in to comment.