Skip to content

Commit

Permalink
Merge pull request #5 from hqwlkj/add-config-file
Browse files Browse the repository at this point in the history
fix:test
  • Loading branch information
hqwlkj authored Oct 27, 2022
2 parents f37d107 + 92b7a48 commit 9a10ca9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .release-it.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module.exports = {
tagName: "v${version}",
commitMessage: "release: v${version}",
requireCleanWorkingDir: false,
requireBranch: "main",
requireBranch: "master",
},
hooks: {
"before:init": ["git pull origin main", "npm run test"],
"before:init": ["git pull origin master", "npm run test"],
},
npm: {
publish: false,
Expand Down
2 changes: 1 addition & 1 deletion src/module/parse-elem-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { DOMElement } from '../utils/dom'
import { IDomEditor, SlateDescendant, SlateElement } from '@wangeditor/editor'
import { IDomEditor, SlateDescendant } from '@wangeditor/editor'
import { ImageElement } from './custom-types'


Expand Down
4 changes: 1 addition & 3 deletions src/module/render-elem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {h, VNode} from 'snabbdom'
import {DomEditor, IDomEditor, SlateElement} from '@wangeditor/editor'
import {ImageElement} from './custom-types'
import {data} from "autoprefixer";

interface IImageSize {
width?: string
Expand All @@ -25,8 +24,7 @@ function renderContainer(
): VNode {
const {width, height, float} = imageInfo
const selected = DomEditor.isNodeSelected(editor, elemNode) // 当前节点是否选中
console.log('selected', selected)
console.log('isDisabled', editor.isDisabled())

const style: any = {}
if (width) style.width = width
if (height) style.height = height
Expand Down
2 changes: 1 addition & 1 deletion test/module/elem-to-html.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('float-image elem-to-html', () => {
const html = elemToHtmlConf.elemToHtml(elem, '')

expect(html).toBe(
`<img src="${src}" alt="logo" data-href="${href}" style="width:'100'; height:'80'; float:none"/>`
`<img src="${src}" alt="logo" data-href="${href}" style="width: 100;height: 80;float: none;"/>`
)
})
})
6 changes: 4 additions & 2 deletions test/module/parse-elem-html.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
* @author Yanghc
*/

import { $ } from 'dom7'
import $ from 'dom7'
import createEditor from '../utils/create-editor'
import {parseHtmlConf} from '../../src/module/parse-elem-html'

describe('parse elem html', () => {
const editor = createEditor()

it('parse html', () => {
debugger;
const $img = $(
'<img src="hello.png" alt="hello" data-href="http://localhost/" style="width: 10px; height: 5px;"/>'
'<img src="hello.png" alt="hello" data-href="http://localhost/" width="10px" height="5px" />'
)

// match selector
Expand All @@ -28,6 +29,7 @@ describe('parse elem html', () => {
style: {
width: '10px',
height: '5px',
float: '',
},
children: [{ text: '' }],
})
Expand Down
4 changes: 2 additions & 2 deletions test/module/render-elem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ describe('float-image render-elem', () => {

const containerVnode = renderImageConf.renderElem(elem, null, editor) as any
expect(containerVnode.sel).toBe('div')
expect(containerVnode.data.className).toBe('w-e-image-container')
expect(containerVnode.data.props.className).toBe('w-e-image-container')
expect(containerVnode.data.style.width).toBe('100')
expect(containerVnode.data.style.height).toBe('80')
expect(containerVnode.data.style.float).toBe('none')

const imageVnode = containerVnode.children[0] as any
expect(imageVnode.sel).toBe('img')
expect(imageVnode.data.src).toBe(src)
expect(imageVnode.data['data-href']).toBe(href)
expect(imageVnode.data.dataHref).toBe(href)
})
})

0 comments on commit 9a10ca9

Please sign in to comment.