-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor-field Output #1136
Comments
The editor will always save as a string, escaped as needed. The best option would be a list with 2 text fields into it for |
Lists and Arrays are too limiting in this regard, as they complicate the syntax and restrict the available properties to just styles:
- background: red
color: red
padding: 10em
- background: green
color: green
padding: 8em
- background: blue
color: blue
padding: 6em In the case of duplicate keys, the latest value in each list is effected. This allows a series of simple, or complex, themes to be defined and applied cyclically. Since the syntax is essentially lists of arrays within styles:
name: styles
type: list
style: vertical
label: Styles
fields:
.items:
type: list
label: Style
fields:
.item:
type: array
label: Styles
placeholder_key: Property
placeholder_value: Value
validate:
type: array But this returned some remarkably formatted YAML: styles:
0:
items:
0:
item: { background: red }
1:
item: { color: red }
'*':
item: { padding: 10em }
1:
items:
0:
item: { background: green, color: green }
'*':
item: { padding: 8em }
'*':
items:
0:
item: { background: blue, color: blue }
'*':
item: { padding: 6em } Currently the most viable solution would be the editor-field, though of course the syntax is unreadable for anything more than a simple |
Without array, you could have something close of what you want, something like:
|
Close, but no cigar. As noted, the virtue of the implementation is its direct relation to CSS: Simply an array of styles:
-
background: red
color: red
padding: 10em
-
background: green
color: green
padding: 8em
-
background: blue
color: blue
padding: 6em Thus, this new field behaves exactly as expected from input to output. I assume you'll document its usage when its done, @flaviocopes? Currently adding new values is not really working, the key disappears from sub-levels and there is no plus-sign to add a new top-level item. |
Please let flavio know any issues on the PR itself, that will keep everything nice and tidy. |
Will do. Closing this as the original question is answered, and the solution lies in that PR. |
Can the Editor-field output processed code, rather than an escaped string? Using a simple initialization:
With this in the editor:
This outputs:
However, I need it to output the actual input rather than this escaped output for it to be valid YAML that matches the original YAML-file. It feels like I'm overlooking something, but the Editor-field seems the most straightforward way to keep the simplicity of this input.
The text was updated successfully, but these errors were encountered: