@tightknitai/block-kitchen 0.10.18 → 0.10.20
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 +27 -0
- package/dist/helpers.d.cts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/index.cjs +822 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +825 -163
- package/dist/index.js.map +1 -1
- package/dist/{palette-Cxh1yNzW.d.cts → palette-4BJw_nd7.d.cts} +99 -7
- package/dist/{palette-Cxh1yNzW.d.ts → palette-4BJw_nd7.d.ts} +99 -7
- package/dist/palette.cjs +52 -0
- package/dist/palette.cjs.map +1 -1
- package/dist/palette.d.cts +1 -1
- package/dist/palette.d.ts +1 -1
- package/dist/palette.js +52 -0
- package/dist/palette.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +15 -4
package/README.md
CHANGED
|
@@ -139,6 +139,7 @@ Given no height to work with — a plain `<div>` in ordinary document flow — i
|
|
|
139
139
|
| `confirmUpdateLabel` | `string` | no | Label for the update dialog's final confirm button. Defaults to `'Update message'` (shows `'Updating…'` while in flight). |
|
|
140
140
|
| `previewHooks` | `PreviewHooks` | no | Hooks forwarded to `slack-blocks-to-jsx`'s `<Message>` for resolving user / channel / emoji directives. |
|
|
141
141
|
| `customEmojis` | `CustomEmoji[]` | no | Workspace custom emoji (`{ name, url, alias }`) the preview resolves. Entries with a `url` render `:name:` as the workspace image; alias entries (`url: null`) fall back to their target emoji. Render-only — never serialized into the emitted Block Kit JSON. A caller-supplied `previewHooks.emoji` takes precedence. |
|
|
142
|
+
| `mentions` | `{ searchUsers, getUserName? }` | no | Opt-in `@` mentions in the rich-text editor: typing `@` or the toolbar's Mention button opens a picker backed by `searchUsers(query, { signal })`, and a pick inserts a rich text `user` element. `getUserName(userId)` labels mentions in the editor. See [Mentions](#mentions-opt-in). |
|
|
142
143
|
| `palette` | `PaletteSection[]` | no | The left-hand palette of draggable variants. Defaults to `defaultPalette`. Spread it to filter, reorder, or add your own pre-configured variants — see [Customizing the palette](#customizing-the-palette). |
|
|
143
144
|
| `disabledBlockTypes` | `SupportedBlockType[]` | no | Block types to hide from the palette without rebuilding it. Filters at the variant level — a section keeps any variants whose block types aren't disabled; sections that end up empty are dropped. Convenient when you want the default palette minus a few types (e.g. `['image', 'table']` for a text-only builder). |
|
|
144
145
|
| `paletteMode` | `'advanced' \| 'simple'` | no | How much of the palette the user meets first. `'advanced'` (default) renders the full sectioned palette with its search input. `'simple'` opens on a flat list of the variants flagged `basic` — in the built-in palette: **Header**, **Divider**, **Rich Text Section** and **Image** — with no search and an "Advanced" link at the top that swaps in the full palette. Nothing is removed; it's a smaller first screen. See [Simple vs advanced palette](#simple-vs-advanced-palette). |
|
|
@@ -607,6 +608,8 @@ import type {
|
|
|
607
608
|
BlockKitchenSendProps, // the send trio + `onUpdate` + `renderSendExtras`
|
|
608
609
|
LoadingConfig, // load an existing message (works in both modes)
|
|
609
610
|
LoadedMessage, // the loaded target: channel + ts + verdict
|
|
611
|
+
MentionsConfig, // opt-in `@` mentions: host search + name lookup
|
|
612
|
+
MentionUser, // one person the `@` picker offers
|
|
610
613
|
BlockKitchenComposeOnlyProps, // the trio explicitly absent + `primaryAction`
|
|
611
614
|
PaletteSection,
|
|
612
615
|
PaletteVariant,
|
|
@@ -635,6 +638,30 @@ A searchable emoji picker (search, categories, skin tone, recents) is built into
|
|
|
635
638
|
|
|
636
639
|
Pass [`customEmojis`](#props) to add your workspace's custom emoji: image entries appear as the picker's **Custom** category and render in the preview; alias entries fall back to their target. Custom emoji never block Send — Slack accepts unknown emoji names, so they're excluded from validation. The emitted Block Kit JSON is unchanged whether or not `customEmojis` is passed.
|
|
637
640
|
|
|
641
|
+
## Mentions (opt-in)
|
|
642
|
+
|
|
643
|
+
Pass `mentions` to let people `@`-mention someone in the rich-text WYSIWYG editor. Typing `@` (after a space or at the start of a line, so `name@domain` is left alone) or clicking the toolbar's **Mention** button opens a picker backed by your search. Picking someone inserts a rich text `user` element, `{ type: "user", user_id }`. The picker's name and avatar are never serialized.
|
|
644
|
+
|
|
645
|
+
```tsx
|
|
646
|
+
<BlockKitchen
|
|
647
|
+
mentions={{
|
|
648
|
+
// Called with the text after `@` (empty right after it); debounced, and
|
|
649
|
+
// `signal` aborts once a newer query supersedes this one.
|
|
650
|
+
searchUsers: async (query, { signal }) => {
|
|
651
|
+
const res = await fetch(`/api/members?q=${encodeURIComponent(query)}`, { signal });
|
|
652
|
+
const members = await res.json();
|
|
653
|
+
return members.map((m) => ({ id: m.slackUserId, name: m.name, avatarUrl: m.avatar }));
|
|
654
|
+
},
|
|
655
|
+
// Optional: labels mentions in the editor by id, including ones that came
|
|
656
|
+
// with the draft or a loaded message. Return undefined when unknown.
|
|
657
|
+
getUserName: (userId) => names.get(userId)
|
|
658
|
+
}}
|
|
659
|
+
{...rest}
|
|
660
|
+
/>
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
Mentions already in a draft round-trip through the WYSIWYG with or without `mentions`; without `getUserName` they show the picked name or the raw id. The builder never looks people up itself. To show names in the Slack preview too, resolve the ids in [`previewHooks.user`](#props).
|
|
664
|
+
|
|
638
665
|
## Validation
|
|
639
666
|
|
|
640
667
|
Defense-in-depth: blocks are validated against [slack-block-kit-validator](https://github.com/TightknitAI/slack-block-kit-validator) before send. Issues are surfaced in the issues sheet with line numbers — users can fix them inline before posting.
|
package/dist/helpers.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SupportedBlock } from './palette-
|
|
2
|
-
export {
|
|
1
|
+
import { S as SupportedBlock } from './palette-4BJw_nd7.cjs';
|
|
2
|
+
export { a7 as SupportedBlockType } from './palette-4BJw_nd7.cjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'slack-web-api-client';
|
|
5
5
|
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SupportedBlock } from './palette-
|
|
2
|
-
export {
|
|
1
|
+
import { S as SupportedBlock } from './palette-4BJw_nd7.js';
|
|
2
|
+
export { a7 as SupportedBlockType } from './palette-4BJw_nd7.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'slack-web-api-client';
|
|
5
5
|
|