Extract modeType
This commit is contained in:
parent
18a6f9063e
commit
68ccee20b3
3 changed files with 15 additions and 13 deletions
|
@ -80,6 +80,7 @@ import { preventXSS } from './render'
|
||||||
import Editor from './lib/editor'
|
import Editor from './lib/editor'
|
||||||
|
|
||||||
import getUIElements from './lib/editor/ui-elements'
|
import getUIElements from './lib/editor/ui-elements'
|
||||||
|
import modeType from './lib/editor/modeType'
|
||||||
|
|
||||||
var defaultTextHeight = 20
|
var defaultTextHeight = 20
|
||||||
var viewportMargin = 20
|
var viewportMargin = 20
|
||||||
|
@ -226,17 +227,6 @@ var supportExtraTags = [
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
window.modeType = {
|
|
||||||
edit: {
|
|
||||||
name: 'edit'
|
|
||||||
},
|
|
||||||
view: {
|
|
||||||
name: 'view'
|
|
||||||
},
|
|
||||||
both: {
|
|
||||||
name: 'both'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var statusType = {
|
var statusType = {
|
||||||
connected: {
|
connected: {
|
||||||
msg: 'CONNECTED',
|
msg: 'CONNECTED',
|
||||||
|
|
11
public/js/lib/editor/modeType.js
Normal file
11
public/js/lib/editor/modeType.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
export default {
|
||||||
|
edit: {
|
||||||
|
name: 'edit'
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
name: 'view'
|
||||||
|
},
|
||||||
|
both: {
|
||||||
|
name: 'both'
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
import markdownitContainer from 'markdown-it-container'
|
import markdownitContainer from 'markdown-it-container'
|
||||||
|
|
||||||
import { md } from './extra'
|
import { md } from './extra'
|
||||||
|
import modeType from './lib/editor/modeType'
|
||||||
|
|
||||||
function addPart (tokens, idx) {
|
function addPart (tokens, idx) {
|
||||||
if (tokens[idx].map && tokens[idx].level === 0) {
|
if (tokens[idx].map && tokens[idx].level === 0) {
|
||||||
|
@ -228,7 +229,7 @@ function buildMapInner (callback) {
|
||||||
let viewScrollingTimer = null
|
let viewScrollingTimer = null
|
||||||
|
|
||||||
export function syncScrollToEdit (event, preventAnimate) {
|
export function syncScrollToEdit (event, preventAnimate) {
|
||||||
if (window.currentMode !== window.modeType.both || !window.syncscroll || !editArea) return
|
if (window.currentMode !== modeType.both || !window.syncscroll || !editArea) return
|
||||||
if (window.preventSyncScrollToEdit) {
|
if (window.preventSyncScrollToEdit) {
|
||||||
if (typeof window.preventSyncScrollToEdit === 'number') {
|
if (typeof window.preventSyncScrollToEdit === 'number') {
|
||||||
window.preventSyncScrollToEdit--
|
window.preventSyncScrollToEdit--
|
||||||
|
@ -310,7 +311,7 @@ function viewScrollingTimeoutInner () {
|
||||||
let editScrollingTimer = null
|
let editScrollingTimer = null
|
||||||
|
|
||||||
export function syncScrollToView (event, preventAnimate) {
|
export function syncScrollToView (event, preventAnimate) {
|
||||||
if (window.currentMode !== window.modeType.both || !window.syncscroll || !viewArea) return
|
if (window.currentMode !== modeType.both || !window.syncscroll || !viewArea) return
|
||||||
if (window.preventSyncScrollToView) {
|
if (window.preventSyncScrollToView) {
|
||||||
if (typeof preventSyncScrollToView === 'number') {
|
if (typeof preventSyncScrollToView === 'number') {
|
||||||
window.preventSyncScrollToView--
|
window.preventSyncScrollToView--
|
||||||
|
|
Loading…
Reference in a new issue