@ni/ok-components 0.2.14 → 0.2.15

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