@fileverse-dev/ddoc 3.3.8-searchreplace-3 → 3.3.8-searchreplace-4

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.
package/dist/index.es.js CHANGED
@@ -192237,74 +192237,77 @@ function IYe(e) {
192237
192237
  return MYe(t.current, r) ? t.current : t.current = r;
192238
192238
  };
192239
192239
  }
192240
- const OYe = ({ editor: e }) => {
192241
- const [, t] = m8((C) => C + 1, 0);
192240
+ const OYe = ({
192241
+ editor: e,
192242
+ viewerMode: t
192243
+ }) => {
192244
+ const [, n] = m8((_) => _ + 1, 0);
192242
192245
  _e(() => {
192243
192246
  if (e)
192244
- return e.on("transaction", t), () => {
192245
- e.off("transaction", t);
192247
+ return e.on("transaction", n), () => {
192248
+ e.off("transaction", n);
192246
192249
  };
192247
192250
  }, [e]);
192248
- const [n, r] = Me(!1), o = Te(null), { searchTerm: i, replaceTerm: s, showSearchReplacePopover: a } = ND(
192249
- IYe((C) => ({
192250
- searchTerm: C.searchTerm,
192251
- replaceTerm: C.replaceTerm,
192252
- showSearchReplacePopover: C.showSearchReplacePopover
192251
+ const [r, o] = Me(!1), i = Te(null), { searchTerm: s, replaceTerm: a, showSearchReplacePopover: l } = ND(
192252
+ IYe((_) => ({
192253
+ searchTerm: _.searchTerm,
192254
+ replaceTerm: _.replaceTerm,
192255
+ showSearchReplacePopover: _.showSearchReplacePopover
192253
192256
  }))
192254
- ), { setShowReplacePopover: l, setSearchTerm: u, setReplaceTerm: c } = ND((C) => C.actions);
192255
- function d() {
192256
- e && e.commands.setSearchTerm(""), l(!1);
192257
+ ), { setShowReplacePopover: u, setSearchTerm: c, setReplaceTerm: d } = ND((_) => _.actions);
192258
+ function p() {
192259
+ e && e.commands.setSearchTerm(""), u(!1);
192257
192260
  }
192258
- Bz("keydown", (C) => {
192259
- C.code === "KeyF" && C.metaKey && (C.preventDefault(), e && kq(e));
192260
- }), Bte(d);
192261
- const h = e == null ? void 0 : e.storage.searchAndReplace.results, f = e == null ? void 0 : e.storage.searchAndReplace.resultIndex;
192262
- function g() {
192263
- r((C) => !C);
192261
+ Bz("keydown", (_) => {
192262
+ t === "suggest" || t == "view-only" || _.code === "KeyF" && _.metaKey && (_.preventDefault(), e && kq(e));
192263
+ }), Bte(p);
192264
+ const f = e == null ? void 0 : e.storage.searchAndReplace.results, g = e == null ? void 0 : e.storage.searchAndReplace.resultIndex;
192265
+ function m() {
192266
+ o((_) => !_);
192264
192267
  }
192265
- function m(C) {
192268
+ function b(_) {
192266
192269
  if (!e) return;
192267
- const { value: _ } = C.target;
192268
- u(_), e.commands.setSearchTerm(_), e.commands.resetIndex();
192270
+ const { value: I } = _.target;
192271
+ c(I), e.commands.setSearchTerm(I), e.commands.resetIndex();
192269
192272
  }
192270
- function b(C) {
192273
+ function y(_) {
192271
192274
  if (!e) return;
192272
- const { value: _ } = C.target;
192273
- c(_), e.commands.setReplaceTerm(_), e.commands.resetIndex();
192275
+ const { value: I } = _.target;
192276
+ d(I), e.commands.setReplaceTerm(I), e.commands.resetIndex();
192274
192277
  }
192275
- function y() {
192278
+ function F() {
192276
192279
  e && e.commands.replace();
192277
192280
  }
192278
- function F() {
192281
+ function v() {
192279
192282
  e && e.commands.replaceAll();
192280
192283
  }
192281
- function v() {
192284
+ function D() {
192282
192285
  if (!e) return;
192283
- const { results: C, resultIndex: _ } = e.storage.searchAndReplace, I = C[_];
192284
- if (!I) return;
192285
- const { node: j } = e.view.domAtPos(I.from);
192286
- j instanceof HTMLElement && Bme({
192287
- el: j,
192286
+ const { results: _, resultIndex: I } = e.storage.searchAndReplace, j = _[I];
192287
+ if (!j) return;
192288
+ const { node: A } = e.view.domAtPos(j.from);
192289
+ A instanceof HTMLElement && Bme({
192290
+ el: A,
192288
192291
  editorRoot: e.view.dom,
192289
192292
  isNativeMobile: !1
192290
192293
  });
192291
192294
  }
192292
- function D() {
192293
- e && (e.commands.nextSearchResult(), v());
192294
- }
192295
192295
  function w() {
192296
- e && (e.commands.previousSearchResult(), v());
192296
+ e && (e.commands.nextSearchResult(), D());
192297
+ }
192298
+ function k() {
192299
+ e && (e.commands.previousSearchResult(), D());
192297
192300
  }
192298
- function k(C) {
192299
- if (C.code === "Enter") {
192300
- if (C.shiftKey) {
192301
- w();
192301
+ function C(_) {
192302
+ if (_.code === "Enter") {
192303
+ if (_.shiftKey) {
192304
+ k();
192302
192305
  return;
192303
192306
  }
192304
- D();
192307
+ w();
192305
192308
  }
192306
192309
  }
192307
- return /* @__PURE__ */ x.jsxs(Dh, { open: a, children: [
192310
+ return /* @__PURE__ */ x.jsxs(Dh, { open: l, children: [
192308
192311
  /* @__PURE__ */ x.jsx(qne, { className: "absolute right-0" }),
192309
192312
  /* @__PURE__ */ x.jsx(
192310
192313
  kh,
@@ -192321,15 +192324,15 @@ const OYe = ({ editor: e }) => {
192321
192324
  Ba,
192322
192325
  {
192323
192326
  placeholder: "Search text...",
192324
- value: i,
192325
- ref: o,
192327
+ value: s,
192328
+ ref: i,
192326
192329
  className: "border-none p-0",
192327
- onChange: m,
192328
- onKeyDown: k
192330
+ onChange: b,
192331
+ onKeyDown: C
192329
192332
  }
192330
192333
  ),
192331
- h && /* @__PURE__ */ x.jsx(x.Fragment, { children: h.length > 0 ? /* @__PURE__ */ x.jsx("span", { className: "color-text-secondary text-sm", children: `${typeof f == "number" ? f + 1 : "?"}/${h.length}` }) : /* @__PURE__ */ x.jsx("span", { className: "color-text-secondary text-xs shrink-0", children: "No results found." }) }),
192332
- h && h.length > 0 && /* @__PURE__ */ x.jsxs("div", { className: "flex items-center", children: [
192334
+ f && /* @__PURE__ */ x.jsx(x.Fragment, { children: f.length > 0 ? /* @__PURE__ */ x.jsx("span", { className: "color-text-secondary text-sm", children: `${typeof g == "number" ? g + 1 : "?"}/${f.length}` }) : /* @__PURE__ */ x.jsx("span", { className: "color-text-secondary text-xs shrink-0", children: "No results found." }) }),
192335
+ f && f.length > 0 && /* @__PURE__ */ x.jsxs("div", { className: "flex items-center", children: [
192333
192336
  /* @__PURE__ */ x.jsxs("div", { className: "flex items-center", children: [
192334
192337
  /* @__PURE__ */ x.jsx(cn, { text: "Previous", children: /* @__PURE__ */ x.jsx(
192335
192338
  Yt,
@@ -192337,7 +192340,7 @@ const OYe = ({ editor: e }) => {
192337
192340
  icon: "ArrowUp",
192338
192341
  variant: "ghost",
192339
192342
  size: "sm",
192340
- onClick: w
192343
+ onClick: k
192341
192344
  }
192342
192345
  ) }),
192343
192346
  /* @__PURE__ */ x.jsx(cn, { text: "Next", children: /* @__PURE__ */ x.jsx(
@@ -192346,7 +192349,7 @@ const OYe = ({ editor: e }) => {
192346
192349
  icon: "ArrowDown",
192347
192350
  variant: "ghost",
192348
192351
  size: "sm",
192349
- onClick: D
192352
+ onClick: w
192350
192353
  }
192351
192354
  ) })
192352
192355
  ] }),
@@ -192356,13 +192359,13 @@ const OYe = ({ editor: e }) => {
192356
192359
  icon: "Replace",
192357
192360
  variant: "ghost",
192358
192361
  size: "sm",
192359
- onClick: g
192362
+ onClick: m
192360
192363
  }
192361
192364
  ) })
192362
192365
  ] }),
192363
- /* @__PURE__ */ x.jsx(_x, { asChild: !0, onClick: d, children: /* @__PURE__ */ x.jsx(Yt, { icon: "X", variant: "ghost", size: "sm" }) })
192366
+ /* @__PURE__ */ x.jsx(_x, { asChild: !0, onClick: p, children: /* @__PURE__ */ x.jsx(Yt, { icon: "X", variant: "ghost", size: "sm" }) })
192364
192367
  ] }),
192365
- /* @__PURE__ */ x.jsx(np, { children: n && /* @__PURE__ */ x.jsxs(
192368
+ /* @__PURE__ */ x.jsx(np, { children: r && /* @__PURE__ */ x.jsxs(
192366
192369
  Is.div,
192367
192370
  {
192368
192371
  className: "space-y-2 overflow-clip",
@@ -192375,8 +192378,8 @@ const OYe = ({ editor: e }) => {
192375
192378
  Ba,
192376
192379
  {
192377
192380
  placeholder: "Replace with...",
192378
- value: s,
192379
- onChange: b,
192381
+ value: a,
192382
+ onChange: y,
192380
192383
  className: "border-none p-0"
192381
192384
  }
192382
192385
  ) }),
@@ -192387,7 +192390,7 @@ const OYe = ({ editor: e }) => {
192387
192390
  variant: "secondary",
192388
192391
  size: "sm",
192389
192392
  className: "min-w-0 text-body-sm-bold",
192390
- onClick: F,
192393
+ onClick: v,
192391
192394
  children: "Replace All"
192392
192395
  }
192393
192396
  ),
@@ -192397,7 +192400,7 @@ const OYe = ({ editor: e }) => {
192397
192400
  variant: "default",
192398
192401
  size: "sm",
192399
192402
  className: "min-w-0 text-body-sm-bold",
192400
- onClick: y,
192403
+ onClick: F,
192401
192404
  children: "Replace"
192402
192405
  }
192403
192406
  )
@@ -193288,7 +193291,7 @@ const OYe = ({ editor: e }) => {
193288
193291
  ),
193289
193292
  style: $e ? void 0 : xt(),
193290
193293
  children: [
193291
- /* @__PURE__ */ x.jsx(OYe, { editor: jt }),
193294
+ /* @__PURE__ */ x.jsx(OYe, { editor: jt, viewerMode: t }),
193292
193295
  /* @__PURE__ */ x.jsx(
193293
193296
  "nav",
193294
193297
  {
@@ -1,6 +1,7 @@
1
1
  import { Editor } from '@tiptap/core';
2
2
 
3
- declare const SearchReplace: ({ editor }: {
3
+ declare const SearchReplace: ({ editor, viewerMode, }: {
4
4
  editor: Editor | null;
5
+ viewerMode?: "suggest" | "view-only";
5
6
  }) => import("react/jsx-runtime").JSX.Element;
6
7
  export default SearchReplace;
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.3.8-searchreplace-3",
5
+ "version": "3.3.8-searchreplace-4",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {