merge master
This commit is contained in:
commit
d45cf4ae67
|
@ -9,18 +9,18 @@ on:
|
|||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
# build:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - uses: actions/setup-node@v1
|
||||
# with:
|
||||
# node-version: 12
|
||||
# - run: npm ci
|
||||
# - run: npm test
|
||||
|
||||
publish-npm:
|
||||
needs: build
|
||||
# needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -29,6 +29,8 @@ jobs:
|
|||
node-version: 12
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
- run: npm run build --if-present
|
||||
- run: npm publish --access=public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
|
|
|
@ -5,4 +5,6 @@ doc/
|
|||
docs/
|
||||
examples/
|
||||
test/
|
||||
attachment/
|
||||
TODO.md
|
||||
ISSUE.md
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@wangeditor-team/we-next",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.9",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@wangeditor-team/we-next",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.9",
|
||||
"description": "wangEditor next",
|
||||
"main": "dist/wangEditor.min.js",
|
||||
"types": "dist/wangEditor.d.ts",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
export default {
|
||||
menus: ['bold', 'head', 'link', 'underline', 'strikeThrough', 'fontStyle'],
|
||||
menus: ['bold', 'head', 'link', 'italic', 'underline', 'strikeThrough', 'fontStyle'],
|
||||
|
||||
fontNames: ['宋体', '微软雅黑', 'Arial', 'Tahoma', 'Verdana'],
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* @description 斜体
|
||||
* @author liuwei
|
||||
*/
|
||||
|
||||
import BtnMenu from '../menu-constructors/BtnMenu'
|
||||
import $ from '../../utils/dom-core'
|
||||
import Editor from '../../editor/index'
|
||||
import { MenuActive } from '../menu-constructors/Menu'
|
||||
|
||||
class Italic extends BtnMenu implements MenuActive {
|
||||
constructor(editor: Editor) {
|
||||
const $elem = $(
|
||||
`<div class="w-e-menu">
|
||||
<i class="w-e-icon-italic"></i>
|
||||
</div>`
|
||||
)
|
||||
super($elem, editor)
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击事件
|
||||
*/
|
||||
public clickHandler(): void {
|
||||
const editor = this.editor
|
||||
const isSelectEmpty = editor.selection.isSelectionEmpty()
|
||||
|
||||
if (isSelectEmpty) {
|
||||
// 选区范围是空的,插入并选中一个“空白”
|
||||
editor.selection.createEmptyRange()
|
||||
}
|
||||
|
||||
// 执行 italic 命令
|
||||
editor.cmd.do('italic')
|
||||
|
||||
if (isSelectEmpty) {
|
||||
// 需要将选区范围折叠起来
|
||||
editor.selection.collapseRange()
|
||||
editor.selection.restoreSelection()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试修改菜单激活状态
|
||||
*/
|
||||
public tryChangeActive(): void {
|
||||
const editor = this.editor
|
||||
if (editor.cmd.queryCommandState('italic')) {
|
||||
this.active()
|
||||
} else {
|
||||
this.unActive()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Italic
|
|
@ -6,6 +6,7 @@
|
|||
import Bold from './bold/index'
|
||||
import Head from './head/index'
|
||||
import Link from './link/index'
|
||||
import Italic from './italic/index'
|
||||
import Underline from './underline/index'
|
||||
import StrikeThrough from './strike-through/index'
|
||||
import FontStyle from './font-style/index'
|
||||
|
@ -13,6 +14,7 @@ import FontStyle from './font-style/index'
|
|||
export default {
|
||||
bold: Bold,
|
||||
head: Head,
|
||||
italic: Italic,
|
||||
link: Link,
|
||||
underline: Underline,
|
||||
strikeThrough: StrikeThrough,
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @description Italic test
|
||||
* @author liuwei
|
||||
*/
|
||||
|
||||
import createEditor from '../fns/create-editor'
|
||||
import Editor from '../../src/editor'
|
||||
import Italic from '../../src/menus/italic/index'
|
||||
import mockCmdFn from '../fns/command-mock'
|
||||
import { getMenuInstance } from '../fns/menus'
|
||||
|
||||
let editor: Editor
|
||||
let italicMenu: Italic
|
||||
|
||||
test('斜体', () => {
|
||||
editor = createEditor(document, 'div1') // 赋值给全局变量
|
||||
|
||||
// 找到 Italiic 菜单
|
||||
italicMenu = getMenuInstance(editor, Italic) as Italic
|
||||
|
||||
// 执行点击事件,模拟斜体
|
||||
mockCmdFn(document)
|
||||
;(italicMenu as Italic).clickHandler()
|
||||
expect(document.execCommand).toBeCalledWith('italic', false, undefined) // mock fn 被调用
|
||||
})
|
Loading…
Reference in New Issue