@nesso-how/ui 1.0.0-beta.17 → 1.0.0-beta.21

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 CHANGED
@@ -52,7 +52,7 @@ Your build must compile this CSS; it is not a precompiled stylesheet. Supply the
52
52
 
53
53
  `BottomSheet` is a controlled, non-modal drawer with a title, close label, optional footer, and popup ref for measuring covered content. It supports swipe-down dismissal, safe-area padding, and reduced motion. Reading text can use `--nesso-reading-font-size` and `--nesso-reading-line-height`, which increase from 13/20px to 15/23px on narrow screens or coarse pointers.
54
54
 
55
- `MarkdownInput` accepts Markdown through `value`/`onChange`, with live preview of emphasis, links, and lists. Syntax reappears around the selection. Cmd/Ctrl+B/I toggles formatting; Enter continues or exits lists, Tab/Shift+Tab changes nesting, and Shift+Enter inserts a line break. Optional `tasks` enables clickable task checkboxes; `placeholder` appears when empty.
55
+ `MarkdownInput` accepts Markdown through `value`/`onChange`, with live preview of emphasis, inline code, links, and lists. Syntax reappears around the selection. Cmd/Ctrl+B/I/E toggles bold, italic, and inline code; Enter continues or exits lists, Tab/Shift+Tab changes nesting, and Shift+Enter inserts a line break. Optional `tasks` enables clickable task checkboxes; `placeholder` appears when empty.
56
56
 
57
57
  Undo/redo is local by default. Use `history={false}` for host-owned history or `history="focus"` to reset local history on blur and external value changes. Exhausted local history never falls through. Menu commands can send `beforeinput` events (`historyUndo`/`historyRedo`) to the focused editor inside `[data-local-history]`.
58
58
 
package/dist/index.js CHANGED
@@ -289,6 +289,26 @@ function DirectoryField({ label, value, labels, disabled, changeDisabled, onOpen
289
289
  const listPrefix = /^(\s*)([-+*]|(\d{1,9})([.)]))([\t ]+|$)/;
290
290
  const taskPrefix = /^\[[ xX]\]([\t ]+|$)/;
291
291
  const taskParser = parser.configure(TaskList);
292
+ const formats = {
293
+ "**": {
294
+ node: "StrongEmphasis",
295
+ mark: "EmphasisMark",
296
+ decoration: Decoration.mark({ class: "nesso-markdown-bold" })
297
+ },
298
+ "*": {
299
+ node: "Emphasis",
300
+ mark: "EmphasisMark",
301
+ decoration: Decoration.mark({ class: "nesso-markdown-italic" })
302
+ },
303
+ "`": {
304
+ node: "InlineCode",
305
+ mark: "CodeMark",
306
+ decoration: Decoration.mark({
307
+ class: "nesso-markdown-code",
308
+ attributes: { spellcheck: "false" }
309
+ })
310
+ }
311
+ };
292
312
  const markdownTasks = Facet.define({ combine: (values) => values.some(Boolean) });
293
313
  const parse = (state) => (state.facet(markdownTasks) ? taskParser : parser).parse(state.doc.toString());
294
314
  var ListMarker = class extends WidgetType {
@@ -388,16 +408,16 @@ function markdownDecorations(state, focused) {
388
408
  parse(state).iterate({ enter(node) {
389
409
  if ([
390
410
  "Image",
391
- "InlineCode",
392
411
  "FencedCode",
393
412
  "CodeBlock",
394
413
  "HTMLBlock"
395
414
  ].includes(node.name)) return false;
396
415
  const active = focused && state.selection.ranges.some((range) => range.from <= node.to && range.to >= node.from);
397
416
  if (node.name === "ListItem") decorations.push(...listItemDecorations(state, node.node, active));
398
- if (node.name === "StrongEmphasis" || node.name === "Emphasis") {
399
- const [open, close] = node.node.getChildren("EmphasisMark");
400
- decorations.push(Decoration.mark({ class: node.name === "StrongEmphasis" ? "nesso-markdown-bold" : "nesso-markdown-italic" }).range(open.to, close.from));
417
+ const format = Object.values(formats).find((format) => format.node === node.name);
418
+ if (format) {
419
+ const [open, close] = node.node.getChildren(format.mark);
420
+ decorations.push(format.decoration.range(open.to, close.from));
401
421
  syntax(open.from, open.to, active);
402
422
  syntax(close.from, close.to, active);
403
423
  }
@@ -530,10 +550,11 @@ function toggleMarkdownFormat(state, marker) {
530
550
  if (state.readOnly) return null;
531
551
  const { from, to } = state.selection.main;
532
552
  const selected = state.sliceDoc(from, to);
553
+ const format = formats[marker];
533
554
  let delimiters;
534
555
  parse(state).iterate({ enter(node) {
535
- if (node.name !== (marker === "**" ? "StrongEmphasis" : "Emphasis")) return;
536
- const [open, close] = node.node.getChildren("EmphasisMark");
556
+ if (node.name !== format.node) return;
557
+ const [open, close] = node.node.getChildren(format.mark);
537
558
  if (from === node.from && to === node.to || from >= open.to && to <= close.from) delimiters = [open, close].map(({ from, to }) => ({
538
559
  from,
539
560
  to
@@ -648,8 +669,12 @@ function MarkdownInput({ value, onChange, readOnly = false, history: history$1 =
648
669
  return true;
649
670
  }
650
671
  },
651
- ...["**", "*"].map((marker) => ({
652
- key: marker === "**" ? "Mod-b" : "Mod-i",
672
+ ...[
673
+ ["Mod-b", "**"],
674
+ ["Mod-i", "*"],
675
+ ["Mod-e", "`"]
676
+ ].map(([key, marker]) => ({
677
+ key,
653
678
  run: (view) => {
654
679
  const transaction = toggleMarkdownFormat(view.state, marker);
655
680
  if (!transaction) return false;
package/dist/styles.css CHANGED
@@ -78,6 +78,16 @@
78
78
  font-style: italic;
79
79
  }
80
80
 
81
+ .nesso-markdown-code {
82
+ padding: 2px 4px;
83
+ border-radius: var(--radius-control);
84
+ background: var(--sidebar);
85
+ font-family: var(--font-mono);
86
+ font-size: 0.92em;
87
+ box-decoration-break: clone;
88
+ -webkit-box-decoration-break: clone;
89
+ }
90
+
81
91
  .nesso-markdown-link {
82
92
  color: var(--primary);
83
93
  text-decoration: underline;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nesso-how/ui",
3
- "version": "1.0.0-beta.17",
3
+ "version": "1.0.0-beta.21",
4
4
  "description": "Reusable React primitives and shared styles for Nesso, usable in the app and in isolated plugin panels",
5
5
  "license": "MIT",
6
6
  "repository": {