@fusion.dev/helix-docs 0.172.0 → 0.174.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/content/metrics.mdx +222 -222
- package/content/sandbox.mdx +73 -6
- package/dist/sources.generated.js +295 -228
- package/package.json +9 -9
package/content/sandbox.mdx
CHANGED
|
@@ -42,12 +42,17 @@ without tracking which element sent each event. The names the sandbox reads:
|
|
|
42
42
|
- A pane named `html` sets the preview's markup.
|
|
43
43
|
- A pane named `css` sets its stylesheet.
|
|
44
44
|
- A pane named `js` sets a script, which runs as a module after the markup.
|
|
45
|
+
- A pane named for a module file, ending in `.js` or `.mjs`, such as
|
|
46
|
+
`utils.js`, is a module the other scripts import by its path.
|
|
47
|
+
- A pane named `package.json` sets the npm packages the scripts import by name,
|
|
48
|
+
from its `dependencies`.
|
|
45
49
|
|
|
46
50
|
The sandbox ignores a pane with any other name, so that pane only displays its
|
|
47
51
|
contents.
|
|
48
52
|
|
|
49
|
-
A pane's text goes in its `value
|
|
50
|
-
|
|
53
|
+
A pane's text goes in its `value`, or inside the pane where `value` is not set.
|
|
54
|
+
Put markup inside a `<template>`, so the page does not render it. The sandbox
|
|
55
|
+
also hands each pane's text to the preview when it starts, so you write the
|
|
51
56
|
text once, in the pane. A preview given its own `source` keeps it until the
|
|
52
57
|
first edit.
|
|
53
58
|
|
|
@@ -80,6 +85,72 @@ holds the `name` of the pane shown. The arrow keys move between the tabs, and
|
|
|
80
85
|
`helix-before-change` with the pane's `name`, which you can cancel, and
|
|
81
86
|
`change` once `file` holds it. The panes not shown carry `hidden`.
|
|
82
87
|
|
|
88
|
+
## Packages and module files
|
|
89
|
+
|
|
90
|
+
In the built-in document, an example imports npm packages by name and its own
|
|
91
|
+
files by path, as it would in a project. A `package.json` pane lists the
|
|
92
|
+
packages and their versions, and each package loads from the preview's `cdn`,
|
|
93
|
+
`https://esm.sh/` by default, at the version or range given. Each module pane
|
|
94
|
+
is a file the scripts import by a relative path:
|
|
95
|
+
|
|
96
|
+
```html
|
|
97
|
+
<helix-sandbox>
|
|
98
|
+
<helix-sandbox-source label="main.js" name="js" slot="source">
|
|
99
|
+
import confetti from 'canvas-confetti'
|
|
100
|
+
import { cheer } from './cheer.js'
|
|
101
|
+
|
|
102
|
+
confetti()
|
|
103
|
+
cheer()
|
|
104
|
+
</helix-sandbox-source>
|
|
105
|
+
<helix-sandbox-source name="cheer.js" slot="source">
|
|
106
|
+
export const cheer = () => console.log('Done')
|
|
107
|
+
</helix-sandbox-source>
|
|
108
|
+
<helix-sandbox-source name="package.json" slot="source">
|
|
109
|
+
{ "dependencies": { "canvas-confetti": "^1.9" } }
|
|
110
|
+
</helix-sandbox-source>
|
|
111
|
+
<helix-sandbox-preview slot="preview"></helix-sandbox-preview>
|
|
112
|
+
</helix-sandbox>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The preview takes the same lists as `dependencies` and `modules` without a
|
|
116
|
+
sandbox around it. `imports` maps a name to an address of your own, and wins
|
|
117
|
+
over a package of the same name. The preview loads its document again when one
|
|
118
|
+
of them changes, because a browser reads an import map only as a document
|
|
119
|
+
starts. A `src` document declares its own import map.
|
|
120
|
+
|
|
121
|
+
## Editing keys
|
|
122
|
+
|
|
123
|
+
In a source pane, Tab inserts two spaces. Shift+Tab moves focus back, and
|
|
124
|
+
Escape then Tab moves it forward. The field's description says this to a
|
|
125
|
+
screen reader. The other keys follow CodeMirror. `Mod` is Command on a Mac and
|
|
126
|
+
Control elsewhere.
|
|
127
|
+
|
|
128
|
+
| Key | Does |
|
|
129
|
+
|---|---|
|
|
130
|
+
| Tab, with text selected | Indents every line the selection touches |
|
|
131
|
+
| `Mod+]` | Indents the lines |
|
|
132
|
+
| `Mod+[` | Outdents the lines |
|
|
133
|
+
| `Mod+/` | Comments the lines out, or back in |
|
|
134
|
+
| Enter | Breaks the line and keeps its indentation, one level deeper after an opening bracket |
|
|
135
|
+
|
|
136
|
+
Three editing aids are off until you set them:
|
|
137
|
+
|
|
138
|
+
- `close-brackets` closes brackets and quotes as you type them. A closing
|
|
139
|
+
character typed before the same one steps over it, and Backspace between an
|
|
140
|
+
empty pair deletes both.
|
|
141
|
+
- `match-brackets` marks the bracket beside the caret and its pair while the
|
|
142
|
+
field has focus.
|
|
143
|
+
- `complete` offers the words of the source that start with the word you are
|
|
144
|
+
typing, and the words in `completions`. The arrow keys move through the list,
|
|
145
|
+
Enter or Tab takes a word, and Escape closes it. `manifestWords` reads the tag
|
|
146
|
+
names, attribute names, and custom properties of a custom elements manifest
|
|
147
|
+
into `completions`.
|
|
148
|
+
|
|
149
|
+
A pane is `:state(modified)` while it holds an edit, and so is the sandbox
|
|
150
|
+
around it. The file tab of an edited pane has a dot after its name, and a
|
|
151
|
+
screen reader reads it as modified. `reset()` on a pane, or on the sandbox for
|
|
152
|
+
every pane, puts back the source it was given.
|
|
153
|
+
|
|
83
154
|
## Your own editor
|
|
84
155
|
|
|
85
156
|
Any element can be the source pane. Put it in the `source` slot, give it a
|
|
@@ -126,10 +197,6 @@ customElements.define('code-editor', CodeEditor)
|
|
|
126
197
|
</helix-sandbox>
|
|
127
198
|
```
|
|
128
199
|
|
|
129
|
-
In a source pane, Tab inserts two spaces. Shift+Tab moves focus back, and
|
|
130
|
-
Escape then Tab moves it forward. The field's description says this to a
|
|
131
|
-
screen reader.
|
|
132
|
-
|
|
133
200
|
Each request has a notification once it is applied: `helix-edit` after
|
|
134
201
|
`helix-before-edit`, `helix-split` after `helix-before-split`, and
|
|
135
202
|
`helix-panel-resize` after `helix-before-panel-resize`. Listen for these to
|