@ni/ok-components 0.3.6 → 0.3.8

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.
@@ -17712,13 +17712,14 @@
17712
17712
  background-color: transparent;
17713
17713
  cursor: pointer;
17714
17714
  outline: none;
17715
- --ni-private-step-icon-background-full-size: 100% 100%;
17716
- ${'' /* 6px = (2px icon border + 1px inset) * 2 sides */}
17717
- --ni-private-step-icon-background-inset-size: calc(100% - 6px) calc(100% - 6px);
17718
- --ni-private-step-icon-background-none-size: 0% 0%;
17715
+ --ni-private-step-icon-background-full-size: scale(1,1);
17716
+ ${'' /* (32px - 2 * (2px focus border + 1px inset gap)) / 32px = .8125 */}
17717
+ --ni-private-step-icon-background-inset-size: scale(0.8125, 0.8125);
17718
+ --ni-private-step-icon-background-none-size: scale(0,0);
17719
17719
 
17720
17720
  --ni-private-step-icon-color: ${buttonLabelFontColor};
17721
17721
  --ni-private-step-icon-border-color: transparent;
17722
+ --ni-private-step-icon-border-width: 1px;
17722
17723
  --ni-private-step-icon-background-color: rgba(${borderRgbPartialColor}, 0.1);
17723
17724
  --ni-private-step-icon-background-size: var(--ni-private-step-icon-background-full-size);
17724
17725
  --ni-private-step-icon-outline-inset-color: transparent;
@@ -17821,6 +17822,20 @@ Defines an interaction area clip-path that leaves out the severity text so it is
17821
17822
  --ni-private-step-line-color: ${borderHoverColor};
17822
17823
  }
17823
17824
 
17825
+ .icon-background {
17826
+ grid-area: icon;
17827
+ display: inline-block;
17828
+ height: ${controlHeight};
17829
+ width: ${controlHeight};
17830
+ ${userSelectNone$1};
17831
+ background-color: var(--ni-private-step-icon-background-color);
17832
+ transform: var(--ni-private-step-icon-background-size);
17833
+ border: none;
17834
+ border-radius: 100%;
17835
+ transition:
17836
+ transform ${smallDelay} ease-in-out;
17837
+ }
17838
+
17824
17839
  .icon {
17825
17840
  grid-area: icon;
17826
17841
  display: inline-flex;
@@ -17833,31 +17848,16 @@ Defines an interaction area clip-path that leaves out the severity text so it is
17833
17848
  font: ${buttonLabelFont};
17834
17849
  color: var(--ni-private-step-icon-color);
17835
17850
  ${iconColor.cssCustomProperty}: var(--ni-private-step-icon-color);
17836
- border-style: solid;
17851
+ border: none;
17837
17852
  border-radius: 100%;
17838
- border-color: var(--ni-private-step-icon-border-color);
17839
- border-width: 1px;
17840
- background-image: radial-gradient(
17841
- closest-side,
17842
- ${'' /* Workaround to prevent aliasing on radial-gradient boundaries, see:
17843
- https://frontendmasters.com/blog/obsessing-over-smooth-radial-gradient-disc-edges
17844
- */}
17845
- var(--ni-private-step-icon-background-color) calc(100% - 1px/var(--ni-private-device-pixel-ratio, 1)),
17846
- transparent 100%
17847
- );
17848
- background-origin: border-box;
17849
- background-size: var(--ni-private-step-icon-background-size);
17850
- background-repeat: no-repeat;
17851
- background-position: center center;
17853
+ box-shadow: inset 0px 0px 0px var(--ni-private-step-icon-border-width) var(--ni-private-step-icon-border-color);
17852
17854
  position: relative;
17853
17855
  transition:
17854
- border-color ${smallDelay} ease-in-out,
17855
- border-width ${smallDelay} ease-in-out,
17856
- background-size ${smallDelay} ease-out;
17856
+ box-shadow ${smallDelay} ease-in-out;
17857
17857
  }
17858
17858
 
17859
17859
  :host([selected]) .icon {
17860
- border-width: 2px;
17860
+ --ni-private-step-icon-border-width: 2px;
17861
17861
  }
17862
17862
 
17863
17863
  .icon::before {
@@ -17870,10 +17870,9 @@ Defines an interaction area clip-path that leaves out the severity text so it is
17870
17870
  outline-style: solid;
17871
17871
  outline-width: 0px;
17872
17872
  outline-offset: 0px;
17873
- border: 1px solid transparent;
17873
+ border: none;
17874
17874
  border-radius: 100%;
17875
17875
  color: transparent;
17876
- background-clip: border-box;
17877
17876
  transition:
17878
17877
  outline-color ${smallDelay} ease-in-out,
17879
17878
  outline-width ${smallDelay} ease-in-out,
@@ -18025,7 +18024,7 @@ Defines an interaction area clip-path that leaves out the severity text so it is
18025
18024
  }
18026
18025
 
18027
18026
  .control:hover .icon {
18028
- border-width: 2px;
18027
+ --ni-private-step-icon-border-width: 2px;
18029
18028
  }
18030
18029
 
18031
18030
  .control:hover .line {
@@ -18076,12 +18075,13 @@ Defines an interaction area clip-path that leaves out the severity text so it is
18076
18075
  }
18077
18076
 
18078
18077
  .control${focusVisible} .icon {
18079
- border-width: 2px;
18078
+ --ni-private-step-icon-border-width: 2px;
18080
18079
  }
18081
18080
 
18082
18081
  .control${focusVisible} .icon::before {
18083
18082
  outline-width: ${borderWidth};
18084
- outline-offset: -2px;
18083
+ ${'' /* -1px control to outline edge -2px focus border -1px inset gap */}
18084
+ outline-offset: -4px;
18085
18085
  }
18086
18086
 
18087
18087
  .control${focusVisible} .line {
@@ -18128,7 +18128,7 @@ Defines an interaction area clip-path that leaves out the severity text so it is
18128
18128
  }
18129
18129
 
18130
18130
  .control:active .icon {
18131
- border-width: 2px;
18131
+ --ni-private-step-icon-border-width: 2px;
18132
18132
  }
18133
18133
 
18134
18134
  .control:active .icon::before {
@@ -19462,6 +19462,7 @@ Defines an interaction area clip-path that leaves out the severity text so it is
19462
19462
  aria-roledescription="${x => x.ariaRoledescription}"
19463
19463
  ${ref('control')}
19464
19464
  >
19465
+ <div class="icon-background"></div>
19465
19466
  <div class="icon">
19466
19467
  <span class="current-label">${x => (x.selected ? popupIconCurrentLabel.getValueFor(x) : '')}</span>
19467
19468
  <div class="step-indicator"><slot name="step-indicator"><span aria-hidden="true">${x => x.stepInternals.position}</span></slot></div>
@@ -32802,7 +32803,8 @@ so this becomes the fallback color for the slot */ ''}
32802
32803
  return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));
32803
32804
  }
32804
32805
  map(mapping) {
32805
- let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
32806
+ let to = mapping.mapResult(this.to, -1);
32807
+ let from = this.from == this.to && ReplaceStep.MAP_BIAS < 0 ? to : mapping.mapResult(this.from, 1);
32806
32808
  if (from.deletedAcross && to.deletedAcross)
32807
32809
  return null;
32808
32810
  return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);
@@ -32841,6 +32843,15 @@ so this becomes the fallback color for the slot */ ''}
32841
32843
  return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);
32842
32844
  }
32843
32845
  }
32846
+ /**
32847
+ By default, for backwards compatibility, an inserting step
32848
+ mapped over an insertion at that same position fill move after
32849
+ the inserted content. In a collaborative editing situation, that
32850
+ can make redone insertions appear in unexpected places. You can
32851
+ set this to -1 to make such mapping keep the step before the
32852
+ insertion instead.
32853
+ */
32854
+ ReplaceStep.MAP_BIAS = 1;
32844
32855
  Step$1.jsonID("replace", ReplaceStep);
32845
32856
  /**
32846
32857
  Replace a part of the document with a slice of content, but
@@ -33827,6 +33838,26 @@ so this becomes the fallback color for the slot */ ''}
33827
33838
  }
33828
33839
  function deleteRange$1(tr, from, to) {
33829
33840
  let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
33841
+ // When the deleted range spans from the start of one textblock to
33842
+ // the start of another one, move out of the start of both blocks.
33843
+ if ($from.parent.isTextblock && $to.parent.isTextblock && $from.start() != $to.start() &&
33844
+ $from.parentOffset == 0 && $to.parentOffset == 0) {
33845
+ let shared = $from.sharedDepth(to), isolated = false;
33846
+ for (let d = $from.depth; d > shared; d--)
33847
+ if ($from.node(d).type.spec.isolating)
33848
+ isolated = true;
33849
+ for (let d = $to.depth; d > shared; d--)
33850
+ if ($to.node(d).type.spec.isolating)
33851
+ isolated = true;
33852
+ if (!isolated) {
33853
+ for (let d = $from.depth; d > 0 && from == $from.start(d); d--)
33854
+ from = $from.before(d);
33855
+ for (let d = $to.depth; d > 0 && to == $to.start(d); d--)
33856
+ to = $to.before(d);
33857
+ $from = tr.doc.resolve(from);
33858
+ $to = tr.doc.resolve(to);
33859
+ }
33860
+ }
33830
33861
  let covered = coveredDepths($from, $to);
33831
33862
  for (let i = 0; i < covered.length; i++) {
33832
33863
  let depth = covered[i], last = i == covered.length - 1;
@@ -42575,7 +42606,6 @@ so this becomes the fallback color for the slot */ ''}
42575
42606
  return !!findMarkInSet(marks, type, attributes);
42576
42607
  }
42577
42608
  function getMarkRange($pos, type, attributes) {
42578
- var _a;
42579
42609
  if (!$pos || !type) {
42580
42610
  return;
42581
42611
  }
@@ -42586,7 +42616,12 @@ so this becomes the fallback color for the slot */ ''}
42586
42616
  if (!start.node || !start.node.marks.some((mark2) => mark2.type === type)) {
42587
42617
  return;
42588
42618
  }
42589
- attributes = attributes || ((_a = start.node.marks[0]) == null ? void 0 : _a.attrs);
42619
+ if (!attributes) {
42620
+ const firstMark = start.node.marks.find((mark2) => mark2.type === type);
42621
+ if (firstMark) {
42622
+ attributes = firstMark.attrs;
42623
+ }
42624
+ }
42590
42625
  const mark = findMarkInSet([...start.node.marks], type, attributes);
42591
42626
  if (!mark) {
42592
42627
  return;
@@ -42621,7 +42656,7 @@ so this becomes the fallback color for the slot */ ''}
42621
42656
  }
42622
42657
 
42623
42658
  // src/commands/extendMarkRange.ts
42624
- var extendMarkRange = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
42659
+ var extendMarkRange = (typeOrName, attributes) => ({ tr, state, dispatch }) => {
42625
42660
  const type = getMarkType(typeOrName, state.schema);
42626
42661
  const { doc, selection } = tr;
42627
42662
  const { $from, from, to } = selection;
@@ -45876,7 +45911,7 @@ so this becomes the fallback color for the slot */ ''}
45876
45911
  const newEnd = mapping.slice(index).map(step.to);
45877
45912
  const oldStart = mapping.invert().map(newStart, -1);
45878
45913
  const oldEnd = mapping.invert().map(newEnd);
45879
- const foundBeforeMark = (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark));
45914
+ const foundBeforeMark = newStart > 0 ? (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark)) : false;
45880
45915
  const foundAfterMark = (_b3 = nextTransaction.doc.nodeAt(newEnd)) == null ? void 0 : _b3.marks.some((mark) => mark.eq(step.mark));
45881
45916
  this.editor.emit("delete", {
45882
45917
  type: "mark",
@@ -61857,6 +61892,19 @@ ${nextLine.slice(indentLevel + 2)}`;
61857
61892
  }
61858
61893
 
61859
61894
  // src/suggestion.ts
61895
+ function hasInsertedWhitespace(transaction) {
61896
+ if (!transaction.docChanged) {
61897
+ return false;
61898
+ }
61899
+ return transaction.steps.some((step) => {
61900
+ const slice = step.slice;
61901
+ if (!(slice == null ? void 0 : slice.content)) {
61902
+ return false;
61903
+ }
61904
+ const inserted = slice.content.textBetween(0, slice.content.size, "\n");
61905
+ return /\s/.test(inserted);
61906
+ });
61907
+ }
61860
61908
  var SuggestionPluginKey = new PluginKey("suggestion");
61861
61909
  function Suggestion({
61862
61910
  pluginKey = SuggestionPluginKey,
@@ -61875,10 +61923,12 @@ ${nextLine.slice(indentLevel + 2)}`;
61875
61923
  render = () => ({}),
61876
61924
  allow = () => true,
61877
61925
  findSuggestionMatch: findSuggestionMatch2 = findSuggestionMatch,
61878
- shouldShow
61926
+ shouldShow,
61927
+ shouldResetDismissed
61879
61928
  }) {
61880
61929
  let props;
61881
61930
  const renderer = render == null ? void 0 : render();
61931
+ const effectiveAllowSpaces = allowSpaces && !allowToIncludeChar;
61882
61932
  const getAnchorClientRect = () => {
61883
61933
  const pos = editor.state.selection.$anchor.pos;
61884
61934
  const coords = editor.view.coordsAtPos(pos);
@@ -61900,6 +61950,27 @@ ${nextLine.slice(indentLevel + 2)}`;
61900
61950
  return (currentDecorationNode == null ? void 0 : currentDecorationNode.getBoundingClientRect()) || null;
61901
61951
  };
61902
61952
  };
61953
+ const shouldKeepDismissed = ({
61954
+ match,
61955
+ dismissedRange,
61956
+ state,
61957
+ transaction
61958
+ }) => {
61959
+ if (shouldResetDismissed == null ? void 0 : shouldResetDismissed({
61960
+ editor,
61961
+ state,
61962
+ range: dismissedRange,
61963
+ match,
61964
+ transaction,
61965
+ allowSpaces: effectiveAllowSpaces
61966
+ })) {
61967
+ return false;
61968
+ }
61969
+ if (effectiveAllowSpaces) {
61970
+ return match.range.from === dismissedRange.from;
61971
+ }
61972
+ return match.range.from === dismissedRange.from && !hasInsertedWhitespace(transaction);
61973
+ };
61903
61974
  function dispatchExit(view, pluginKeyRef) {
61904
61975
  var _a;
61905
61976
  try {
@@ -62002,7 +62073,8 @@ ${nextLine.slice(indentLevel + 2)}`;
62002
62073
  },
62003
62074
  query: null,
62004
62075
  text: null,
62005
- composing: false
62076
+ composing: false,
62077
+ dismissedRange: null
62006
62078
  };
62007
62079
  return state;
62008
62080
  },
@@ -62020,9 +62092,16 @@ ${nextLine.slice(indentLevel + 2)}`;
62020
62092
  next.range = { from: 0, to: 0 };
62021
62093
  next.query = null;
62022
62094
  next.text = null;
62095
+ next.dismissedRange = prev.active ? { ...prev.range } : prev.dismissedRange;
62023
62096
  return next;
62024
62097
  }
62025
62098
  next.composing = composing;
62099
+ if (transaction.docChanged && next.dismissedRange !== null) {
62100
+ next.dismissedRange = {
62101
+ from: transaction.mapping.map(next.dismissedRange.from),
62102
+ to: transaction.mapping.map(next.dismissedRange.to)
62103
+ };
62104
+ }
62026
62105
  if (isEditable && (empty || editor.view.composing)) {
62027
62106
  if ((from < prev.range.from || from > prev.range.to) && !composing && !prev.composing) {
62028
62107
  next.active = false;
@@ -62048,12 +62127,27 @@ ${nextLine.slice(indentLevel + 2)}`;
62048
62127
  text: match.text,
62049
62128
  transaction
62050
62129
  }))) {
62051
- next.active = true;
62052
- next.decorationId = prev.decorationId ? prev.decorationId : decorationId;
62053
- next.range = match.range;
62054
- next.query = match.query;
62055
- next.text = match.text;
62130
+ if (next.dismissedRange !== null && !shouldKeepDismissed({
62131
+ match,
62132
+ dismissedRange: next.dismissedRange,
62133
+ state,
62134
+ transaction
62135
+ })) {
62136
+ next.dismissedRange = null;
62137
+ }
62138
+ if (next.dismissedRange === null) {
62139
+ next.active = true;
62140
+ next.decorationId = prev.decorationId ? prev.decorationId : decorationId;
62141
+ next.range = match.range;
62142
+ next.query = match.query;
62143
+ next.text = match.text;
62144
+ } else {
62145
+ next.active = false;
62146
+ }
62056
62147
  } else {
62148
+ if (!match) {
62149
+ next.dismissedRange = null;
62150
+ }
62057
62151
  next.active = false;
62058
62152
  }
62059
62153
  } else {
@@ -62071,41 +62165,18 @@ ${nextLine.slice(indentLevel + 2)}`;
62071
62165
  props: {
62072
62166
  // Call the keydown hook if suggestion is active.
62073
62167
  handleKeyDown(view, event) {
62074
- var _a, _b, _c, _d;
62168
+ var _a, _b;
62075
62169
  const { active, range } = plugin.getState(view.state);
62076
62170
  if (!active) {
62077
62171
  return false;
62078
62172
  }
62079
62173
  if (event.key === "Escape" || event.key === "Esc") {
62080
62174
  const state = plugin.getState(view.state);
62081
- const cachedNode = (_a = props == null ? void 0 : props.decorationNode) != null ? _a : null;
62082
- const decorationNode = cachedNode != null ? cachedNode : (state == null ? void 0 : state.decorationId) ? view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`) : null;
62083
- const handledByKeyDown = ((_b = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _b.call(renderer, { view, event, range: state.range })) || false;
62084
- if (handledByKeyDown) {
62085
- return true;
62086
- }
62087
- const exitProps = {
62088
- editor,
62089
- range: state.range,
62090
- query: state.query,
62091
- text: state.text,
62092
- items: [],
62093
- command: (commandProps) => {
62094
- return command({ editor, range: state.range, props: commandProps });
62095
- },
62096
- decorationNode,
62097
- // If we have a cached decoration node, use it for the clientRect
62098
- // to avoid another DOM lookup. If not, leave clientRect null and
62099
- // let consumer decide if they want to query.
62100
- clientRect: decorationNode ? () => {
62101
- return decorationNode.getBoundingClientRect() || null;
62102
- } : null
62103
- };
62104
- (_c = renderer == null ? void 0 : renderer.onExit) == null ? void 0 : _c.call(renderer, exitProps);
62175
+ (_a = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _a.call(renderer, { view, event, range: state.range });
62105
62176
  dispatchExit(view, pluginKey);
62106
62177
  return true;
62107
62178
  }
62108
- const handled = ((_d = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _d.call(renderer, { view, event, range })) || false;
62179
+ const handled = ((_b = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _b.call(renderer, { view, event, range })) || false;
62109
62180
  return handled;
62110
62181
  },
62111
62182
  // Setup decorator on the currently active suggestion.
@@ -62398,7 +62469,8 @@ ${nextLine.slice(indentLevel + 2)}`;
62398
62469
  return helpers.parseChildren([tokens[0]]);
62399
62470
  }
62400
62471
  const content = helpers.parseInline(tokens);
62401
- if (content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
62472
+ const hasExplicitEmptyParagraphMarker = tokens.length === 1 && tokens[0].type === "text" && (tokens[0].raw === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].text === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].raw === NBSP_CHAR || tokens[0].text === NBSP_CHAR);
62473
+ if (hasExplicitEmptyParagraphMarker && content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
62402
62474
  return helpers.createNode("paragraph", void 0, []);
62403
62475
  }
62404
62476
  return helpers.createNode("paragraph", void 0, content);
@@ -63715,6 +63787,7 @@ ${nextLine.slice(indentLevel + 2)}`;
63715
63787
  ];
63716
63788
  }
63717
63789
  });
63790
+ var skipTrailingNodeMeta = "skipTrailingNode";
63718
63791
  function nodeEqualsType({ types, node }) {
63719
63792
  return node && Array.isArray(types) && types.includes(node.type) || (node == null ? void 0 : node.type) === types;
63720
63793
  }
@@ -63734,11 +63807,14 @@ ${nextLine.slice(indentLevel + 2)}`;
63734
63807
  return [
63735
63808
  new Plugin({
63736
63809
  key: plugin,
63737
- appendTransaction: (_, __, state) => {
63810
+ appendTransaction: (transactions, __, state) => {
63738
63811
  const { doc, tr, schema } = state;
63739
63812
  const shouldInsertNodeAtEnd = plugin.getState(state);
63740
63813
  const endPosition = doc.content.size;
63741
63814
  const type = schema.nodes[defaultNode];
63815
+ if (transactions.some((transaction) => transaction.getMeta(skipTrailingNodeMeta))) {
63816
+ return;
63817
+ }
63742
63818
  if (!shouldInsertNodeAtEnd) {
63743
63819
  return;
63744
63820
  }
@@ -66453,6 +66529,7 @@ ${nextLine.slice(indentLevel + 2)}`;
66453
66529
  aria-roledescription="${x => x.ariaRoledescription}"
66454
66530
  ${ref('control')}
66455
66531
  >
66532
+ <div class="icon-background"></div>
66456
66533
  <div class="icon">
66457
66534
  <span class="current-label">${x => (x.selected ? popupIconCurrentLabel.getValueFor(x) : '')}</span>
66458
66535
  <div class="step-indicator"><slot name="step-indicator"><span aria-hidden="true">${x => x.stepInternals.position}</span></slot></div>
@@ -66551,28 +66628,7 @@ ${nextLine.slice(indentLevel + 2)}`;
66551
66628
  }
66552
66629
  `;
66553
66630
 
66554
- /**
66555
- * Observable class to subscribe to changes in the page's device pixel ratio
66556
- * Based on: https://frontendmasters.com/blog/obsessing-over-smooth-radial-gradient-disc-edges/#the-less-code-and-more-flexible-js-solution
66557
- */
66558
- class DevicePixelRatio {
66559
- constructor() {
66560
- const update = () => {
66561
- this.current = window.devicePixelRatio;
66562
- window
66563
- .matchMedia(`(resolution: ${this.current}x)`)
66564
- .addEventListener('change', update, { once: true });
66565
- };
66566
- update();
66567
- }
66568
- }
66569
- __decorate([
66570
- observable
66571
- ], DevicePixelRatio.prototype, "current", void 0);
66572
- const devicePixelRatio = new DevicePixelRatio();
66573
-
66574
66631
  const template$w = html `<ol><slot
66575
- style="--ni-private-device-pixel-ratio: ${() => devicePixelRatio.current};"
66576
66632
  name="step"
66577
66633
  ${slotted('steps')}
66578
66634
  ></slot></ol>`;