@zhangqingcq/vgce 0.0.20 → 0.0.22

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 (56) hide show
  1. package/README.md +1 -1
  2. package/dist/style.css +2 -2
  3. package/dist/vgce.js +15858 -15276
  4. package/dist/vgce.umd.cjs +82 -129
  5. package/package.json +13 -15
  6. package/src/assets/base.less +79 -31
  7. package/src/assets/icons/delete-gray.svg +1 -0
  8. package/src/assets/icons/delete.svg +1 -12
  9. package/src/assets/icons/export.svg +1 -1
  10. package/src/assets/icons/import.svg +1 -1
  11. package/src/assets/icons/line-active.svg +1 -0
  12. package/src/assets/icons/line.svg +1 -0
  13. package/src/assets/icons/menu-fold.svg +1 -9
  14. package/src/assets/icons/menu-unfold.svg +1 -9
  15. package/src/assets/icons/preview.svg +1 -6
  16. package/src/assets/icons/question.svg +1 -0
  17. package/src/assets/icons/redo-gray.svg +1 -0
  18. package/src/assets/icons/redo.svg +1 -8
  19. package/src/assets/icons/return.svg +1 -8
  20. package/src/assets/icons/rotate.svg +1 -1
  21. package/src/assets/icons/save.svg +1 -9
  22. package/src/assets/icons/undo-gray.svg +1 -0
  23. package/src/assets/icons/undo.svg +1 -7
  24. package/src/assets/svgs/sheet-border.svg +1 -0
  25. package/src/assets/svgs/svg-text.svg +1 -5
  26. package/src/components/svg-analysis/index.vue +1 -1
  27. package/src/components/svg-editor/center-panel/index.vue +508 -176
  28. package/src/components/svg-editor/component-tree/index.vue +4 -0
  29. package/src/components/svg-editor/connection-line/index.vue +12 -8
  30. package/src/components/svg-editor/connection-panel/index.vue +121 -181
  31. package/src/components/svg-editor/handle-panel/index.vue +32 -24
  32. package/src/components/svg-editor/index.vue +24 -25
  33. package/src/components/svg-editor/left-panel/index.vue +2 -2
  34. package/src/components/svg-editor/right-panel/bind-anchor.vue +124 -0
  35. package/src/components/svg-editor/right-panel/code-edit-modal.vue +1 -1
  36. package/src/components/svg-editor/right-panel/dynamic-el-form-item.vue +8 -1
  37. package/src/components/svg-editor/right-panel/index.vue +117 -56
  38. package/src/components/svg-editor/top-panel/index.vue +109 -25
  39. package/src/components/svg-viewer/index.vue +31 -21
  40. package/src/components/vue3-ruler-tool/index.vue +329 -372
  41. package/src/config/files/clock-a.vue +64 -64
  42. package/src/config/svg/animation/index.ts +1 -1
  43. package/src/config/svg/custom/svg-text.ts +2 -2
  44. package/src/config/svg/stateful/index.ts +1 -1
  45. package/src/config/svg/stateless/index.ts +3 -2
  46. package/src/config/svg/stateless/sheet-border.ts +22 -0
  47. package/src/config/types.ts +1 -0
  48. package/src/stores/config/index.ts +1 -8
  49. package/src/stores/config/types.ts +0 -8
  50. package/src/stores/global/index.ts +0 -10
  51. package/src/stores/global/types.ts +33 -10
  52. package/src/stores/svg-edit-layout/index.ts +7 -0
  53. package/src/stores/svg-edit-layout/types.ts +1 -0
  54. package/src/utils/index.ts +227 -103
  55. package/src/utils/scale-core.ts +1 -0
  56. package/src/views/EditorS.vue +1 -1
@@ -1,64 +1,64 @@
1
- <script lang="ts" setup>
2
- const props = withDefaults(defineProps<{ id: string }>(), { id: '' })
3
- const nowTime = ref(new Date())
4
- const s = nowTime.value.getSeconds()
5
- const m = nowTime.value.getMinutes()
6
- const h = Math.floor((nowTime.value.getHours() + (m + s / 60) / 60) * 30)
7
- </script>
8
- <template>
9
- <g :id="props.id">
10
- <symbol :id="`${props.id}clock-a-n`" viewBox="0 0 1024 1024">
11
- <path d="M512.3 518.9m-469.2 0a469.2 469.2 0 1 0 938.4 0 469.2 469.2 0 1 0-938.4 0Z" fill="#429BCF" />
12
- <path d="M512.3 518.9m-392.5 0a392.5 392.5 0 1 0 785 0 392.5 392.5 0 1 0-785 0Z" fill="#FFFFFF" />
13
- <path
14
- d="M512.3 523.8c-4.5 0-9-1.7-12.4-5.1-6.8-6.8-6.8-17.9 0-24.8l130.8-130.8c6.8-6.8 17.9-6.8 24.8 0 6.8 6.8 6.8 17.9 0 24.8L524.7 518.7c-3.5 3.4-7.9 5.1-12.4 5.1z"
15
- fill="#2D416C"
16
- >
17
- <animateTransform
18
- attributeName="transform"
19
- attributeType="XML"
20
- type="rotate"
21
- :from="`${-45 + h} 512.3 506.3`"
22
- :to="`${315 + h} 512.3 506.3`"
23
- dur="43200s"
24
- repeatCount="indefinite"
25
- />
26
- </path>
27
- <path
28
- d="M512.3 523.8c-4.5 0-9-1.7-12.4-5.1L318.3 337.1c-6.8-6.8-6.8-17.9 0-24.8 6.8-6.8 17.9-6.8 24.8 0L524.7 494c6.8 6.8 6.8 17.9 0 24.8-3.5 3.3-7.9 5-12.4 5z"
29
- fill="#365087"
30
- >
31
- <animateTransform
32
- attributeName="transform"
33
- attributeType="XML"
34
- type="rotate"
35
- :from="`${45 + m * 6} 512.3 506.3`"
36
- :to="`${405 + m * 6} 512.3 506.3`"
37
- dur="3600s"
38
- repeatCount="indefinite"
39
- />
40
- </path>
41
- <path d="M512.3 506.3m-47.5 0a47.5 47.5 0 1 0 95 0 47.5 47.5 0 1 0-95 0Z" fill="#365087" />
42
- <path
43
- d="M512.3 218.8c-9 0-16.3-7.3-16.3-16.3v-29.1c0-9 7.3-16.3 16.3-16.3s16.3 7.3 16.3 16.3v29.1c0 9-7.4 16.3-16.3 16.3zM512.3 880.8c-9 0-16.3-7.3-16.3-16.3v-29.1c0-9 7.3-16.3 16.3-16.3s16.3 7.3 16.3 16.3v29.1c0 9-7.4 16.3-16.3 16.3zM812.4 518.9c0-9 7.3-16.3 16.3-16.3h29.1c9 0 16.3 7.3 16.3 16.3s-7.3 16.3-16.3 16.3h-29.1c-8.9 0-16.3-7.3-16.3-16.3zM150.4 518.9c0-9 7.3-16.3 16.3-16.3h29.1c9 0 16.3 7.3 16.3 16.3s-7.3 16.3-16.3 16.3h-29.1c-8.9 0-16.3-7.3-16.3-16.3z"
44
- fill="#2D416C"
45
- />
46
- <path
47
- d="M296.9 733.5c-2.2 0-4.5-0.9-6.2-2.6-3.4-3.4-3.4-9 0-12.4L540 469.2c3.4-3.4 9-3.4 12.4 0 3.4 3.4 3.4 9 0 12.4L303.1 731c-1.7 1.7-4 2.5-6.2 2.5z"
48
- fill="#C11B16"
49
- >
50
- <animateTransform
51
- attributeName="transform"
52
- attributeType="XML"
53
- type="rotate"
54
- :from="`${135.5 + s * 6} 512.3 506.3`"
55
- :to="`${495.5 + s * 6} 512.3 506.3`"
56
- dur="60s"
57
- repeatCount="indefinite"
58
- />
59
- </path>
60
- <path d="M512.3 506.3m-22.8 0a22.8 22.8 0 1 0 45.6 0 22.8 22.8 0 1 0-45.6 0Z" fill="#fff" />
61
- </symbol>
62
- <use :xlink:href="`#${props.id}clock-a-n`" width="200" height="200" />
63
- </g>
64
- </template>
1
+ <script lang="ts" setup>
2
+ const props = withDefaults(defineProps<{ id: string }>(), { id: '' })
3
+ const nowTime = ref(new Date())
4
+ const s = nowTime.value.getSeconds()
5
+ const m = nowTime.value.getMinutes()
6
+ const h = Math.floor((nowTime.value.getHours() + (m + s / 60) / 60) * 30)
7
+ </script>
8
+ <template>
9
+ <g :id="props.id">
10
+ <symbol :id="`${props.id}clock-a-n`" viewBox="0 0 1024 1024">
11
+ <path d="M512.3 518.9m-469.2 0a469.2 469.2 0 1 0 938.4 0 469.2 469.2 0 1 0-938.4 0Z" fill="#429BCF" />
12
+ <path d="M512.3 518.9m-392.5 0a392.5 392.5 0 1 0 785 0 392.5 392.5 0 1 0-785 0Z" fill="#FFFFFF" />
13
+ <path
14
+ d="M512.3 523.8c-4.5 0-9-1.7-12.4-5.1-6.8-6.8-6.8-17.9 0-24.8l130.8-130.8c6.8-6.8 17.9-6.8 24.8 0 6.8 6.8 6.8 17.9 0 24.8L524.7 518.7c-3.5 3.4-7.9 5.1-12.4 5.1z"
15
+ fill="#2D416C"
16
+ >
17
+ <animateTransform
18
+ attributeName="transform"
19
+ attributeType="XML"
20
+ type="rotate"
21
+ :from="`${-45 + h} 512.3 506.3`"
22
+ :to="`${315 + h} 512.3 506.3`"
23
+ dur="43200s"
24
+ repeatCount="indefinite"
25
+ />
26
+ </path>
27
+ <path
28
+ d="M512.3 523.8c-4.5 0-9-1.7-12.4-5.1L318.3 337.1c-6.8-6.8-6.8-17.9 0-24.8 6.8-6.8 17.9-6.8 24.8 0L524.7 494c6.8 6.8 6.8 17.9 0 24.8-3.5 3.3-7.9 5-12.4 5z"
29
+ fill="#365087"
30
+ >
31
+ <animateTransform
32
+ attributeName="transform"
33
+ attributeType="XML"
34
+ type="rotate"
35
+ :from="`${45 + m * 6} 512.3 506.3`"
36
+ :to="`${405 + m * 6} 512.3 506.3`"
37
+ dur="3600s"
38
+ repeatCount="indefinite"
39
+ />
40
+ </path>
41
+ <path d="M512.3 506.3m-47.5 0a47.5 47.5 0 1 0 95 0 47.5 47.5 0 1 0-95 0Z" fill="#365087" />
42
+ <path
43
+ d="M512.3 218.8c-9 0-16.3-7.3-16.3-16.3v-29.1c0-9 7.3-16.3 16.3-16.3s16.3 7.3 16.3 16.3v29.1c0 9-7.4 16.3-16.3 16.3zM512.3 880.8c-9 0-16.3-7.3-16.3-16.3v-29.1c0-9 7.3-16.3 16.3-16.3s16.3 7.3 16.3 16.3v29.1c0 9-7.4 16.3-16.3 16.3zM812.4 518.9c0-9 7.3-16.3 16.3-16.3h29.1c9 0 16.3 7.3 16.3 16.3s-7.3 16.3-16.3 16.3h-29.1c-8.9 0-16.3-7.3-16.3-16.3zM150.4 518.9c0-9 7.3-16.3 16.3-16.3h29.1c9 0 16.3 7.3 16.3 16.3s-7.3 16.3-16.3 16.3h-29.1c-8.9 0-16.3-7.3-16.3-16.3z"
44
+ fill="#2D416C"
45
+ />
46
+ <path
47
+ d="M296.9 733.5c-2.2 0-4.5-0.9-6.2-2.6-3.4-3.4-3.4-9 0-12.4L540 469.2c3.4-3.4 9-3.4 12.4 0 3.4 3.4 3.4 9 0 12.4L303.1 731c-1.7 1.7-4 2.5-6.2 2.5z"
48
+ fill="#C11B16"
49
+ >
50
+ <animateTransform
51
+ attributeName="transform"
52
+ attributeType="XML"
53
+ type="rotate"
54
+ :from="`${135.5 + s * 6} 512.3 506.3`"
55
+ :to="`${495.5 + s * 6} 512.3 506.3`"
56
+ dur="60s"
57
+ repeatCount="indefinite"
58
+ />
59
+ </path>
60
+ <path d="M512.3 506.3m-22.8 0a22.8 22.8 0 1 0 45.6 0 22.8 22.8 0 1 0-45.6 0Z" fill="#fff" />
61
+ </symbol>
62
+ <use :xlink:href="`#${props.id}clock-a-n`" width="100" height="100" />
63
+ </g>
64
+ </template>
@@ -3,6 +3,6 @@ import { reservoir } from './reservoir'
3
3
 
4
4
  export const animation_group: IConfigComponentGroup = {
5
5
  groupType: 'have_animation',
6
- title: '动画图标',
6
+ title: '动画SVG',
7
7
  list: [reservoir]
8
8
  }
@@ -15,8 +15,8 @@ export const svg_text: IConfigItem = {
15
15
  props: {
16
16
  text: {
17
17
  title: '文字内容',
18
- type: EConfigItemPropsType.Input,
19
- val: '文字'
18
+ type: EConfigItemPropsType.Textarea,
19
+ val: '文字内容'
20
20
  },
21
21
  fontFamily: {
22
22
  title: '字体',
@@ -3,6 +3,6 @@ import { circuit_breaker_svg_file } from './circuit-breaker'
3
3
 
4
4
  export const stateful_group: IConfigComponentGroup = {
5
5
  groupType: 'stateful',
6
- title: '状态图标',
6
+ title: '状态SVG',
7
7
  list: [circuit_breaker_svg_file]
8
8
  }
@@ -2,9 +2,10 @@ import type { IConfigComponentGroup } from '@/config/types'
2
2
  import { alternator_svg_file } from './alternator'
3
3
  import { svg_house } from './house'
4
4
  import { svg_bot_2 } from './bot-2'
5
+ import { sheet_border } from './sheet-border'
5
6
 
6
7
  export const stateless_group: IConfigComponentGroup = {
7
8
  groupType: 'stateless',
8
- title: '静态图标',
9
- list: [alternator_svg_file, svg_house, svg_bot_2]
9
+ title: '静态SVG',
10
+ list: [alternator_svg_file, svg_house, svg_bot_2, sheet_border]
10
11
  }
@@ -0,0 +1,22 @@
1
+ import { EDoneJsonType } from '@/config/types'
2
+ import type { IConfigItem } from '@/config/types'
3
+
4
+ export const sheet_border: IConfigItem = {
5
+ name: 'sheet-border',
6
+ title: '田字格',
7
+ type: EDoneJsonType.File,
8
+ display: true,
9
+ config: {
10
+ can_zoom: true,
11
+ have_anchor: true,
12
+ actual_rect: true
13
+ },
14
+ props: {},
15
+ common_animations: {
16
+ val: '',
17
+ delay: 'delay-0s',
18
+ speed: 'slow',
19
+ repeat: 'infinite'
20
+ },
21
+ events: []
22
+ }
@@ -55,6 +55,7 @@ export enum EConfigAnimationsType {
55
55
 
56
56
  export enum EConfigItemPropsType {
57
57
  Input = 'Input',
58
+ Textarea = 'Textarea',
58
59
  Color = 'Color',
59
60
  InputNumber = 'InputNumber',
60
61
  Switch = 'Switch', //此类型option默认索引0为关闭
@@ -14,15 +14,8 @@ if (l) {
14
14
  s = {
15
15
  background_color: '#fff',
16
16
  scale: 1,
17
- position_center: {
18
- x: -333,
19
- y: -113
20
- },
21
- svg_position_center: {
22
- x: 50,
23
- y: 50
24
- },
25
17
  grid: true,
18
+ grid_color: '#ebebeb',
26
19
  ruler: true
27
20
  }
28
21
  }
@@ -5,14 +5,6 @@ export interface IPositionCenter {
5
5
  export interface IPositionCenterSvg {
6
6
  background_color: string
7
7
  scale: number
8
- position_center: {
9
- x: number
10
- y: number
11
- }
12
- svg_position_center: {
13
- x: number
14
- y: number
15
- }
16
8
  grid: boolean
17
9
  ruler: boolean
18
10
  }
@@ -52,7 +52,6 @@ export const useGlobalStore = defineStore('global-store', {
52
52
  }
53
53
  }
54
54
  },
55
- getters: {},
56
55
  actions: {
57
56
  setCreateInfo(create_svg_info: IConfigItem | null) {
58
57
  this.intention = EGlobalStoreIntention.Create
@@ -74,9 +73,6 @@ export const useGlobalStore = defineStore('global-store', {
74
73
  useHistoryRecord(objectDeepClone<IDoneJson[]>(this.done_json))
75
74
  })
76
75
  },
77
- setMouseInfo(mouse_info: IMouseInfo) {
78
- this.mouse_info = mouse_info
79
- },
80
76
  setHandleSvgInfo(info: IDoneJson | null, index?: number) {
81
77
  let current_index = index
82
78
  if (info) {
@@ -92,9 +88,6 @@ export const useGlobalStore = defineStore('global-store', {
92
88
  this.handle_svg_info = info
93
89
  }
94
90
  },
95
- setScaleInfo(info: IScaleInfo) {
96
- this.scale_info = info
97
- },
98
91
  spliceDoneJson(index: number) {
99
92
  const globalStore = useGlobalStore()
100
93
  globalStore.done_json.splice(index, 1)
@@ -102,6 +95,3 @@ export const useGlobalStore = defineStore('global-store', {
102
95
  }
103
96
  }
104
97
  })
105
- // useGlobalStore().$subscribe((mutation, state) => {
106
- // console.log(mutation, state, 102);
107
- // });
@@ -1,4 +1,5 @@
1
1
  import type { IConfig, IConfigItem } from '@/config/types'
2
+ import type { IBindAnchors } from '@/components/config/types'
2
3
 
3
4
  export interface IGlobalStore {
4
5
  config_center: IConfig
@@ -11,6 +12,18 @@ export interface IGlobalStore {
11
12
  rotate_info: IRotateInfo
12
13
  connection_line_node_info: IConnectionLineNodeInfo
13
14
  }
15
+
16
+ export interface IPointCoordinate {
17
+ tl: ICoordinate
18
+ tc: ICoordinate
19
+ tr: ICoordinate
20
+ l: ICoordinate
21
+ r: ICoordinate
22
+ bl: ICoordinate
23
+ bc: ICoordinate
24
+ br: ICoordinate
25
+ }
26
+
14
27
  export interface IDoneJson extends IConfigItem {
15
28
  id: string
16
29
  x: number
@@ -25,29 +38,32 @@ export interface IDoneJson extends IConfigItem {
25
38
  width: number
26
39
  height: number
27
40
  }
28
- point_coordinate: {
29
- tl: ICoordinate
30
- tc: ICoordinate
31
- tr: ICoordinate
32
- l: ICoordinate
33
- r: ICoordinate
34
- bl: ICoordinate
35
- bc: ICoordinate
36
- br: ICoordinate
41
+ point_coordinate: IPointCoordinate
42
+ point_coordinate_old?: IPointCoordinate
43
+ selected?: boolean
44
+ old_position?: { x: number; y: number }
45
+ center_position: { x: number; y: number }
46
+ bind_anchors?: {
47
+ start: IBindAnchors | null
48
+ end: IBindAnchors | null
37
49
  }
38
50
  }
51
+
39
52
  export enum EGlobalStoreIntention {
40
53
  None = 'None',
41
54
  Create = 'Create',
42
55
  Move = 'Move',
56
+ GroupMove = 'GroupMove',
43
57
  MoveCanvas = 'MoveCanvas',
44
58
  Select = 'Select',
45
59
  Zoom = 'Zoom',
46
60
  Rotate = 'Rotate',
47
61
  Connection = 'Connection',
48
62
  SetConnectionLineNode = 'SetConnectionLineNode',
49
- ContextMenu = 'ContextMenu'
63
+ ContextMenu = 'ContextMenu',
64
+ SelectArea = 'SelectArea'
50
65
  }
66
+
51
67
  export interface IMouseInfo {
52
68
  state: EMouseInfoState
53
69
  position_x: number //鼠标指针坐标
@@ -57,14 +73,17 @@ export interface IMouseInfo {
57
73
  new_position_x: number //移动之后目标的坐标
58
74
  new_position_y: number
59
75
  }
76
+
60
77
  export enum EMouseInfoState {
61
78
  Down = 'Down',
62
79
  Up = 'Up'
63
80
  }
81
+
64
82
  export interface IHandleSvgInfo {
65
83
  info: IDoneJson
66
84
  index: number
67
85
  }
86
+
68
87
  /**
69
88
  * 缩放信息
70
89
  */
@@ -85,12 +104,14 @@ export interface IScaleInfo {
85
104
  y: number
86
105
  }
87
106
  }
107
+
88
108
  /**
89
109
  * 旋转信息
90
110
  */
91
111
  export interface IRotateInfo {
92
112
  angle: number
93
113
  }
114
+
94
115
  export enum EScaleInfoType {
95
116
  None = '',
96
117
  TopLeft = 'TopLeft',
@@ -102,10 +123,12 @@ export enum EScaleInfoType {
102
123
  BottomCenter = 'BottomCenter',
103
124
  BottomRight = 'BottomRight'
104
125
  }
126
+
105
127
  export interface ICoordinate {
106
128
  x: number
107
129
  y: number
108
130
  }
131
+
109
132
  export interface IConnectionLineNodeInfo {
110
133
  init_pos: {
111
134
  x: number
@@ -1,4 +1,5 @@
1
1
  import type { ISvgEditLayoutStore } from './types'
2
+
2
3
  /**
3
4
  * 编辑器布局状态
4
5
  */
@@ -10,6 +11,12 @@ export const useSvgEditLayoutStore = defineStore('svg-edit-layout-store', {
10
11
  center_offset: {
11
12
  x: 0,
12
13
  y: 0
14
+ },
15
+ canvasInfo: {
16
+ with: 0,
17
+ height: 0,
18
+ top: 0,
19
+ left: 0
13
20
  }
14
21
  }
15
22
  }
@@ -5,4 +5,5 @@ export interface ISvgEditLayoutStore {
5
5
  x: number
6
6
  y: number
7
7
  }
8
+ canvasInfo: { with: number; height: number; top: number; left: number }
8
9
  }