@ni/nimble-components 34.6.1 → 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.
@@ -41441,6 +41441,7 @@ so this becomes the fallback color for the slot */ ''}
41441
41441
  setMeta: () => setMeta,
41442
41442
  setNode: () => setNode,
41443
41443
  setNodeSelection: () => setNodeSelection,
41444
+ setTextDirection: () => setTextDirection,
41444
41445
  setTextSelection: () => setTextSelection,
41445
41446
  sinkListItem: () => sinkListItem,
41446
41447
  splitBlock: () => splitBlock,
@@ -41452,6 +41453,7 @@ so this becomes the fallback color for the slot */ ''}
41452
41453
  undoInputRule: () => undoInputRule,
41453
41454
  unsetAllMarks: () => unsetAllMarks,
41454
41455
  unsetMark: () => unsetMark,
41456
+ unsetTextDirection: () => unsetTextDirection,
41455
41457
  updateAttributes: () => updateAttributes,
41456
41458
  wrapIn: () => wrapIn,
41457
41459
  wrapInList: () => wrapInList
@@ -42227,23 +42229,28 @@ so this becomes the fallback color for the slot */ ''}
42227
42229
  if (schemaType === "mark") {
42228
42230
  markType = getMarkType(typeOrName, state.schema);
42229
42231
  }
42230
- if (dispatch) {
42231
- tr.selection.ranges.forEach((range) => {
42232
- state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
42233
- 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) {
42234
42238
  tr.setNodeMarkup(pos, void 0, deleteProps(node.attrs, attributes));
42235
42239
  }
42236
- if (markType && node.marks.length) {
42237
- node.marks.forEach((mark) => {
42238
- 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) {
42239
42246
  tr.addMark(pos, pos + node.nodeSize, markType.create(deleteProps(mark.attrs, attributes)));
42240
42247
  }
42241
- });
42242
- }
42243
- });
42248
+ }
42249
+ });
42250
+ }
42244
42251
  });
42245
- }
42246
- return true;
42252
+ });
42253
+ return canReset;
42247
42254
  };
42248
42255
 
42249
42256
  // src/commands/scrollIntoView.ts
@@ -42639,12 +42646,12 @@ so this becomes the fallback color for the slot */ ''}
42639
42646
  );
42640
42647
  }
42641
42648
  function buildAttributeSpec(extensionAttribute) {
42642
- var _a, _b, _c;
42649
+ var _a, _b;
42643
42650
  const spec = {};
42644
- 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) || {})) {
42645
42652
  spec.default = extensionAttribute.attribute.default;
42646
42653
  }
42647
- 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) {
42648
42655
  spec.validate = extensionAttribute.attribute.validate;
42649
42656
  }
42650
42657
  return [extensionAttribute.name, spec];
@@ -43282,6 +43289,35 @@ so this becomes the fallback color for the slot */ ''}
43282
43289
  }
43283
43290
  return true;
43284
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
+ };
43285
43321
  var setTextSelection = (position) => ({ tr, dispatch }) => {
43286
43322
  if (dispatch) {
43287
43323
  const { doc } = tr;
@@ -43628,6 +43664,34 @@ so this becomes the fallback color for the slot */ ''}
43628
43664
  return true;
43629
43665
  };
43630
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
+
43631
43695
  // src/commands/updateAttributes.ts
43632
43696
  var updateAttributes = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
43633
43697
  let nodeType = null;
@@ -43645,41 +43709,48 @@ so this becomes the fallback color for the slot */ ''}
43645
43709
  if (schemaType === "mark") {
43646
43710
  markType = getMarkType(typeOrName, state.schema);
43647
43711
  }
43648
- if (dispatch) {
43649
- tr.selection.ranges.forEach((range) => {
43650
- const from = range.$from.pos;
43651
- const to = range.$to.pos;
43652
- let lastPos;
43653
- let lastNode;
43654
- let trimmedFrom;
43655
- let trimmedTo;
43656
- if (tr.selection.empty) {
43657
- 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) {
43658
43740
  if (nodeType && nodeType === node.type) {
43659
- trimmedFrom = Math.max(pos, from);
43660
- trimmedTo = Math.min(pos + node.nodeSize, to);
43661
- lastPos = pos;
43662
- lastNode = node;
43663
- }
43664
- });
43665
- } else {
43666
- state.doc.nodesBetween(from, to, (node, pos) => {
43667
- if (pos < from && nodeType && nodeType === node.type) {
43668
- trimmedFrom = Math.max(pos, from);
43669
- trimmedTo = Math.min(pos + node.nodeSize, to);
43670
- lastPos = pos;
43671
- lastNode = node;
43672
- }
43673
- if (pos >= from && pos <= to) {
43674
- if (nodeType && nodeType === node.type) {
43741
+ canUpdate = true;
43742
+ if (dispatch) {
43675
43743
  tr.setNodeMarkup(pos, void 0, {
43676
43744
  ...node.attrs,
43677
43745
  ...attributes
43678
43746
  });
43679
43747
  }
43680
- if (markType && node.marks.length) {
43681
- node.marks.forEach((mark) => {
43682
- 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) {
43683
43754
  const trimmedFrom2 = Math.max(pos, from);
43684
43755
  const trimmedTo2 = Math.min(pos + node.nodeSize, to);
43685
43756
  tr.addMark(
@@ -43691,36 +43762,36 @@ so this becomes the fallback color for the slot */ ''}
43691
43762
  })
43692
43763
  );
43693
43764
  }
43694
- });
43695
- }
43765
+ }
43766
+ });
43696
43767
  }
43768
+ }
43769
+ });
43770
+ }
43771
+ if (lastNode) {
43772
+ if (lastPos !== void 0 && dispatch) {
43773
+ tr.setNodeMarkup(lastPos, void 0, {
43774
+ ...lastNode.attrs,
43775
+ ...attributes
43697
43776
  });
43698
43777
  }
43699
- if (lastNode) {
43700
- if (lastPos !== void 0) {
43701
- tr.setNodeMarkup(lastPos, void 0, {
43702
- ...lastNode.attrs,
43703
- ...attributes
43704
- });
43705
- }
43706
- if (markType && lastNode.marks.length) {
43707
- lastNode.marks.forEach((mark) => {
43708
- if (markType === mark.type) {
43709
- tr.addMark(
43710
- trimmedFrom,
43711
- trimmedTo,
43712
- markType.create({
43713
- ...mark.attrs,
43714
- ...attributes
43715
- })
43716
- );
43717
- }
43718
- });
43719
- }
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
+ });
43720
43791
  }
43721
- });
43722
- }
43723
- return true;
43792
+ }
43793
+ });
43794
+ return canUpdate;
43724
43795
  };
43725
43796
  var wrapIn = (typeOrName, attributes = {}) => ({ state, dispatch }) => {
43726
43797
  const type = getNodeType(typeOrName, state.schema);
@@ -44576,6 +44647,7 @@ so this becomes the fallback color for the slot */ ''}
44576
44647
  Keymap: () => Keymap,
44577
44648
  Paste: () => Paste,
44578
44649
  Tabindex: () => Tabindex,
44650
+ TextDirection: () => TextDirection,
44579
44651
  focusEventsPluginKey: () => focusEventsPluginKey
44580
44652
  });
44581
44653
 
@@ -44920,6 +44992,63 @@ so this becomes the fallback color for the slot */ ''}
44920
44992
  ];
44921
44993
  }
44922
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
+ });
44923
45052
 
44924
45053
  // src/NodePos.ts
44925
45054
  var NodePos = class _NodePos {
@@ -45212,6 +45341,7 @@ img.ProseMirror-separator {
45212
45341
  extensions: [],
45213
45342
  autofocus: false,
45214
45343
  editable: true,
45344
+ textDirection: void 0,
45215
45345
  editorProps: {},
45216
45346
  parseOptions: {},
45217
45347
  coreExtensionOptions: {},
@@ -45489,7 +45619,10 @@ img.ProseMirror-separator {
45489
45619
  Tabindex,
45490
45620
  Drop,
45491
45621
  Paste,
45492
- Delete
45622
+ Delete,
45623
+ TextDirection.configure({
45624
+ direction: this.options.textDirection
45625
+ })
45493
45626
  ].filter((ext) => {
45494
45627
  if (typeof this.options.enableCoreExtensions === "object") {
45495
45628
  return this.options.enableCoreExtensions[ext.name] !== false;
@@ -46216,6 +46349,8 @@ ${renderedContent}
46216
46349
  break;
46217
46350
  } else if (currentLine.trim() === "") {
46218
46351
  i += 1;
46352
+ totalRaw = `${totalRaw}${currentLine}
46353
+ `;
46219
46354
  continue;
46220
46355
  } else {
46221
46356
  return void 0;
@@ -46276,7 +46411,7 @@ ${renderedContent}
46276
46411
  }
46277
46412
  return {
46278
46413
  items,
46279
- raw: totalRaw.trim()
46414
+ raw: totalRaw
46280
46415
  };
46281
46416
  }
46282
46417
 
@@ -62324,7 +62459,7 @@ ${nextLine.slice(indentLevel + 2)}`;
62324
62459
  addProseMirrorPlugins() {
62325
62460
  var _a;
62326
62461
  const plugin = new PluginKey(this.name);
62327
- 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";
62328
62463
  const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(defaultNode).includes(node.name));
62329
62464
  return [
62330
62465
  new Plugin({