zydx-plus 1.33.333 → 1.33.334
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/package.json
CHANGED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="reactRef" class="react"></div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import { createElement } from 'react'
|
|
7
|
+
import { createRoot } from 'react-dom/client'
|
|
8
|
+
import { Tldraw } from 'tldraw'
|
|
9
|
+
import 'tldraw/tldraw.css'
|
|
10
|
+
|
|
11
|
+
const clearJson = {
|
|
12
|
+
store:{
|
|
13
|
+
"document:document":{
|
|
14
|
+
gridSize:10,
|
|
15
|
+
name:"",
|
|
16
|
+
meta:{},
|
|
17
|
+
id:"document:document",
|
|
18
|
+
typeName:"document"
|
|
19
|
+
},
|
|
20
|
+
"page:page":{
|
|
21
|
+
meta:{},
|
|
22
|
+
id:"page:page",
|
|
23
|
+
name:"Page 1",
|
|
24
|
+
index:"a1",
|
|
25
|
+
typeName:"page"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
schema:{
|
|
29
|
+
schemaVersion:1,
|
|
30
|
+
storeVersion:4,
|
|
31
|
+
recordVersions:{
|
|
32
|
+
asset:{
|
|
33
|
+
version:1,
|
|
34
|
+
subTypeKey:"type",
|
|
35
|
+
subTypeVersions:{
|
|
36
|
+
image:3,
|
|
37
|
+
video:3,
|
|
38
|
+
bookmark:1
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
camera:{version:1},
|
|
42
|
+
document:{version:2},
|
|
43
|
+
instance:{version:24},
|
|
44
|
+
instance_page_state:{version:5},
|
|
45
|
+
page:{"version":1},
|
|
46
|
+
shape:{
|
|
47
|
+
version:3,
|
|
48
|
+
subTypeKey:"type",
|
|
49
|
+
subTypeVersions:{
|
|
50
|
+
group:0,
|
|
51
|
+
text:1,
|
|
52
|
+
bookmark:2,
|
|
53
|
+
draw:1,
|
|
54
|
+
geo:8,
|
|
55
|
+
note:5,
|
|
56
|
+
line:4,
|
|
57
|
+
frame:0,
|
|
58
|
+
arrow:3,
|
|
59
|
+
highlight:0,
|
|
60
|
+
embed:4,
|
|
61
|
+
image:3,
|
|
62
|
+
video:2
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
instance_presence:{version:5},pointer:{version:1}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default {
|
|
71
|
+
name: "zydx-sketchpad",
|
|
72
|
+
data() {
|
|
73
|
+
return {
|
|
74
|
+
editor:null
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
mounted() {
|
|
78
|
+
const root = createRoot(this.$refs.reactRef)
|
|
79
|
+
root.render(createElement(Tldraw, {
|
|
80
|
+
onMount: this.handleMountedEditor,
|
|
81
|
+
hideUi: true
|
|
82
|
+
}, null))
|
|
83
|
+
},
|
|
84
|
+
methods: {
|
|
85
|
+
handleMountedEditor(editor) {
|
|
86
|
+
this.editor = editor
|
|
87
|
+
// editor.store.listen((entry) => {
|
|
88
|
+
// const up = entry.changes.updated
|
|
89
|
+
// })
|
|
90
|
+
},
|
|
91
|
+
// 清空
|
|
92
|
+
clear() {
|
|
93
|
+
this.editor.store.loadSnapshot(clearJson)
|
|
94
|
+
},
|
|
95
|
+
// 添加快照
|
|
96
|
+
setSnapshot(v) {
|
|
97
|
+
this.editor.store.loadSnapshot(v)
|
|
98
|
+
},
|
|
99
|
+
// 获取快照
|
|
100
|
+
getSnapshot() {
|
|
101
|
+
return this.editor.store.getSnapshot()
|
|
102
|
+
},
|
|
103
|
+
draw(v) {
|
|
104
|
+
this.styleProps('draw','color').defaultValue = v?.color?? 'black'
|
|
105
|
+
this.styleProps('draw','size').defaultValue = v?.size?? 'm'
|
|
106
|
+
this.editor.setCurrentTool('draw')
|
|
107
|
+
},
|
|
108
|
+
select() {
|
|
109
|
+
this.editor.setCurrentTool('select')
|
|
110
|
+
},
|
|
111
|
+
hand() {
|
|
112
|
+
this.editor.setCurrentTool('hand')
|
|
113
|
+
},
|
|
114
|
+
eraser() {
|
|
115
|
+
this.editor.setCurrentTool('eraser')
|
|
116
|
+
},
|
|
117
|
+
arrow(v) {
|
|
118
|
+
this.styleProps('arrow','color').defaultValue = v?.color?? 'black'
|
|
119
|
+
this.styleProps('arrow','size').defaultValue = v?.size?? 'm'
|
|
120
|
+
this.editor.setCurrentTool('arrow')
|
|
121
|
+
},
|
|
122
|
+
text(v) {
|
|
123
|
+
this.styleProps('arrow','color').defaultValue = v?.color?? 'black'
|
|
124
|
+
this.styleProps('arrow','size').defaultValue = v?.size?? 'm'
|
|
125
|
+
this.editor.setCurrentTool('text')
|
|
126
|
+
},
|
|
127
|
+
line(v) {
|
|
128
|
+
this.styleProps('arrow','color').defaultValue = v?.color?? 'black'
|
|
129
|
+
this.styleProps('arrow','size').defaultValue = v?.size?? 'm'
|
|
130
|
+
this.editor.setCurrentTool('line')
|
|
131
|
+
},
|
|
132
|
+
rectangle(v) {
|
|
133
|
+
this.styleProps('geo','geo').defaultValue = 'rectangle'
|
|
134
|
+
this.styleProps('geo','color').defaultValue = v?.color?? 'black'
|
|
135
|
+
this.styleProps('geo','size').defaultValue = v?.size?? 'm'
|
|
136
|
+
this.editor.setCurrentTool('geo')
|
|
137
|
+
},
|
|
138
|
+
ellipse(v) {
|
|
139
|
+
this.styleProps('geo','geo').defaultValue = 'ellipse'
|
|
140
|
+
this.styleProps('geo','color').defaultValue = v?.color?? 'black'
|
|
141
|
+
this.styleProps('geo','size').defaultValue = v?.size?? 'm'
|
|
142
|
+
this.editor.setCurrentTool('geo')
|
|
143
|
+
},
|
|
144
|
+
triangle(v) {
|
|
145
|
+
this.styleProps('geo','geo').defaultValue = 'triangle'
|
|
146
|
+
this.styleProps('geo','color').defaultValue = v?.color?? 'black'
|
|
147
|
+
this.styleProps('geo','size').defaultValue = v?.size?? 'm'
|
|
148
|
+
this.editor.setCurrentTool('geo')
|
|
149
|
+
},
|
|
150
|
+
star(v) {
|
|
151
|
+
this.styleProps('geo','geo').defaultValue = 'star'
|
|
152
|
+
this.styleProps('geo','color').defaultValue = v?.color?? 'black'
|
|
153
|
+
this.styleProps('geo','size').defaultValue = v?.size?? 'm'
|
|
154
|
+
this.editor.setCurrentTool('geo')
|
|
155
|
+
},
|
|
156
|
+
highlight(v) {
|
|
157
|
+
this.styleProps('geo','color').defaultValue = v?.color?? 'black'
|
|
158
|
+
this.styleProps('geo','size').defaultValue = v?.size?? 'm'
|
|
159
|
+
this.editor.setCurrentTool('highlight')
|
|
160
|
+
},
|
|
161
|
+
laser() {
|
|
162
|
+
this.editor.setCurrentTool('laser')
|
|
163
|
+
},
|
|
164
|
+
styleProps(t,e) {
|
|
165
|
+
const style = [...this.editor.styleProps[t]]
|
|
166
|
+
const index = style.findIndex(item => item[1] === e)
|
|
167
|
+
return style[index][0]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
</script>
|
|
172
|
+
|
|
173
|
+
<style scoped>
|
|
174
|
+
.react{
|
|
175
|
+
width: 100%;
|
|
176
|
+
height: 100%;
|
|
177
|
+
}
|
|
178
|
+
</style>
|
|
@@ -102,7 +102,6 @@ export default {
|
|
|
102
102
|
},
|
|
103
103
|
getContent() {
|
|
104
104
|
const html = this.$refs.textarea.innerHTML
|
|
105
|
-
console.log(html)
|
|
106
105
|
const br = html
|
|
107
106
|
.replace(/<div>/g, '\n')
|
|
108
107
|
.replace(/<\/div>/g, '')
|
|
@@ -147,7 +146,6 @@ export default {
|
|
|
147
146
|
box-sizing: border-box;
|
|
148
147
|
text-indent: 2em;
|
|
149
148
|
background-color: #fff;
|
|
150
|
-
word-wrap: break-word;
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
.text[contenteditable]:empty:before {
|
package/src/index.js
CHANGED
|
@@ -34,6 +34,7 @@ import paper from './components/word2/index';
|
|
|
34
34
|
import question from './components/question/index';
|
|
35
35
|
import tagging from './components/tagging/index';
|
|
36
36
|
import seek from './components/seek/index';
|
|
37
|
+
import sketchpad from './components/sketchpad/index';
|
|
37
38
|
|
|
38
39
|
const components = [
|
|
39
40
|
Calendar,
|
|
@@ -68,7 +69,8 @@ const components = [
|
|
|
68
69
|
paper,
|
|
69
70
|
question,
|
|
70
71
|
tagging,
|
|
71
|
-
seek
|
|
72
|
+
seek,
|
|
73
|
+
sketchpad
|
|
72
74
|
];
|
|
73
75
|
|
|
74
76
|
function install(app) {
|
|
@@ -81,7 +83,7 @@ function install(app) {
|
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
export default {
|
|
84
|
-
version: '1.33.
|
|
86
|
+
version: '1.33.334',
|
|
85
87
|
install,
|
|
86
88
|
Calendar,
|
|
87
89
|
Message,
|
|
@@ -118,6 +120,7 @@ export default {
|
|
|
118
120
|
paper,
|
|
119
121
|
question,
|
|
120
122
|
tagging,
|
|
121
|
-
seek
|
|
123
|
+
seek,
|
|
124
|
+
sketchpad
|
|
122
125
|
};
|
|
123
126
|
|