diff --git a/commitlint.config.js b/commitlint.config.js index 309803c..277b4b0 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -2,7 +2,7 @@ export default { parserPreset: 'conventional-changelog-conventionalcommits', rules: { 'body-leading-blank': [1, 'always'], - 'body-max-line-length': [2, 'always', 100], + 'body-max-line-length': [2, 'always', 120], 'footer-leading-blank': [1, 'always'], 'footer-max-line-length': [2, 'always', 100], 'header-max-length': [2, 'always', 100], diff --git a/package.json b/package.json index 55ec578..c5e6523 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mind-elixir", - "version": "4.2.2", + "version": "4.2.3", "type": "module", "description": "Mind elixir is a free open source mind map core.", "keywords": [ diff --git a/src/dev.ts b/src/dev.ts index 3f7d751..c8c781b 100644 --- a/src/dev.ts +++ b/src/dev.ts @@ -43,7 +43,6 @@ const options: Options = { }, ], }, - mobileMenu: true, toolBar: true, nodeMenu: true, keypress: true, diff --git a/src/index.ts b/src/index.ts index 934fd43..d6da062 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,7 +38,6 @@ function MindElixir( generateMainBranch, generateSubBranch, overflowHidden, - mobileMenu, theme, }: Options ): void { @@ -63,7 +62,6 @@ function MindElixir( this.toolBar = toolBar === undefined ? true : toolBar this.keypress = keypress === undefined ? true : keypress this.mouseSelectionButton = mouseSelectionButton || 0 - this.mobileMenu = mobileMenu || false // record the direction before enter focus mode, must true in focus mode, reset to null after exit focus this.direction = typeof direction === 'number' ? direction : 1 this.draggable = draggable === undefined ? true : draggable diff --git a/src/methods.ts b/src/methods.ts index 5732778..9e2ae4c 100644 --- a/src/methods.ts +++ b/src/methods.ts @@ -2,13 +2,12 @@ import type { MindElixirInstance, MindElixirData } from './index' import linkDiv from './linkDiv' import contextMenu from './plugin/contextMenu' import keypress from './plugin/keypress' -import mobileMenu from './plugin/mobileMenu' import nodeDraggable from './plugin/nodeDraggable' import operationHistory from './plugin/operationHistory' import toolBar from './plugin/toolBar' import selection from './plugin/selection' import { editTopic, createWrapper, createParent, createChildren, createTopic, findEle } from './utils/dom' -import { getObjById, generateNewObj, fillParent, isMobile } from './utils/index' +import { getObjById, generateNewObj, fillParent } from './utils/index' import { layout } from './utils/layout' import changeTheme from './utils/theme' import * as interact from './interact' @@ -89,9 +88,7 @@ const methods = { if (this.editable) { selection(this) } - if (isMobile() && this.mobileMenu) { - mobileMenu(this) - } else if (this.contextMenu) { + if (this.contextMenu) { this.disposable.push(contextMenu(this, this.contextMenuOption)) } this.draggable && nodeDraggable(this) diff --git a/src/plugin/mobileMenu.less b/src/plugin/mobileMenu.less deleted file mode 100644 index 3dec2d5..0000000 --- a/src/plugin/mobileMenu.less +++ /dev/null @@ -1,42 +0,0 @@ -.mind-elixir .mobile-menu { - position: absolute; - left: 20px; - bottom: 70px; - z-index: 99; - margin: 0; - padding: 0; - // font: 300 15px 'Roboto', sans-serif; - color: #333; - border-radius: 5px; - box-shadow: 0 12px 15px 0 rgba(0, 0, 0, 0.2); - overflow: hidden; - * { - transition: color 0.4s, background-color 0.4s; - } - div { - float: left; - text-align: center; - width: 30px; - overflow: hidden; - white-space: nowrap; - padding: 8px; - background-color: #fff; - border-bottom: 1px solid #ecf0f1; - a { - color: #333; - text-decoration: none; - } - &.disabled { - color: rgb(94, 94, 94); - background-color: rgb(247, 247, 247); - &:hover { - cursor: default; - background-color: rgb(247, 247, 247); - } - } - &:hover { - cursor: pointer; - background-color: #ecf0f1; - } - } -} diff --git a/src/plugin/mobileMenu.ts b/src/plugin/mobileMenu.ts deleted file mode 100644 index 9b1355a..0000000 --- a/src/plugin/mobileMenu.ts +++ /dev/null @@ -1,155 +0,0 @@ -import type { MindElixirInstance, NodeObj } from '../types/index' -import './mobileMenu.less' - -export default function (mind: MindElixirInstance, option?: any) { - const createLi = (id: string, name: string) => { - const div = document.createElement('div') - div.id = id - div.innerHTML = `` - return div - } - - const add_child = createLi('cm-add_child', 'zijiedian') - const add_sibling = createLi('cm-add_sibling', 'tongjijiedian-') - const remove_child = createLi('cm-remove_child', 'shanchu2') - // let focus = createLi('cm-fucus', i18n[locale].focus, '') - // let unfocus = createLi('cm-unfucus', i18n[locale].cancelFocus, '') - const up = createLi('cm-up', 'rising') - const down = createLi('cm-down', 'falling') - const edit = createLi('cm-edit', 'edit') - // let link = createLi('cm-down', i18n[locale].link, '') - - const menuUl = document.createElement('ul') - menuUl.className = 'menu-list' - // if (!option || option.link) { - // menuUl.appendChild(link) - // } - if (option && option.extend) { - for (let i = 0; i < option.extend.length; i++) { - const item = option.extend[i] - const dom = createLi(item.name, item.name) - menuUl.appendChild(dom) - dom.onclick = e => { - item.onclick(e) - } - } - } - const menuContainer = document.createElement('mmenu') - menuContainer.className = 'mobile-menu' - menuContainer.appendChild(add_child) - menuContainer.appendChild(add_sibling) - menuContainer.appendChild(remove_child) - // if (!option || option.focus) { - // menuContainer.appendChild(focus) - // menuContainer.appendChild(unfocus) - // } - menuContainer.appendChild(up) - menuContainer.appendChild(down) - menuContainer.appendChild(edit) - menuContainer.hidden = true - - mind.container.append(menuContainer) - let isRoot = true - // mind.container.onclick = function (e) { - // e.preventDefault() - // // console.log(e.pageY, e.screenY, e.clientY) - // let target = e.target - // if (target.tagName === 'ME-TPC') { - // if (target.parentElement.tagName === 'ME-ROOT') { - // isRoot = true - // } else { - // isRoot = false - // } - // // if (isRoot) { - // // focus.className = 'disabled' - // // up.className = 'disabled' - // // down.className = 'disabled' - // // add_sibling.className = 'disabled' - // // remove_child.className = 'disabled' - // // } else { - // // focus.className = '' - // // up.className = '' - // // down.className = '' - // // add_sibling.className = '' - // // remove_child.className = '' - // // } - // mind.selectNode(target) - // menuContainer.hidden = false - // let height = menuUl.offsetHeight - // let width = menuUl.offsetWidth - // let rect = target.getBoundingClientRect() - // // menuUl.style.top = rect.top - 10 - height + 'px' - // // menuUl.style.left = rect.left - (width - rect.width) / 2 + 'px' - // // menuUl.style.left = e.clientX + 'px' - // } - // } - - mind.bus.addListener('unselectNode', function () { - menuContainer.hidden = true - }) - mind.bus.addListener('selectNode', function (nodeObj: NodeObj) { - menuContainer.hidden = false - if (!nodeObj.parent) { - isRoot = true - } else { - isRoot = false - } - }) - menuContainer.onclick = e => { - if (e.target === menuContainer) menuContainer.hidden = true - } - - add_child.onclick = () => { - mind.addChild() - } - add_sibling.onclick = () => { - if (isRoot) return - mind.insertSibling('after') - } - remove_child.onclick = () => { - if (isRoot) return - mind.removeNode() - } - // focus.onclick = e => { - // if (isRoot) return - // mind.focusNode(mind.currentNode) - // menuContainer.hidden = true - // } - // unfocus.onclick = e => { - // mind.cancelFocus() - // menuContainer.hidden = true - // } - up.onclick = e => { - if (isRoot) return - mind.moveUpNode() - } - down.onclick = e => { - if (isRoot) return - mind.moveDownNode() - } - edit.onclick = e => { - mind.beginEdit() - } - // link.onclick = e => { - // let from = mind.currentNode - // mind.map.addEventListener( - // 'click', - // e => { - // e.preventDefault() - // if ( - // e.target.parentElement.tagName === 'ME-PARENT' || - // e.target.parentElement.tagName === 'ME-ROOT' - // ) { - // mind.drawArrow(from, mind.currentNode) - // } else { - // console.log('取消连接') - // } - // }, - // { - // once: true, - // } - // ) - // } -} diff --git a/src/types/index.ts b/src/types/index.ts index 5abdfa6..50877e9 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -74,7 +74,6 @@ export interface MindElixirInstance extends MindElixirMethods { overflowHidden: boolean mainBranchStyle: number subBranchStyle: number - mobileMenu: boolean generateMainBranch: (params: MainLineParams) => PathString generateSubBranch: (params: SubLineParams) => PathString @@ -130,7 +129,6 @@ export type Options = { overflowHidden?: boolean generateMainBranch?: (this: MindElixirInstance, params: MainLineParams) => PathString generateSubBranch?: (this: MindElixirInstance, params: SubLineParams) => PathString - mobileMenu?: boolean theme?: Theme nodeMenu?: boolean selectionContainer?: string | HTMLElement