forked from Hufe921/canvas-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Hufe921#32 from Hufe921/feature/control
Feature/control
- Loading branch information
Showing
26 changed files
with
1,350 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Editor, { ControlType, ElementType } from '../../../src/editor' | ||
|
||
describe('控件-列举型', () => { | ||
|
||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/canvas-editor/') | ||
|
||
cy.get('canvas').first().as('canvas').should('have.length', 1) | ||
}) | ||
|
||
const text = `有` | ||
const elementType: ElementType = <ElementType>'control' | ||
const controlType: ControlType = <ControlType>'select' | ||
|
||
it('列举型', () => { | ||
cy.getEditor().then((editor: Editor) => { | ||
editor.listener.saved = function (payload) { | ||
const data = payload.data[0] | ||
|
||
expect(data.control!.value![0].value).to.be.eq(text) | ||
|
||
expect(data.control!.code).to.be.eq('98175') | ||
} | ||
|
||
editor.command.executeSelectAll() | ||
|
||
editor.command.executeBackspace() | ||
|
||
editor.command.executeInsertElementList([{ | ||
type: elementType, | ||
value: '', | ||
control: { | ||
type: controlType, | ||
value: null, | ||
placeholder: '列举型', | ||
valueSets: [{ | ||
value: '有', | ||
code: '98175' | ||
}, { | ||
value: '无', | ||
code: '98176' | ||
}] | ||
} | ||
}]) | ||
|
||
cy.get('@canvas').type(`{leftArrow}`) | ||
|
||
cy.get('.select-control-popup li').eq(0).click() | ||
|
||
cy.get('@canvas').type('{ctrl}s') | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Editor, { ControlType, ElementType } from '../../../src/editor' | ||
|
||
describe('控件-文本型', () => { | ||
|
||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/canvas-editor/') | ||
|
||
cy.get('canvas').first().as('canvas').should('have.length', 1) | ||
}) | ||
|
||
const text = `canvas-editor` | ||
const elementType: ElementType = <ElementType>'control' | ||
const controlType: ControlType = <ControlType>'text' | ||
|
||
it('文本型', () => { | ||
cy.getEditor().then((editor: Editor) => { | ||
editor.listener.saved = function (payload) { | ||
const data = payload.data[0] | ||
|
||
expect(data.control!.value![0].value).to.be.eq(text) | ||
} | ||
|
||
editor.command.executeSelectAll() | ||
|
||
editor.command.executeBackspace() | ||
|
||
editor.command.executeInsertElementList([{ | ||
type: elementType, | ||
value: '', | ||
control: { | ||
type: controlType, | ||
value: null, | ||
placeholder: '文本型' | ||
} | ||
}]) | ||
|
||
cy.get('@canvas').type(`{leftArrow}`) | ||
|
||
cy.get('.inputarea').type(text) | ||
|
||
cy.get('@canvas').type('{ctrl}s') | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.select-control-popup { | ||
max-width: 160px; | ||
min-width: 69px; | ||
max-height: 225px; | ||
position: absolute; | ||
z-index: 1; | ||
border: 1px solid #e4e7ed; | ||
border-radius: 4px; | ||
background-color: #fff; | ||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1); | ||
box-sizing: border-box; | ||
margin: 5px 0; | ||
overflow-y: auto; | ||
} | ||
|
||
.select-control-popup ul { | ||
list-style: none; | ||
padding: 3px 0; | ||
margin: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
.select-control-popup ul li { | ||
font-size: 13px; | ||
padding: 0 20px; | ||
position: relative; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
color: #666; | ||
height: 36px; | ||
line-height: 36px; | ||
box-sizing: border-box; | ||
cursor: pointer; | ||
} | ||
|
||
.select-control-popup ul li:hover { | ||
background-color: #EEF2FD; | ||
} | ||
|
||
.select-control-popup ul li.active { | ||
color: var(--COLOR-HOVER, #5175f4); | ||
font-weight: 700; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
@import './control/select.css'; | ||
|
||
.inputarea { | ||
width: 0; | ||
height: 12px; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.