@instructure/platform-notebook 1.1.0 → 1.2.0

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.
Files changed (2) hide show
  1. package/dist/index.js +45 -43
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import { TruncateText as Ne } from "@instructure/ui-truncate-text";
12
12
  import { ScreenReaderContent as ze } from "@instructure/ui-a11y-content";
13
13
  import { SimpleSelect as De } from "@instructure/ui-simple-select";
14
14
  import { Heading as fe } from "@instructure/ui-heading";
15
- import { Text as U } from "@instructure/ui-text";
15
+ import { Text as W } from "@instructure/ui-text";
16
16
  import { CloseButton as lt, Button as K, IconButton as re } from "@instructure/ui-buttons";
17
17
  import { Tray as at } from "@instructure/ui-tray";
18
18
  import { TextArea as $e } from "@instructure/ui-text-area";
@@ -102,14 +102,14 @@ d.object({
102
102
  d.object({
103
103
  deleteNote: d.string()
104
104
  });
105
- var We = /* @__PURE__ */ ((t) => (t[t.FORWARDS = 1] = "FORWARDS", t[t.BACKWARDS = 2] = "BACKWARDS", t))(We || {});
105
+ var Ge = /* @__PURE__ */ ((t) => (t[t.FORWARDS = 1] = "FORWARDS", t[t.BACKWARDS = 2] = "BACKWARDS", t))(Ge || {});
106
106
  class X {
107
107
  constructor(e, n) {
108
108
  this.start = e, this.end = n;
109
109
  }
110
110
  toRange() {
111
111
  let e, n;
112
- if (this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, n] = Ue(this.start.element, this.start.offset, this.end.offset) : (e = this.start.resolve({
112
+ if (this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, n] = We(this.start.element, this.start.offset, this.end.offset) : (e = this.start.resolve({
113
113
  direction: 1
114
114
  /* FORWARDS */
115
115
  }), n = this.end.resolve({
@@ -137,12 +137,12 @@ class j {
137
137
  }
138
138
  resolve(e = {}) {
139
139
  try {
140
- return Ue(this.element, this.offset)[0];
140
+ return We(this.element, this.offset)[0];
141
141
  } catch (n) {
142
142
  if (this.offset === 0 && e.direction !== void 0) {
143
143
  const o = document.createTreeWalker(this.element.getRootNode(), NodeFilter.SHOW_TEXT);
144
144
  o.currentNode = this.element;
145
- const r = e.direction === We.FORWARDS, i = r ? o.nextNode() : o.previousNode();
145
+ const r = e.direction === Ge.FORWARDS, i = r ? o.nextNode() : o.previousNode();
146
146
  if (!i)
147
147
  throw n;
148
148
  return { node: i, offset: r ? 0 : i.data.length };
@@ -175,7 +175,7 @@ class j {
175
175
  return console.error("Child node offset is out of range"), null;
176
176
  let o = 0;
177
177
  for (let r = 0; r < n; r++)
178
- o += Ge(e.childNodes[r]);
178
+ o += Ue(e.childNodes[r]);
179
179
  return new j(e, o);
180
180
  }
181
181
  default:
@@ -310,7 +310,7 @@ class Y {
310
310
  return X.fromOffsets(this.root, this.start, this.end).toRange();
311
311
  }
312
312
  }
313
- const Ge = (t) => {
313
+ const Ue = (t) => {
314
314
  var e;
315
315
  switch (t.nodeType) {
316
316
  case Node.ELEMENT_NODE:
@@ -322,9 +322,9 @@ const Ge = (t) => {
322
322
  }, Fe = (t) => {
323
323
  let e = t.previousSibling, n = 0;
324
324
  for (; e; )
325
- n += Ge(e), e = e.previousSibling;
325
+ n += Ue(e), e = e.previousSibling;
326
326
  return n;
327
- }, Ue = (t, ...e) => {
327
+ }, We = (t, ...e) => {
328
328
  let n = e.shift();
329
329
  const o = t.ownerDocument.createNodeIterator(t, NodeFilter.SHOW_TEXT), r = [];
330
330
  let i = o.nextNode(), l = null, a = 0;
@@ -415,10 +415,12 @@ const Ge = (t) => {
415
415
  const { highlightData: n, id: o } = t, { range: r } = n ?? {};
416
416
  r && ((l = ee.fromSelector(e, r)) == null ? void 0 : l.toRange()) && Lt({ id: o });
417
417
  }, xt = (t) => {
418
- const e = document.getElementById(xe(t));
419
- if (e) {
420
- const n = e.getBoundingClientRect();
421
- n.top >= 0 && n.left >= 0 && n.bottom <= (window.innerHeight || document.documentElement.clientHeight) && n.right <= (window.innerWidth || document.documentElement.clientWidth) || e.scrollIntoView({ behavior: "smooth", block: "start" });
418
+ const n = document.querySelector(
419
+ `[data-highlight-id="${CSS.escape(t)}"].highlight-content`
420
+ ) ?? document.getElementById(xe(t));
421
+ if (n) {
422
+ const o = n.getBoundingClientRect();
423
+ o.top >= 0 && o.bottom <= (window.innerHeight || document.documentElement.clientHeight) || n.scrollIntoView({ behavior: "smooth", block: "center" });
422
424
  }
423
425
  }, ae = 90, ce = 172, wt = (t) => {
424
426
  const e = t.getClientRects();
@@ -510,7 +512,7 @@ const Ge = (t) => {
510
512
  N.setStartAfter(u), N.setEndBefore(p);
511
513
  const L = Rt(N).filter((b) => b.textContent && b.textContent.length > 0);
512
514
  L.forEach((b, I) => {
513
- var G;
515
+ var U;
514
516
  const R = b.parentElement;
515
517
  if ((R == null ? void 0 : R.dataset.highlightId) === o) return;
516
518
  const C = I === 0, B = I === L.length - 1, x = L.length === 1;
@@ -520,7 +522,7 @@ const Ge = (t) => {
520
522
  w.className = "highlight-content", w.dataset.highlightId = o || "", w.dataset.position = A, w.style.backgroundColor = m, w.style.textDecorationLine = "underline", w.style.textDecorationColor = c, w.style.textDecorationStyle = h, w.style.textDecorationThickness = n.borderWidthSmall, w.style.textUnderlineOffset = n.underlineOffset, w.style.cursor = "pointer", w.addEventListener("click", (te) => {
521
523
  var $;
522
524
  te.target.tagName !== "A" && (($ = e.onClick) == null || $.call(e));
523
- }), (G = b.parentNode) == null || G.insertBefore(w, b), w.appendChild(b);
525
+ }), (U = b.parentNode) == null || U.insertBefore(w, b), w.appendChild(b);
524
526
  }), u.addEventListener("click", (b) => {
525
527
  var I;
526
528
  b.target.tagName !== "A" && ((I = e.onClick) == null || I.call(e));
@@ -631,16 +633,16 @@ function _t(t) {
631
633
  }
632
634
  });
633
635
  }
634
- const Mt = "Notebook", Bt = "Notes", Ht = "Important", jt = "Unclear", zt = "Back", $t = "Edit note", Wt = "Save", Gt = "Cancel", Ut = "Delete note", qt = "note", Kt = "Add note (optional)", Xt = "Remove from Notebook", Qt = "Add a note (optional)", Vt = "Mark important", Yt = "Mark unclear", Zt = "Saved to Notebook.", Jt = "Note updated", en = "Note deleted", tn = "Error saving to Notebook.", nn = "Error updating note", on = "Note deletion failed", rn = "Loading notes", sn = "Failed to load notes", ln = "Start capturing your notes", an = "Your notes from learning materials will appear here. Highlight key ideas, reflections, or questions as you learn—they'll all be saved in your Notebook for easy review later.", cn = "Nothing here yet", dn = "Adjust your filters or create a new note to get started.", un = "You have no notes for the selected filter", fn = "Previous page", mn = "Next page", gn = "All courses", hn = "All notes", pn = "Close Notebook panel", Nn = "To use the Notebook feature, highlight an excerpt from your learning material to flag it as 'confusing' or 'important' and leave an optional note.", yn = "The content you highlighted is no longer available.", ke = {
636
+ const Mt = "Notebook", Bt = "Notes", Ht = "Important", jt = "Unclear", zt = "Back", $t = "Edit note", Gt = "Save", Ut = "Cancel", Wt = "Delete note", qt = "note", Kt = "Add note (optional)", Xt = "Remove from Notebook", Qt = "Add a note (optional)", Vt = "Mark important", Yt = "Mark unclear", Zt = "Saved to Notebook.", Jt = "Note updated", en = "Note deleted", tn = "Error saving to Notebook.", nn = "Error updating note", on = "Note deletion failed", rn = "Loading notes", sn = "Failed to load notes", ln = "Start capturing your notes", an = "Your notes from learning materials will appear here. Highlight key ideas, reflections, or questions as you learn—they'll all be saved in your Notebook for easy review later.", cn = "Nothing here yet", dn = "Adjust your filters or create a new note to get started.", un = "You have no notes for the selected filter", fn = "Previous page", mn = "Next page", gn = "All courses", hn = "All notes", pn = "Close Notebook panel", Nn = "To use the Notebook feature, highlight an excerpt from your learning material to flag it as 'confusing' or 'important' and leave an optional note.", yn = "The content you highlighted is no longer available.", ke = {
635
637
  notebook: Mt,
636
638
  notes: Bt,
637
639
  important: Ht,
638
640
  unclear: jt,
639
641
  back: zt,
640
642
  editNote: $t,
641
- save: Wt,
642
- cancel: Gt,
643
- deleteNote: Ut,
643
+ save: Gt,
644
+ cancel: Ut,
645
+ deleteNote: Wt,
644
646
  note: qt,
645
647
  addNotePrompt: Kt,
646
648
  removeFromNotebook: Xt,
@@ -834,7 +836,7 @@ function eo({
834
836
  },
835
837
  courseId: c,
836
838
  pageSize: 100
837
- }), { mutate: T } = At(l), { mutateAsync: N } = _t(l), { mutate: O } = Ft(l), L = J([]), [b, I] = H([]), [R, C] = H(null), [B, x] = H(""), [A, w] = H(null), [G, te] = H(!1);
839
+ }), { mutate: T } = At(l), { mutateAsync: N } = _t(l), { mutate: O } = Ft(l), L = J([]), [b, I] = H([]), [R, C] = H(null), [B, x] = H(""), [A, w] = H(null), [U, te] = H(!1);
838
840
  Z(() => {
839
841
  const D = t.current;
840
842
  if (!D) return;
@@ -852,19 +854,19 @@ function eo({
852
854
  });
853
855
  return F.observe(f, { attributes: !0, attributeFilter: ["class"] }), () => F.disconnect();
854
856
  }, [t]), Z(() => {
855
- if (!G || !t.current) return;
857
+ if (!U || !t.current) return;
856
858
  let f = null;
857
859
  const F = () => {
858
860
  f && clearTimeout(f), f = setTimeout(() => {
859
861
  var Re;
860
862
  const v = window.getSelection(), P = t.current;
861
863
  if (!(v != null && v.rangeCount) || !P) return;
862
- const W = v.toString().trim();
863
- if (W === "") return;
864
+ const G = v.toString().trim();
865
+ if (G === "") return;
864
866
  const V = v.getRangeAt(0);
865
867
  if (!P.contains(V.commonAncestorContainer)) return;
866
868
  const Oe = (Re = Y.fromRange(P, V)) == null ? void 0 : Re.toSelector();
867
- Oe && !kt(Oe, b) && (C(V.cloneRange()), x(W), w(wt(V)));
869
+ Oe && !kt(Oe, b) && (C(V.cloneRange()), x(G), w(wt(V)));
868
870
  }, n);
869
871
  }, _ = (v) => {
870
872
  if (!(v.target instanceof Node)) return;
@@ -876,13 +878,13 @@ function eo({
876
878
  return document.addEventListener("selectionchange", F), document.addEventListener("mousedown", _), document.addEventListener("touchstart", _), window.addEventListener("scroll", M, !0), () => {
877
879
  f && clearTimeout(f), document.removeEventListener("selectionchange", F), document.removeEventListener("mousedown", _), document.removeEventListener("touchstart", _), window.removeEventListener("scroll", M, !0);
878
880
  };
879
- }, [G, b, n, t]);
881
+ }, [U, b, n, t]);
880
882
  const $ = q(
881
883
  (D) => {
882
- var W;
884
+ var G;
883
885
  const f = t.current;
884
886
  if (!f || !D.highlightData) return null;
885
- const { highlightData: F, reaction: _, id: M } = D, { range: v } = F, P = v && ((W = ee.fromSelector(f, v)) == null ? void 0 : W.toRange());
887
+ const { highlightData: F, reaction: _, id: M } = D, { range: v } = F, P = v && ((G = ee.fromSelector(f, v)) == null ? void 0 : G.toRange());
886
888
  if (P) {
887
889
  const V = {
888
890
  id: M,
@@ -899,7 +901,7 @@ function eo({
899
901
  [t, g, e, u, p]
900
902
  );
901
903
  Z(() => {
902
- if (!G || !y || !t.current) return;
904
+ if (!U || !y || !t.current) return;
903
905
  const D = t.current, f = y.notes, F = /* @__PURE__ */ new Set(), _ = [], M = [];
904
906
  if (f.length === 0) {
905
907
  if (L.current.length > 0) {
@@ -915,10 +917,10 @@ function eo({
915
917
  f,
916
918
  h
917
919
  );
918
- for (const W of v)
919
- N({ id: W.id, input: W }).catch((V) => r == null ? void 0 : r(V));
920
- for (const W of P)
921
- O(W, { onError: i });
920
+ for (const G of v)
921
+ N({ id: G.id, input: G }).catch((V) => r == null ? void 0 : r(V));
922
+ for (const G of P)
923
+ O(G, { onError: i });
922
924
  } else {
923
925
  for (const v of f) {
924
926
  const P = $(v);
@@ -929,7 +931,7 @@ function eo({
929
931
  I(M), L.current = _, g && xt(g);
930
932
  }
931
933
  }, [
932
- G,
934
+ U,
933
935
  y,
934
936
  $,
935
937
  h,
@@ -1142,7 +1144,7 @@ const xn = ({ hasActiveFilter: t = !1 }) => {
1142
1144
  return /* @__PURE__ */ s(z, { as: "div", textAlign: "center", children: /* @__PURE__ */ E(S, { direction: "column", alignItems: "center", gap: "small", children: [
1143
1145
  !t && /* @__PURE__ */ s(st, { size: "medium" }),
1144
1146
  /* @__PURE__ */ s(fe, { level: "h3", children: n }),
1145
- /* @__PURE__ */ s(U, { color: "secondary", children: o })
1147
+ /* @__PURE__ */ s(W, { color: "secondary", children: o })
1146
1148
  ] }) });
1147
1149
  }, oo = ({ children: t }) => {
1148
1150
  const { isTrayOpen: e, closeTray: n } = Ye(), { translations: o } = Q();
@@ -1243,9 +1245,9 @@ const kn = ({
1243
1245
  var f, F;
1244
1246
  c && ((f = A.current) == null || f.scrollIntoView({ behavior: "smooth", block: "nearest" }), (F = A.current) == null || F.focus());
1245
1247
  }, [c]);
1246
- const G = r === k.IMPORTANT ? N.important : N.unclear, te = (f) => {
1248
+ const U = r === k.IMPORTANT ? N.important : N.unclear, te = (f) => {
1247
1249
  f.key === "Enter" && (f.preventDefault(), i == null || i());
1248
- }, $ = [G, N.note];
1250
+ }, $ = [U, N.note];
1249
1251
  n && $.push(n), o && $.push(o), e && $.push(Me(e, u)), g && $.push(g);
1250
1252
  const le = $.join(", "), D = /* @__PURE__ */ E(
1251
1253
  z,
@@ -1276,7 +1278,7 @@ const kn = ({
1276
1278
  renderAsMenuTrigger: h && !!m && !!c
1277
1279
  }
1278
1280
  ),
1279
- n ? /* @__PURE__ */ s("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: /* @__PURE__ */ s(U, { children: c && h ? /* @__PURE__ */ s(
1281
+ n ? /* @__PURE__ */ s("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: /* @__PURE__ */ s(W, { children: c && h ? /* @__PURE__ */ s(
1280
1282
  ye,
1281
1283
  {
1282
1284
  type: r,
@@ -1332,7 +1334,7 @@ const kn = ({
1332
1334
  }
1333
1335
  ) })
1334
1336
  ] })
1335
- ] }) : o ? /* @__PURE__ */ s("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: c && h ? /* @__PURE__ */ E(U, { children: [
1337
+ ] }) : o ? /* @__PURE__ */ s("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: c && h ? /* @__PURE__ */ E(W, { children: [
1336
1338
  o,
1337
1339
  " ",
1338
1340
  /* @__PURE__ */ s(
@@ -1349,7 +1351,7 @@ const kn = ({
1349
1351
  children: /* @__PURE__ */ s(pe, {})
1350
1352
  }
1351
1353
  )
1352
- ] }) : /* @__PURE__ */ s(U, { children: /* @__PURE__ */ s(Ne, { maxLines: 3, truncate: "word", children: o }) }) }) : h && c ? /* @__PURE__ */ s("div", { children: /* @__PURE__ */ E(U, { color: "secondary", children: [
1354
+ ] }) : /* @__PURE__ */ s(W, { children: /* @__PURE__ */ s(Ne, { maxLines: 3, truncate: "word", children: o }) }) }) : h && c ? /* @__PURE__ */ s("div", { children: /* @__PURE__ */ E(W, { color: "secondary", children: [
1353
1355
  N.addNotePrompt,
1354
1356
  " ",
1355
1357
  /* @__PURE__ */ s(
@@ -1368,7 +1370,7 @@ const kn = ({
1368
1370
  )
1369
1371
  ] }) }) : null,
1370
1372
  /* @__PURE__ */ E(S, { justifyItems: "space-between", alignItems: "center", children: [
1371
- /* @__PURE__ */ s(U, { size: "small", color: "secondary", children: Me(e, u) }),
1373
+ /* @__PURE__ */ s(W, { size: "small", color: "secondary", children: Me(e, u) }),
1372
1374
  c && l && /* @__PURE__ */ s(
1373
1375
  re,
1374
1376
  {
@@ -1385,7 +1387,7 @@ const kn = ({
1385
1387
  }
1386
1388
  )
1387
1389
  ] }),
1388
- g && /* @__PURE__ */ s(U, { size: "small", color: "secondary", children: g })
1390
+ g && /* @__PURE__ */ s(W, { size: "small", color: "secondary", children: g })
1389
1391
  ] })
1390
1392
  ] }),
1391
1393
  B && l && /* @__PURE__ */ s(
@@ -1548,7 +1550,7 @@ const Rn = {
1548
1550
  }) => {
1549
1551
  const { translations: c } = Q(), [h, g] = H(m), [u, p] = H(t || ""), [y, T] = H(!1);
1550
1552
  return /* @__PURE__ */ E(S, { direction: "column", gap: "small", "data-testid": "single-note", children: [
1551
- n != null ? /* @__PURE__ */ s(z, { as: "div", children: /* @__PURE__ */ s(U, { children: /* @__PURE__ */ s(ye, { type: e, isCardActive: !0, theme: o, children: n }) }) }) : /* @__PURE__ */ s(Ze, {}),
1553
+ n != null ? /* @__PURE__ */ s(z, { as: "div", children: /* @__PURE__ */ s(W, { children: /* @__PURE__ */ s(ye, { type: e, isCardActive: !0, theme: o, children: n }) }) }) : /* @__PURE__ */ s(Ze, {}),
1552
1554
  /* @__PURE__ */ s(Je, { type: e, onTypeChange: l, renderAsMenuTrigger: !!l }),
1553
1555
  h ? /* @__PURE__ */ E(S, { direction: "column", gap: "x-small", children: [
1554
1556
  /* @__PURE__ */ s(
@@ -1590,7 +1592,7 @@ const Rn = {
1590
1592
  ] }) : /* @__PURE__ */ E(S, { direction: "column", gap: "small", children: [
1591
1593
  t && /* @__PURE__ */ E(z, { as: "div", children: [
1592
1594
  /* @__PURE__ */ s(fe, { level: "h4", margin: "0 0 xx-small 0", children: c.note }),
1593
- /* @__PURE__ */ s(U, { children: t })
1595
+ /* @__PURE__ */ s(W, { children: t })
1594
1596
  ] }),
1595
1597
  /* @__PURE__ */ E(S, { justifyItems: "space-between", children: [
1596
1598
  /* @__PURE__ */ s(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/platform-notebook",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",