@ni/nimble-components 34.6.0 → 34.6.3

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.
@@ -22247,6 +22247,7 @@ so this becomes the fallback color for the slot */ ''}
22247
22247
  @cancel="${(x, c) => x.cancelHandler(c.event)}"
22248
22248
  @close="${(x, c) => x.closeHandler(c.event)}"
22249
22249
  aria-labelledby="header"
22250
+ closedby="${x => (x.preventDismiss ? 'none' : 'closerequest')}"
22250
22251
  >
22251
22252
  <header id="header">
22252
22253
  <div class="title">
@@ -22541,6 +22542,7 @@ so this becomes the fallback color for the slot */ ''}
22541
22542
  aria-label="${x => x.ariaLabel}"
22542
22543
  @cancel="${(x, c) => x.cancelHandler(c.event)}"
22543
22544
  @close="${(x, c) => x.closeHandler(c.event)}"
22545
+ closedby="${x => (x.preventDismiss ? 'none' : 'closerequest')}"
22544
22546
  >
22545
22547
  <div class="dialog-contents">
22546
22548
  <slot></slot>
@@ -41439,6 +41441,7 @@ so this becomes the fallback color for the slot */ ''}
41439
41441
  setMeta: () => setMeta,
41440
41442
  setNode: () => setNode,
41441
41443
  setNodeSelection: () => setNodeSelection,
41444
+ setTextDirection: () => setTextDirection,
41442
41445
  setTextSelection: () => setTextSelection,
41443
41446
  sinkListItem: () => sinkListItem,
41444
41447
  splitBlock: () => splitBlock,
@@ -41450,6 +41453,7 @@ so this becomes the fallback color for the slot */ ''}
41450
41453
  undoInputRule: () => undoInputRule,
41451
41454
  unsetAllMarks: () => unsetAllMarks,
41452
41455
  unsetMark: () => unsetMark,
41456
+ unsetTextDirection: () => unsetTextDirection,
41453
41457
  updateAttributes: () => updateAttributes,
41454
41458
  wrapIn: () => wrapIn,
41455
41459
  wrapInList: () => wrapInList
@@ -42225,23 +42229,28 @@ so this becomes the fallback color for the slot */ ''}
42225
42229
  if (schemaType === "mark") {
42226
42230
  markType = getMarkType(typeOrName, state.schema);
42227
42231
  }
42228
- if (dispatch) {
42229
- tr.selection.ranges.forEach((range) => {
42230
- state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
42231
- if (nodeType && nodeType === node.type) {
42232
+ let canReset = false;
42233
+ tr.selection.ranges.forEach((range) => {
42234
+ state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
42235
+ if (nodeType && nodeType === node.type) {
42236
+ canReset = true;
42237
+ if (dispatch) {
42232
42238
  tr.setNodeMarkup(pos, void 0, deleteProps(node.attrs, attributes));
42233
42239
  }
42234
- if (markType && node.marks.length) {
42235
- node.marks.forEach((mark) => {
42236
- if (markType === mark.type) {
42240
+ }
42241
+ if (markType && node.marks.length) {
42242
+ node.marks.forEach((mark) => {
42243
+ if (markType === mark.type) {
42244
+ canReset = true;
42245
+ if (dispatch) {
42237
42246
  tr.addMark(pos, pos + node.nodeSize, markType.create(deleteProps(mark.attrs, attributes)));
42238
42247
  }
42239
- });
42240
- }
42241
- });
42248
+ }
42249
+ });
42250
+ }
42242
42251
  });
42243
- }
42244
- return true;
42252
+ });
42253
+ return canReset;
42245
42254
  };
42246
42255
 
42247
42256
  // src/commands/scrollIntoView.ts
@@ -42637,12 +42646,12 @@ so this becomes the fallback color for the slot */ ''}
42637
42646
  );
42638
42647
  }
42639
42648
  function buildAttributeSpec(extensionAttribute) {
42640
- var _a, _b, _c;
42649
+ var _a, _b;
42641
42650
  const spec = {};
42642
- if (!((_a = extensionAttribute == null ? void 0 : extensionAttribute.attribute) == null ? void 0 : _a.isRequired) && ((_b = extensionAttribute == null ? void 0 : extensionAttribute.attribute) == null ? void 0 : _b.default) !== void 0) {
42651
+ if (!((_a = extensionAttribute == null ? void 0 : extensionAttribute.attribute) == null ? void 0 : _a.isRequired) && "default" in ((extensionAttribute == null ? void 0 : extensionAttribute.attribute) || {})) {
42643
42652
  spec.default = extensionAttribute.attribute.default;
42644
42653
  }
42645
- if (((_c = extensionAttribute == null ? void 0 : extensionAttribute.attribute) == null ? void 0 : _c.validate) !== void 0) {
42654
+ if (((_b = extensionAttribute == null ? void 0 : extensionAttribute.attribute) == null ? void 0 : _b.validate) !== void 0) {
42646
42655
  spec.validate = extensionAttribute.attribute.validate;
42647
42656
  }
42648
42657
  return [extensionAttribute.name, spec];
@@ -43280,6 +43289,35 @@ so this becomes the fallback color for the slot */ ''}
43280
43289
  }
43281
43290
  return true;
43282
43291
  };
43292
+
43293
+ // src/commands/setTextDirection.ts
43294
+ var setTextDirection = (direction, position) => ({ tr, state, dispatch }) => {
43295
+ const { selection } = state;
43296
+ let from;
43297
+ let to;
43298
+ if (typeof position === "number") {
43299
+ from = position;
43300
+ to = position;
43301
+ } else if (position && "from" in position && "to" in position) {
43302
+ from = position.from;
43303
+ to = position.to;
43304
+ } else {
43305
+ from = selection.from;
43306
+ to = selection.to;
43307
+ }
43308
+ if (dispatch) {
43309
+ tr.doc.nodesBetween(from, to, (node, pos) => {
43310
+ if (node.isText) {
43311
+ return;
43312
+ }
43313
+ tr.setNodeMarkup(pos, void 0, {
43314
+ ...node.attrs,
43315
+ dir: direction
43316
+ });
43317
+ });
43318
+ }
43319
+ return true;
43320
+ };
43283
43321
  var setTextSelection = (position) => ({ tr, dispatch }) => {
43284
43322
  if (dispatch) {
43285
43323
  const { doc } = tr;
@@ -43626,6 +43664,34 @@ so this becomes the fallback color for the slot */ ''}
43626
43664
  return true;
43627
43665
  };
43628
43666
 
43667
+ // src/commands/unsetTextDirection.ts
43668
+ var unsetTextDirection = (position) => ({ tr, state, dispatch }) => {
43669
+ const { selection } = state;
43670
+ let from;
43671
+ let to;
43672
+ if (typeof position === "number") {
43673
+ from = position;
43674
+ to = position;
43675
+ } else if (position && "from" in position && "to" in position) {
43676
+ from = position.from;
43677
+ to = position.to;
43678
+ } else {
43679
+ from = selection.from;
43680
+ to = selection.to;
43681
+ }
43682
+ if (dispatch) {
43683
+ tr.doc.nodesBetween(from, to, (node, pos) => {
43684
+ if (node.isText) {
43685
+ return;
43686
+ }
43687
+ const newAttrs = { ...node.attrs };
43688
+ delete newAttrs.dir;
43689
+ tr.setNodeMarkup(pos, void 0, newAttrs);
43690
+ });
43691
+ }
43692
+ return true;
43693
+ };
43694
+
43629
43695
  // src/commands/updateAttributes.ts
43630
43696
  var updateAttributes = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
43631
43697
  let nodeType = null;
@@ -43643,41 +43709,48 @@ so this becomes the fallback color for the slot */ ''}
43643
43709
  if (schemaType === "mark") {
43644
43710
  markType = getMarkType(typeOrName, state.schema);
43645
43711
  }
43646
- if (dispatch) {
43647
- tr.selection.ranges.forEach((range) => {
43648
- const from = range.$from.pos;
43649
- const to = range.$to.pos;
43650
- let lastPos;
43651
- let lastNode;
43652
- let trimmedFrom;
43653
- let trimmedTo;
43654
- if (tr.selection.empty) {
43655
- state.doc.nodesBetween(from, to, (node, pos) => {
43712
+ let canUpdate = false;
43713
+ tr.selection.ranges.forEach((range) => {
43714
+ const from = range.$from.pos;
43715
+ const to = range.$to.pos;
43716
+ let lastPos;
43717
+ let lastNode;
43718
+ let trimmedFrom;
43719
+ let trimmedTo;
43720
+ if (tr.selection.empty) {
43721
+ state.doc.nodesBetween(from, to, (node, pos) => {
43722
+ if (nodeType && nodeType === node.type) {
43723
+ canUpdate = true;
43724
+ trimmedFrom = Math.max(pos, from);
43725
+ trimmedTo = Math.min(pos + node.nodeSize, to);
43726
+ lastPos = pos;
43727
+ lastNode = node;
43728
+ }
43729
+ });
43730
+ } else {
43731
+ state.doc.nodesBetween(from, to, (node, pos) => {
43732
+ if (pos < from && nodeType && nodeType === node.type) {
43733
+ canUpdate = true;
43734
+ trimmedFrom = Math.max(pos, from);
43735
+ trimmedTo = Math.min(pos + node.nodeSize, to);
43736
+ lastPos = pos;
43737
+ lastNode = node;
43738
+ }
43739
+ if (pos >= from && pos <= to) {
43656
43740
  if (nodeType && nodeType === node.type) {
43657
- trimmedFrom = Math.max(pos, from);
43658
- trimmedTo = Math.min(pos + node.nodeSize, to);
43659
- lastPos = pos;
43660
- lastNode = node;
43661
- }
43662
- });
43663
- } else {
43664
- state.doc.nodesBetween(from, to, (node, pos) => {
43665
- if (pos < from && nodeType && nodeType === node.type) {
43666
- trimmedFrom = Math.max(pos, from);
43667
- trimmedTo = Math.min(pos + node.nodeSize, to);
43668
- lastPos = pos;
43669
- lastNode = node;
43670
- }
43671
- if (pos >= from && pos <= to) {
43672
- if (nodeType && nodeType === node.type) {
43741
+ canUpdate = true;
43742
+ if (dispatch) {
43673
43743
  tr.setNodeMarkup(pos, void 0, {
43674
43744
  ...node.attrs,
43675
43745
  ...attributes
43676
43746
  });
43677
43747
  }
43678
- if (markType && node.marks.length) {
43679
- node.marks.forEach((mark) => {
43680
- if (markType === mark.type) {
43748
+ }
43749
+ if (markType && node.marks.length) {
43750
+ node.marks.forEach((mark) => {
43751
+ if (markType === mark.type) {
43752
+ canUpdate = true;
43753
+ if (dispatch) {
43681
43754
  const trimmedFrom2 = Math.max(pos, from);
43682
43755
  const trimmedTo2 = Math.min(pos + node.nodeSize, to);
43683
43756
  tr.addMark(
@@ -43689,36 +43762,36 @@ so this becomes the fallback color for the slot */ ''}
43689
43762
  })
43690
43763
  );
43691
43764
  }
43692
- });
43693
- }
43765
+ }
43766
+ });
43694
43767
  }
43768
+ }
43769
+ });
43770
+ }
43771
+ if (lastNode) {
43772
+ if (lastPos !== void 0 && dispatch) {
43773
+ tr.setNodeMarkup(lastPos, void 0, {
43774
+ ...lastNode.attrs,
43775
+ ...attributes
43695
43776
  });
43696
43777
  }
43697
- if (lastNode) {
43698
- if (lastPos !== void 0) {
43699
- tr.setNodeMarkup(lastPos, void 0, {
43700
- ...lastNode.attrs,
43701
- ...attributes
43702
- });
43703
- }
43704
- if (markType && lastNode.marks.length) {
43705
- lastNode.marks.forEach((mark) => {
43706
- if (markType === mark.type) {
43707
- tr.addMark(
43708
- trimmedFrom,
43709
- trimmedTo,
43710
- markType.create({
43711
- ...mark.attrs,
43712
- ...attributes
43713
- })
43714
- );
43715
- }
43716
- });
43717
- }
43778
+ if (markType && lastNode.marks.length) {
43779
+ lastNode.marks.forEach((mark) => {
43780
+ if (markType === mark.type && dispatch) {
43781
+ tr.addMark(
43782
+ trimmedFrom,
43783
+ trimmedTo,
43784
+ markType.create({
43785
+ ...mark.attrs,
43786
+ ...attributes
43787
+ })
43788
+ );
43789
+ }
43790
+ });
43718
43791
  }
43719
- });
43720
- }
43721
- return true;
43792
+ }
43793
+ });
43794
+ return canUpdate;
43722
43795
  };
43723
43796
  var wrapIn = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
43724
43797
  const type = getNodeType(typeOrName, state.schema);
@@ -44574,6 +44647,7 @@ so this becomes the fallback color for the slot */ ''}
44574
44647
  Keymap: () => Keymap,
44575
44648
  Paste: () => Paste,
44576
44649
  Tabindex: () => Tabindex,
44650
+ TextDirection: () => TextDirection,
44577
44651
  focusEventsPluginKey: () => focusEventsPluginKey
44578
44652
  });
44579
44653
 
@@ -44918,6 +44992,63 @@ so this becomes the fallback color for the slot */ ''}
44918
44992
  ];
44919
44993
  }
44920
44994
  });
44995
+ var TextDirection = Extension.create({
44996
+ name: "textDirection",
44997
+ addOptions() {
44998
+ return {
44999
+ direction: void 0
45000
+ };
45001
+ },
45002
+ addGlobalAttributes() {
45003
+ if (!this.options.direction) {
45004
+ return [];
45005
+ }
45006
+ const { nodeExtensions } = splitExtensions(this.extensions);
45007
+ return [
45008
+ {
45009
+ types: nodeExtensions.filter((extension) => extension.name !== "text").map((extension) => extension.name),
45010
+ attributes: {
45011
+ dir: {
45012
+ default: this.options.direction,
45013
+ parseHTML: (element) => {
45014
+ const dir = element.getAttribute("dir");
45015
+ if (dir && (dir === "ltr" || dir === "rtl" || dir === "auto")) {
45016
+ return dir;
45017
+ }
45018
+ return this.options.direction;
45019
+ },
45020
+ renderHTML: (attributes) => {
45021
+ if (!attributes.dir) {
45022
+ return {};
45023
+ }
45024
+ return {
45025
+ dir: attributes.dir
45026
+ };
45027
+ }
45028
+ }
45029
+ }
45030
+ }
45031
+ ];
45032
+ },
45033
+ addProseMirrorPlugins() {
45034
+ return [
45035
+ new Plugin({
45036
+ key: new PluginKey("textDirection"),
45037
+ props: {
45038
+ attributes: () => {
45039
+ const direction = this.options.direction;
45040
+ if (!direction) {
45041
+ return {};
45042
+ }
45043
+ return {
45044
+ dir: direction
45045
+ };
45046
+ }
45047
+ }
45048
+ })
45049
+ ];
45050
+ }
45051
+ });
44921
45052
 
44922
45053
  // src/NodePos.ts
44923
45054
  var NodePos = class _NodePos {
@@ -45210,6 +45341,7 @@ img.ProseMirror-separator {
45210
45341
  extensions: [],
45211
45342
  autofocus: false,
45212
45343
  editable: true,
45344
+ textDirection: void 0,
45213
45345
  editorProps: {},
45214
45346
  parseOptions: {},
45215
45347
  coreExtensionOptions: {},
@@ -45487,7 +45619,10 @@ img.ProseMirror-separator {
45487
45619
  Tabindex,
45488
45620
  Drop,
45489
45621
  Paste,
45490
- Delete
45622
+ Delete,
45623
+ TextDirection.configure({
45624
+ direction: this.options.textDirection
45625
+ })
45491
45626
  ].filter((ext) => {
45492
45627
  if (typeof this.options.enableCoreExtensions === "object") {
45493
45628
  return this.options.enableCoreExtensions[ext.name] !== false;
@@ -46214,6 +46349,8 @@ ${renderedContent}
46214
46349
  break;
46215
46350
  } else if (currentLine.trim() === "") {
46216
46351
  i += 1;
46352
+ totalRaw = `${totalRaw}${currentLine}
46353
+ `;
46217
46354
  continue;
46218
46355
  } else {
46219
46356
  return void 0;
@@ -46274,7 +46411,7 @@ ${renderedContent}
46274
46411
  }
46275
46412
  return {
46276
46413
  items,
46277
- raw: totalRaw.trim()
46414
+ raw: totalRaw
46278
46415
  };
46279
46416
  }
46280
46417
 
@@ -62322,7 +62459,7 @@ ${nextLine.slice(indentLevel + 2)}`;
62322
62459
  addProseMirrorPlugins() {
62323
62460
  var _a;
62324
62461
  const plugin = new PluginKey(this.name);
62325
- const defaultNode = ((_a = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : _a.name) || this.options.node || "paragraph";
62462
+ const defaultNode = this.options.node || ((_a = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : _a.name) || "paragraph";
62326
62463
  const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(defaultNode).includes(node.name));
62327
62464
  return [
62328
62465
  new Plugin({