Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
183 additions
and
123 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import createEditor, { selector } from '../../helpers/create-editor' | ||
import Editor from '../../../src/editor/index' | ||
import $ from 'jquery' | ||
|
||
let editor: Editor | ||
const FULLSCREEN_MENU_CLASS_SELECTOR = '.w-e-icon-fullscreen' | ||
|
||
describe('设置全屏', () => { | ||
beforeEach(() => { | ||
editor = createEditor(document, selector()) | ||
}) | ||
|
||
test('编辑器默认初始化全屏菜单', () => { | ||
const toolbarSelector = editor.$toolbarElem.elems[0].className | ||
const fullMenuEl = $(`.${toolbarSelector}`).find(FULLSCREEN_MENU_CLASS_SELECTOR) | ||
|
||
expect(fullMenuEl.length).toBe(1) | ||
}) | ||
|
||
test('编辑器区和菜单分离的编辑器不初始化全屏菜单', () => { | ||
const seprateModeEditor = createEditor(document, selector(), selector()) | ||
const toolbarSelector = seprateModeEditor.$toolbarElem.selector as string | ||
const fullMenuEl = $(toolbarSelector).find(FULLSCREEN_MENU_CLASS_SELECTOR) | ||
|
||
expect(fullMenuEl.length).toBe(0) | ||
}) | ||
|
||
test('编辑器配置 showFullScreen 为false时不初始化全屏菜单', () => { | ||
const seprateModeEditor = createEditor(document, selector(), '', { showFullScreen: false }) | ||
const toolbarSelector = seprateModeEditor.$toolbarElem.selector as string | ||
const fullMenuEl = $(toolbarSelector).find(FULLSCREEN_MENU_CLASS_SELECTOR) | ||
|
||
expect(fullMenuEl.length).toBe(0) | ||
}) | ||
}) |
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,23 @@ | ||
import createEditor, { selector } from '../../helpers/create-editor' | ||
import { setFullScreen } from '../../../src/editor/init-fns/set-full-screen' | ||
import $ from 'jquery' | ||
|
||
const EDIT_CONTAINER_FULLSCREEN_CLASS = 'w-e-full-screen-editor' | ||
|
||
test('调用 setFullScreen 设置编辑器全屏模式', () => { | ||
const editor = createEditor(document, selector()) | ||
|
||
setFullScreen(editor) | ||
|
||
const toolbarSelector = editor.$toolbarElem.elems[0].className | ||
const $iconElem = $(`.${toolbarSelector}`).children().last().find('i') | ||
const $editorParent = $(`.${toolbarSelector}`).parent().get(0) | ||
const $textContainerElem = editor.$textContainerElem | ||
|
||
expect($iconElem.get(0).className).toContain('w-e-icon-fullscreen_exit') | ||
console.log($editorParent.className) | ||
expect($editorParent.className).toContain(EDIT_CONTAINER_FULLSCREEN_CLASS) | ||
expect(+$editorParent.style.zIndex).toEqual(editor.config.zIndexFullScreen) | ||
const bar = editor.$toolbarElem.getBoundingClientRect() | ||
expect($textContainerElem.elems[0].style.height).toBe(`calc(100% - ${bar.height}px)`) | ||
}) |
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,23 @@ | ||
import createEditor, { selector } from '../../helpers/create-editor' | ||
import { setFullScreen, setUnFullScreen } from '../../../src/editor/init-fns/set-full-screen' | ||
import $ from 'jquery' | ||
|
||
const EDIT_CONTAINER_FULLSCREEN_CLASS = 'w-e-full-screen-editor' | ||
|
||
test.only('调用 setUnFullScreen 取消编辑器全屏模式', () => { | ||
const editor = createEditor(document, selector()) | ||
|
||
setFullScreen(editor) | ||
|
||
setUnFullScreen(editor) | ||
|
||
const toolbarSelector = editor.$toolbarElem.elems[0].className | ||
const $iconElem = $(`.${toolbarSelector}`).children().last().find('i') | ||
const $editorParent = $(`.${toolbarSelector}`).parent().get(0) | ||
const $textContainerElem = editor.$textContainerElem | ||
|
||
expect($iconElem.get(0).className).toContain('w-e-icon-fullscreen') | ||
expect($editorParent.className).not.toContain(EDIT_CONTAINER_FULLSCREEN_CLASS) | ||
expect($editorParent.style.zIndex).toBe('auto') | ||
expect($textContainerElem.elems[0].style.height).toBe(editor.config.height + 'px') | ||
}) |
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
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.