@nordcraft/runtime 1.0.57 → 1.0.59
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/dist/components/createComponent.js +12 -13
- package/dist/components/createComponent.js.map +1 -1
- package/dist/components/createElement.js +9 -7
- package/dist/components/createElement.js.map +1 -1
- package/dist/components/createNode.js.map +1 -1
- package/dist/custom-element.main.esm.js +27 -27
- package/dist/custom-element.main.esm.js.map +4 -4
- package/dist/editor/input.d.ts +1 -0
- package/dist/editor/input.js +16 -0
- package/dist/editor/input.js.map +1 -0
- package/dist/editor/links.d.ts +6 -0
- package/dist/editor/links.js +15 -0
- package/dist/editor/links.js.map +1 -0
- package/dist/editor/overlay.d.ts +12 -0
- package/dist/editor/overlay.js +20 -0
- package/dist/editor/overlay.js.map +1 -0
- package/dist/editor/types.d.ts +254 -0
- package/dist/editor/types.js +42 -0
- package/dist/editor/types.js.map +1 -0
- package/dist/editor-preview.main.js +147 -198
- package/dist/editor-preview.main.js.map +1 -1
- package/dist/page.main.esm.js +3 -3
- package/dist/page.main.esm.js.map +4 -4
- package/dist/page.main.js +20 -0
- package/dist/page.main.js.map +1 -1
- package/dist/styles/CustomPropertyStyleSheet.test.js +12 -3
- package/dist/styles/CustomPropertyStyleSheet.test.js.map +1 -1
- package/package.json +4 -4
- package/src/components/createComponent.ts +27 -20
- package/src/components/createElement.ts +29 -21
- package/src/components/createNode.ts +0 -1
- package/src/editor/input.ts +17 -0
- package/src/editor/links.ts +16 -0
- package/src/editor/overlay.ts +21 -0
- package/src/editor/types.ts +271 -0
- package/src/editor-preview.main.ts +180 -411
- package/src/page.main.ts +23 -0
- package/src/styles/CustomPropertyStyleSheet.test.ts +12 -3
- package/src/editor/types.d.ts +0 -36
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnimationKeyframe,
|
|
3
|
+
Component,
|
|
4
|
+
ComponentData,
|
|
5
|
+
} from '@nordcraft/core/dist/component/component.types'
|
|
6
|
+
import type { PluginFormula } from '@nordcraft/core/dist/formula/formulaTypes'
|
|
7
|
+
import type { OldTheme, Theme } from '@nordcraft/core/dist/styling/theme'
|
|
8
|
+
import type {
|
|
9
|
+
FormulaHandlerV2,
|
|
10
|
+
PluginAction,
|
|
11
|
+
PluginActionV2,
|
|
12
|
+
} from '@nordcraft/core/dist/types'
|
|
13
|
+
import type { getRectData } from './overlay'
|
|
14
|
+
|
|
15
|
+
export type NordcraftPreviewEvent =
|
|
16
|
+
| {
|
|
17
|
+
type: 'style_variant_changed'
|
|
18
|
+
variantIndex: number | null
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
type: 'component'
|
|
22
|
+
component: Component
|
|
23
|
+
}
|
|
24
|
+
| { type: 'components'; components: Component[] }
|
|
25
|
+
| {
|
|
26
|
+
type: 'packages'
|
|
27
|
+
packages: Record<
|
|
28
|
+
string,
|
|
29
|
+
{
|
|
30
|
+
components: Record<string, Component>
|
|
31
|
+
formulas: Record<
|
|
32
|
+
string,
|
|
33
|
+
PluginFormula<FormulaHandlerV2> | PluginFormula<string>
|
|
34
|
+
>
|
|
35
|
+
actions: Record<string, PluginActionV2 | PluginAction>
|
|
36
|
+
manifest: {
|
|
37
|
+
name: string
|
|
38
|
+
// commit represents the commit hash (version) of the package
|
|
39
|
+
commit: string
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
>
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
type: 'global_formulas'
|
|
46
|
+
formulas: Record<
|
|
47
|
+
string,
|
|
48
|
+
PluginFormula<FormulaHandlerV2> | PluginFormula<string>
|
|
49
|
+
>
|
|
50
|
+
}
|
|
51
|
+
| {
|
|
52
|
+
type: 'global_actions'
|
|
53
|
+
actions: Record<string, PluginActionV2 | PluginAction>
|
|
54
|
+
}
|
|
55
|
+
| { type: 'theme'; theme: Record<string, OldTheme | Theme> }
|
|
56
|
+
| { type: 'mode'; mode: 'design' | 'test' }
|
|
57
|
+
| { type: 'attrs'; attrs: Record<string, unknown> }
|
|
58
|
+
| { type: 'selection'; selectedNodeId: string | null }
|
|
59
|
+
| { type: 'highlight'; highlightedNodeId: string | null }
|
|
60
|
+
| {
|
|
61
|
+
type: 'click' | 'mousemove' | 'dblclick'
|
|
62
|
+
metaKey: boolean
|
|
63
|
+
x: number
|
|
64
|
+
y: number
|
|
65
|
+
}
|
|
66
|
+
| { type: 'report_document_scroll_size' }
|
|
67
|
+
| { type: 'update_inner_text'; innerText: string }
|
|
68
|
+
| { type: 'reload' }
|
|
69
|
+
| { type: 'fetch_api'; apiKey: string }
|
|
70
|
+
| { type: 'introspect_qraphql_api'; apiKey: string }
|
|
71
|
+
| { type: 'drag-started'; x: number; y: number }
|
|
72
|
+
| { type: 'drag-ended'; canceled?: true }
|
|
73
|
+
| { type: 'keydown'; key: string; altKey: boolean; metaKey: boolean }
|
|
74
|
+
| { type: 'keyup'; key: string; altKey: boolean; metaKey: boolean }
|
|
75
|
+
| {
|
|
76
|
+
type: 'get_computed_style'
|
|
77
|
+
styles?: string[]
|
|
78
|
+
}
|
|
79
|
+
| {
|
|
80
|
+
type: 'set_timeline_keyframes'
|
|
81
|
+
keyframes: Record<string, AnimationKeyframe> | null
|
|
82
|
+
}
|
|
83
|
+
| {
|
|
84
|
+
type: 'set_timeline_time'
|
|
85
|
+
time: number | null
|
|
86
|
+
timingFunction:
|
|
87
|
+
| 'linear'
|
|
88
|
+
| 'ease'
|
|
89
|
+
| 'ease-in'
|
|
90
|
+
| 'ease-out'
|
|
91
|
+
| 'ease-in-out'
|
|
92
|
+
| 'step-start'
|
|
93
|
+
| 'step-end'
|
|
94
|
+
| string
|
|
95
|
+
| undefined
|
|
96
|
+
fillMode: 'none' | 'forwards' | 'backwards' | 'both' | undefined
|
|
97
|
+
}
|
|
98
|
+
| {
|
|
99
|
+
type: 'preview_style'
|
|
100
|
+
styles: Record<string, string> | null
|
|
101
|
+
theme?: {
|
|
102
|
+
key: string
|
|
103
|
+
value: Theme
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
| {
|
|
107
|
+
type: 'preview_theme'
|
|
108
|
+
theme: string | null
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type EditorPostMessageType =
|
|
112
|
+
| {
|
|
113
|
+
type: 'textComputedStyle'
|
|
114
|
+
computedStyle: Record<string, string>
|
|
115
|
+
}
|
|
116
|
+
| {
|
|
117
|
+
type: 'selection'
|
|
118
|
+
selectedNodeId: string | null
|
|
119
|
+
}
|
|
120
|
+
| {
|
|
121
|
+
type: 'highlight'
|
|
122
|
+
highlightedNodeId: string | null
|
|
123
|
+
}
|
|
124
|
+
| {
|
|
125
|
+
type: 'navigate'
|
|
126
|
+
name: string
|
|
127
|
+
}
|
|
128
|
+
| {
|
|
129
|
+
type: 'documentScrollSize'
|
|
130
|
+
scrollHeight: number
|
|
131
|
+
scrollWidth: number
|
|
132
|
+
}
|
|
133
|
+
| {
|
|
134
|
+
type: 'nodeMoved'
|
|
135
|
+
copy: boolean
|
|
136
|
+
parent?: string | null
|
|
137
|
+
index?: number
|
|
138
|
+
}
|
|
139
|
+
| {
|
|
140
|
+
type: 'computedStyle'
|
|
141
|
+
computedStyle: Record<string, string>
|
|
142
|
+
}
|
|
143
|
+
| {
|
|
144
|
+
type: 'style'
|
|
145
|
+
time: string
|
|
146
|
+
}
|
|
147
|
+
| {
|
|
148
|
+
type: 'component event'
|
|
149
|
+
event: any
|
|
150
|
+
time: string
|
|
151
|
+
data: any
|
|
152
|
+
}
|
|
153
|
+
| {
|
|
154
|
+
type: 'keydown'
|
|
155
|
+
event: {
|
|
156
|
+
key: string
|
|
157
|
+
metaKey: boolean
|
|
158
|
+
shiftKey: boolean
|
|
159
|
+
altKey: boolean
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
| {
|
|
163
|
+
type: 'keyup'
|
|
164
|
+
event: {
|
|
165
|
+
key: string
|
|
166
|
+
metaKey: boolean
|
|
167
|
+
shiftKey: boolean
|
|
168
|
+
altKey: boolean
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
| {
|
|
172
|
+
type: 'keypress'
|
|
173
|
+
event: {
|
|
174
|
+
key: string
|
|
175
|
+
metaKey: boolean
|
|
176
|
+
shiftKey: boolean
|
|
177
|
+
altKey: boolean
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
| { type: 'data'; data: ComponentData }
|
|
181
|
+
| {
|
|
182
|
+
type: 'selectionRect'
|
|
183
|
+
rect: ReturnType<typeof getRectData>
|
|
184
|
+
}
|
|
185
|
+
| {
|
|
186
|
+
type: 'highlightRect'
|
|
187
|
+
rect: ReturnType<typeof getRectData>
|
|
188
|
+
}
|
|
189
|
+
| {
|
|
190
|
+
type: 'introspectionResult'
|
|
191
|
+
data: any
|
|
192
|
+
apiKey: string
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export type DragState = {
|
|
196
|
+
/**
|
|
197
|
+
* Dragging elements within the initial container is a reorder operation while dragging elements outside the initial container is an insert operation.
|
|
198
|
+
* While they share some common properties, we need to differentiate between the two to handle them differently.
|
|
199
|
+
*/
|
|
200
|
+
mode: 'reorder' | 'insert'
|
|
201
|
+
elementType: 'element' | 'component' | 'text'
|
|
202
|
+
copy?: HTMLElement
|
|
203
|
+
element: HTMLElement
|
|
204
|
+
repeatedNodes: HTMLElement[]
|
|
205
|
+
offset: Point
|
|
206
|
+
lastCursorPosition: Point
|
|
207
|
+
initialContainer: HTMLElement
|
|
208
|
+
initialNextSibling: Element | null
|
|
209
|
+
initialRect: DOMRect
|
|
210
|
+
reorderPermutations: Array<{
|
|
211
|
+
nextSibling: Node | null
|
|
212
|
+
rect: DOMRect
|
|
213
|
+
}>
|
|
214
|
+
isTransitioning: boolean
|
|
215
|
+
selectedInsertAreaIndex?: number
|
|
216
|
+
insertAreas?: Array<InsertArea>
|
|
217
|
+
destroying: boolean
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export type InsertArea = {
|
|
221
|
+
layout: 'block' | 'inline'
|
|
222
|
+
parent: Element
|
|
223
|
+
index: number
|
|
224
|
+
center: Point
|
|
225
|
+
size: number
|
|
226
|
+
direction: 1 | -1
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export type Point = { x: number; y: number }
|
|
230
|
+
export type Line = { x1: number; y1: number; x2: number; y2: number }
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Styles required for rendering the same exact text again somewhere else (on a overlay rect in the editor)
|
|
234
|
+
*/
|
|
235
|
+
export enum TextNodeComputedStyles {
|
|
236
|
+
// Caret color is important as it is the only visible part of the text node (when text is not highlighted)
|
|
237
|
+
CARET_COLOR = 'caret-color',
|
|
238
|
+
DISPLAY = 'display',
|
|
239
|
+
FONT_FAMILY = 'font-family',
|
|
240
|
+
FONT_SIZE = 'font-size',
|
|
241
|
+
FONT_WEIGHT = 'font-weight',
|
|
242
|
+
FONT_STYLE = 'font-style',
|
|
243
|
+
FONT_VARIANT = 'font-variant',
|
|
244
|
+
FONT_STRETCH = 'font-stretch',
|
|
245
|
+
LINE_HEIGHT = 'line-height',
|
|
246
|
+
TEXT_ALIGN = 'text-align',
|
|
247
|
+
TEXT_TRANSFORM = 'text-transform',
|
|
248
|
+
LETTER_SPACING = 'letter-spacing',
|
|
249
|
+
WHITE_SPACE = 'white-space',
|
|
250
|
+
WORD_SPACING = 'word-spacing',
|
|
251
|
+
TEXT_INDENT = 'text-indent',
|
|
252
|
+
TEXT_OVERFLOW = 'text-overflow',
|
|
253
|
+
TEXT_RENDERING = 'text-rendering',
|
|
254
|
+
WORD_BREAK = 'word-break',
|
|
255
|
+
WORD_WRAP = 'word-wrap',
|
|
256
|
+
DIRECTION = 'direction',
|
|
257
|
+
UNICODE_BIDI = 'unicode-bidi',
|
|
258
|
+
VERTICAL_ALIGN = 'vertical-align',
|
|
259
|
+
FONT_KERNING = 'font-kerning',
|
|
260
|
+
FONT_FEATURE_SETTINGS = 'font-feature-settings',
|
|
261
|
+
FONT_VARIATION_SETTINGS = 'font-variation-settings',
|
|
262
|
+
FONT_SMOOTHING = '-webkit-font-smoothing',
|
|
263
|
+
ANTI_ALIASING = '-moz-osx-font-smoothing',
|
|
264
|
+
FONT_OPTICAL_SIZING = 'font-optical-sizing',
|
|
265
|
+
TAB_SIZE = 'tab-size',
|
|
266
|
+
HYPHENS = 'hyphens',
|
|
267
|
+
TEXT_ORIENTATION = 'text-orientation',
|
|
268
|
+
WRITING_MODE = 'writing-mode',
|
|
269
|
+
LINE_BREAK = 'line-break',
|
|
270
|
+
OVERFLOW_WRAP = 'overflow-wrap',
|
|
271
|
+
}
|