12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /*
- menu - header
- */
- import $ from '../../util/dom-core.js'
- import DropList from '../droplist.js'
- // 构造函数
- function Questionborder(editor) {
- this.editor = editor
- this.$elem = $('<div class="lsiten-e-menu">题框</div>')
- this.type = 'droplist'
- // 当前是否 active 状态
- this._active = false
- // 初始化 droplist
- this.droplist = new DropList(this, {
- width: 100,
- $title: $('<p>题框</p>'),
- type: 'list', // droplist 以列表形式展示
- list: [
- { $elem: $('<p>客观题框</p>'), value: 'question_1' },
- { $elem: $('<p>主观题框</p>'), value: 'question_2' }
- ],
- onClick: (value) => {
- // 注意 this 是指向当前的 Head 对象
- this._command(value)
- }
- })
- }
- // 原型
- Questionborder.prototype = {
- constructor: Questionborder,
- // 执行命令
- _command: function (value) {
- console.log(value)
- let funName = 'lsiten_' + value;
- if (this[funName]) {
- this[funName]();
- }
- },
- lsiten_question_1: function () {
- this.editor.cmd.do('border', {type: 1, data: {
- row: 2,
- column: 3
- }});
- },
- lsiten_question_2: function () {
- this.editor.cmd.do('border', {type: 2, data: {}});
- }
- }
- export default Questionborder
|