@ni/nimble-components 35.3.1 → 35.3.2

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.
@@ -42642,6 +42642,9 @@ so this becomes the fallback color for the slot */ ''}
42642
42642
  keepOnSplit: true,
42643
42643
  isRequired: false
42644
42644
  };
42645
+ const nodeExtensionTypes = nodeExtensions.filter((ext) => ext.name !== "text").map((ext) => ext.name);
42646
+ const markExtensionTypes = markExtensions.map((ext) => ext.name);
42647
+ const allExtensionTypes = [...nodeExtensionTypes, ...markExtensionTypes];
42645
42648
  extensions.forEach((extension) => {
42646
42649
  const context = {
42647
42650
  name: extension.name,
@@ -42659,7 +42662,19 @@ so this becomes the fallback color for the slot */ ''}
42659
42662
  }
42660
42663
  const globalAttributes = addGlobalAttributes();
42661
42664
  globalAttributes.forEach((globalAttribute) => {
42662
- globalAttribute.types.forEach((type) => {
42665
+ let resolvedTypes;
42666
+ if (Array.isArray(globalAttribute.types)) {
42667
+ resolvedTypes = globalAttribute.types;
42668
+ } else if (globalAttribute.types === "*") {
42669
+ resolvedTypes = allExtensionTypes;
42670
+ } else if (globalAttribute.types === "nodes") {
42671
+ resolvedTypes = nodeExtensionTypes;
42672
+ } else if (globalAttribute.types === "marks") {
42673
+ resolvedTypes = markExtensionTypes;
42674
+ } else {
42675
+ resolvedTypes = [];
42676
+ }
42677
+ resolvedTypes.forEach((type) => {
42663
42678
  Object.entries(globalAttribute.attributes).forEach(([name, attribute]) => {
42664
42679
  extensionAttributes.push({
42665
42680
  type,
@@ -43199,6 +43214,9 @@ so this becomes the fallback color for the slot */ ''}
43199
43214
  const from = $from.pos;
43200
43215
  const to = $to.pos;
43201
43216
  state.doc.nodesBetween(from, to, (node, pos) => {
43217
+ if (type && node.inlineContent && !node.type.allowsMarkType(type)) {
43218
+ return false;
43219
+ }
43202
43220
  if (!node.isText && !node.marks.length) {
43203
43221
  return;
43204
43222
  }
@@ -44759,6 +44777,39 @@ so this becomes the fallback color for the slot */ ''}
44759
44777
  };
44760
44778
  }, baseDispatch);
44761
44779
  }
44780
+ /**
44781
+ * Get the composed transformPastedHTML function from all extensions.
44782
+ * @param baseTransform The base transform function (e.g. from the editor props)
44783
+ * @returns A composed transform function that chains all extension transforms
44784
+ */
44785
+ transformPastedHTML(baseTransform) {
44786
+ const { editor } = this;
44787
+ const extensions = sortExtensions([...this.extensions]);
44788
+ return extensions.reduce(
44789
+ (transform, extension) => {
44790
+ const context = {
44791
+ name: extension.name,
44792
+ options: extension.options,
44793
+ storage: this.editor.extensionStorage[extension.name],
44794
+ editor,
44795
+ type: getSchemaTypeByName(extension.name, this.schema)
44796
+ };
44797
+ const extensionTransform = getExtensionField(
44798
+ extension,
44799
+ "transformPastedHTML",
44800
+ context
44801
+ );
44802
+ if (!extensionTransform) {
44803
+ return transform;
44804
+ }
44805
+ return (html, view) => {
44806
+ const transformedHtml = transform(html, view);
44807
+ return extensionTransform.call(context, transformedHtml);
44808
+ };
44809
+ },
44810
+ baseTransform || ((html) => html)
44811
+ );
44812
+ }
44762
44813
  get markViews() {
44763
44814
  const { editor } = this;
44764
44815
  const { markExtensions } = splitExtensions(this.extensions);
@@ -45754,7 +45805,7 @@ img.ProseMirror-separator {
45754
45805
  return this.options.editable && this.view && this.view.editable;
45755
45806
  }
45756
45807
  /**
45757
- * Returns the editor state.
45808
+ * Returns the editor view.
45758
45809
  */
45759
45810
  get view() {
45760
45811
  if (this.editorView) {
@@ -45922,6 +45973,8 @@ img.ProseMirror-separator {
45922
45973
  const { editorProps, enableExtensionDispatchTransaction } = this.options;
45923
45974
  const baseDispatch = editorProps.dispatchTransaction || this.dispatchTransaction.bind(this);
45924
45975
  const dispatch = enableExtensionDispatchTransaction ? this.extensionManager.dispatchTransaction(baseDispatch) : baseDispatch;
45976
+ const baseTransformPastedHTML = editorProps.transformPastedHTML;
45977
+ const transformPastedHTML = this.extensionManager.transformPastedHTML(baseTransformPastedHTML);
45925
45978
  this.editorView = new EditorView(element, {
45926
45979
  ...editorProps,
45927
45980
  attributes: {
@@ -45930,6 +45983,7 @@ img.ProseMirror-separator {
45930
45983
  ...editorProps == null ? void 0 : editorProps.attributes
45931
45984
  },
45932
45985
  dispatchTransaction: dispatch,
45986
+ transformPastedHTML,
45933
45987
  state: this.editorState,
45934
45988
  markViews: this.extensionManager.markViews,
45935
45989
  nodeViews: this.extensionManager.nodeViews
@@ -52693,7 +52747,14 @@ ${renderedContent}
52693
52747
  if (url.length <= proto.length) return false
52694
52748
 
52695
52749
  // disallow '*' at the end of the link (conflicts with emphasis)
52696
- url = url.replace(/\*+$/, '');
52750
+ // do manual backsearch to avoid perf issues with regex /\*+$/ on "****...****a".
52751
+ let urlEnd = url.length;
52752
+ while (urlEnd > 0 && url.charCodeAt(urlEnd - 1) === 0x2A/* * */) {
52753
+ urlEnd--;
52754
+ }
52755
+ if (urlEnd !== url.length) {
52756
+ url = url.slice(0, urlEnd);
52757
+ }
52697
52758
 
52698
52759
  const fullUrl = state.md.normalizeLink(url);
52699
52760
  if (!state.md.validateLink(fullUrl)) return false
@@ -71897,6 +71958,7 @@ focus outline in that case.
71897
71958
  const [offset, align] = offsetInfo;
71898
71959
  this._scrollToOffset(offset, { adjustments: void 0, behavior });
71899
71960
  this.targetWindow.requestAnimationFrame(() => {
71961
+ if (!this.targetWindow) return;
71900
71962
  const verify = () => {
71901
71963
  if (this.currentScrollToIndex !== index) return;
71902
71964
  const currentOffset = this.getScrollOffset();