@colixsystems/widget-sdk 0.322.0 → 0.324.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 +10 -2
- package/dist/contract.cjs +7 -2
- package/dist/contract.js +7 -2
- package/dist/index.d.ts +15 -0
- package/dist/linter.cjs +43 -0
- package/dist/linter.js +43 -0
- 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/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/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
|
},
|
|
@@ -7020,7 +7020,12 @@ const CONTRACT = deepFreeze({
|
|
|
7020
7020
|
// publish-blocking `bankid-order-not-shown` finding.
|
|
7021
7021
|
// 1.262.0: stricter lint (sc-16000) — a charging widget whose create or
|
|
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
|
+
// propertySchema text field holding group ids is `group-ids-as-text`.
|
|
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
|
+
version: "1.264.0",
|
|
7024
7029
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7025
7030
|
hooks: HOOKS,
|
|
7026
7031
|
primitives: PRIMITIVES,
|