wy-editor 1.0.0 → 1.0.3

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.
Files changed (39) hide show
  1. package/dist/demo.html +1 -0
  2. package/dist/fonts/element-icons.f1a45d74.ttf +0 -0
  3. package/dist/fonts/element-icons.ff18efd1.woff +0 -0
  4. package/dist/wy-editor.common.js +109385 -0
  5. package/dist/wy-editor.common.js.map +1 -0
  6. package/dist/wy-editor.css +1 -0
  7. package/dist/wy-editor.umd.js +109396 -0
  8. package/dist/wy-editor.umd.js.map +1 -0
  9. package/dist/wy-editor.umd.min.js +47 -0
  10. package/dist/wy-editor.umd.min.js.map +1 -0
  11. package/package.json +9 -4
  12. package/.browserslistrc +0 -3
  13. package/babel.config.js +0 -5
  14. package/jsconfig.json +0 -19
  15. package/public/favicon.ico +0 -0
  16. package/public/index.html +0 -17
  17. package/src/App.vue +0 -127
  18. package/src/assets/logo.png +0 -0
  19. package/src/components/FieldVariable.vue +0 -104
  20. package/src/components/FormulaList.vue +0 -132
  21. package/src/core/calculate.js +0 -90
  22. package/src/core/functionCore.js +0 -92
  23. package/src/core/index.js +0 -249
  24. package/src/formula/base.js +0 -11
  25. package/src/formula/frequentlyUse/formula.json +0 -30
  26. package/src/formula/frequentlyUse/index.js +0 -13
  27. package/src/formula/index.js +0 -12
  28. package/src/formula/mathFormula/formula.json +0 -142
  29. package/src/formula/mathFormula/index.js +0 -13
  30. package/src/formula/statistics/formula.json +0 -30
  31. package/src/formula/statistics/index.js +0 -13
  32. package/src/formula/stringData/formula.json +0 -93
  33. package/src/formula/stringData/index.js +0 -13
  34. package/src/index.js +0 -5
  35. package/src/index.vue +0 -219
  36. package/src/main.js +0 -14
  37. package/src/router/index.js +0 -14
  38. package/src/utils/index.js +0 -35
  39. package/vue.config.js +0 -4
package/src/index.vue DELETED
@@ -1,219 +0,0 @@
1
- <template>
2
- <div class="vue-formula">
3
- <codemirror @ready="onCmReady" v-model="code" :options="options" />
4
-
5
- <div class="formula-info-container" :data-error="`${validInfo != ''}`">
6
- <span v-if="validInfo">公式错误:{{ validInfo }}</span>
7
- </div>
8
- <div class="operator-container">
9
- <FieldVariable @fieldSelect="onFieldSelect" :fieldList="fieldList" />
10
- <FormulaList :nodes="nodes" @formulaClick="onFormulaClick" @enterInfo="onEnterInfo" />
11
- <div v-if="currentFormula" class="formula-info">
12
- <div class="info-text">{{ currentFormula.tip }}</div>
13
- <div class="info-text">用法:{{ currentFormula.usage }}</div>
14
- <div class="info-text">示例:{{ currentFormula.example }}</div>
15
- </div>
16
- </div>
17
- </div>
18
- </template>
19
-
20
- <script>
21
- // 组件样式
22
- import 'codemirror/lib/codemirror.css'
23
- // 主题
24
- import 'codemirror/theme/3024-day.css'
25
- import 'codemirror/theme/ayu-mirage.css'
26
- import 'codemirror/theme/monokai.css'
27
- // 语言模式
28
- import 'codemirror/mode/javascript/javascript.js'
29
- import 'codemirror/addon/hint/show-hint.css'
30
- import 'codemirror/addon/hint/show-hint.js'
31
- import { codemirror } from 'vue-codemirror'
32
- import FormulaEditorCore from './core/index'
33
- import FieldVariable from './components/FieldVariable.vue'
34
- import FormulaList from './components/FormulaList.vue'
35
- export default {
36
- name: 'vue-formula',
37
- components: {
38
- codemirror,
39
- FieldVariable,
40
- FormulaList,
41
- },
42
- props: {
43
- fieldList: {
44
- type: Array,
45
- default: () => [],
46
- },
47
- formulaList: {
48
- type: Array,
49
- default: () => [],
50
- },
51
- formulaConf: {
52
- type: Object,
53
- default: () => ({}),
54
- },
55
- },
56
- data() {
57
- return {
58
- editorCore: null,
59
- code: '',
60
- currentFormula: null,
61
- validInfo: '',
62
- options: {
63
- autofocus: true,
64
- line: true,
65
- height: 200,
66
- theme: '3024-day', // 主题
67
- tabSize: 4, // 制表符的宽度
68
- readOnly: false, // 只读
69
- autorefresh: false,
70
- smartIndent: true, // 上下文缩进
71
- lineNumbers: false, // 是否显示行号
72
- styleActiveLine: true, // 高亮选中行
73
- showCursorWhenSelecting: true, // 当选择处于活动状态时是否应绘制游标
74
- },
75
- }
76
- },
77
- computed: {
78
- nodes() {
79
- return this.formulaList || []
80
- },
81
- },
82
- watch: {
83
- code(val) {
84
- if (!val) {
85
- this.validInfo = ''
86
- return
87
- }
88
- const { error, message } = this.editorCore.validateFormula(
89
- this.fieldList
90
- )
91
-
92
- this.validInfo = error ? message : ''
93
- },
94
- },
95
- methods: {
96
- reset() {
97
- this.currentFormula = null
98
- this.editorCore.reset()
99
- },
100
- getData() {
101
- return this.editorCore.getData()
102
- },
103
- onCmReady(codemirror) {
104
- this.editorCore = new FormulaEditorCore(
105
- codemirror,
106
- '',
107
- this.formulaList
108
- )
109
- this.editorCore.registerListen()
110
-
111
- this.editorCore.renderData(this.formulaConf)
112
- },
113
-
114
- onFormulaClick(formula) {
115
- this.currentFormula = formula
116
- this.editorCore.insertText(`${formula.name}()`, 'formula')
117
- },
118
- onFieldSelect(field) {
119
- this.editorCore.insertText(
120
- {
121
- ...field,
122
- menuId: this.currentMenuId,
123
- },
124
- 'field'
125
- )
126
- },
127
- onEnterInfo(fumulaInfo) {
128
- this.currentFormula = fumulaInfo
129
- }
130
- },
131
- created() { },
132
- mounted() { },
133
- }
134
- </script>
135
- <style lang="less" scoped>
136
- .vue-formula {
137
- .formula-info-container {
138
- padding: 0 6px;
139
- color: #8d3030;
140
- display: flex;
141
- height: 40px;
142
- align-items: center;
143
- &[data-error='false'] {
144
- background-color: #f7f7f7;
145
- }
146
- }
147
-
148
- .operator-container {
149
- display: flex;
150
- flex: 1;
151
- overflow: hidden;
152
- margin-top: 10px;
153
- .field-variable {
154
- width: 250px;
155
- }
156
-
157
- .formula-list {
158
- width: 220px;
159
- }
160
-
161
- .formula-info {
162
- flex: 1;
163
- display: flex;
164
- flex-direction: column;
165
- padding: 6px;
166
- border-radius: 5px;
167
- border: 1px solid #eee;
168
- height: 228px;
169
- .info-text {
170
- font-size: 12px;
171
- color: #6b7280;
172
- margin: 6px 0;
173
- }
174
- }
175
- }
176
- }
177
- </style>
178
-
179
- <style>
180
- .vue-formula {
181
- height: fit-content;
182
- margin-top: 10px;
183
- border-radius: 4px;
184
- display: flex;
185
- flex-direction: column;
186
- height: 500px;
187
-
188
- .CodeMirror {
189
- height: 200px;
190
- }
191
- }
192
-
193
- .CodeMirror-hints {
194
- z-index: 30000 !important;
195
- background-color: #f0f0f0;
196
- color: #333;
197
- width: 130px;
198
- font-size: 14px;
199
- border: 1px solid #ccc;
200
- padding: 10px;
201
- border-radius: 4px;
202
- max-height: 200px;
203
- overflow-y: auto;
204
- }
205
-
206
- .cm-string {
207
- color: #f56c6c !important;
208
- }
209
-
210
- .cm-field {
211
- background: #eaf2fd;
212
- color: #2f7deb !important;
213
- border-radius: 2px;
214
- display: inline-block;
215
- font-size: 14px;
216
- margin: 0 2px;
217
- padding: 3px 5px;
218
- }
219
- </style>
package/src/main.js DELETED
@@ -1,14 +0,0 @@
1
- import Vue from 'vue'
2
-
3
- import ElementUI from 'element-ui'
4
- import 'element-ui/lib/theme-chalk/index.css'
5
- import App from './App.vue'
6
- import router from './router'
7
-
8
- Vue.use(ElementUI)
9
- Vue.config.productionTip = false
10
-
11
- new Vue({
12
- router,
13
- render: h => h(App),
14
- }).$mount('#app')
@@ -1,14 +0,0 @@
1
- import Vue from 'vue'
2
- import VueRouter from 'vue-router'
3
-
4
- Vue.use(VueRouter)
5
-
6
- const routes = []
7
-
8
- const router = new VueRouter({
9
- mode: 'history',
10
- base: process.env.BASE_URL,
11
- routes,
12
- })
13
-
14
- export default router
@@ -1,35 +0,0 @@
1
- function generateRandomString(length) {
2
- const characters =
3
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
4
- let result = ''
5
- for (let i = 0; i < length; i++) {
6
- result += characters.charAt(Math.floor(Math.random() * characters.length))
7
- }
8
- return result
9
- }
10
-
11
- function generateRandomNumber(min, max) {
12
- return Math.floor(Math.random() * (max - min + 1)) + min
13
- }
14
-
15
- function generateRandomArray(length, min, max) {
16
- const result = []
17
- for (let i = 0; i < length; i++) {
18
- result.push(generateRandomNumber(min, max))
19
- }
20
- return result
21
- }
22
-
23
- export function generateRandomData(dataType, options) {
24
- const { length = 10, min = 0, max = 100 } = options || {}
25
- switch (dataType) {
26
- case 'string':
27
- return generateRandomString(length)
28
- case 'number':
29
- return generateRandomNumber(min, max)
30
- case 'array':
31
- return generateRandomArray(length, min, max)
32
- default:
33
- throw new Error('Invalid data type')
34
- }
35
- }
package/vue.config.js DELETED
@@ -1,4 +0,0 @@
1
- const { defineConfig } = require('@vue/cli-service')
2
- module.exports = defineConfig({
3
- transpileDependencies: true
4
- })