@colixsystems/widget-sdk 0.323.0 → 0.326.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/README.md +8 -4
- package/dist/contract.cjs +7 -2
- package/dist/contract.js +7 -2
- package/dist/host.d.ts +10 -0
- package/dist/host.js +3 -0
- package/dist/index.d.ts +17 -0
- package/dist/linter.cjs +50 -5
- package/dist/linter.js +50 -5
- package/dist/markdown-editor-bridge.js +6 -0
- package/dist/markdown-editor-bundle.js +1 -1
- package/dist/markdown-editor-core.js +14 -1
- package/dist/markdown-editor-field.js +8 -3
- package/dist/markdown-editor-html.js +1 -1
- package/dist/markdown-editor-webview.js +2 -0
- package/dist/markdown-input-view.js +13 -1
- package/dist/property-schema.js +3 -0
- package/dist/widget-font-families.cjs +47 -0
- package/dist/widget-font-families.js +40 -0
- package/package.json +1 -1
- package/src/contract.js +7 -2
|
@@ -40,6 +40,7 @@ function init(message) {
|
|
|
40
40
|
onFocusChange: (focused) => post({ type: "focus", focused }),
|
|
41
41
|
onState: (state) => post({ type: "state", inTable: state.inTable === true }),
|
|
42
42
|
});
|
|
43
|
+
instance.setEditable(message.editable);
|
|
43
44
|
instance.editor.on("selectionUpdate", () => post({ type: "selection", text: instance.selectedText() }));
|
|
44
45
|
|
|
45
46
|
let lastHeight = 0;
|
|
@@ -64,6 +65,7 @@ window.mdEditor = {
|
|
|
64
65
|
else if (message.type === "set") instance.setMarkdown(message.markdown);
|
|
65
66
|
else if (message.type === "command") instance.command(message.name, message.args);
|
|
66
67
|
else if (message.type === "focus") instance.focus();
|
|
68
|
+
else if (message.type === "editable") instance.setEditable(message.editable);
|
|
67
69
|
},
|
|
68
70
|
};
|
|
69
71
|
|
|
@@ -62,6 +62,8 @@ export function makeMarkdownInput(rn, Modal, Button, EditorField) {
|
|
|
62
62
|
accessibilityLabel,
|
|
63
63
|
style,
|
|
64
64
|
testID,
|
|
65
|
+
editorRef,
|
|
66
|
+
editable = true,
|
|
65
67
|
}) {
|
|
66
68
|
const theme = useHostTheme();
|
|
67
69
|
const tokens = React.useMemo(() => resolveRichTextTokens(theme), [theme]);
|
|
@@ -72,9 +74,16 @@ export function makeMarkdownInput(rn, Modal, Button, EditorField) {
|
|
|
72
74
|
|
|
73
75
|
const run = React.useCallback((name, args) => {
|
|
74
76
|
const field = fieldRef.current;
|
|
75
|
-
|
|
77
|
+
return field ? field.command(name, args) : false;
|
|
76
78
|
}, []);
|
|
77
79
|
|
|
80
|
+
// Lets a widget insert at the caret (an emoji picker) without the editor.
|
|
81
|
+
React.useImperativeHandle(
|
|
82
|
+
editorRef,
|
|
83
|
+
() => ({ insertText: (text) => run("insertText", { text }) }),
|
|
84
|
+
[run],
|
|
85
|
+
);
|
|
86
|
+
|
|
78
87
|
const pressTool = React.useCallback(
|
|
79
88
|
(tool) => {
|
|
80
89
|
// The selection seeds the form's Link text, so a highlighted phrase
|
|
@@ -112,6 +121,7 @@ export function makeMarkdownInput(rn, Modal, Button, EditorField) {
|
|
|
112
121
|
{
|
|
113
122
|
key: tool.key,
|
|
114
123
|
onPress: () => pressTool(tool),
|
|
124
|
+
disabled: !editable,
|
|
115
125
|
accessibilityRole: "button",
|
|
116
126
|
accessibilityLabel: tool.accessibilityLabel,
|
|
117
127
|
testID: testID ? `${testID}-${tool.key}` : undefined,
|
|
@@ -125,6 +135,7 @@ export function makeMarkdownInput(rn, Modal, Button, EditorField) {
|
|
|
125
135
|
borderColor: tokens.border,
|
|
126
136
|
borderRadius: tokens.radius,
|
|
127
137
|
alignItems: "center",
|
|
138
|
+
opacity: editable ? 1 : 0.5,
|
|
128
139
|
},
|
|
129
140
|
},
|
|
130
141
|
React.createElement(
|
|
@@ -153,6 +164,7 @@ export function makeMarkdownInput(rn, Modal, Button, EditorField) {
|
|
|
153
164
|
tokens,
|
|
154
165
|
minHeight,
|
|
155
166
|
maxHeight,
|
|
167
|
+
editable,
|
|
156
168
|
testID: testID ? `${testID}-field` : undefined,
|
|
157
169
|
}),
|
|
158
170
|
React.createElement(MarkdownLinkDialog, {
|
package/dist/property-schema.js
CHANGED
|
@@ -8,6 +8,8 @@ import { isPlainObject } from "./plain-object.js";
|
|
|
8
8
|
const VALID_TYPES = new Set([
|
|
9
9
|
"string", "number", "boolean",
|
|
10
10
|
"color", "icon", "image",
|
|
11
|
+
// sc-17364: a font family picker; both hosts load the family it names.
|
|
12
|
+
"font",
|
|
11
13
|
"select", "multiselect",
|
|
12
14
|
"tableRef", "columnRef", "recordBinding",
|
|
13
15
|
// REQ-WDG-VALUEREF: `valueRef` is a composite "single value from the
|
|
@@ -157,6 +159,7 @@ function coerceLeaf(def, value, path, errors) {
|
|
|
157
159
|
switch (t) {
|
|
158
160
|
case "string":
|
|
159
161
|
case "color":
|
|
162
|
+
case "font":
|
|
160
163
|
case "icon":
|
|
161
164
|
case "image":
|
|
162
165
|
case "tableRef":
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// GENERATED from widget-font-families.js by scripts/generate-cjs.js — DO NOT EDIT.
|
|
2
|
+
// Change widget-font-families.js, then run `npm run generate:cjs` in packages/widget-sdk.
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
// The font families a widget instance names through its manifest's `font`
|
|
6
|
+
// fields. Each host must fetch (web) or embed (native) these faces, or a
|
|
7
|
+
// picked font renders as the platform's fallback face. One reading, shared by
|
|
8
|
+
// the web host and the compiler, so both hosts load the same set (CLAUDE.md §8).
|
|
9
|
+
|
|
10
|
+
const isBlank = (value) => value === undefined || value === null || (typeof value === "string" && !value.trim());
|
|
11
|
+
|
|
12
|
+
// The Studio offers a font picker at any depth: inside an object's
|
|
13
|
+
// `properties` and each element of an array's `items`.
|
|
14
|
+
function collectField(field, value, into) {
|
|
15
|
+
if (!field || typeof field !== "object") return;
|
|
16
|
+
const resolved = isBlank(value) ? field.default : value;
|
|
17
|
+
if (field.type === "font") {
|
|
18
|
+
const family = typeof resolved === "string" ? resolved.trim() : "";
|
|
19
|
+
if (family && !into.includes(family)) into.push(family);
|
|
20
|
+
} else if (field.type === "object") {
|
|
21
|
+
collectFields(field.properties, resolved, into);
|
|
22
|
+
} else if (field.type === "array" && Array.isArray(resolved)) {
|
|
23
|
+
for (const item of resolved) collectField(field.items, item, into);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function collectFields(schema, values, into) {
|
|
28
|
+
if (!schema || typeof schema !== "object") return;
|
|
29
|
+
const record = values && typeof values === "object" ? values : {};
|
|
30
|
+
for (const [key, field] of Object.entries(schema)) collectField(field, record[key], into);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Every family a `type: "font"` field resolves to: the instance's value, else
|
|
35
|
+
* the field's `default`, at any depth. Property fields read `props`, style
|
|
36
|
+
* fields read `props.style`. Unfiltered: each host keeps its catalog allowlist.
|
|
37
|
+
*/
|
|
38
|
+
function widgetFontFamilies({ propertySchema, styleSchema, props } = {}) {
|
|
39
|
+
const families = [];
|
|
40
|
+
const instance = props && typeof props === "object" ? props : {};
|
|
41
|
+
collectFields(propertySchema, instance, families);
|
|
42
|
+
collectFields(styleSchema, instance.style, families);
|
|
43
|
+
return families;
|
|
44
|
+
}
|
|
45
|
+
module.exports = {
|
|
46
|
+
widgetFontFamilies,
|
|
47
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// The font families a widget instance names through its manifest's `font`
|
|
2
|
+
// fields. Each host must fetch (web) or embed (native) these faces, or a
|
|
3
|
+
// picked font renders as the platform's fallback face. One reading, shared by
|
|
4
|
+
// the web host and the compiler, so both hosts load the same set (CLAUDE.md §8).
|
|
5
|
+
|
|
6
|
+
const isBlank = (value) => value === undefined || value === null || (typeof value === "string" && !value.trim());
|
|
7
|
+
|
|
8
|
+
// The Studio offers a font picker at any depth: inside an object's
|
|
9
|
+
// `properties` and each element of an array's `items`.
|
|
10
|
+
function collectField(field, value, into) {
|
|
11
|
+
if (!field || typeof field !== "object") return;
|
|
12
|
+
const resolved = isBlank(value) ? field.default : value;
|
|
13
|
+
if (field.type === "font") {
|
|
14
|
+
const family = typeof resolved === "string" ? resolved.trim() : "";
|
|
15
|
+
if (family && !into.includes(family)) into.push(family);
|
|
16
|
+
} else if (field.type === "object") {
|
|
17
|
+
collectFields(field.properties, resolved, into);
|
|
18
|
+
} else if (field.type === "array" && Array.isArray(resolved)) {
|
|
19
|
+
for (const item of resolved) collectField(field.items, item, into);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function collectFields(schema, values, into) {
|
|
24
|
+
if (!schema || typeof schema !== "object") return;
|
|
25
|
+
const record = values && typeof values === "object" ? values : {};
|
|
26
|
+
for (const [key, field] of Object.entries(schema)) collectField(field, record[key], into);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Every family a `type: "font"` field resolves to: the instance's value, else
|
|
31
|
+
* the field's `default`, at any depth. Property fields read `props`, style
|
|
32
|
+
* fields read `props.style`. Unfiltered: each host keeps its catalog allowlist.
|
|
33
|
+
*/
|
|
34
|
+
export function widgetFontFamilies({ propertySchema, styleSchema, props } = {}) {
|
|
35
|
+
const families = [];
|
|
36
|
+
const instance = props && typeof props === "object" ? props : {};
|
|
37
|
+
collectFields(propertySchema, instance, families);
|
|
38
|
+
collectFields(styleSchema, instance.style, families);
|
|
39
|
+
return families;
|
|
40
|
+
}
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -3741,7 +3741,7 @@ const PRIMITIVES = [
|
|
|
3741
3741
|
{
|
|
3742
3742
|
name: "MarkdownInput",
|
|
3743
3743
|
description:
|
|
3744
|
-
"Formatted-content editor. `<MarkdownInput value={draft} onChange={setDraft} />`. The default way to let an app USER write formatted text: a rich-text field where the user edits the FORMATTED RESULT directly — headings, bold, italic, code, links, bulleted and numbered lists and real tables are shown as they will read, with no markdown markers in view — plus a toolbar (bold, italic, code, H2, H3, bullets, numbered list), a Table button that inserts a real table, with buttons to add or remove rows and columns or delete the table while the caret is in one, and a Link button that opens a form for the link text plus its target. Typing `## `, `- `, `1. `, `**bold**` or `*italic*` formats as you type. Use it rather than a bare `TextInput` plus formatting buttons of your own, and do NOT add a `<RichText>` preview under it: the field already shows the result; an editor you do build (one that only bolds, a checklist editor) still stores markdown markers and previews with `<RichText>` — buttons that splice `<strong>`/`<br>`/`<table>` tags into the string leave the author reading tag soup. The stored value is markdown text in the `<RichText>` grammar; loading a value never rewrites it, and an edit writes each construct in its canonical spelling. On iOS and Android the field runs in a WebView bundled into the SDK (no network). Props: `value`, `onChange(next)`, `placeholder`, `pages` (optional `[{ id, name }]` — supply it and the Link form offers those pages to link to by name; without it the form offers only an external address, because a widget cannot know the app's pages on its own), `minHeight` (default 150) and `maxHeight` (default 280) — the field grows with its content between them, then scrolls — `accessibilityLabel`, `style`, `testID
|
|
3744
|
+
"Formatted-content editor. `<MarkdownInput value={draft} onChange={setDraft} />`. The default way to let an app USER write formatted text: a rich-text field where the user edits the FORMATTED RESULT directly — headings, bold, italic, code, links, bulleted and numbered lists and real tables are shown as they will read, with no markdown markers in view — plus a toolbar (bold, italic, code, H2, H3, bullets, numbered list), a Table button that inserts a real table, with buttons to add or remove rows and columns or delete the table while the caret is in one, and a Link button that opens a form for the link text plus its target. Typing `## `, `- `, `1. `, `**bold**` or `*italic*` formats as you type. Use it rather than a bare `TextInput` plus formatting buttons of your own, and do NOT add a `<RichText>` preview under it: the field already shows the result; an editor you do build (one that only bolds, a checklist editor) still stores markdown markers and previews with `<RichText>` — buttons that splice `<strong>`/`<br>`/`<table>` tags into the string leave the author reading tag soup. The stored value is markdown text in the `<RichText>` grammar; loading a value never rewrites it, and an edit writes each construct in its canonical spelling. On iOS and Android the field runs in a WebView bundled into the SDK (no network). Props: `value`, `onChange(next)`, `placeholder`, `pages` (optional `[{ id, name }]` — supply it and the Link form offers those pages to link to by name; without it the form offers only an external address, because a widget cannot know the app's pages on its own), `minHeight` (default 150) and `maxHeight` (default 280) — the field grows with its content between them, then scrolls — `accessibilityLabel`, `style`, `testID`, `editorRef` (a ref filled with `{ insertText(text) }`, which inserts plain text at the caret, e.g. from an emoji picker, or at the end before the user has placed one, and returns false while the editor loads), and `editable` (default true; `false` locks the field and its toolbar, e.g. while saving). `showPreview`, `previewLabel` and `renderImage` are still accepted and ignored. Images show inside the field when their source is an http(s) URL and as a labelled placeholder when it is a filestore id. Links in the field are inert, so a tap while editing cannot navigate away from the draft.",
|
|
3745
3745
|
rnComponent: null,
|
|
3746
3746
|
docsUrl: null,
|
|
3747
3747
|
},
|
|
@@ -7022,7 +7022,12 @@ const CONTRACT = deepFreeze({
|
|
|
7022
7022
|
// update writes a paid status is the `payment-status-written` warning.
|
|
7023
7023
|
// 1.263.0: stricter lint — in a widget reading groupIds or useGroups(), a
|
|
7024
7024
|
// propertySchema text field holding group ids is `group-ids-as-text`.
|
|
7025
|
-
|
|
7025
|
+
// 1.264.0: additive (sc-17317) — `<MarkdownInput editorRef>` is filled
|
|
7026
|
+
// with `{ insertText(text) }`, inserting plain text at the caret, and
|
|
7027
|
+
// `editable={false}` locks the field and its toolbar.
|
|
7028
|
+
// 1.265.0: `font` is a field type, and a font named in the source is
|
|
7029
|
+
// `no-hardcoded-design` with no licence (sc-17364).
|
|
7030
|
+
version: "1.265.0",
|
|
7026
7031
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7027
7032
|
hooks: HOOKS,
|
|
7028
7033
|
primitives: PRIMITIVES,
|