@design.estate/dees-catalog 21.43.0 → 21.44.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.
Files changed (69) hide show
  1. package/dist_bundle/bundle.js +529 -178
  2. package/dist_bundle/bundle.js.map +1 -1
  3. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-72W55DOJ.js → chunk-ETDITRNI.js} +4 -3
  4. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-72W55DOJ.js.map → chunk-ETDITRNI.js.map} +1 -1
  5. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-PAFNUCDL.js → chunk-UD6S2QIF.js} +3 -3
  6. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-GTAAYRP5.js → chunk-WZGJITN2.js} +2 -2
  7. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{de-CQ56NZVB.js → de-NIKZVWN2.js} +4 -3
  8. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-NIKZVWN2.js.map +1 -0
  9. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-JNRW3HIY.js → dees-modal-BOGBX6EB.js} +3 -3
  10. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-Y532Z546.js → dees-workspace-terminal-M3DB4LUI.js} +4 -4
  11. package/dist_ts_web/00_commitinfo_data.js +1 -1
  12. package/dist_ts_web/elements/00group-dataview/dees-thread/dees-thread.d.ts +20 -4
  13. package/dist_ts_web/elements/00group-dataview/dees-thread/dees-thread.demo.js +21 -4
  14. package/dist_ts_web/elements/00group-dataview/dees-thread/dees-thread.js +65 -10
  15. package/dist_ts_web/elements/00group-dataview/dees-thread/interfaces.d.ts +5 -0
  16. package/dist_ts_web/elements/00group-dataview/dees-thread/thread.markdown.d.ts +2 -1
  17. package/dist_ts_web/elements/00group-dataview/dees-thread/thread.markdown.js +6 -3
  18. package/dist_ts_web/elements/00group-input/dees-input-reference/dees-input-reference.d.ts +1 -7
  19. package/dist_ts_web/elements/00group-input/dees-input-reference/dees-input-reference.js +22 -97
  20. package/dist_ts_web/elements/00group-input/dees-input-richtext/component.d.ts +23 -0
  21. package/dist_ts_web/elements/00group-input/dees-input-richtext/component.js +105 -5
  22. package/dist_ts_web/elements/00group-input/dees-input-richtext/demo.js +29 -1
  23. package/dist_ts_web/elements/00group-input/dees-input-richtext/index.d.ts +1 -1
  24. package/dist_ts_web/elements/00group-input/dees-input-richtext/index.js +5 -2
  25. package/dist_ts_web/elements/00group-input/dees-input-richtext/markdown.d.ts +21 -0
  26. package/dist_ts_web/elements/00group-input/dees-input-richtext/markdown.js +90 -6
  27. package/dist_ts_web/elements/00group-input/dees-input-richtext/references.d.ts +52 -0
  28. package/dist_ts_web/elements/00group-input/dees-input-richtext/references.js +152 -0
  29. package/dist_ts_web/elements/00group-input/dees-input-richtext/styles.js +23 -1
  30. package/dist_ts_web/elements/00group-input/dees-input-richtext/template.js +2 -1
  31. package/dist_ts_web/elements/00group-kanban/dees-kanban/dees-kanban.js +6 -1
  32. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.d.ts +15 -2
  33. package/dist_ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.js +44 -11
  34. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.d.ts +7 -0
  35. package/dist_ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.js +67 -5
  36. package/dist_ts_web/elements/00group-kanban/kanban.demodata.js +2 -2
  37. package/dist_ts_web/i18n/de.d.ts +6 -2
  38. package/dist_ts_web/i18n/de.js +3 -2
  39. package/dist_ts_web/i18n/messages.d.ts +6 -2
  40. package/dist_ts_web/i18n/messages.js +3 -2
  41. package/dist_ts_web/richtextmarkdown.d.ts +5 -1
  42. package/dist_ts_web/richtextmarkdown.js +6 -2
  43. package/package.json +1 -1
  44. package/readme.md +66 -10
  45. package/ts_web/00_commitinfo_data.ts +1 -1
  46. package/ts_web/elements/00group-dataview/dees-thread/dees-thread.demo.ts +23 -3
  47. package/ts_web/elements/00group-dataview/dees-thread/dees-thread.ts +50 -7
  48. package/ts_web/elements/00group-dataview/dees-thread/interfaces.ts +6 -0
  49. package/ts_web/elements/00group-dataview/dees-thread/thread.markdown.ts +5 -2
  50. package/ts_web/elements/00group-input/dees-input-reference/dees-input-reference.ts +20 -88
  51. package/ts_web/elements/00group-input/dees-input-richtext/component.ts +83 -3
  52. package/ts_web/elements/00group-input/dees-input-richtext/demo.ts +34 -0
  53. package/ts_web/elements/00group-input/dees-input-richtext/index.ts +6 -0
  54. package/ts_web/elements/00group-input/dees-input-richtext/markdown.ts +93 -5
  55. package/ts_web/elements/00group-input/dees-input-richtext/references.ts +171 -0
  56. package/ts_web/elements/00group-input/dees-input-richtext/styles.ts +22 -0
  57. package/ts_web/elements/00group-input/dees-input-richtext/template.ts +1 -0
  58. package/ts_web/elements/00group-kanban/dees-kanban/dees-kanban.ts +5 -0
  59. package/ts_web/elements/00group-kanban/dees-kanban-discussion/dees-kanban-discussion.ts +39 -10
  60. package/ts_web/elements/00group-kanban/dees-kanban-ticket-detail/dees-kanban-ticket-detail.ts +61 -3
  61. package/ts_web/elements/00group-kanban/kanban.demodata.ts +1 -1
  62. package/ts_web/i18n/de.ts +2 -1
  63. package/ts_web/i18n/messages.ts +2 -1
  64. package/ts_web/richtextmarkdown.ts +8 -0
  65. package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/de-CQ56NZVB.js.map +0 -1
  66. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-PAFNUCDL.js.map → chunk-UD6S2QIF.js.map} +0 -0
  67. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{chunk-GTAAYRP5.js.map → chunk-WZGJITN2.js.map} +0 -0
  68. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-modal-JNRW3HIY.js.map → dees-modal-BOGBX6EB.js.map} +0 -0
  69. /package/dist_bundle/chunks/U6Ua8p1giFoD1s7vrUZUdpbg/{dees-workspace-terminal-Y532Z546.js.map → dees-workspace-terminal-M3DB4LUI.js.map} +0 -0
package/readme.md CHANGED
@@ -41,7 +41,7 @@ switcher**, **view-toggle**, and **single-selection toggle** all lead to
41
41
  | Track epics, tasks and subtasks across workflow columns | [`dees-kanban`](#deeskanban) | Board, ordering, projects, filters, ticket detail with links, source and history, discussion, live refresh and stable ticket references. |
42
42
  | Show a conversation about a record: comments by people and agents, what happened, a reply | [`dees-thread`](#deesthread) | Timeline of comments and events, Markdown composer with close/reopen actions, pending and refused posts, read-only and failed states. The host owns posting and adds the posted entry. |
43
43
  | Show who wrote, did or owns something: a picture, else initials; an agent apart from a person | [`dees-avatar`](#deesavatar) | Round for a person, a rounded square with its own glyph for an agent or the system; a picture that fails falls back to the initials. `decorative` beside a visible name. |
44
- | Compose comments with searchable inline references | [`dees-input-reference`](#deesinputreference) | Typing `#_` opens a searchable picker at the caret; the value contains text and stable reference IDs. |
44
+ | Compose comments with searchable inline references | [`dees-input-richtext`](#deesinputrichtext) `searchReferences`, [`dees-input-reference`](#deesinputreference) | In Markdown, `#` at the start of a word searches the host's records at the caret and links the one chosen; `dees-input-reference` writes plain text with references, at `#_`. Both keep stable reference IDs. |
45
45
  | Search, filter, sort, edit and act on records | [`dees-table`](#deestable) | Use its columns, selection and data actions before building a table toolbar or row-action layer. |
46
46
  | Offer an action about what a tile shows: open its details, export it, add to it | [`dees-tile`](#deestile) `actions` | Footer or header actions, drawn and held while they run exactly like a table's header and footer actions. Never a footer bar of buttons built by hand; actions on a table's rows or on the table itself are the table's own. See [Where actions go](#where-actions-go). |
47
47
  | Filter a view's rows: an account, a month, "Include private" | [`dees-table`](#deestable) `filters` | Behind the filter button at the end of the table's search field, which counts the active filters and opens them in the speech bubble; each active one is a removable chip in the bar above the column headers. Never a row of dropdowns and checkboxes in the header. See [Where actions go](#where-actions-go). |
@@ -115,7 +115,7 @@ class MyApp extends DeesElement {
115
115
  | `@design.estate/dees-catalog` | Every component, registered on import, with the types of their properties and events. |
116
116
  | `@design.estate/dees-catalog/icon` | `dees-icon` alone (see [DeesIcon](#deesicon)). |
117
117
  | `@design.estate/dees-catalog/cdn` | Where the catalog loads Monaco from, as constants, and `monacoVsDirectoryUrl()` for a server that serves Monaco itself. Imports no component, Lit or DOM API, so it runs in plain Node. |
118
- | `@design.estate/dees-catalog/richtext-markdown` | The richtext editor's Markdown format without the editor: `richtextMarkdownToDoc`, `richtextDocToMarkdown` and `richtextMarkdownRenderOptions`. Imports no component, Lit or DOM API, so it runs in plain Node. |
118
+ | `@design.estate/dees-catalog/richtext-markdown` | The richtext editor's Markdown format without the editor: `richtextMarkdownToDoc`, `richtextDocToMarkdown` and `richtextMarkdownRenderOptions`, and its references: `richtextReferenceHref`, `richtextReferenceId`, `richtextMarkdownToReferences` and `richtextReferencesToMarkdown`. Imports no component, Lit or DOM API, so it runs in plain Node. |
119
119
 
120
120
  Name a component's event and property types from the package root, never from a
121
121
  `dist_ts_web/...` path:
@@ -2181,6 +2181,7 @@ Rich text editor with formatting toolbar powered by TipTap.
2181
2181
  - Undo/redo support
2182
2182
  - Word count
2183
2183
  - HTML or Markdown output (`format`), and a choice of toolbar buttons (`toolbar`)
2184
+ - Links to the host's records, searched at `#` (`searchReferences`)
2184
2185
  - [`frameless`](#frameless-components) drops the editor's outer frame when the host owns it
2185
2186
 
2186
2187
  The box is `minHeight` px tall (200 by default), toolbar and footer included, and its
@@ -2260,6 +2261,36 @@ the editor reads the value with the same `frontmatter: false`, so a note that st
2260
2261
  - Set `format` with the value; changing it later builds the editor again and reads the
2261
2262
  value in the new format. `setValue()`, `getValue()` and `dees-form` speak the format.
2262
2263
 
2264
+ **References.** With `searchReferences` (`TReferenceSearch`, `(query, signal) =>
2265
+ IInputReference[]`) the field links the host's own records: tickets, people, documents.
2266
+ `#` (`reference-trigger`) typed at the start of a word, outside code and links, opens a
2267
+ search at the caret that takes the focus, so `C#` stays text; the record chosen takes
2268
+ the trigger's place as one piece, shown as a link with its label. Escape closes the
2269
+ search and leaves the `#` as typed, so a heading is Escape and a space. In Markdown a
2270
+ reference is a link to `#reference:` and the record's id, percent-encoded
2271
+ (`[#CAT-12 Login fails](#reference:cat-12)`), in HTML a
2272
+ `<span data-reference-id="cat-12">`; references in a value show as links in either
2273
+ format, with or without a search. A click on one, or Enter on it, dispatches
2274
+ `reference-open` with its `id` and `label`, for the host to open the record. A search
2275
+ that cannot open shows why under the field until the next one opens; one whose
2276
+ `searchReferences` fails says so in its list. `reference-search-label` names the
2277
+ search ("Search to link" by default, `richtext.referenceSearch`).
2278
+
2279
+ ```typescript
2280
+ <dees-input-richtext
2281
+ label="Payment note"
2282
+ format="markdown"
2283
+ .searchReferences=${(query, signal) => api.searchRecords(query, signal)}
2284
+ reference-search-label="Search records"
2285
+ @reference-open=${(event) => openRecord(event.detail.id)}
2286
+ ></dees-input-richtext>
2287
+ ```
2288
+
2289
+ `richtextReferenceHref(id)` and `richtextReferenceId(href)` write and read a reference's
2290
+ link; a host that keeps a text's references as records, as `TReferenceContent`, reads the
2291
+ Markdown with `richtextMarkdownToReferences(markdown)` (text parts stay Markdown) and
2292
+ writes it back with `richtextReferencesToMarkdown(content)`.
2293
+
2263
2294
  #### `DeesInputWysiwyg`
2264
2295
  Rich editor for HTML or Markdown. Use `changeSubject` for field updates, or collect
2265
2296
  `.value` through `dees-form`.
@@ -3850,8 +3881,19 @@ composer. `submit(action?)` posts from code and `focusComposer()` focuses the ed
3850
3881
  `.draft` restores a draft; `thread-draft` reports every change, so a host can keep one
3851
3882
  per thread. `composerInfo` (a string, paragraphs split by blank lines, or a template) is an ⓘ
3852
3883
  button at the leading end of the composer's footer that opens it in a speech bubble: who
3853
- reads a reply and what it does, said once instead of above every composer. `format="references"` writes with `dees-input-reference` and
3854
- `.searchReferences` instead, as the Kanban discussion does.
3884
+ reads a reply and what it does, said once instead of above every composer.
3885
+ `.searchReferences` links the host's records from the composer: `#` at the start of a
3886
+ word searches them, as [`dees-input-richtext`](#deesinputrichtext) does, and
3887
+ `referenceSearchLabel` names that search. A reference in a body (a link to
3888
+ `#reference:` and the record's id) shows as a link and opens its record through
3889
+ `thread-reference-open`. `format="references"` writes plain text with references through
3890
+ `dees-input-reference` instead, at `#_`.
3891
+
3892
+ `view` places the composer apart: `'entries'` shows the timeline alone and
3893
+ `'composer'` the composer alone (`'full'`, the default, both). A host that pins the
3894
+ composer under the timeline, as the Kanban ticket detail does, renders the thread twice
3895
+ with the same properties; the composer alone starts at three lines, grows as the reader
3896
+ writes, and shows while the thread is loading too.
3855
3897
 
3856
3898
  `readOnly` replaces the composer with `readOnlyReason`. `loading` and `error` keep the
3857
3899
  items a thread has; a thread without items says it is loading, empty or failed, and
@@ -5388,7 +5430,8 @@ action footer, and the active-filter bar below the header shows each filter and
5388
5430
  the search as a removable chip with Clear all. `.filterValues` (`IKanbanFilterValues`: `text`, `project`, `epic`,
5389
5431
  `assignee` with `'none'` for unassigned, `label`, `mine`) starts the board
5390
5432
  filtered; the reader's changes emit `kanban-filter-change`. "Assigned to me"
5391
- appears when `.currentPersonId` is set. `clearFilters()` clears them.
5433
+ appears when `.currentPersonId` is set, and that person in `.people` heads the
5434
+ comment composer with their avatar. `clearFilters()` clears them.
5392
5435
 
5393
5436
  A ticket's `links` (`TKanbanLink`) name where its work lives: a branch with
5394
5437
  an optional sha, a commit, a release with its version, or any page. A link with
@@ -5464,7 +5507,7 @@ the ticket ID and anchor element. Secondary cards remain usable independently.
5464
5507
  board's modal. It displays the parent, child tickets, description, links, source,
5465
5508
  fields, created and updated stamps, and the discussion beside the history. It
5466
5509
  accepts `.ticket`, `.tickets`, `.columns`, `.people`, `.projects`, `.provider`,
5467
- `.draft`, `.comments`, `.commentDraft`, `.activity`, `.loadingActivity`,
5510
+ `.draft`, `.comments`, `.commentDraft`, `.currentPerson`, `.activity`, `.loadingActivity`,
5468
5511
  `.activityError` and `.conflict` (`IKanbanEditConflict`, a save refused as stale).
5469
5512
  It emits `kanban-ticket-save` and `kanban-ticket-draft` intents, and for a
5470
5513
  conflict `kanban-ticket-reload`, `kanban-conflict-apply` and
@@ -5495,16 +5538,26 @@ section, with the edit's actions at its foot, before the links, the child ticket
5495
5538
  and the discussion. The fields stand there in the document as well, so the focus
5496
5539
  order is the order on screen at every width: **Edit ticket** comes before the
5497
5540
  discussion.
5541
+ The discussion's composer, headed by `.currentPerson`'s avatar, stays at the foot of
5542
+ the main column while the comments scroll beneath it, opaque in the detail's surface:
5543
+ `--dees-kanban-detail-surface`, the page's background unless the host sets its own, as
5544
+ the board does for its modal. On a short ticket it rests at the bottom, and the space
5545
+ above it belongs to the conversation. The history in the discussion's place hides it,
5546
+ keeping its draft; on a phone it follows the comments.
5498
5547
  With [`frameless`](#frameless-components), as the board sets it, the detail lines
5499
5548
  its content up with the modal's heading through the [region inset](#region-inset).
5500
5549
 
5501
5550
  #### DeesKanbanDiscussion
5502
5551
 
5503
5552
  `dees-kanban-discussion` renders a ticket's comments as a
5504
- [`dees-thread`](#deesthread) with a reference composer (`format="references"`).
5505
- Provide `.ticketId`, `.comments`, `.draft`, `.searchTickets`, `.addComment`,
5506
- `.loading`, `.error` and `.readOnly`. `submit()` awaits the save callback; errors
5507
- leave the draft intact. Ctrl/⌘ Enter submits; Enter inserts a newline.
5553
+ [`dees-thread`](#deesthread) with its standard Markdown composer, which links tickets
5554
+ at `#` through `.searchTickets` and is headed by `.currentPerson`'s avatar.
5555
+ Provide `.ticketId`, `.comments`, `.draft`, `.searchTickets`, `.currentPerson`,
5556
+ `.addComment`, `.loading`, `.error` and `.readOnly`. Comment bodies and the draft stay
5557
+ `TReferenceContent`, their text parts Markdown, so a comment written before shows as
5558
+ Markdown too. `.view` (`'full'`, `'entries'` or `'composer'`) shows the comments or the
5559
+ composer alone, as the thread's `view`. `submit()` awaits the save callback; errors
5560
+ leave the draft intact. Ctrl/⌘ Enter submits; Enter starts a new paragraph.
5508
5561
  Standalone consumers handle `kanban-comment-draft` (`ticketId`, `body`),
5509
5562
  `kanban-comment-added` (`comment`, `submittedBody`), `kanban-ticket-open` and
5510
5563
  `kanban-comments-refresh`. The assembled board handles these events itself.
@@ -5552,6 +5605,9 @@ and cancels obsolete searches. References participate in editor undo and clipboa
5552
5605
  operations. Changing `.documentKey` resets history so undo cannot cross tickets.
5553
5606
 
5554
5607
  Set `.trigger`, `.label`, `.placeholder`, `.searchLabel` and `.disabled` as needed.
5608
+ A composer that writes Markdown links records the same way through
5609
+ [`dees-input-richtext`](#deesinputrichtext)'s `searchReferences`, as `dees-thread` and
5610
+ the Kanban discussion do.
5555
5611
  For an integrated composer, style `::part(editor)` and set
5556
5612
  `--dees-reference-min-height` (default `84px`) or `--dees-reference-font-size`
5557
5613
  (default `var(--dees-font-body-size)`). Keep a visible focus indicator when
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-catalog',
6
- version: '21.43.0',
6
+ version: '21.44.0',
7
7
  description: 'A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.'
8
8
  }
@@ -47,7 +47,7 @@ const conversation = (): { entries: IThreadEntry[]; events: IThreadEvent[] } =>
47
47
  },
48
48
  {
49
49
  id: 'c2', author: lukas, createdAt: ago(185), actions: entryActions,
50
- body: 'Booked the €84 on account `4288`.',
50
+ body: 'Booked the €84 on account `4288`: [#2026-0314 Home office March](#reference:booking-2026-0314).',
51
51
  attachments: [
52
52
  { id: 'booking-4288', name: 'Booking 2026-0314.pdf', url: 'https://example.com/bookings/2026-0314.pdf', size: 31_904 },
53
53
  { id: 'rent-march', name: 'Rent March.pdf', url: 'https://example.com/bookings/rent-march.pdf', size: 1_284_113 },
@@ -62,6 +62,16 @@ const conversation = (): { entries: IThreadEntry[]; events: IThreadEvent[] } =>
62
62
  ],
63
63
  });
64
64
 
65
+ const bookings = [
66
+ { id: 'booking-2026-0314', label: '#2026-0314 Home office March' },
67
+ { id: 'booking-2026-0302', label: '#2026-0302 Rent March' },
68
+ { id: 'booking-2026-0219', label: '#2026-0219 Rent February' },
69
+ ];
70
+
71
+ /** The bookings a reply links with #: those whose label holds the query. */
72
+ const searchBookings = async (queryArg: string) =>
73
+ bookings.filter((booking) => booking.label.toLowerCase().includes(queryArg.toLowerCase()));
74
+
65
75
  const delay = (msArg: number) => new Promise((resolve) => setTimeout(resolve, msArg));
66
76
 
67
77
  /** A question as a team, its tax advisor and its agent work on it. */
@@ -121,13 +131,14 @@ class DeesDemoThreadIssue extends DeesElement {
121
131
  @newValue=${(event: CustomEvent<boolean>) => { this.refuseNext = event.detail; }}></dees-input-checkbox>
122
132
  <dees-thread threadId="question-0314" .entries=${this.entries} .events=${this.events} .currentUser=${mara}
123
133
  .onSubmit=${this.submit} .composerActions=${this.closed ? this.reopenAction : this.closeAction}
134
+ .searchReferences=${searchBookings} referenceSearchLabel="Search bookings"
124
135
  .composerInfo=${'Jonas Weber and the Ledger assistant see your reply. A reply from you reopens the question; a reply from anyone else marks it answered.'}
125
136
  @thread-action=${(event: CustomEvent) => showDemoResult(this, { action: event.detail.action, entry: event.detail.entry.id })}
126
137
  @thread-reference-open=${(event: CustomEvent) => showDemoResult(this, { open: event.detail.id })}
127
138
  @thread-attachment-open=${(event: CustomEvent) => showDemoResult(this, { attachment: event.detail.attachment.id })}
128
139
  @thread-submit=${(event: CustomEvent) => showDemoResult(this, event.detail)}
129
140
  ></dees-thread>
130
- ${demoOutput('Reply, close or reopen the question; open a comment\'s menu.')}
141
+ ${demoOutput('Reply, close or reopen the question; type # to link a booking; open a comment\'s menu or a booking.')}
131
142
  `;
132
143
  }
133
144
  }
@@ -175,12 +186,21 @@ export const demoFunc = () => demoPage(
175
186
  'Thread',
176
187
  'A conversation about a record, as an issue tracker shows one: comments by people and agents, what happened between them, and a composer at its end.',
177
188
  html`
178
- ${demoSection('A question', 'Two people, a tax advisor and the agent answering on the advisor\'s behalf. Replying makes the agent answer; closing turns the action into Reopen.', html`
189
+ ${demoSection('A question', 'Two people, a tax advisor and the agent answering on the advisor\'s behalf. Replying makes the agent answer; # in a reply links a booking, which opens as thread-reference-open; closing turns the action into Reopen.', html`
179
190
  <dees-demo-thread-issue></dees-demo-thread-issue>
180
191
  `)}
181
192
  ${demoSection('A long thread', 'More items than collapseAfter: the middle collapses until the reader loads it.', html`
182
193
  <dees-thread threadId="trip" .entries=${longThread().entries} .events=${longThread().events} .currentUser=${mara}></dees-thread>
183
194
  `)}
195
+ ${demoSection('The composer apart', 'A host that places the composer apart renders the thread twice, with the same properties: view="entries" for the timeline and view="composer" for the composer, here pinned under the timeline as a ticket\'s detail does.', html`
196
+ <div style="display: flex; flex-direction: column; height: 480px; overflow: hidden; border: var(--dees-line-width-hairline) solid var(--dees-color-border-default); border-radius: var(--dees-radius-lg);">
197
+ <div style="flex: 1; min-height: 0; overflow: auto; padding: var(--dees-spacing-md) var(--dees-spacing-lg);">
198
+ <dees-thread threadId="trip-apart" view="entries" .collapseAfter=${100} .entries=${longThread().entries} .events=${longThread().events} .currentUser=${mara}></dees-thread>
199
+ </div>
200
+ <dees-thread threadId="trip-apart" view="composer" .currentUser=${mara}
201
+ style="padding: var(--dees-spacing-md) var(--dees-spacing-lg) var(--dees-spacing-lg); border-top: var(--dees-line-width-hairline) solid var(--dees-color-border-subtle);"></dees-thread>
202
+ </div>
203
+ `)}
184
204
  ${demoSection('Read-only', 'A closed question the reader may read but not answer; dates in full.', html`
185
205
  <dees-thread threadId="vat" timeFormat="absolute" readOnly readOnlyReason="This question is closed. Only its owner can reopen it."
186
206
  .entries=${closedThread().entries} .events=${closedThread().events}></dees-thread>
@@ -19,6 +19,7 @@ import { DeesContextmenu, type TContextMenuItem } from '../../00group-overlay/de
19
19
  import type { DeesActionFooter, IActionFooterAction } from '../../00group-button/dees-actionfooter/dees-actionfooter.js';
20
20
  import type { TRichtextToolbarButton } from '../../00group-input/dees-input-richtext/types.js';
21
21
  import { referenceText, type TReferenceContent, type TReferenceSearch } from '../../00group-input/dees-input-reference/index.js';
22
+ import { referenceId } from '../../00group-input/dees-input-richtext/markdown.js';
22
23
  import { renderThreadMarkdown, threadMarkdownHtml } from './thread.markdown.js';
23
24
  import type { TBarInfo } from '../../00barinfo.js';
24
25
  import type {
@@ -33,6 +34,7 @@ import type {
33
34
  TThreadFormat,
34
35
  TThreadSubmit,
35
36
  TThreadTimeFormat,
37
+ TThreadView,
36
38
  } from './interfaces.js';
37
39
  import { demoFunc } from './dees-thread.demo.js';
38
40
  import '../../00group-layout/dees-tile/dees-tile.js';
@@ -128,13 +130,14 @@ const safeHref = (hrefArg?: string): string | undefined => {
128
130
  * `subjectId` opens its record through `thread-reference-open`, one with an `href` its page.
129
131
  *
130
132
  * COMPOSER: `dees-input-richtext` in Markdown (`format: 'markdown'`) or `dees-input-reference`
131
- * (`'references'`), and the actions: the primary rightmost ("Comment", `submitLabel`), the
133
+ * (`'references'`), both linking records through `searchReferences` (`#` in Markdown), and the actions: the primary rightmost ("Comment", `submitLabel`), the
132
134
  * `composerActions` beside it ("Close with comment"), and `composerInfo` behind an ⓘ at the footer's
133
135
  * leading end. Ctrl/⌘ Enter runs the primary. Posting is not
134
136
  * optimistic: `onSubmit` is awaited while the composer holds its text, locked, and the button shows
135
137
  * its pending state; fulfilled, the text is gone and `thread-submit` follows, and the host adds the
136
138
  * entry; rejected, the text stays and the error's message shows under the composer. `readOnly`
137
- * replaces the composer with `readOnlyReason`.
139
+ * replaces the composer with `readOnlyReason`. `view` shows the timeline or the composer alone,
140
+ * for a host that places the composer apart, pinned under the timeline as a ticket's detail does.
138
141
  *
139
142
  * STATES: `loading` (a thread without items says so), `error` (with a retry as `thread-reload`;
140
143
  * the items stay), empty, and a long thread — more items than `collapseAfter` — whose middle
@@ -190,10 +193,18 @@ export class DeesThread extends DeesElement {
190
193
  @property({ type: String, reflect: true })
191
194
  accessor format: TThreadFormat = 'markdown';
192
195
 
193
- /** Finds the records a references composer links, at its `#_` trigger. */
196
+ /**
197
+ * Finds the records the composer links: typed `#` at the start of a word in Markdown, `#_` with
198
+ * references. A record linked in Markdown is a link to `#reference:<id>` (`richtextReferenceHref`);
199
+ * in a body the thread shows it as a reference, and opening it dispatches `thread-reference-open`.
200
+ */
194
201
  @property({ attribute: false })
195
202
  accessor searchReferences: TReferenceSearch | undefined = undefined;
196
203
 
204
+ /** The name of the composer's search for a record to link; the composer's own when empty. */
205
+ @property({ type: String, reflect: true })
206
+ accessor referenceSearchLabel = '';
207
+
197
208
  /**
198
209
  * The composer's text: a string in Markdown, `TReferenceContent` with references. Every change
199
210
  * the reader makes is reported as `thread-draft`, so a host can keep it per thread.
@@ -213,6 +224,15 @@ export class DeesThread extends DeesElement {
213
224
  @property({ type: String, reflect: true })
214
225
  accessor readOnlyReason = '';
215
226
 
227
+ /**
228
+ * The timeline with the composer at its end (`full`, the default), the timeline alone
229
+ * (`entries`), or the composer alone (`composer`). A host placing the composer apart renders the
230
+ * thread twice, with the same properties; the composer alone shows once the thread is loading
231
+ * too, starts at three lines and grows as the reader writes.
232
+ */
233
+ @property({ type: String, reflect: true })
234
+ accessor view: TThreadView = 'full';
235
+
216
236
  @property({ type: Boolean, reflect: true })
217
237
  accessor loading = false;
218
238
 
@@ -510,6 +530,12 @@ export class DeesThread extends DeesElement {
510
530
  overflow-x: auto;
511
531
  }
512
532
 
533
+ .markdown-body a.reference,
534
+ .markdown-body a.reference:hover {
535
+ color: var(--dees-color-link);
536
+ text-decoration: none;
537
+ }
538
+
513
539
  .plain {
514
540
  white-space: pre-wrap;
515
541
  overflow-wrap: anywhere;
@@ -806,6 +832,7 @@ export class DeesThread extends DeesElement {
806
832
  }
807
833
 
808
834
  public render(): TemplateResult {
835
+ if (this.view === 'composer') return this.readOnly ? this.renderReadOnly(true) : this.renderComposer(true);
809
836
  const items = this.items();
810
837
  const collapsing = this.collapseAfter > 0 && items.length > this.collapseAfter
811
838
  && collapsedHead + this.revealed + collapsedTail < items.length;
@@ -837,7 +864,7 @@ export class DeesThread extends DeesElement {
837
864
  ${directives.repeat(tail, key, renderItem(tail))}
838
865
  </ol>`
839
866
  : ''}
840
- ${!items.length && (this.loading || this.error)
867
+ ${this.view === 'entries' || (!items.length && (this.loading || this.error))
841
868
  ? ''
842
869
  : this.readOnly ? this.renderReadOnly(!items.length) : this.renderComposer(!items.length)}
843
870
  `;
@@ -849,6 +876,7 @@ export class DeesThread extends DeesElement {
849
876
  */
850
877
  public async submit(action?: string): Promise<void> {
851
878
  await this.updateComplete;
879
+ if (this.view === 'entries') return;
852
880
  const footer = this.shadowRoot?.querySelector<DeesActionFooter>('.composerTile dees-actionfooter');
853
881
  if (!action && footer) {
854
882
  await footer.runPrimary();
@@ -982,9 +1010,18 @@ export class DeesThread extends DeesElement {
982
1010
  const rendered = threadMarkdownHtml(body);
983
1011
  return rendered === undefined
984
1012
  ? html`<div class="plain">${body}</div>`
985
- : html`<div class="markdown-body">${unsafeHTML(rendered)}</div>`;
1013
+ : html`<div class="markdown-body" @click=${this.markdownClick}>${unsafeHTML(rendered)}</div>`;
986
1014
  }
987
1015
 
1016
+ /** A reference in a Markdown body opens its record, as one in a body with references does. */
1017
+ private readonly markdownClick = (event: MouseEvent): void => {
1018
+ const link = (event.target as Element | null)?.closest('a[data-reference]');
1019
+ if (!link) return;
1020
+ event.preventDefault();
1021
+ const id = referenceId(link.getAttribute('href'));
1022
+ if (id !== null) this.openReference(id, link.textContent ?? '');
1023
+ };
1024
+
988
1025
  private refusedActions(entry: IThreadEntry): IActionFooterAction[] {
989
1026
  const threadId = this.threadId;
990
1027
  return [
@@ -1115,6 +1152,7 @@ export class DeesThread extends DeesElement {
1115
1152
  ${this.format === 'references'
1116
1153
  ? html`<dees-input-reference class="composerInput" .label=${this.t('thread.composer')} .placeholder=${placeholder}
1117
1154
  .documentKey=${threadId} .value=${this.referenceDraft()} .searchReferences=${this.searchReferences}
1155
+ .searchLabel=${this.referenceSearchLabel}
1118
1156
  @reference-input=${(event: CustomEvent<{ value: TReferenceContent }>) => {
1119
1157
  event.stopPropagation();
1120
1158
  this.updateDraft(event.detail.value);
@@ -1127,13 +1165,18 @@ export class DeesThread extends DeesElement {
1127
1165
  ></dees-input-reference>`
1128
1166
  : html`<dees-input-richtext class="composerInput" format="markdown" frameless auto-grow
1129
1167
  .label=${this.t('thread.composer')} .labelPosition=${'none'} .placeholder=${placeholder}
1130
- .minHeight=${128} .maxHeight=${360} .showWordCount=${false} .toolbar=${composerToolbar}
1131
- .value=${bodyText(this.draft)}
1168
+ .minHeight=${this.view === 'composer' ? 64 : 128} .maxHeight=${360} .showWordCount=${false} .toolbar=${composerToolbar}
1169
+ .value=${bodyText(this.draft)} .searchReferences=${this.searchReferences}
1170
+ .referenceSearchLabel=${this.referenceSearchLabel}
1132
1171
  @input=${(event: CustomEvent<{ value: string }>) => {
1133
1172
  event.stopPropagation();
1134
1173
  if (typeof event.detail?.value === 'string') this.updateDraft(event.detail.value);
1135
1174
  }}
1136
1175
  @change=${(event: Event) => event.stopPropagation()}
1176
+ @reference-open=${(event: CustomEvent<{ id: string; label: string }>) => {
1177
+ event.stopPropagation();
1178
+ this.openReference(event.detail.id, event.detail.label);
1179
+ }}
1137
1180
  ></dees-input-richtext>`}
1138
1181
  ${postError
1139
1182
  ? html`<p class="postError" role="alert"><dees-icon icon="lucide:CircleAlert" .iconSize=${14} aria-hidden="true"></dees-icon><span>${postError}</span></p>`
@@ -133,6 +133,12 @@ export type TThreadSubmit = (submission: IThreadSubmission) => unknown | Promise
133
133
  /** What the composer writes: Markdown through `dees-input-richtext`, or references through `dees-input-reference`. */
134
134
  export type TThreadFormat = 'markdown' | 'references';
135
135
 
136
+ /**
137
+ * What a thread shows: its timeline with the composer at its end (`full`), the timeline alone
138
+ * (`entries`), or the composer alone (`composer`), for a host that places the composer apart.
139
+ */
140
+ export type TThreadView = 'full' | 'entries' | 'composer';
141
+
136
142
  /** How a thread says when things happened: "3 hours ago", or the date and time. */
137
143
  export type TThreadTimeFormat = 'relative' | 'absolute';
138
144
 
@@ -8,7 +8,8 @@ const maxCacheEntries = 200;
8
8
  * An entry's Markdown as HTML, rendered as `dees-input-richtext` writes it and as text nobody vouches
9
9
  * for: `richtextMarkdownRenderOptions` show HTML written into the text as text and images as links,
10
10
  * and smartmarkdown drops unsafe link targets. Links open in a new context and never leak the
11
- * opener. Results are kept, least recently used first out, as a thread renders the same bodies again
11
+ * opener; a link to `#reference:<id>` is a reference the thread opens itself (`class="reference"`,
12
+ * `data-reference`). Results are kept, least recently used first out, as a thread renders the same bodies again
12
13
  * on every change.
13
14
  */
14
15
  export const threadMarkdownHtml = (markdownArg: string): string | undefined => {
@@ -27,7 +28,9 @@ export const renderThreadMarkdown = async (markdownArg: string): Promise<string>
27
28
  markdownArg,
28
29
  richtextMarkdownRenderOptions,
29
30
  );
30
- const processed = rendered.replaceAll('<a href=', '<a target="_blank" rel="noopener noreferrer" href=');
31
+ const processed = rendered
32
+ .replaceAll('<a href="#reference:', '<a class="reference" data-reference href="#reference:')
33
+ .replaceAll('<a href=', '<a target="_blank" rel="noopener noreferrer" href=');
31
34
  cache.set(markdownArg, processed);
32
35
  if (cache.size > maxCacheEntries) {
33
36
  const oldest = cache.keys().next().value;
@@ -1,9 +1,8 @@
1
- import { provideOverlayI18n } from '../../00overlay.js';
2
1
  import { DeesElement, customElement, property, state, html, css, cssManager } from '@design.estate/dees-element';
3
2
  import type { Editor } from '@tiptap/core';
4
3
  import { DeesServiceLibLoader } from '../../../services/DeesServiceLibLoader.js';
5
4
  import { themeDefaultStyles } from '../../00theme.js';
6
- import { DeesInputDropdownPopup } from '../dees-input-dropdown/dees-input-dropdown-popup.js';
5
+ import { ReferencePicker, referenceInsertMeta, referenceNode } from '../dees-input-richtext/references.js';
7
6
  import type { IInputReference, TReferenceContent, TReferenceSearch } from './interfaces.js';
8
7
  import { referenceContent, referenceDocument } from './document.js';
9
8
  import { demoFunc } from './dees-input-reference.demo.js';
@@ -33,9 +32,16 @@ export class DeesInputReference extends DeesElement {
33
32
  private editor?: Editor;
34
33
  private initializing?: Promise<void>;
35
34
  private connection = 0;
36
- private popup?: DeesInputDropdownPopup;
37
- private popupOpening?: Promise<void>;
38
- private referenceRange?: { from: number; to: number };
35
+ private readonly picker = new ReferencePicker({
36
+ element: this,
37
+ editor: () => this.editor,
38
+ search: () => this.searchReferences,
39
+ searchLabel: () => this.searchLabel || this.t('reference.search'),
40
+ i18n: () => this.t.i18n,
41
+ disabled: () => this.disabled,
42
+ failed: (error) => { this.loadError = error instanceof Error ? error.message : this.t('reference.searchFailed'); },
43
+ opened: () => { this.loadError = ''; },
44
+ });
39
45
  private serializedValue = '';
40
46
 
41
47
  public static styles = [themeDefaultStyles, cssManager.defaultStyles, css`
@@ -75,23 +81,14 @@ export class DeesInputReference extends DeesElement {
75
81
  const connection = this.connection;
76
82
  const operation = (async () => {
77
83
  await this.updateComplete;
78
- const { Editor, Node, StarterKit } = await DeesServiceLibLoader.getInstance().loadTiptap();
84
+ const bundle = await DeesServiceLibLoader.getInstance().loadTiptap();
85
+ const { Editor, StarterKit } = bundle;
79
86
  if (!this.isConnected || connection !== this.connection) return;
80
- const referenceNode = Node.create({
81
- name: 'catalogReference', group: 'inline', inline: true, atom: true, selectable: true,
82
- addAttributes: () => ({
83
- id: { default: '', parseHTML: element => element.getAttribute('data-reference-id') },
84
- label: { default: '', parseHTML: element => element.textContent },
85
- }),
86
- parseHTML: () => [{ tag: 'span[data-reference-id]' }],
87
- renderHTML: ({ node }) => ['span', { 'data-reference-id': String(node.attrs.id), contenteditable: 'false', role: 'link', tabindex: '0' }, String(node.attrs.label)],
88
- renderText: ({ node }) => String(node.attrs.label),
89
- });
90
87
  this.editor = new Editor({
91
88
  element: this.shadowRoot!.querySelector<HTMLElement>('.editor')!,
92
89
  injectCSS: false,
93
90
  editable: !this.disabled,
94
- extensions: [StarterKit.configure({ blockquote: false, bold: false, bulletList: false, code: false, codeBlock: false, heading: false, horizontalRule: false, italic: false, listItem: false, orderedList: false, strike: false }), referenceNode],
91
+ extensions: [StarterKit.configure({ blockquote: false, bold: false, bulletList: false, code: false, codeBlock: false, heading: false, horizontalRule: false, italic: false, listItem: false, orderedList: false, strike: false }), referenceNode(bundle)],
95
92
  content: referenceDocument(this.value),
96
93
  editorProps: {
97
94
  attributes: { role: 'textbox', 'aria-multiline': 'true', 'aria-label': this.label || this.t('reference.label'), 'data-placeholder': this.placeholder || this.t('reference.placeholder') },
@@ -110,14 +107,14 @@ export class DeesInputReference extends DeesElement {
110
107
  }
111
108
  return false;
112
109
  },
113
- compositionend: () => { queueMicrotask(() => this.detectTrigger()); return false; },
110
+ compositionend: () => { queueMicrotask(() => this.picker.detect(this.trigger)); return false; },
114
111
  },
115
112
  },
116
113
  onUpdate: ({ editor, transaction }) => {
117
114
  this.value = referenceContent(editor.getJSON());
118
115
  this.serializedValue = JSON.stringify(this.value);
119
116
  this.dispatchEvent(new CustomEvent('reference-input', { detail: { value: this.value }, bubbles: true, composed: true }));
120
- if (!transaction.getMeta('preventReferenceTrigger')) this.detectTrigger();
117
+ if (!transaction.getMeta(referenceInsertMeta)) this.picker.detect(this.trigger);
121
118
  },
122
119
  });
123
120
  this.serializedValue = JSON.stringify(this.value);
@@ -131,16 +128,16 @@ export class DeesInputReference extends DeesElement {
131
128
  public updated(changed: Map<string, unknown>): void {
132
129
  if (changed.has('documentKey') && changed.get('documentKey') !== undefined && this.editor) {
133
130
  this.connection++;
134
- void this.closePicker(false);
131
+ void this.picker.close(false);
135
132
  this.editor.destroy(); this.editor = undefined; this.initializing = undefined;
136
133
  void this.initialize();
137
134
  }
138
135
  if (changed.has('disabled')) {
139
136
  this.editor?.setEditable(!this.disabled, false);
140
- if (this.disabled) void this.closePicker(false);
137
+ if (this.disabled) void this.picker.close(false);
141
138
  }
142
139
  if (changed.has('value') && this.editor && JSON.stringify(this.value) !== this.serializedValue) {
143
- void this.closePicker(false);
140
+ void this.picker.close(false);
144
141
  this.editor.commands.setContent(referenceDocument(this.value), false);
145
142
  this.serializedValue = JSON.stringify(this.value);
146
143
  }
@@ -152,78 +149,13 @@ export class DeesInputReference extends DeesElement {
152
149
 
153
150
  public focus(options?: FocusOptions): void { this.editor?.view.dom.focus(options); }
154
151
 
155
- private detectTrigger(): void {
156
- const editor = this.editor;
157
- if (!editor || this.disabled || this.popup || !this.searchReferences || !this.trigger || editor.view.composing || !editor.isFocused) return;
158
- const { from, to, $from } = editor.state.selection;
159
- if (from !== to || $from.parentOffset < this.trigger.length) return;
160
- if ($from.parent.textBetween($from.parentOffset - this.trigger.length, $from.parentOffset, '', '\ufffc') !== this.trigger) return;
161
- this.referenceRange = { from: from - this.trigger.length, to };
162
- void this.openPicker();
163
- }
164
-
165
- private positionPicker(): void {
166
- if (!this.editor || !this.popup || !this.referenceRange) return;
167
- const coords = this.editor.view.coordsAtPos(this.referenceRange.to);
168
- // The text around the caret, which a scroll in the editor moves along
169
- const { node } = this.editor.view.domAtPos(this.referenceRange.to);
170
- this.popup.triggerElement = node instanceof HTMLElement ? node : node.parentElement;
171
- this.popup.triggerRect = new DOMRect(coords.left, coords.top, 340, coords.bottom - coords.top);
172
- this.popup.opensToTop = window.innerHeight - coords.bottom < 300 && coords.top > window.innerHeight - coords.bottom;
173
- }
174
-
175
- private async openPicker(): Promise<void> {
176
- const popup = this.popup = new DeesInputDropdownPopup();
177
- popup.ownerComponent = this;
178
- popup.searchLabel = this.searchLabel || this.t('reference.search');
179
- provideOverlayI18n(popup, { i18n: this.t.i18n });
180
- popup.searchOptions = async (query, signal) => (await this.searchReferences!(query, signal))
181
- .map(reference => ({ key: reference.id, option: reference.label, payload: reference }));
182
- this.positionPicker();
183
- popup.addEventListener('reposition-request', () => this.positionPicker());
184
- popup.addEventListener('close-request', () => { void this.closePicker(true); });
185
- popup.addEventListener('keydown', (event: KeyboardEvent) => {
186
- if (event.key === 'Tab') { event.preventDefault(); void this.closePicker(true); }
187
- });
188
- popup.addEventListener('option-selected', (event: Event) => {
189
- const reference = (event as CustomEvent<{ payload: IInputReference }>).detail.payload;
190
- const range = this.referenceRange;
191
- if (range && this.editor && !this.disabled) {
192
- this.editor.chain().setMeta('preventReferenceTrigger', true).insertContentAt(range, [
193
- { type: 'catalogReference', attrs: reference }, { type: 'text', text: ' ' },
194
- ]).run();
195
- }
196
- void this.closePicker(true);
197
- });
198
- this.popupOpening = popup.show();
199
- try {
200
- await this.popupOpening;
201
- if (this.popup === popup && this.isConnected && !this.disabled) await popup.focusSearchInput();
202
- } catch (error) {
203
- this.loadError = error instanceof Error ? error.message : this.t('reference.searchFailed');
204
- void this.closePicker(false);
205
- }
206
- }
207
-
208
- private async closePicker(restoreFocus: boolean): Promise<void> {
209
- const popup = this.popup;
210
- const editor = this.editor;
211
- const opening = this.popupOpening;
212
- this.popup = undefined;
213
- this.referenceRange = undefined;
214
- if (!popup) return;
215
- await opening?.catch(() => undefined);
216
- await popup.hide();
217
- if (restoreFocus && this.isConnected && !this.disabled && this.editor === editor) editor?.commands.focus();
218
- }
219
-
220
152
  private openReference(reference: IInputReference): void {
221
153
  this.dispatchEvent(new CustomEvent('reference-open', { detail: reference, bubbles: true, composed: true }));
222
154
  }
223
155
 
224
156
  public async disconnectedCallback(): Promise<void> {
225
157
  this.connection++;
226
- void this.closePicker(false);
158
+ void this.picker.close(false);
227
159
  this.editor?.destroy();
228
160
  this.editor = undefined;
229
161
  this.initializing = undefined;