vue-editify 0.0.50 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/examples/App.vue CHANGED
@@ -1,6 +1,21 @@
1
1
  <template>
2
2
  <div style="padding: 100px 50px 50px 50px; height: 100%; box-sizing: border-box">
3
- <editify v-model="value" placeholder="请输入正文内容..." allow-paste-html @change="change" :menu="menuConfig" ref="editify" :height="'300px'" @after-render="afterRender" :paste-keep-marks="{ 'data-zip': ['span'] }" autofocus :custom-parse-node="parseNode" :show-word-length="true" :border="true"></editify>
3
+ <div style="display: none" ref="bigData">
4
+ <div>
5
+ <div id="1">
6
+ <div id="2">
7
+ <h3 id="3">
8
+ <p>333div</p>
9
+ <p>333div</p>
10
+ </h3>
11
+ </div>
12
+ </div>
13
+ <p>
14
+ <pre>3333</pre>
15
+ </p>
16
+ </div>
17
+ </div>
18
+ <editify v-model="value" placeholder="请输入正文内容..." allow-paste-html :menu="menuConfig" ref="editify" :paste-keep-marks="{ 'data-zip': ['span'] }" autofocus :show-word-length="true" :border="true" :disabled="disabled" @updateview="updateview" :customParseNoe="customParseNoe"></editify>
4
19
  </div>
5
20
  </template>
6
21
  <script>
@@ -46,7 +61,7 @@ export default {
46
61
  //转成base64
47
62
  const base64 = await Dap.file.dataFileToBase64(file)
48
63
  //创建元素
49
- const zipEle = new AlexElement('closed', 'span', { 'data-zip': 'true', contenteditable: 'false' }, null, null)
64
+ const zipEle = new AlexElement('closed', 'span', { 'data-zip': base64, contenteditable: 'false' }, null, null)
50
65
  //插入编辑器
51
66
  this.$refs.editify.editor.insertElement(zipEle)
52
67
  //移动光标到新插入的元素
@@ -60,48 +75,21 @@ export default {
60
75
  }
61
76
  upload.click()
62
77
  }
63
- },
64
- alert: {
65
- title: '自定义菜单按钮',
66
- leftBorder: true,
67
- rightBorder: false,
68
- disabled: false,
69
- active: false,
70
- type: 'select',
71
- options: [
72
- {
73
- label: '自定义功能1',
74
- value: '1',
75
- style: {
76
- color: '#f30'
77
- }
78
- },
79
- {
80
- label: '自定义功能2',
81
- value: '2',
82
- style: {
83
- fontWeight: 'bold'
84
- }
85
- },
86
- {
87
- label: '自定义功能3',
88
- value: '3'
89
- }
90
- ],
91
- onOperate: function (name, val, instance) {
92
- this.insertHtml('<p>我是插入的HTML</p>', true, false)
93
- },
94
- default: () => h('span', {}, '自定义菜单')
95
78
  }
96
79
  }
97
80
  },
98
- btn: null
81
+ btn: null,
82
+ disabled: false
99
83
  }
100
84
  },
101
- mounted() {},
85
+ mounted() {
86
+ setTimeout(() => {
87
+ this.value = this.$refs.bigData.innerHTML
88
+ }, 500)
89
+ },
102
90
  methods: {
103
- afterRender() {
104
- this.$refs.editify.$el.querySelectorAll('[data-zip]').forEach(el => {
91
+ updateview() {
92
+ this.$refs.editify.$el.querySelectorAll('span[data-zip]').forEach(el => {
105
93
  el.onclick = function () {
106
94
  const url = el.getAttribute('data-zip')
107
95
  const a = document.createElement('a')
@@ -111,17 +99,11 @@ export default {
111
99
  }
112
100
  })
113
101
  },
114
- parseNode(ele) {
102
+ customParseNoe(ele) {
115
103
  if (ele.hasMarks() && ele.marks['data-zip']) {
116
104
  ele.type = 'closed'
117
105
  }
118
106
  return ele
119
- },
120
- change() {
121
- //console.log(this.$refs.editify.textValue)
122
- },
123
- operate(name, val) {
124
- //console.log('触发operate事件', name, val)
125
107
  }
126
108
  }
127
109
  }