@colixsystems/widget-sdk 0.275.1 → 0.276.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 +11 -3
- package/dist/contract.cjs +8 -5
- package/dist/contract.js +8 -5
- package/dist/index.d.ts +13 -13
- package/dist/linter.cjs +444 -162
- package/dist/linter.js +444 -164
- package/dist/markdown-doc.js +209 -0
- package/dist/markdown-editor-bridge.js +162 -0
- package/dist/markdown-editor-core.js +184 -0
- package/dist/markdown-editor-css.js +50 -0
- package/dist/markdown-editor-field.js +111 -0
- package/dist/markdown-editor-field.native.js +9 -0
- package/dist/markdown-editor-html.js +4 -0
- package/dist/markdown-editor-webview.js +70 -0
- package/dist/markdown-input-view.js +43 -101
- package/dist/markdown-input.js +4 -6
- package/dist/markdown-input.native.js +3 -5
- package/dist/markdown.js +1 -112
- package/dist/richtext-tokens.js +1 -25
- package/package.json +62 -2
- package/src/contract.js +8 -5
- package/dist/markdown-edit.js +0 -164
- package/dist/markdown-live-field.js +0 -312
- package/dist/markdown-live-field.native.js +0 -36
package/README.md
CHANGED
|
@@ -86,7 +86,15 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
86
86
|
|
|
87
87
|
## Status
|
|
88
88
|
|
|
89
|
-
`v0.
|
|
89
|
+
`v0.276.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
90
|
+
|
|
91
|
+
### What's new in 0.276.0 (contract 1.226.0)
|
|
92
|
+
|
|
93
|
+
**`<MarkdownInput>` edits the formatted result directly.** The field is now a rich-text editor: headings, bold, italic, code, links, bulleted and numbered lists and real tables appear as they will read, with no markdown markers in view. The toolbar applies formatting to the selection, the Table button inserts a real table, and while the caret is in one the toolbar adds buttons to add or remove rows and columns or delete it, and typing `## `, `- `, `1. ` or `**bold**` formats as you type. The value is still markdown in the `<RichText>` grammar, so stored content and `<RichText>` output are unchanged; loading a value never rewrites it, and an edit writes each construct in its canonical spelling. On iOS and Android the editor runs in a WebView from a page bundled into the SDK, so it needs no network. `showPreview`, `previewLabel` and `renderImage` are still accepted and ignored. Nothing to change in a widget that uses it.
|
|
94
|
+
|
|
95
|
+
### What's new in 0.275.2
|
|
96
|
+
|
|
97
|
+
**The linter's cost stays linear on any input.** Many checks re-read the source once per match. The affected checks were: finding each `<Text>` tag's end and braced child; the look-around at each `React` / SDK-primitive mention; the `useDatastoreMutation`, `useMemo` and lucide-import patterns; the measured-width and full-width-margin checks; the bordered-row check over nested or shared style objects; closing-tag matching; the per-field style-wiring check; and the line number of every finding. A large or malformed file could take minutes to lint. Each check now reads the source a bounded number of times. Findings are unchanged, with one exception: an `<Image>` or `<Marker>` written inside another tag of the same kind's attributes is no longer checked on its own.
|
|
90
98
|
|
|
91
99
|
### What's new in 0.275.1 (contract 1.225.0)
|
|
92
100
|
|
|
@@ -2176,7 +2184,7 @@ Content is **markdown text** now: one primitive authors it, the other renders it
|
|
|
2176
2184
|
<RichText value={post.body} />
|
|
2177
2185
|
```
|
|
2178
2186
|
|
|
2179
|
-
`<MarkdownInput>` is a
|
|
2187
|
+
`<MarkdownInput>` is a rich-text field where the author edits the formatted result directly — headings, bold, italic, code, links, bulleted and numbered lists and real tables, with no markdown markers in view — plus a toolbar (bold, italic, code, H2, H3, bullets, numbered list, each toggling back off), a Table button and a Link button. The value it reads and writes is markdown in the `<RichText>` grammar below; loading a value never rewrites it. `minHeight` (150) and `maxHeight` (280) bound the field: it grows with its content between them, then scrolls inside its box instead of growing past its card. Don't put a `<RichText>` preview under it — the field already shows the result. Reach for it instead of a bare `TextInput` plus hand-rolled formatting buttons, which can only splice literal tags into the text.
|
|
2180
2188
|
|
|
2181
2189
|
`<RichText>` parses the subset — `**bold**`, `*italic*` / `_italic_`, `` `code` ``, `#`/`##`/`###` headings, `-`/`*` bullets, `1.` ordered items, and one-line `` images — and renders it with SDK primitives, so formatted content reads the same in the web Player and the exported Expo app. Colour, type scale and leading come from the workspace theme; never re-style them. Pass `renderImage` (`({ src, alt, size }) => node`) when images are filestore ids, because resolving one needs the scopes your own widget holds — without it only absolute `http(s)` URLs render. HTML is never interpreted: stored text that still holds markup is stripped to plain text rather than shown as tags.
|
|
2182
2190
|
|
|
@@ -3344,7 +3352,7 @@ import { defineWidget, validateManifest, useDatastoreQuery, Text, View } from "@
|
|
|
3344
3352
|
- `ConfirmDialog` — the standard confirmation prompt, a preset of `Modal` and `Button`. `<ConfirmDialog visible={asking} tone="destructive" title="Delete this order?" message="This cannot be undone." confirmLabel="Delete" onCancel={() => setAsking(false)} onConfirm={removeOrder} />` asks before a delete or any other action that cannot be undone. Cancel, the close button, the backdrop, Escape and the Android back button fire `onCancel`; a promise returned from `onConfirm` keeps it busy (buttons disabled, a second press ignored) until it settles. Props: `visible`, `title`, `message`, `confirmLabel`, `cancelLabel`, `tone` (`default` | `destructive`), `busy`, `onConfirm`, `onCancel`, `closeAccessibilityLabel`, `testID`. Use it instead of building a confirmation from `Modal` yourself.
|
|
3345
3353
|
- `Modal` — the standard dialog, built on `Overlay`. `<Modal visible={open} onRequestClose={() => setOpen(false)} title="Edit order" footer={<Button title="Save" onPress={save} />}>…</Modal>` draws a title, a close button, a body that scrolls when it is long and a footer action row laid out below it. Its background, corner radius, padding, scrim, shadow and title colour come from the theme's `modal` scope (Design > Components > Dialogs), so every dialog in an app matches. Props: `visible`, `onRequestClose`, `dismissible`, `title`, `footer`, `presentation` (`dialog` | `sheet`), `size` (`sm` | `md` | `lg` | `full`), `dismissOnBackdropPress`, `role`, `initialFocusRef`, `closeAccessibilityLabel`, `accessibilityLabel`, `testID`. Use it for every dialog instead of hand-building a header and an action row inside `Overlay`.
|
|
3346
3354
|
- `RichText` — the formatted-content renderer. `<RichText value={post.body} />` parses the markdown subset (`**bold**`, `*italic*` / `_italic_`, `` `code` ``, `#`/`##`/`###` headings, `-`/`*` bullets, `1.` ordered items, one-line `` images) and renders it with SDK primitives, so formatted content reads the same in the web Player and the exported Expo app. `value` is markdown, NOT HTML — widgets have no `dangerouslySetInnerHTML` on either host, so tags in a content string render as literal tag soup; stored text that still holds legacy HTML is stripped to plain text rather than shown as markup. Props: `value`, `renderImage` (`({ src, alt, size }) => node` — supply it when images are filestore ids, because resolving one needs the scopes your own widget holds; without it only absolute `http(s)` URLs render), `style`, `testID`. Colour, type scale and leading come from the workspace theme — never re-style them.
|
|
3347
|
-
- `MarkdownInput` — the authoring half of `<RichText>`. `<MarkdownInput value={draft} onChange={setDraft} />` is a
|
|
3355
|
+
- `MarkdownInput` — the authoring half of `<RichText>`. `<MarkdownInput value={draft} onChange={setDraft} />` is a rich-text field where the author edits the formatted result directly (headings, emphasis, code, links, lists and real tables), with a toolbar, a Table button and a Link button — the way to let an app USER write formatted text, instead of a bare `TextInput` plus hand-rolled buttons that can only splice literal tags into the value. The value stays markdown. Props: `value`, `onChange(next)`, `placeholder`, `pages` (offered by name in the Link form), `minHeight` (150) and `maxHeight` (280) — it grows between them, then scrolls — `accessibilityLabel`, `style`, `testID`. `showPreview`, `previewLabel` and `renderImage` are accepted and ignored.
|
|
3348
3356
|
- `parseMarkdown`, `markdownToPlainText`, `parseMarkdownImage`, `formatMarkdownImage`, `stripHtmlToMarkdown`, `MARKDOWN_IMAGE_SIZES` — the same grammar as pure helpers, for content you inspect rather than render: the block list, a marker-free projection (list previews, search, a11y labels), the one-line image form read and written, a legacy-HTML row normalised to markdown on read, and the closed size list (`small` | `medium` | `large` | `full`).
|
|
3349
3357
|
- `isSafeMarkdownImageSrc`, `isHttpImageSrc`, `normaliseMarkdownImageSize`, `readMarkdownAlt` — the image half of that grammar, for a widget rendering images itself via `renderImage`. `isSafeMarkdownImageSrc` is the same allowlist the parser applies (an `http(s)` URL or a filestore id; a `javascript:` scheme is refused), so the widget and the parser cannot disagree about which src is renderable.
|
|
3350
3358
|
- `List`, `ListRow`, `ListHeader`, `EmptyState` — the themed list building blocks. `<ListRow title subtitle leading trailing onPress selected divider>` draws one record row from the theme's `list` scope (padding, height, gap, radius, background, divider); `<List>` spaces its rows and hands overrides down; `<ListHeader>` labels a table's columns on the rows' own inset; `<EmptyState icon title message>` is the "nothing here" panel. Use them by default for record rows and a table's header; build your own row when it needs what `ListRow` cannot do (a swipe-to-delete row, a row that expands in place).
|
package/dist/contract.cjs
CHANGED
|
@@ -3467,13 +3467,13 @@ const PRIMITIVES = [
|
|
|
3467
3467
|
rnComponent: null,
|
|
3468
3468
|
docsUrl: null,
|
|
3469
3469
|
},
|
|
3470
|
-
// sc-6970 — formatted content, authored. The authoring half of `<RichText
|
|
3471
|
-
// a
|
|
3472
|
-
//
|
|
3470
|
+
// sc-6970 — formatted content, authored. The authoring half of `<RichText>`,
|
|
3471
|
+
// so a generated widget never has to splice HTML tags into a plain TextInput
|
|
3472
|
+
// again. sc-15080: the field edits the formatted result directly.
|
|
3473
3473
|
{
|
|
3474
3474
|
name: "MarkdownInput",
|
|
3475
3475
|
description:
|
|
3476
|
-
|
|
3476
|
+
"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`. `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.",
|
|
3477
3477
|
rnComponent: null,
|
|
3478
3478
|
docsUrl: null,
|
|
3479
3479
|
},
|
|
@@ -6573,7 +6573,10 @@ const CONTRACT = deepFreeze({
|
|
|
6573
6573
|
// ships a hand-written `sv` value beside `en`.
|
|
6574
6574
|
// 1.225.0: behaviour (sc-14974) — `<MarkdownInput>` styles its own field
|
|
6575
6575
|
// live; `showPreview` now defaults to false.
|
|
6576
|
-
|
|
6576
|
+
// 1.226.0: behaviour (sc-15080) — `<MarkdownInput>` is a rich-text editor
|
|
6577
|
+
// showing the formatted result; `showPreview`, `previewLabel` and
|
|
6578
|
+
// `renderImage` are accepted and ignored.
|
|
6579
|
+
version: "1.226.0",
|
|
6577
6580
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6578
6581
|
hooks: HOOKS,
|
|
6579
6582
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -3464,13 +3464,13 @@ const PRIMITIVES = [
|
|
|
3464
3464
|
rnComponent: null,
|
|
3465
3465
|
docsUrl: null,
|
|
3466
3466
|
},
|
|
3467
|
-
// sc-6970 — formatted content, authored. The authoring half of `<RichText
|
|
3468
|
-
// a
|
|
3469
|
-
//
|
|
3467
|
+
// sc-6970 — formatted content, authored. The authoring half of `<RichText>`,
|
|
3468
|
+
// so a generated widget never has to splice HTML tags into a plain TextInput
|
|
3469
|
+
// again. sc-15080: the field edits the formatted result directly.
|
|
3470
3470
|
{
|
|
3471
3471
|
name: "MarkdownInput",
|
|
3472
3472
|
description:
|
|
3473
|
-
|
|
3473
|
+
"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`. `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.",
|
|
3474
3474
|
rnComponent: null,
|
|
3475
3475
|
docsUrl: null,
|
|
3476
3476
|
},
|
|
@@ -6570,7 +6570,10 @@ const CONTRACT = deepFreeze({
|
|
|
6570
6570
|
// ships a hand-written `sv` value beside `en`.
|
|
6571
6571
|
// 1.225.0: behaviour (sc-14974) — `<MarkdownInput>` styles its own field
|
|
6572
6572
|
// live; `showPreview` now defaults to false.
|
|
6573
|
-
|
|
6573
|
+
// 1.226.0: behaviour (sc-15080) — `<MarkdownInput>` is a rich-text editor
|
|
6574
|
+
// showing the formatted result; `showPreview`, `previewLabel` and
|
|
6575
|
+
// `renderImage` are accepted and ignored.
|
|
6576
|
+
version: "1.226.0",
|
|
6574
6577
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6575
6578
|
hooks: HOOKS,
|
|
6576
6579
|
primitives: PRIMITIVES,
|
package/dist/index.d.ts
CHANGED
|
@@ -5711,12 +5711,13 @@ export const RichText: (props: {
|
|
|
5711
5711
|
}) => any;
|
|
5712
5712
|
|
|
5713
5713
|
/**
|
|
5714
|
-
* sc-6970 — the authoring half of `<RichText
|
|
5715
|
-
*
|
|
5716
|
-
*
|
|
5717
|
-
*
|
|
5718
|
-
*
|
|
5719
|
-
*
|
|
5714
|
+
* sc-6970 — the authoring half of `<RichText>`. sc-15080: a rich-text field
|
|
5715
|
+
* where the author edits the formatted result directly — headings, emphasis,
|
|
5716
|
+
* code, links, lists and real tables — with a formatting toolbar, while the
|
|
5717
|
+
* value stays markdown in the `<RichText>` grammar. Loading a value never
|
|
5718
|
+
* rewrites it. On iOS and Android the field runs in a bundled WebView. Use it
|
|
5719
|
+
* instead of a bare `TextInput` plus hand-rolled formatting buttons, which can
|
|
5720
|
+
* only splice literal tags into the text.
|
|
5720
5721
|
*
|
|
5721
5722
|
* @example
|
|
5722
5723
|
* <MarkdownInput value={draft} onChange={setDraft} placeholder="Write…" />
|
|
@@ -5727,14 +5728,13 @@ export const MarkdownInput: (props: {
|
|
|
5727
5728
|
/** Receives the next markdown string on every edit. */
|
|
5728
5729
|
onChange?: (next: string) => void;
|
|
5729
5730
|
placeholder?: string;
|
|
5730
|
-
/**
|
|
5731
|
+
/** The app's pages, offered by name in the Link form. */
|
|
5732
|
+
pages?: ReadonlyArray<{ id: string; name: string }>;
|
|
5733
|
+
/** @deprecated Ignored: the field shows the formatted result itself. */
|
|
5731
5734
|
previewLabel?: string;
|
|
5732
|
-
/**
|
|
5733
|
-
* Also draw a rendered `<RichText>` copy under the field, for images and
|
|
5734
|
-
* tables the field shows only as markers. Defaults to false.
|
|
5735
|
-
*/
|
|
5735
|
+
/** @deprecated Ignored: the field shows the formatted result itself. */
|
|
5736
5736
|
showPreview?: boolean;
|
|
5737
|
-
/**
|
|
5737
|
+
/** @deprecated Ignored: the field shows the formatted result itself. */
|
|
5738
5738
|
renderImage?: (block: {
|
|
5739
5739
|
src: string;
|
|
5740
5740
|
alt: string;
|
|
@@ -5742,7 +5742,7 @@ export const MarkdownInput: (props: {
|
|
|
5742
5742
|
}) => ReactNode;
|
|
5743
5743
|
/** Field floor, so it opens at a usable height. Defaults to 150. */
|
|
5744
5744
|
minHeight?: number;
|
|
5745
|
-
/**
|
|
5745
|
+
/** The field grows with its content up to this, then scrolls. Defaults to 280. */
|
|
5746
5746
|
maxHeight?: number;
|
|
5747
5747
|
accessibilityLabel?: string;
|
|
5748
5748
|
style?: any;
|