@fileverse-dev/ddoc 3.0.56-patch-1 → 3.0.56-patch-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.
Files changed (2) hide show
  1. package/dist/index.es.js +94 -68
  2. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -167906,96 +167906,118 @@ const l5 = ek.getInstance(), xIe = (e) => ({
167906
167906
  };
167907
167907
  },
167908
167908
  addCommands() {
167909
- const e = (t) => {
167910
- var o;
167911
- const n = (o = this.editor.view) == null ? void 0 : o.dom;
167912
- if (!n) return;
167913
- n.querySelectorAll("[data-comment-id]").forEach((i) => {
167914
- const s = i.getAttribute("data-comment-id"), a = !!t && s === t, l = i.getAttribute("data-resolved") === "true";
167915
- i.setAttribute("data-active", a ? "true" : "false"), i.classList.remove(
167916
- "inline-comment--active",
167917
- "inline-comment--resolved",
167918
- "inline-comment--unresolved"
167919
- ), a ? i.classList.add("inline-comment--active") : i.classList.add(
167920
- l ? "inline-comment--resolved" : "inline-comment--unresolved"
167921
- );
167922
- });
167909
+ const e = () => {
167910
+ var i;
167911
+ try {
167912
+ return (i = this.editor.view) == null ? void 0 : i.dom;
167913
+ } catch {
167914
+ return;
167915
+ }
167916
+ }, t = (i) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(i) : i.replace(/\\/g, "\\\\").replace(/"/g, '\\"'), n = (i, s) => {
167917
+ const a = t(s);
167918
+ return i.querySelectorAll(
167919
+ `[data-comment-id="${a}"]`
167920
+ );
167921
+ }, r = (i, s) => {
167922
+ const a = i.getAttribute("data-resolved") === "true";
167923
+ i.setAttribute("data-active", s ? "true" : "false"), i.classList.toggle("inline-comment--active", s), i.classList.toggle(
167924
+ "inline-comment--resolved",
167925
+ !s && a
167926
+ ), i.classList.toggle(
167927
+ "inline-comment--unresolved",
167928
+ !s && !a
167929
+ );
167930
+ }, o = (i, s) => {
167931
+ if (i === s) return;
167932
+ const a = e();
167933
+ a && (i && n(a, i).forEach((l) => {
167934
+ r(l, !1);
167935
+ }), s && n(a, s).forEach((l) => {
167936
+ r(l, !0);
167937
+ }));
167923
167938
  };
167924
167939
  return {
167925
- setComment: (t) => ({ commands: n }) => t ? (n.setMark("comment", { commentId: t }), !0) : !1,
167926
- unsetComment: (t) => ({ tr: n, dispatch: r }) => {
167927
- var i, s;
167928
- if (!t) return !1;
167929
- const o = [];
167930
- return n.doc.descendants((a, l) => {
167931
- const u = a.marks.find(
167932
- (c) => c.type.name === "comment" && c.attrs.commentId === t
167940
+ setComment: (i) => ({ commands: s }) => i ? (s.setMark("comment", { commentId: i }), !0) : !1,
167941
+ unsetComment: (i) => ({ tr: s, dispatch: a }) => {
167942
+ var u, c;
167943
+ if (!i) return !1;
167944
+ const l = [];
167945
+ return s.doc.descendants((d, p) => {
167946
+ const h = d.marks.find(
167947
+ (f) => f.type.name === "comment" && f.attrs.commentId === i
167933
167948
  );
167934
- u && o.push({
167935
- mark: u,
167949
+ h && l.push({
167950
+ mark: h,
167936
167951
  range: {
167937
- from: l,
167938
- to: l + a.nodeSize
167952
+ from: p,
167953
+ to: p + d.nodeSize
167939
167954
  }
167940
167955
  });
167941
- }), o.forEach(({ mark: a, range: l }) => {
167942
- n.removeMark(l.from, l.to, a);
167943
- }), (s = (i = this.options).onCommentDeleted) == null || s.call(i, t), r == null ? void 0 : r(n);
167944
- },
167945
- resolveComment: (t) => ({ tr: n, dispatch: r }) => {
167946
- var i, s;
167947
- if (!t) return !1;
167948
- const o = [];
167949
- return n.doc.descendants((a, l) => {
167950
- const u = a.marks.find(
167951
- (c) => c.type.name === "comment" && c.attrs.commentId === t
167956
+ }), l.forEach(({ mark: d, range: p }) => {
167957
+ s.removeMark(p.from, p.to, d);
167958
+ }), (c = (u = this.options).onCommentDeleted) == null || c.call(u, i), a == null ? void 0 : a(s);
167959
+ },
167960
+ resolveComment: (i) => ({ tr: s, dispatch: a }) => {
167961
+ var u, c;
167962
+ if (!i) return !1;
167963
+ const l = [];
167964
+ return s.doc.descendants((d, p) => {
167965
+ const h = d.marks.find(
167966
+ (f) => f.type.name === "comment" && f.attrs.commentId === i
167952
167967
  );
167953
- u && o.push({
167954
- mark: u,
167968
+ h && l.push({
167969
+ mark: h,
167955
167970
  range: {
167956
- from: l,
167957
- to: l + a.nodeSize
167971
+ from: p,
167972
+ to: p + d.nodeSize
167958
167973
  }
167959
167974
  });
167960
- }), o.forEach(({ range: a }) => {
167961
- n.addMark(
167962
- a.from,
167963
- a.to,
167975
+ }), l.forEach(({ range: d }) => {
167976
+ s.addMark(
167977
+ d.from,
167978
+ d.to,
167964
167979
  this.editor.schema.marks.comment.create({
167965
- commentId: t,
167980
+ commentId: i,
167966
167981
  resolved: !0
167967
167982
  })
167968
167983
  );
167969
- }), (s = (i = this.options).onCommentResolved) == null || s.call(i, t), r == null ? void 0 : r(n);
167970
- },
167971
- unresolveComment: (t) => ({ tr: n, dispatch: r }) => {
167972
- var i, s;
167973
- if (!t) return !1;
167974
- const o = [];
167975
- return n.doc.descendants((a, l) => {
167976
- const u = a.marks.find(
167977
- (c) => c.type.name === "comment" && c.attrs.commentId === t
167984
+ }), (c = (u = this.options).onCommentResolved) == null || c.call(u, i), a == null ? void 0 : a(s);
167985
+ },
167986
+ unresolveComment: (i) => ({ tr: s, dispatch: a }) => {
167987
+ var u, c;
167988
+ if (!i) return !1;
167989
+ const l = [];
167990
+ return s.doc.descendants((d, p) => {
167991
+ const h = d.marks.find(
167992
+ (f) => f.type.name === "comment" && f.attrs.commentId === i
167978
167993
  );
167979
- u && o.push({
167980
- mark: u,
167994
+ h && l.push({
167995
+ mark: h,
167981
167996
  range: {
167982
- from: l,
167983
- to: l + a.nodeSize
167997
+ from: p,
167998
+ to: p + d.nodeSize
167984
167999
  }
167985
168000
  });
167986
- }), o.forEach(({ range: a }) => {
167987
- n.addMark(
167988
- a.from,
167989
- a.to,
168001
+ }), l.forEach(({ range: d }) => {
168002
+ s.addMark(
168003
+ d.from,
168004
+ d.to,
167990
168005
  this.editor.schema.marks.comment.create({
167991
- commentId: t,
168006
+ commentId: i,
167992
168007
  resolved: !1
167993
168008
  })
167994
168009
  );
167995
- }), (s = (i = this.options).onCommentUnresolved) == null || s.call(i, t), r == null ? void 0 : r(n);
168010
+ }), (c = (u = this.options).onCommentUnresolved) == null || c.call(u, i), a == null ? void 0 : a(s);
167996
168011
  },
167997
- setCommentActive: (t) => () => t ? (this.storage.activeCommentId = t, e(t), !0) : !1,
167998
- unsetCommentActive: () => () => (this.storage.activeCommentId = null, e(null), !0)
168012
+ setCommentActive: (i) => () => {
168013
+ if (!i) return !1;
168014
+ const s = this.storage.activeCommentId;
168015
+ return s === i || (this.storage.activeCommentId = i, o(s, i)), !0;
168016
+ },
168017
+ unsetCommentActive: () => () => {
168018
+ const i = this.storage.activeCommentId;
168019
+ return i && (this.storage.activeCommentId = null, o(i, null)), !0;
168020
+ }
167999
168021
  };
168000
168022
  }
168001
168023
  });
@@ -169546,7 +169568,11 @@ User prompt: ${u} /no_think` : `${u} /no_think`;
169546
169568
  }
169547
169569
  },
169548
169570
  blur: () => {
169549
- J == null || J.commands.unsetCommentActive();
169571
+ try {
169572
+ J == null || J.commands.unsetCommentActive();
169573
+ } catch {
169574
+ return;
169575
+ }
169550
169576
  }
169551
169577
  },
169552
169578
  handleClick: (_e, Te, Be) => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "3.0.56-patch-1",
5
+ "version": "3.0.56-patch-2",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {