@carlonicora/nextjs-jsonapi 1.4.0 → 1.6.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.
- package/README.md +208 -127
- package/dist/{ApiResponseInterface-DDI7QQPR.d.ts → ApiResponseInterface-CfcC7pPC.d.mts} +11 -2
- package/dist/{ApiResponseInterface-BHN5D9r5.d.mts → ApiResponseInterface-DTBJaV5R.d.ts} +11 -2
- package/dist/{BlockNoteEditor-QV6ESIQA.js → BlockNoteEditor-7FM7B737.js} +19 -24
- package/dist/BlockNoteEditor-7FM7B737.js.map +1 -0
- package/dist/{BlockNoteEditor-U2IHUVUF.mjs → BlockNoteEditor-RVL76ZAS.mjs} +11 -16
- package/dist/BlockNoteEditor-RVL76ZAS.mjs.map +1 -0
- package/dist/JsonApiRequest-KOKGVPBI.js +25 -0
- package/dist/{JsonApiRequest-UJ7FGIVI.js.map → JsonApiRequest-KOKGVPBI.js.map} +1 -1
- package/dist/{JsonApiRequest-6UR7DIAR.mjs → JsonApiRequest-VCCRO732.mjs} +2 -2
- package/dist/chunk-2Z56AS2S.js +2723 -0
- package/dist/chunk-2Z56AS2S.js.map +1 -0
- package/dist/{chunk-HTLEKZND.mjs → chunk-37NJZ2VD.mjs} +281 -1019
- package/dist/chunk-37NJZ2VD.mjs.map +1 -0
- package/dist/{chunk-2K3Q24UF.js → chunk-3ZPK4QOB.js} +24 -14
- package/dist/chunk-3ZPK4QOB.js.map +1 -0
- package/dist/chunk-AGWQ75PQ.js +142 -0
- package/dist/chunk-AGWQ75PQ.js.map +1 -0
- package/dist/{chunk-32HM6MDD.js → chunk-CSM6AIAP.js} +1 -1
- package/dist/{chunk-32HM6MDD.js.map → chunk-CSM6AIAP.js.map} +1 -1
- package/dist/{chunk-IKBA4AHN.mjs → chunk-F4Y3GZG4.mjs} +3 -3
- package/dist/{chunk-YF5XQZDR.mjs → chunk-F5UNXZ3J.mjs} +1 -1
- package/dist/chunk-F5UNXZ3J.mjs.map +1 -0
- package/dist/chunk-IGOWVLJH.mjs +142 -0
- package/dist/chunk-IGOWVLJH.mjs.map +1 -0
- package/dist/{chunk-HAG77QBV.mjs → chunk-K4W5QXL5.mjs} +1 -1
- package/dist/chunk-KFL5ZFM4.mjs +2723 -0
- package/dist/chunk-KFL5ZFM4.mjs.map +1 -0
- package/dist/{chunk-HR4H2FP7.mjs → chunk-KJ4ETLJB.mjs} +24 -14
- package/dist/chunk-KJ4ETLJB.mjs.map +1 -0
- package/dist/chunk-LOSPCUCF.js +637 -0
- package/dist/chunk-LOSPCUCF.js.map +1 -0
- package/dist/{chunk-E2HRC2OG.js → chunk-SVX7E6RR.js} +10360 -6256
- package/dist/chunk-SVX7E6RR.js.map +1 -0
- package/dist/{chunk-EFJEWLRL.js → chunk-YUO55Q5A.js} +1 -1
- package/dist/chunk-YUO55Q5A.js.map +1 -0
- package/dist/chunk-ZQTFZKLJ.mjs +12089 -0
- package/dist/chunk-ZQTFZKLJ.mjs.map +1 -0
- package/dist/{chunk-PMXG5WBC.js → chunk-ZUEEIQHW.js} +3 -3
- package/dist/{chunk-PMXG5WBC.js.map → chunk-ZUEEIQHW.js.map} +1 -1
- package/dist/client/index.d.mts +161 -11
- package/dist/client/index.d.ts +161 -11
- package/dist/client/index.js +74 -12
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +73 -11
- package/dist/components/index.d.mts +762 -73
- package/dist/components/index.d.ts +762 -73
- package/dist/components/index.js +465 -12
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +466 -13
- package/dist/config-B43zxEvn.d.mts +69 -0
- package/dist/config-D2OUrI_G.d.ts +69 -0
- package/dist/content.fields-Ck5lkQ5d.d.mts +47 -0
- package/dist/content.fields-Ck5lkQ5d.d.ts +47 -0
- package/dist/{content.interface-C_PGZMuy.d.ts → content.interface-Bs8a7uW6.d.mts} +2 -3
- package/dist/{content.interface-D_WS6CrB.d.mts → content.interface-UtsJ-mzs.d.ts} +2 -3
- package/dist/contexts/index.d.mts +13 -6
- package/dist/contexts/index.d.ts +13 -6
- package/dist/contexts/index.js +10 -12
- package/dist/contexts/index.js.map +1 -1
- package/dist/contexts/index.mjs +9 -11
- package/dist/core/index.d.mts +539 -8
- package/dist/core/index.d.ts +539 -8
- package/dist/core/index.js +104 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +105 -3
- package/dist/index.d.mts +131 -70
- package/dist/index.d.ts +131 -70
- package/dist/index.js +97 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -28
- package/dist/notification.interface-BdcwkuQE.d.mts +228 -0
- package/dist/notification.interface-BdcwkuQE.d.ts +228 -0
- package/dist/request-GBLBPYFM.js +8 -0
- package/dist/request-GBLBPYFM.js.map +1 -0
- package/dist/request-XABCMU25.mjs +8 -0
- package/dist/{AbstractService-wLid8dB0.d.ts → s3.interface-D7ttGatc.d.ts} +36 -26
- package/dist/{AbstractService-BsY6W3Ej.d.mts → s3.interface-DlaMDRTn.d.mts} +36 -26
- package/dist/scripts/generate-web-module/generator.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/generator.js +8 -5
- package/dist/scripts/generate-web-module/generator.js.map +1 -1
- package/dist/scripts/generate-web-module/index.js +1 -1
- package/dist/scripts/generate-web-module/index.js.map +1 -1
- package/dist/scripts/generate-web-module/templates/components/editor.template.js +8 -1
- package/dist/scripts/generate-web-module/templates/components/editor.template.js.map +1 -1
- package/dist/scripts/generate-web-module/transformers/parent-detector.d.ts +4 -3
- package/dist/scripts/generate-web-module/transformers/parent-detector.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/transformers/parent-detector.js +9 -3
- package/dist/scripts/generate-web-module/transformers/parent-detector.js.map +1 -1
- package/dist/scripts/generate-web-module/transformers/relationship-resolver.d.ts +11 -0
- package/dist/scripts/generate-web-module/transformers/relationship-resolver.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/transformers/relationship-resolver.js +36 -9
- package/dist/scripts/generate-web-module/transformers/relationship-resolver.js.map +1 -1
- package/dist/scripts/generate-web-module/types/json-schema.interface.d.ts +2 -0
- package/dist/scripts/generate-web-module/types/json-schema.interface.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/types/template-data.interface.d.ts +1 -0
- package/dist/scripts/generate-web-module/types/template-data.interface.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/utils/i18n-updater.d.ts +4 -3
- package/dist/scripts/generate-web-module/utils/i18n-updater.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/utils/i18n-updater.js +9 -9
- package/dist/scripts/generate-web-module/utils/i18n-updater.js.map +1 -1
- package/dist/scripts/generate-web-module/validators/json-schema-validator.js +3 -3
- package/dist/scripts/generate-web-module/validators/json-schema-validator.js.map +1 -1
- package/dist/server/index.d.mts +299 -4
- package/dist/server/index.d.ts +299 -4
- package/dist/server/index.js +215 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +214 -4
- package/dist/server/index.mjs.map +1 -1
- package/dist/token-2UWQJY5T.js +8 -0
- package/dist/token-2UWQJY5T.js.map +1 -0
- package/dist/token-EOK3N45S.mjs +8 -0
- package/dist/{useSocket-DzMKRKCA.d.ts → useSocket-8vwK_R_c.d.ts} +1 -1
- package/dist/{useSocket-Cn7fB_B1.d.mts → useSocket-BWJUXuOl.d.mts} +1 -1
- package/package.json +12 -52
- package/scripts/generate-web-module/generator.ts +8 -5
- package/scripts/generate-web-module/index.ts +1 -1
- package/scripts/generate-web-module/templates/components/editor.template.ts +7 -2
- package/scripts/generate-web-module/transformers/parent-detector.ts +10 -3
- package/scripts/generate-web-module/transformers/relationship-resolver.ts +36 -9
- package/scripts/generate-web-module/types/json-schema.interface.ts +2 -0
- package/scripts/generate-web-module/types/template-data.interface.ts +1 -0
- package/scripts/generate-web-module/utils/i18n-updater.ts +9 -9
- package/scripts/generate-web-module/validators/json-schema-validator.ts +3 -3
- package/src/client/JsonApiClient.ts +248 -0
- package/src/client/config.ts +78 -0
- package/src/client/index.ts +6 -1
- package/src/components/containers/TabsContainer.tsx +1 -1
- package/src/components/editors/BlockNoteEditor.tsx +3 -1
- package/src/components/index.ts +4 -0
- package/src/components/navigations/Breadcrumb.tsx +1 -1
- package/src/components/navigations/Header.tsx +2 -2
- package/src/contexts/CommonContext.tsx +1 -1
- package/src/contexts/SocketContext.tsx +1 -1
- package/src/contexts/index.ts +3 -0
- package/src/core/abstracts/ClientAbstractService.ts +255 -0
- package/src/core/abstracts/ServerAbstractService.ts +180 -0
- package/src/core/abstracts/index.ts +2 -0
- package/src/core/index.ts +32 -3
- package/src/discord/config.ts +15 -0
- package/src/discord/index.ts +1 -0
- package/src/features/auth/components/details/LandingComponent.tsx +2 -2
- package/src/features/auth/components/forms/AcceptInvitation.tsx +1 -1
- package/src/features/auth/components/forms/ActivateAccount.tsx +1 -1
- package/src/features/auth/components/forms/Cookies.tsx +2 -1
- package/src/features/auth/components/forms/ForgotPassword.tsx +1 -1
- package/src/features/auth/components/forms/Login.tsx +1 -1
- package/src/features/auth/components/forms/Logout.tsx +1 -1
- package/src/features/auth/components/forms/RefreshUser.tsx +2 -1
- package/src/features/auth/components/forms/Register.tsx +1 -1
- package/src/features/auth/components/forms/ResetPassword.tsx +1 -1
- package/src/features/auth/data/auth.service.ts +1 -1
- package/src/features/auth/data/index.ts +0 -1
- package/src/features/auth/utils/AuthCookies.ts +1 -1
- package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +4 -2
- package/src/features/company/components/forms/CompanyDeleter.tsx +2 -1
- package/src/features/company/components/forms/CompanyEditor.tsx +6 -3
- package/src/features/company/components/forms/CompanyLicense.tsx +4 -2
- package/src/features/company/components/lists/CompaniesList.tsx +2 -1
- package/src/features/company/data/index.ts +0 -1
- package/src/features/content/components/lists/ContentsListById.tsx +2 -1
- package/src/features/content/components/lists/RelevantContentsList.tsx +2 -1
- package/src/features/content/data/index.ts +0 -1
- package/src/features/feature/data/index.ts +0 -1
- package/src/features/notification/components/lists/NotificationsList.tsx +2 -1
- package/src/features/notification/contexts/NotificationContext.tsx +2 -1
- package/src/features/notification/data/index.ts +0 -1
- package/src/features/push/data/index.ts +0 -1
- package/src/features/role/components/forms/RemoveUserFromRole.tsx +4 -2
- package/src/features/role/components/forms/UserRoleAdd.tsx +2 -1
- package/src/features/role/components/lists/RolesList.tsx +2 -1
- package/src/features/role/components/lists/UserRolesList.tsx +2 -1
- package/src/features/role/data/index.ts +0 -1
- package/src/features/s3/data/index.ts +0 -1
- package/src/features/user/components/forms/RoleUserAdd.tsx +4 -2
- package/src/features/user/components/forms/UserDeleter.tsx +2 -1
- package/src/features/user/components/forms/UserEditor.tsx +6 -3
- package/src/features/user/components/forms/UserMultiSelect.tsx +2 -1
- package/src/features/user/components/forms/UserReactivator.tsx +2 -1
- package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -1
- package/src/features/user/components/forms/UserSelector.tsx +2 -1
- package/src/features/user/components/lists/AdminUsersList.tsx +2 -1
- package/src/features/user/components/lists/CompanyUsersList.tsx +2 -1
- package/src/features/user/components/lists/RelevantUsersList.tsx +2 -1
- package/src/features/user/components/lists/RoleUsersList.tsx +2 -1
- package/src/features/user/components/lists/UsersListByContentIds.tsx +2 -1
- package/src/features/user/data/index.ts +0 -1
- package/src/features/user/hooks/useUserSearch.ts +2 -1
- package/src/features/user/index.ts +1 -0
- package/src/hooks/useDataListRetriever.ts +4 -4
- package/src/hooks/usePageTracker.ts +1 -1
- package/src/hooks/usePushNotifications.ts +3 -2
- package/src/hooks/useSocket.ts +1 -1
- package/src/index.ts +7 -2
- package/src/roles/config.ts +0 -15
- package/src/roles/index.ts +1 -9
- package/src/server/JsonApiServer.ts +249 -0
- package/src/server/cache.ts +1 -1
- package/src/server/index.ts +13 -0
- package/src/server/request.ts +32 -18
- package/src/server/token.ts +1 -1
- package/dist/ApiData-DPKNfY-9.d.mts +0 -10
- package/dist/ApiData-DPKNfY-9.d.ts +0 -10
- package/dist/ApiDataInterface-DPP8s46n.d.mts +0 -21
- package/dist/ApiDataInterface-DPP8s46n.d.ts +0 -21
- package/dist/BlockNoteEditor-QV6ESIQA.js.map +0 -1
- package/dist/BlockNoteEditor-U2IHUVUF.mjs.map +0 -1
- package/dist/JsonApiRequest-UJ7FGIVI.js +0 -25
- package/dist/atoms/index.d.mts +0 -12
- package/dist/atoms/index.d.ts +0 -12
- package/dist/atoms/index.js +0 -9
- package/dist/atoms/index.js.map +0 -1
- package/dist/atoms/index.mjs +0 -9
- package/dist/chunk-2K3Q24UF.js.map +0 -1
- package/dist/chunk-3FBCC4G3.js +0 -8
- package/dist/chunk-3FBCC4G3.js.map +0 -1
- package/dist/chunk-3UELCPIN.js +0 -46
- package/dist/chunk-3UELCPIN.js.map +0 -1
- package/dist/chunk-5IET37O4.js +0 -4210
- package/dist/chunk-5IET37O4.js.map +0 -1
- package/dist/chunk-AYHKQWHH.js +0 -68
- package/dist/chunk-AYHKQWHH.js.map +0 -1
- package/dist/chunk-DEYKTLA3.js +0 -1131
- package/dist/chunk-DEYKTLA3.js.map +0 -1
- package/dist/chunk-E2HRC2OG.js.map +0 -1
- package/dist/chunk-EFJEWLRL.js.map +0 -1
- package/dist/chunk-FMBQZAIP.mjs +0 -490
- package/dist/chunk-FMBQZAIP.mjs.map +0 -1
- package/dist/chunk-HR4H2FP7.mjs.map +0 -1
- package/dist/chunk-HTLEKZND.mjs.map +0 -1
- package/dist/chunk-JGFWIT2E.mjs +0 -1131
- package/dist/chunk-JGFWIT2E.mjs.map +0 -1
- package/dist/chunk-P2F54I7Q.mjs +0 -4210
- package/dist/chunk-P2F54I7Q.mjs.map +0 -1
- package/dist/chunk-PO5Q3H5I.js +0 -1375
- package/dist/chunk-PO5Q3H5I.js.map +0 -1
- package/dist/chunk-Q2N6SQYW.mjs +0 -8
- package/dist/chunk-Q2N6SQYW.mjs.map +0 -1
- package/dist/chunk-Q4FXESVT.js +0 -490
- package/dist/chunk-Q4FXESVT.js.map +0 -1
- package/dist/chunk-R2ONK22M.mjs +0 -7985
- package/dist/chunk-R2ONK22M.mjs.map +0 -1
- package/dist/chunk-SM63SZCP.mjs +0 -68
- package/dist/chunk-SM63SZCP.mjs.map +0 -1
- package/dist/chunk-SZZYEG3P.mjs +0 -46
- package/dist/chunk-SZZYEG3P.mjs.map +0 -1
- package/dist/chunk-YF5XQZDR.mjs.map +0 -1
- package/dist/config-BmnK65TD.d.mts +0 -35
- package/dist/config-BmnK65TD.d.ts +0 -35
- package/dist/config-DQeAo9Kf.d.mts +0 -49
- package/dist/config-DQeAo9Kf.d.ts +0 -49
- package/dist/content.fields-cHPdM8GJ.d.mts +0 -27
- package/dist/content.fields-cHPdM8GJ.d.ts +0 -27
- package/dist/d3.link.interface-ClC4Irqp.d.mts +0 -21
- package/dist/d3.link.interface-ClC4Irqp.d.ts +0 -21
- package/dist/features/index.d.mts +0 -476
- package/dist/features/index.d.ts +0 -476
- package/dist/features/index.js +0 -87
- package/dist/features/index.js.map +0 -1
- package/dist/features/index.mjs +0 -87
- package/dist/hooks/index.d.mts +0 -69
- package/dist/hooks/index.d.ts +0 -69
- package/dist/hooks/index.js +0 -56
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs +0 -56
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/interfaces/index.d.mts +0 -4
- package/dist/interfaces/index.d.ts +0 -4
- package/dist/interfaces/index.js +0 -2
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/index.mjs +0 -2
- package/dist/interfaces/index.mjs.map +0 -1
- package/dist/notification.interface-BBgMUdLR.d.mts +0 -14
- package/dist/notification.interface-gyvT-Z2F.d.ts +0 -14
- package/dist/permissions/index.d.mts +0 -41
- package/dist/permissions/index.d.ts +0 -41
- package/dist/permissions/index.js +0 -14
- package/dist/permissions/index.js.map +0 -1
- package/dist/permissions/index.mjs +0 -14
- package/dist/permissions/index.mjs.map +0 -1
- package/dist/request-7FE3LJLV.mjs +0 -9
- package/dist/request-7FE3LJLV.mjs.map +0 -1
- package/dist/request-QFS7NEIE.js +0 -9
- package/dist/request-QFS7NEIE.js.map +0 -1
- package/dist/roles/index.d.mts +0 -39
- package/dist/roles/index.d.ts +0 -39
- package/dist/roles/index.js +0 -18
- package/dist/roles/index.js.map +0 -1
- package/dist/roles/index.mjs +0 -18
- package/dist/roles/index.mjs.map +0 -1
- package/dist/shadcnui/index.d.mts +0 -698
- package/dist/shadcnui/index.d.ts +0 -698
- package/dist/shadcnui/index.js +0 -468
- package/dist/shadcnui/index.js.map +0 -1
- package/dist/shadcnui/index.mjs +0 -467
- package/dist/shadcnui/index.mjs.map +0 -1
- package/dist/token-IJSPOMW6.mjs +0 -9
- package/dist/token-IJSPOMW6.mjs.map +0 -1
- package/dist/token-UYE7CV6X.js +0 -9
- package/dist/token-UYE7CV6X.js.map +0 -1
- package/dist/types-B2QRyqyK.d.ts +0 -39
- package/dist/types-CgvNmxTd.d.mts +0 -39
- package/dist/types-t2PyXhDu.d.mts +0 -116
- package/dist/types-t2PyXhDu.d.ts +0 -116
- package/dist/user.interface-CAsTIbuQ.d.mts +0 -85
- package/dist/user.interface-CbWqMaaU.d.ts +0 -85
- package/dist/utils/index.d.mts +0 -224
- package/dist/utils/index.d.ts +0 -224
- package/dist/utils/index.js +0 -46
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/index.mjs +0 -46
- package/dist/utils/index.mjs.map +0 -1
- /package/dist/{JsonApiRequest-6UR7DIAR.mjs.map → JsonApiRequest-VCCRO732.mjs.map} +0 -0
- /package/dist/{chunk-IKBA4AHN.mjs.map → chunk-F4Y3GZG4.mjs.map} +0 -0
- /package/dist/{chunk-HAG77QBV.mjs.map → chunk-K4W5QXL5.mjs.map} +0 -0
- /package/dist/{atoms/index.mjs.map → request-XABCMU25.mjs.map} +0 -0
- /package/dist/{features/index.mjs.map → token-EOK3N45S.mjs.map} +0 -0
package/dist/chunk-JGFWIT2E.mjs
DELETED
|
@@ -1,1131 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
Modules
|
|
4
|
-
} from "./chunk-FMBQZAIP.mjs";
|
|
5
|
-
import {
|
|
6
|
-
__name
|
|
7
|
-
} from "./chunk-PAWJFY3S.mjs";
|
|
8
|
-
|
|
9
|
-
// src/utils/cn.ts
|
|
10
|
-
import { clsx } from "clsx";
|
|
11
|
-
import { twMerge } from "tailwind-merge";
|
|
12
|
-
function cn(...inputs) {
|
|
13
|
-
return twMerge(clsx(inputs));
|
|
14
|
-
}
|
|
15
|
-
__name(cn, "cn");
|
|
16
|
-
|
|
17
|
-
// src/utils/compose-refs.ts
|
|
18
|
-
import * as React from "react";
|
|
19
|
-
function setRef(ref, value) {
|
|
20
|
-
if (typeof ref === "function") {
|
|
21
|
-
return ref(value);
|
|
22
|
-
}
|
|
23
|
-
if (ref !== null && ref !== void 0) {
|
|
24
|
-
ref.current = value;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
__name(setRef, "setRef");
|
|
28
|
-
function composeRefs(...refs) {
|
|
29
|
-
return (node) => {
|
|
30
|
-
let hasCleanup = false;
|
|
31
|
-
const cleanups = refs.map((ref) => {
|
|
32
|
-
const cleanup = setRef(ref, node);
|
|
33
|
-
if (!hasCleanup && typeof cleanup === "function") {
|
|
34
|
-
hasCleanup = true;
|
|
35
|
-
}
|
|
36
|
-
return cleanup;
|
|
37
|
-
});
|
|
38
|
-
if (hasCleanup) {
|
|
39
|
-
return () => {
|
|
40
|
-
for (let i = 0; i < cleanups.length; i++) {
|
|
41
|
-
const cleanup = cleanups[i];
|
|
42
|
-
if (typeof cleanup === "function") {
|
|
43
|
-
cleanup();
|
|
44
|
-
} else {
|
|
45
|
-
setRef(refs[i], null);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
__name(composeRefs, "composeRefs");
|
|
53
|
-
function useComposedRefs(...refs) {
|
|
54
|
-
return React.useCallback(composeRefs(...refs), refs);
|
|
55
|
-
}
|
|
56
|
-
__name(useComposedRefs, "useComposedRefs");
|
|
57
|
-
|
|
58
|
-
// src/utils/use-mobile.tsx
|
|
59
|
-
import * as React2 from "react";
|
|
60
|
-
var MOBILE_BREAKPOINT = 768;
|
|
61
|
-
function useIsMobile() {
|
|
62
|
-
const [isMobile, setIsMobile] = React2.useState(void 0);
|
|
63
|
-
React2.useEffect(() => {
|
|
64
|
-
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
65
|
-
const onChange = /* @__PURE__ */ __name(() => {
|
|
66
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
67
|
-
}, "onChange");
|
|
68
|
-
mql.addEventListener("change", onChange);
|
|
69
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
70
|
-
return () => mql.removeEventListener("change", onChange);
|
|
71
|
-
}, []);
|
|
72
|
-
return !!isMobile;
|
|
73
|
-
}
|
|
74
|
-
__name(useIsMobile, "useIsMobile");
|
|
75
|
-
|
|
76
|
-
// src/utils/date-formatter.ts
|
|
77
|
-
var formatDate = /* @__PURE__ */ __name((eventDate, formatOption) => {
|
|
78
|
-
const browserLocale = navigator.language || "en-US";
|
|
79
|
-
const formatPart = /* @__PURE__ */ __name((date, options) => new Intl.DateTimeFormat(browserLocale, options).format(date), "formatPart");
|
|
80
|
-
const now = /* @__PURE__ */ new Date();
|
|
81
|
-
const diff = now.getTime() - eventDate.getTime();
|
|
82
|
-
if (formatOption === "default") {
|
|
83
|
-
if (diff < 24 * 60 * 60 * 1e3) formatOption = "timeSince";
|
|
84
|
-
else formatOption = "dateTime";
|
|
85
|
-
}
|
|
86
|
-
if (formatOption === "timeSince") {
|
|
87
|
-
const seconds = Math.floor(diff / 1e3);
|
|
88
|
-
const minutes = Math.floor(seconds / 60);
|
|
89
|
-
const hours = Math.floor(minutes / 60);
|
|
90
|
-
const days = Math.floor(hours / 24);
|
|
91
|
-
if (days > 0) return `${days} days ago`;
|
|
92
|
-
if (hours > 0) return `${hours} hours ago`;
|
|
93
|
-
if (minutes > 0) return `${minutes} minutes ago`;
|
|
94
|
-
return `${seconds} seconds ago`;
|
|
95
|
-
}
|
|
96
|
-
const dateOptions = {
|
|
97
|
-
year: "numeric",
|
|
98
|
-
month: "2-digit",
|
|
99
|
-
day: "2-digit"
|
|
100
|
-
};
|
|
101
|
-
const timeOptions = {
|
|
102
|
-
hour: "2-digit",
|
|
103
|
-
minute: "2-digit"
|
|
104
|
-
};
|
|
105
|
-
switch (formatOption) {
|
|
106
|
-
case "date":
|
|
107
|
-
return formatPart(eventDate, dateOptions);
|
|
108
|
-
case "time":
|
|
109
|
-
return formatPart(eventDate, timeOptions);
|
|
110
|
-
case "dateTime":
|
|
111
|
-
return `${formatPart(eventDate, dateOptions)} ${formatPart(eventDate, timeOptions)}`;
|
|
112
|
-
default:
|
|
113
|
-
throw new Error("Invalid format option");
|
|
114
|
-
}
|
|
115
|
-
}, "formatDate");
|
|
116
|
-
|
|
117
|
-
// src/utils/exists.ts
|
|
118
|
-
var exists = /* @__PURE__ */ __name((itemOrArray) => {
|
|
119
|
-
if (!itemOrArray) return false;
|
|
120
|
-
if (Array.isArray(itemOrArray)) {
|
|
121
|
-
return itemOrArray.length > 0;
|
|
122
|
-
}
|
|
123
|
-
return true;
|
|
124
|
-
}, "exists");
|
|
125
|
-
|
|
126
|
-
// src/utils/table-options.ts
|
|
127
|
-
import { cloneElement, createElement, Fragment } from "react";
|
|
128
|
-
var TableOptions = class {
|
|
129
|
-
static {
|
|
130
|
-
__name(this, "TableOptions");
|
|
131
|
-
}
|
|
132
|
-
_components;
|
|
133
|
-
_hasPermissionToModule;
|
|
134
|
-
constructor(hasPermissionToModule) {
|
|
135
|
-
this._hasPermissionToModule = hasPermissionToModule;
|
|
136
|
-
this._components = [];
|
|
137
|
-
}
|
|
138
|
-
addOption(component, module, action) {
|
|
139
|
-
if (!component || module && action && !this._hasPermissionToModule({ module, action })) return;
|
|
140
|
-
this._components.push(component);
|
|
141
|
-
}
|
|
142
|
-
getComponents() {
|
|
143
|
-
return this._components;
|
|
144
|
-
}
|
|
145
|
-
getOptions() {
|
|
146
|
-
if (this._components.length === 0) return null;
|
|
147
|
-
const response = this._components.map(
|
|
148
|
-
(option, index) => cloneElement(option, { key: option.key ?? index })
|
|
149
|
-
);
|
|
150
|
-
return createElement(Fragment, {}, response);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
function getTableOptions(params) {
|
|
154
|
-
const tableOptions = new TableOptions(params.hasPermissionToModule);
|
|
155
|
-
params.options.forEach((option) => tableOptions.addOption(option.component, option.module, option.action));
|
|
156
|
-
return tableOptions.getOptions();
|
|
157
|
-
}
|
|
158
|
-
__name(getTableOptions, "getTableOptions");
|
|
159
|
-
function getTableComponents(params) {
|
|
160
|
-
const tableOptions = new TableOptions(params.hasPermissionToModule);
|
|
161
|
-
params.options.forEach((option) => tableOptions.addOption(option.component, option.module, option.action));
|
|
162
|
-
return tableOptions.getComponents();
|
|
163
|
-
}
|
|
164
|
-
__name(getTableComponents, "getTableComponents");
|
|
165
|
-
|
|
166
|
-
// src/utils/schemas/user.object.schema.ts
|
|
167
|
-
import { z } from "zod";
|
|
168
|
-
var userObjectSchema = z.object({
|
|
169
|
-
id: z.string(),
|
|
170
|
-
name: z.string(),
|
|
171
|
-
avatar: z.string().optional()
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// src/utils/schemas/entity.object.schema.ts
|
|
175
|
-
import { z as z2 } from "zod";
|
|
176
|
-
var entityObjectSchema = z2.object({
|
|
177
|
-
id: z2.uuidv4(),
|
|
178
|
-
name: z2.string()
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// src/utils/blocknote-diff.util.ts
|
|
182
|
-
var BlockNoteDiffUtil = class {
|
|
183
|
-
static {
|
|
184
|
-
__name(this, "BlockNoteDiffUtil");
|
|
185
|
-
}
|
|
186
|
-
static DEFAULT_OPTIONS = {
|
|
187
|
-
ignoreIds: false,
|
|
188
|
-
compareContent: true,
|
|
189
|
-
similarityThreshold: 0.8
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* Compare two BlockNote documents and return diff result
|
|
193
|
-
*/
|
|
194
|
-
static diff(originalBlocks = [], newBlocks = [], options = {}) {
|
|
195
|
-
const opts = { ...this.DEFAULT_OPTIONS, ...options };
|
|
196
|
-
const originalMap = /* @__PURE__ */ new Map();
|
|
197
|
-
const newMap = /* @__PURE__ */ new Map();
|
|
198
|
-
originalBlocks.forEach((block) => {
|
|
199
|
-
if (block.id) {
|
|
200
|
-
originalMap.set(block.id, block);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
newBlocks.forEach((block) => {
|
|
204
|
-
if (block.id) {
|
|
205
|
-
newMap.set(block.id, block);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
const diffBlocks = [];
|
|
209
|
-
const processedNewIds = /* @__PURE__ */ new Set();
|
|
210
|
-
for (const originalBlock of originalBlocks) {
|
|
211
|
-
const blockId = originalBlock.id;
|
|
212
|
-
const processId = blockId || crypto.randomUUID();
|
|
213
|
-
const newBlock = blockId ? newMap.get(blockId) : null;
|
|
214
|
-
if (!newBlock) {
|
|
215
|
-
const removedBlock = {
|
|
216
|
-
...originalBlock,
|
|
217
|
-
id: processId,
|
|
218
|
-
diffType: "removed",
|
|
219
|
-
diffId: `removed-${processId}`
|
|
220
|
-
};
|
|
221
|
-
diffBlocks.push(removedBlock);
|
|
222
|
-
} else {
|
|
223
|
-
if (blockId) {
|
|
224
|
-
processedNewIds.add(blockId);
|
|
225
|
-
}
|
|
226
|
-
if (this.areBlocksEqual(originalBlock, newBlock, opts)) {
|
|
227
|
-
const unchangedBlock = {
|
|
228
|
-
...newBlock,
|
|
229
|
-
diffType: "unchanged"
|
|
230
|
-
};
|
|
231
|
-
diffBlocks.push(unchangedBlock);
|
|
232
|
-
} else {
|
|
233
|
-
const wordDiffs = this.generateWordDiffs(originalBlock.content, newBlock.content, processId);
|
|
234
|
-
const modifiedBlock = {
|
|
235
|
-
...newBlock,
|
|
236
|
-
diffType: "modified",
|
|
237
|
-
originalContent: originalBlock.content,
|
|
238
|
-
diffId: `modified-${processId}`,
|
|
239
|
-
wordDiffs
|
|
240
|
-
};
|
|
241
|
-
diffBlocks.push(modifiedBlock);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
for (const newBlock of newBlocks) {
|
|
246
|
-
const blockId = newBlock.id;
|
|
247
|
-
if (blockId && processedNewIds.has(blockId)) continue;
|
|
248
|
-
const generatedId = blockId || crypto.randomUUID();
|
|
249
|
-
const addedBlock = {
|
|
250
|
-
...newBlock,
|
|
251
|
-
id: generatedId,
|
|
252
|
-
diffType: "added",
|
|
253
|
-
diffId: `added-${generatedId}`
|
|
254
|
-
};
|
|
255
|
-
diffBlocks.push(addedBlock);
|
|
256
|
-
}
|
|
257
|
-
const sortedDiffBlocks = this.sortDiffBlocks(diffBlocks, originalBlocks, newBlocks);
|
|
258
|
-
return {
|
|
259
|
-
blocks: sortedDiffBlocks,
|
|
260
|
-
hasChanges: sortedDiffBlocks.some((block) => block.diffType !== "unchanged")
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Compare two blocks for equality
|
|
265
|
-
*/
|
|
266
|
-
static areBlocksEqual(block1, block2, options) {
|
|
267
|
-
if (block1.type !== block2.type) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
if (!this.deepEqual(block1.props, block2.props)) {
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
if (options.compareContent) {
|
|
274
|
-
if (!this.deepEqual(block1.content, block2.content)) {
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
const children1 = block1.children || [];
|
|
279
|
-
const children2 = block2.children || [];
|
|
280
|
-
if (children1.length !== children2.length) {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
for (let i = 0; i < children1.length; i++) {
|
|
284
|
-
if (!this.areBlocksEqual(children1[i], children2[i], options)) {
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Deep equality comparison for objects
|
|
292
|
-
*/
|
|
293
|
-
static deepEqual(obj1, obj2) {
|
|
294
|
-
if (obj1 === obj2) return true;
|
|
295
|
-
if (obj1 == null || obj2 == null) return obj1 === obj2;
|
|
296
|
-
if (typeof obj1 !== typeof obj2) return false;
|
|
297
|
-
if (typeof obj1 !== "object") return obj1 === obj2;
|
|
298
|
-
if (Array.isArray(obj1) !== Array.isArray(obj2)) return false;
|
|
299
|
-
if (Array.isArray(obj1)) {
|
|
300
|
-
if (obj1.length !== obj2.length) return false;
|
|
301
|
-
for (let i = 0; i < obj1.length; i++) {
|
|
302
|
-
if (!this.deepEqual(obj1[i], obj2[i])) return false;
|
|
303
|
-
}
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
const keys1 = Object.keys(obj1);
|
|
307
|
-
const keys2 = Object.keys(obj2);
|
|
308
|
-
if (keys1.length !== keys2.length) return false;
|
|
309
|
-
for (const key of keys1) {
|
|
310
|
-
if (!keys2.includes(key)) return false;
|
|
311
|
-
if (!this.deepEqual(obj1[key], obj2[key])) return false;
|
|
312
|
-
}
|
|
313
|
-
return true;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Sort diff blocks to maintain logical order
|
|
317
|
-
*/
|
|
318
|
-
static sortDiffBlocks(diffBlocks, originalBlocks, newBlocks) {
|
|
319
|
-
const originalPositions = /* @__PURE__ */ new Map();
|
|
320
|
-
const newPositions = /* @__PURE__ */ new Map();
|
|
321
|
-
originalBlocks.forEach((block, index) => {
|
|
322
|
-
if (block.id) {
|
|
323
|
-
originalPositions.set(block.id, index);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
newBlocks.forEach((block, index) => {
|
|
327
|
-
if (block.id) {
|
|
328
|
-
newPositions.set(block.id, index);
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
return diffBlocks.sort((a, b) => {
|
|
332
|
-
const aId = a.id;
|
|
333
|
-
const bId = b.id;
|
|
334
|
-
if (!aId || !bId) return 0;
|
|
335
|
-
const aPos = newPositions.get(aId) ?? originalPositions.get(aId) ?? Infinity;
|
|
336
|
-
const bPos = newPositions.get(bId) ?? originalPositions.get(bId) ?? Infinity;
|
|
337
|
-
return aPos - bPos;
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Calculate similarity between two text contents
|
|
342
|
-
*/
|
|
343
|
-
static calculateSimilarity(content1, content2) {
|
|
344
|
-
if (!content1 || !content2) return 0;
|
|
345
|
-
const text1 = this.extractTextFromContent(content1);
|
|
346
|
-
const text2 = this.extractTextFromContent(content2);
|
|
347
|
-
if (text1 === text2) return 1;
|
|
348
|
-
if (!text1 || !text2) return 0;
|
|
349
|
-
const maxLength = Math.max(text1.length, text2.length);
|
|
350
|
-
const distance = this.levenshteinDistance(text1, text2);
|
|
351
|
-
return 1 - distance / maxLength;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Extract plain text from BlockNote content array
|
|
355
|
-
*/
|
|
356
|
-
static extractTextFromContent(content) {
|
|
357
|
-
if (!Array.isArray(content)) return "";
|
|
358
|
-
return content.map((item) => {
|
|
359
|
-
if (item.type === "text") {
|
|
360
|
-
return item.text || "";
|
|
361
|
-
}
|
|
362
|
-
return "";
|
|
363
|
-
}).join("");
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Calculate Levenshtein distance between two strings
|
|
367
|
-
*/
|
|
368
|
-
static levenshteinDistance(str1, str2) {
|
|
369
|
-
const matrix = Array(str2.length + 1).fill(null).map(() => Array(str1.length + 1).fill(null));
|
|
370
|
-
for (let i = 0; i <= str1.length; i++) {
|
|
371
|
-
matrix[0][i] = i;
|
|
372
|
-
}
|
|
373
|
-
for (let j = 0; j <= str2.length; j++) {
|
|
374
|
-
matrix[j][0] = j;
|
|
375
|
-
}
|
|
376
|
-
for (let j = 1; j <= str2.length; j++) {
|
|
377
|
-
for (let i = 1; i <= str1.length; i++) {
|
|
378
|
-
const substitutionCost = str1[i - 1] === str2[j - 1] ? 0 : 1;
|
|
379
|
-
matrix[j][i] = Math.min(
|
|
380
|
-
matrix[j][i - 1] + 1,
|
|
381
|
-
// deletion
|
|
382
|
-
matrix[j - 1][i] + 1,
|
|
383
|
-
// insertion
|
|
384
|
-
matrix[j - 1][i - 1] + substitutionCost
|
|
385
|
-
// substitution
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
return matrix[str2.length][str1.length];
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Generate word-level diffs between two content arrays
|
|
393
|
-
*/
|
|
394
|
-
static generateWordDiffs(originalContent, newContent, blockId) {
|
|
395
|
-
const originalText = this.extractTextFromContent(originalContent || []);
|
|
396
|
-
const newText = this.extractTextFromContent(newContent || []);
|
|
397
|
-
if (!originalText && !newText) return [];
|
|
398
|
-
if (!originalText) {
|
|
399
|
-
return newText.split(/\s+/).filter((word) => word.trim()).map((word, index) => ({
|
|
400
|
-
type: "added",
|
|
401
|
-
text: word,
|
|
402
|
-
diffId: `${blockId}-add-${index}`,
|
|
403
|
-
accepted: false,
|
|
404
|
-
rejected: false
|
|
405
|
-
}));
|
|
406
|
-
}
|
|
407
|
-
if (!newText) {
|
|
408
|
-
return originalText.split(/\s+/).filter((word) => word.trim()).map((word, index) => ({
|
|
409
|
-
type: "removed",
|
|
410
|
-
text: word,
|
|
411
|
-
diffId: `${blockId}-remove-${index}`,
|
|
412
|
-
accepted: false,
|
|
413
|
-
rejected: false
|
|
414
|
-
}));
|
|
415
|
-
}
|
|
416
|
-
return this.diffWords(originalText, newText, blockId);
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Perform word-level diff using word-only approach (no space tokenization)
|
|
420
|
-
*/
|
|
421
|
-
static diffWords(text1, text2, blockId) {
|
|
422
|
-
const words1 = text1.split(/\s+/).filter((word) => word.length > 0);
|
|
423
|
-
const words2 = text2.split(/\s+/).filter((word) => word.length > 0);
|
|
424
|
-
const diffs = this.myersDiff(words1, words2);
|
|
425
|
-
const consolidatedDiffs = this.consolidateAdjacentChanges(diffs);
|
|
426
|
-
const result = [];
|
|
427
|
-
let diffIndex = 0;
|
|
428
|
-
for (let i = 0; i < consolidatedDiffs.length; i++) {
|
|
429
|
-
const diff = consolidatedDiffs[i];
|
|
430
|
-
const isLastDiff = i === consolidatedDiffs.length - 1;
|
|
431
|
-
switch (diff.type) {
|
|
432
|
-
case "equal":
|
|
433
|
-
result.push({
|
|
434
|
-
type: "unchanged",
|
|
435
|
-
text: diff.value,
|
|
436
|
-
diffId: `${blockId}-unchanged-${diffIndex++}`,
|
|
437
|
-
accepted: true,
|
|
438
|
-
rejected: false
|
|
439
|
-
});
|
|
440
|
-
if (!isLastDiff) {
|
|
441
|
-
result.push({
|
|
442
|
-
type: "unchanged",
|
|
443
|
-
text: " ",
|
|
444
|
-
diffId: `${blockId}-space-${diffIndex++}`,
|
|
445
|
-
accepted: true,
|
|
446
|
-
rejected: false
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
break;
|
|
450
|
-
case "delete":
|
|
451
|
-
if (diff.consolidated) {
|
|
452
|
-
const nextDiff = i + 1 < consolidatedDiffs.length ? consolidatedDiffs[i + 1] : null;
|
|
453
|
-
const isConsolidatedReplacement = nextDiff && nextDiff.type === "insert" && nextDiff.consolidated;
|
|
454
|
-
if (isConsolidatedReplacement) {
|
|
455
|
-
const replacementId = `${blockId}-replace-${diffIndex++}`;
|
|
456
|
-
result.push({
|
|
457
|
-
type: "removed",
|
|
458
|
-
text: diff.value,
|
|
459
|
-
diffId: replacementId,
|
|
460
|
-
accepted: false,
|
|
461
|
-
rejected: false
|
|
462
|
-
});
|
|
463
|
-
result.push({
|
|
464
|
-
type: "added",
|
|
465
|
-
text: nextDiff.value,
|
|
466
|
-
diffId: replacementId,
|
|
467
|
-
accepted: false,
|
|
468
|
-
rejected: false
|
|
469
|
-
});
|
|
470
|
-
i++;
|
|
471
|
-
if (i < consolidatedDiffs.length - 1) {
|
|
472
|
-
result.push({
|
|
473
|
-
type: "unchanged",
|
|
474
|
-
text: " ",
|
|
475
|
-
diffId: `${blockId}-space-${diffIndex++}`,
|
|
476
|
-
accepted: true,
|
|
477
|
-
rejected: false
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
} else {
|
|
481
|
-
result.push({
|
|
482
|
-
type: "removed",
|
|
483
|
-
text: diff.value,
|
|
484
|
-
diffId: `${blockId}-remove-${diffIndex++}`,
|
|
485
|
-
accepted: false,
|
|
486
|
-
rejected: false
|
|
487
|
-
});
|
|
488
|
-
if (!isLastDiff) {
|
|
489
|
-
result.push({
|
|
490
|
-
type: "unchanged",
|
|
491
|
-
text: " ",
|
|
492
|
-
diffId: `${blockId}-space-${diffIndex++}`,
|
|
493
|
-
accepted: true,
|
|
494
|
-
rejected: false
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
} else {
|
|
499
|
-
const nextDiff = i + 1 < consolidatedDiffs.length ? consolidatedDiffs[i + 1] : null;
|
|
500
|
-
const isReplacement = nextDiff && nextDiff.type === "insert" && this.areWordsSimilar(diff.value, nextDiff.value);
|
|
501
|
-
if (isReplacement) {
|
|
502
|
-
const replacementId = `${blockId}-replace-${diffIndex++}`;
|
|
503
|
-
result.push({
|
|
504
|
-
type: "removed",
|
|
505
|
-
text: diff.value,
|
|
506
|
-
diffId: replacementId,
|
|
507
|
-
accepted: false,
|
|
508
|
-
rejected: false
|
|
509
|
-
});
|
|
510
|
-
result.push({
|
|
511
|
-
type: "added",
|
|
512
|
-
text: nextDiff.value,
|
|
513
|
-
diffId: replacementId,
|
|
514
|
-
accepted: false,
|
|
515
|
-
rejected: false
|
|
516
|
-
});
|
|
517
|
-
i++;
|
|
518
|
-
if (i < consolidatedDiffs.length - 1) {
|
|
519
|
-
result.push({
|
|
520
|
-
type: "unchanged",
|
|
521
|
-
text: " ",
|
|
522
|
-
diffId: `${blockId}-space-${diffIndex++}`,
|
|
523
|
-
accepted: true,
|
|
524
|
-
rejected: false
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
} else {
|
|
528
|
-
result.push({
|
|
529
|
-
type: "removed",
|
|
530
|
-
text: diff.value,
|
|
531
|
-
diffId: `${blockId}-remove-${diffIndex++}`,
|
|
532
|
-
accepted: false,
|
|
533
|
-
rejected: false
|
|
534
|
-
});
|
|
535
|
-
if (!isLastDiff) {
|
|
536
|
-
result.push({
|
|
537
|
-
type: "unchanged",
|
|
538
|
-
text: " ",
|
|
539
|
-
diffId: `${blockId}-space-${diffIndex++}`,
|
|
540
|
-
accepted: true,
|
|
541
|
-
rejected: false
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
break;
|
|
547
|
-
case "insert":
|
|
548
|
-
if (diff.consolidated) {
|
|
549
|
-
const prevDiff = i > 0 ? consolidatedDiffs[i - 1] : null;
|
|
550
|
-
const wasProcessedAsConsolidatedReplacement = prevDiff && prevDiff.type === "delete" && prevDiff.consolidated;
|
|
551
|
-
if (!wasProcessedAsConsolidatedReplacement) {
|
|
552
|
-
result.push({
|
|
553
|
-
type: "added",
|
|
554
|
-
text: diff.value,
|
|
555
|
-
diffId: `${blockId}-add-${diffIndex++}`,
|
|
556
|
-
accepted: false,
|
|
557
|
-
rejected: false
|
|
558
|
-
});
|
|
559
|
-
if (!isLastDiff) {
|
|
560
|
-
result.push({
|
|
561
|
-
type: "unchanged",
|
|
562
|
-
text: " ",
|
|
563
|
-
diffId: `${blockId}-space-${diffIndex++}`,
|
|
564
|
-
accepted: true,
|
|
565
|
-
rejected: false
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
} else {
|
|
570
|
-
const prevDiff = i > 0 ? consolidatedDiffs[i - 1] : null;
|
|
571
|
-
const wasProcessedAsReplacement = prevDiff && prevDiff.type === "delete" && this.areWordsSimilar(prevDiff.value, diff.value);
|
|
572
|
-
if (!wasProcessedAsReplacement) {
|
|
573
|
-
result.push({
|
|
574
|
-
type: "added",
|
|
575
|
-
text: diff.value,
|
|
576
|
-
diffId: `${blockId}-add-${diffIndex++}`,
|
|
577
|
-
accepted: false,
|
|
578
|
-
rejected: false
|
|
579
|
-
});
|
|
580
|
-
if (!isLastDiff) {
|
|
581
|
-
result.push({
|
|
582
|
-
type: "unchanged",
|
|
583
|
-
text: " ",
|
|
584
|
-
diffId: `${blockId}-space-${diffIndex++}`,
|
|
585
|
-
accepted: true,
|
|
586
|
-
rejected: false
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
return result;
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* Improved diff algorithm that better handles word insertions
|
|
598
|
-
* Uses a combination of LCS and heuristics to minimize false changes
|
|
599
|
-
*/
|
|
600
|
-
static myersDiff(a, b) {
|
|
601
|
-
if (a.length === 0) {
|
|
602
|
-
return b.map((value) => ({ type: "insert", value }));
|
|
603
|
-
}
|
|
604
|
-
if (b.length === 0) {
|
|
605
|
-
return a.map((value) => ({ type: "delete", value }));
|
|
606
|
-
}
|
|
607
|
-
const dp = this.computeEditScript(a, b);
|
|
608
|
-
return this.reconstructDiff(a, b, dp);
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* Compute edit script using dynamic programming
|
|
612
|
-
*/
|
|
613
|
-
static computeEditScript(a, b) {
|
|
614
|
-
const m = a.length;
|
|
615
|
-
const n = b.length;
|
|
616
|
-
const dp = Array(m + 1).fill(null).map(() => Array(n + 1).fill(0));
|
|
617
|
-
for (let i = 0; i <= m; i++) dp[i][0] = i;
|
|
618
|
-
for (let j = 0; j <= n; j++) dp[0][j] = j;
|
|
619
|
-
for (let i = 1; i <= m; i++) {
|
|
620
|
-
for (let j = 1; j <= n; j++) {
|
|
621
|
-
if (a[i - 1] === b[j - 1]) {
|
|
622
|
-
dp[i][j] = dp[i - 1][j - 1];
|
|
623
|
-
} else {
|
|
624
|
-
dp[i][j] = 1 + Math.min(
|
|
625
|
-
dp[i - 1][j],
|
|
626
|
-
// Delete from a
|
|
627
|
-
dp[i][j - 1],
|
|
628
|
-
// Insert into a
|
|
629
|
-
dp[i - 1][j - 1]
|
|
630
|
-
// Replace
|
|
631
|
-
);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
return dp;
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Reconstruct the actual diff from the DP table
|
|
639
|
-
*/
|
|
640
|
-
static reconstructDiff(a, b, dp) {
|
|
641
|
-
const result = [];
|
|
642
|
-
let i = a.length;
|
|
643
|
-
let j = b.length;
|
|
644
|
-
while (i > 0 || j > 0) {
|
|
645
|
-
if (i > 0 && j > 0 && a[i - 1] === b[j - 1]) {
|
|
646
|
-
result.unshift({ type: "equal", value: a[i - 1] });
|
|
647
|
-
i--;
|
|
648
|
-
j--;
|
|
649
|
-
} else {
|
|
650
|
-
const deleteCost = i > 0 ? dp[i - 1][j] : Infinity;
|
|
651
|
-
const insertCost = j > 0 ? dp[i][j - 1] : Infinity;
|
|
652
|
-
const replaceCost = i > 0 && j > 0 ? dp[i - 1][j - 1] : Infinity;
|
|
653
|
-
const minCost = Math.min(deleteCost, insertCost, replaceCost);
|
|
654
|
-
if (minCost === insertCost && j > 0) {
|
|
655
|
-
result.unshift({ type: "insert", value: b[j - 1] });
|
|
656
|
-
j--;
|
|
657
|
-
} else if (minCost === deleteCost && i > 0) {
|
|
658
|
-
result.unshift({ type: "delete", value: a[i - 1] });
|
|
659
|
-
i--;
|
|
660
|
-
} else if (minCost === replaceCost && i > 0 && j > 0) {
|
|
661
|
-
if (this.areWordsSimilar(a[i - 1], b[j - 1])) {
|
|
662
|
-
result.unshift({ type: "insert", value: b[j - 1], sharedDiffId: true });
|
|
663
|
-
result.unshift({ type: "delete", value: a[i - 1], sharedDiffId: true });
|
|
664
|
-
i--;
|
|
665
|
-
j--;
|
|
666
|
-
} else {
|
|
667
|
-
result.unshift({ type: "insert", value: b[j - 1] });
|
|
668
|
-
j--;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
return result;
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Consolidate adjacent changes to reduce fragmentation
|
|
677
|
-
* e.g., if we have: delete "Key", insert "Key!", delete "Challenges"
|
|
678
|
-
* We can consolidate this into: replace ["Key", "Challenges"] with ["Key!"]
|
|
679
|
-
*/
|
|
680
|
-
static consolidateAdjacentChanges(diffs) {
|
|
681
|
-
const result = [];
|
|
682
|
-
let i = 0;
|
|
683
|
-
while (i < diffs.length) {
|
|
684
|
-
const current = diffs[i];
|
|
685
|
-
if (current.type === "equal") {
|
|
686
|
-
result.push(current);
|
|
687
|
-
i++;
|
|
688
|
-
continue;
|
|
689
|
-
}
|
|
690
|
-
const changeSequence = [];
|
|
691
|
-
let j = i;
|
|
692
|
-
while (j < diffs.length && diffs[j].type !== "equal") {
|
|
693
|
-
changeSequence.push(diffs[j]);
|
|
694
|
-
j++;
|
|
695
|
-
}
|
|
696
|
-
if (changeSequence.length <= 1) {
|
|
697
|
-
result.push(current);
|
|
698
|
-
i++;
|
|
699
|
-
continue;
|
|
700
|
-
}
|
|
701
|
-
const shouldConsolidate = this.shouldConsolidateChanges(
|
|
702
|
-
changeSequence
|
|
703
|
-
);
|
|
704
|
-
if (shouldConsolidate) {
|
|
705
|
-
const deletedWords = changeSequence.filter((c) => c.type === "delete").map((c) => c.value);
|
|
706
|
-
const insertedWords = changeSequence.filter((c) => c.type === "insert").map((c) => c.value);
|
|
707
|
-
if (deletedWords.length > 0) {
|
|
708
|
-
result.push({
|
|
709
|
-
type: "delete",
|
|
710
|
-
value: deletedWords.join(" "),
|
|
711
|
-
consolidated: true
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
if (insertedWords.length > 0) {
|
|
715
|
-
result.push({
|
|
716
|
-
type: "insert",
|
|
717
|
-
value: insertedWords.join(" "),
|
|
718
|
-
consolidated: true
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
} else {
|
|
722
|
-
changeSequence.forEach((change) => result.push(change));
|
|
723
|
-
}
|
|
724
|
-
i = j;
|
|
725
|
-
}
|
|
726
|
-
return result;
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Determine if a sequence of changes should be consolidated
|
|
730
|
-
*/
|
|
731
|
-
static shouldConsolidateChanges(changes) {
|
|
732
|
-
const hasDeletes = changes.some((c) => c.type === "delete");
|
|
733
|
-
const hasInserts = changes.some((c) => c.type === "insert");
|
|
734
|
-
return hasDeletes && hasInserts;
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* Check if two words are similar enough to be considered a replacement
|
|
738
|
-
*/
|
|
739
|
-
static areWordsSimilar(word1, word2) {
|
|
740
|
-
if (word1 === word2) return true;
|
|
741
|
-
const maxLen = Math.max(word1.length, word2.length);
|
|
742
|
-
const minLen = Math.min(word1.length, word2.length);
|
|
743
|
-
if (maxLen > minLen * 2) {
|
|
744
|
-
return false;
|
|
745
|
-
}
|
|
746
|
-
const word1Clean = word1.replace(/[^\w]/g, "");
|
|
747
|
-
const word2Clean = word2.replace(/[^\w]/g, "");
|
|
748
|
-
if (word1Clean === word2Clean && word1 !== word2) {
|
|
749
|
-
return false;
|
|
750
|
-
}
|
|
751
|
-
const distance = this.levenshteinDistance(word1, word2);
|
|
752
|
-
const similarity = 1 - distance / maxLen;
|
|
753
|
-
return similarity > 0.7;
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
// src/utils/blocknote-word-diff-renderer.util.ts
|
|
758
|
-
var BlockNoteWordDiffRendererUtil = class {
|
|
759
|
-
static {
|
|
760
|
-
__name(this, "BlockNoteWordDiffRendererUtil");
|
|
761
|
-
}
|
|
762
|
-
static renderWordDiffs(diffBlocks, onAcceptChange, onRejectChange, acceptedChanges, rejectedChanges) {
|
|
763
|
-
if (acceptedChanges || rejectedChanges) {
|
|
764
|
-
diffBlocks = this.updateWordDiffStates(diffBlocks, acceptedChanges, rejectedChanges);
|
|
765
|
-
}
|
|
766
|
-
return diffBlocks.map((block) => this.renderDiffBlock(block, onAcceptChange, onRejectChange));
|
|
767
|
-
}
|
|
768
|
-
static updateWordDiffStates(diffBlocks, acceptedChanges, rejectedChanges) {
|
|
769
|
-
return diffBlocks.map((block) => {
|
|
770
|
-
const updatedBlock = { ...block };
|
|
771
|
-
if (updatedBlock.diffId) {
|
|
772
|
-
updatedBlock.accepted = acceptedChanges?.has(updatedBlock.diffId) || false;
|
|
773
|
-
updatedBlock.rejected = rejectedChanges?.has(updatedBlock.diffId) || false;
|
|
774
|
-
}
|
|
775
|
-
if (updatedBlock.wordDiffs) {
|
|
776
|
-
updatedBlock.wordDiffs = updatedBlock.wordDiffs.map((wordDiff) => ({
|
|
777
|
-
...wordDiff,
|
|
778
|
-
accepted: acceptedChanges?.has(wordDiff.diffId) || false,
|
|
779
|
-
rejected: rejectedChanges?.has(wordDiff.diffId) || false
|
|
780
|
-
}));
|
|
781
|
-
}
|
|
782
|
-
if (updatedBlock.children) {
|
|
783
|
-
updatedBlock.children = this.updateWordDiffStates(
|
|
784
|
-
updatedBlock.children,
|
|
785
|
-
acceptedChanges,
|
|
786
|
-
rejectedChanges
|
|
787
|
-
);
|
|
788
|
-
}
|
|
789
|
-
return updatedBlock;
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
static renderDiffBlock(block, onAcceptChange, onRejectChange) {
|
|
793
|
-
if (block.diffType === "modified" && block.wordDiffs) {
|
|
794
|
-
return this.renderWordLevelDiff(block, onAcceptChange, onRejectChange);
|
|
795
|
-
}
|
|
796
|
-
if (block.diffType === "added" || block.diffType === "removed") {
|
|
797
|
-
return this.renderBlockLevelDiff(block, onAcceptChange, onRejectChange);
|
|
798
|
-
}
|
|
799
|
-
const baseBlock = {
|
|
800
|
-
id: block.id || crypto.randomUUID(),
|
|
801
|
-
type: block.type || "paragraph",
|
|
802
|
-
props: this.getBlockProps(block),
|
|
803
|
-
content: Array.isArray(block.content) ? block.content : [],
|
|
804
|
-
children: block.children?.map(
|
|
805
|
-
(child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)
|
|
806
|
-
)
|
|
807
|
-
};
|
|
808
|
-
return baseBlock;
|
|
809
|
-
}
|
|
810
|
-
static renderBlockLevelDiff(block, onAcceptChange, onRejectChange) {
|
|
811
|
-
if (!block.diffId) {
|
|
812
|
-
return {
|
|
813
|
-
id: block.id || crypto.randomUUID(),
|
|
814
|
-
type: block.type || "paragraph",
|
|
815
|
-
props: block.props || {},
|
|
816
|
-
content: Array.isArray(block.content) ? block.content : [],
|
|
817
|
-
children: block.children?.map(
|
|
818
|
-
(child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)
|
|
819
|
-
)
|
|
820
|
-
};
|
|
821
|
-
}
|
|
822
|
-
const blockAccepted = block.accepted || false;
|
|
823
|
-
const blockRejected = block.rejected || false;
|
|
824
|
-
let content = Array.isArray(block.content) ? [...block.content] : [];
|
|
825
|
-
if (block.diffType === "added") {
|
|
826
|
-
if (blockRejected) {
|
|
827
|
-
return {
|
|
828
|
-
id: block.id || crypto.randomUUID(),
|
|
829
|
-
type: "paragraph",
|
|
830
|
-
props: {},
|
|
831
|
-
content: [],
|
|
832
|
-
children: []
|
|
833
|
-
};
|
|
834
|
-
} else if (!blockAccepted) {
|
|
835
|
-
content = content.map((item) => ({
|
|
836
|
-
...item,
|
|
837
|
-
styles: { ...item.styles, bold: true }
|
|
838
|
-
}));
|
|
839
|
-
content.push({
|
|
840
|
-
type: "diffActions",
|
|
841
|
-
props: { diffIds: block.diffId }
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
} else if (block.diffType === "removed") {
|
|
845
|
-
if (blockAccepted) {
|
|
846
|
-
return {
|
|
847
|
-
id: block.id || crypto.randomUUID(),
|
|
848
|
-
type: "paragraph",
|
|
849
|
-
props: {},
|
|
850
|
-
content: [],
|
|
851
|
-
children: []
|
|
852
|
-
};
|
|
853
|
-
} else if (!blockRejected) {
|
|
854
|
-
content = content.map((item) => ({
|
|
855
|
-
...item,
|
|
856
|
-
styles: { ...item.styles, strike: true }
|
|
857
|
-
}));
|
|
858
|
-
content.push({
|
|
859
|
-
type: "diffActions",
|
|
860
|
-
props: { diffIds: block.diffId }
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
const baseBlock = {
|
|
865
|
-
id: block.id || crypto.randomUUID(),
|
|
866
|
-
type: block.type || "paragraph",
|
|
867
|
-
props: this.getBlockProps(block),
|
|
868
|
-
content,
|
|
869
|
-
children: block.children?.map(
|
|
870
|
-
(child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)
|
|
871
|
-
)
|
|
872
|
-
};
|
|
873
|
-
return baseBlock;
|
|
874
|
-
}
|
|
875
|
-
static renderWordLevelDiff(block, onAcceptChange, onRejectChange) {
|
|
876
|
-
if (!block.wordDiffs) {
|
|
877
|
-
return {
|
|
878
|
-
id: block.id || crypto.randomUUID(),
|
|
879
|
-
type: block.type || "paragraph",
|
|
880
|
-
props: block.props || {},
|
|
881
|
-
content: Array.isArray(block.content) ? block.content : [],
|
|
882
|
-
children: []
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
const content = this.groupAndRenderWordDiffs(block.wordDiffs);
|
|
886
|
-
return {
|
|
887
|
-
id: block.id || crypto.randomUUID(),
|
|
888
|
-
type: block.type || "paragraph",
|
|
889
|
-
props: block.props || {},
|
|
890
|
-
content: Array.isArray(content) ? content : [],
|
|
891
|
-
children: block.children?.map((child) => this.renderDiffBlock(child, onAcceptChange, onRejectChange)) || []
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
static groupAndRenderWordDiffs(wordDiffs) {
|
|
895
|
-
const content = [];
|
|
896
|
-
for (let i = 0; i < wordDiffs.length; i++) {
|
|
897
|
-
const wordDiff = wordDiffs[i];
|
|
898
|
-
const isLastOfGroup = this.isLastDiffInGroup(wordDiffs, i);
|
|
899
|
-
const textContent = this.createTextContent(wordDiff, isLastOfGroup);
|
|
900
|
-
if (textContent) {
|
|
901
|
-
if (Array.isArray(textContent)) {
|
|
902
|
-
content.push(...textContent);
|
|
903
|
-
} else {
|
|
904
|
-
content.push(textContent);
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
const cleanedContent = this.cleanupSpaces(content);
|
|
909
|
-
return cleanedContent;
|
|
910
|
-
}
|
|
911
|
-
static cleanupSpaces(content) {
|
|
912
|
-
const filtered = content.filter((item) => item !== null && item !== void 0);
|
|
913
|
-
const cleaned = [];
|
|
914
|
-
for (let i = 0; i < filtered.length; i++) {
|
|
915
|
-
const current = filtered[i];
|
|
916
|
-
if (current.type === "text" && current.text === " ") {
|
|
917
|
-
const lastItem = cleaned[cleaned.length - 1];
|
|
918
|
-
if (i === 0 || i === filtered.length - 1 || lastItem && lastItem.type === "text" && lastItem.text === " " || lastItem && lastItem.type === "diffActions") {
|
|
919
|
-
continue;
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
if (current.type === "diffActions") {
|
|
923
|
-
const nextItem = i + 1 < filtered.length ? filtered[i + 1] : null;
|
|
924
|
-
cleaned.push(current);
|
|
925
|
-
if (nextItem && nextItem.type === "text" && nextItem.text !== " " && nextItem.type !== "diffActions") {
|
|
926
|
-
cleaned.push({
|
|
927
|
-
type: "text",
|
|
928
|
-
text: " ",
|
|
929
|
-
styles: {}
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
continue;
|
|
933
|
-
}
|
|
934
|
-
cleaned.push(current);
|
|
935
|
-
}
|
|
936
|
-
return cleaned;
|
|
937
|
-
}
|
|
938
|
-
static isLastDiffInGroup(wordDiffs, currentIndex) {
|
|
939
|
-
const currentDiff = wordDiffs[currentIndex];
|
|
940
|
-
if (currentDiff.type === "unchanged") {
|
|
941
|
-
return false;
|
|
942
|
-
}
|
|
943
|
-
for (let i = currentIndex + 1; i < wordDiffs.length; i++) {
|
|
944
|
-
const nextDiff = wordDiffs[i];
|
|
945
|
-
if (nextDiff.diffId === currentDiff.diffId && (nextDiff.type === "added" || nextDiff.type === "removed")) {
|
|
946
|
-
return false;
|
|
947
|
-
}
|
|
948
|
-
if (nextDiff.type !== "unchanged" && nextDiff.diffId !== currentDiff.diffId) {
|
|
949
|
-
break;
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
return true;
|
|
953
|
-
}
|
|
954
|
-
static createTextContent(wordDiff, isLastOfGroup) {
|
|
955
|
-
switch (wordDiff.type) {
|
|
956
|
-
case "added":
|
|
957
|
-
if (wordDiff.accepted) {
|
|
958
|
-
return {
|
|
959
|
-
type: "text",
|
|
960
|
-
text: wordDiff.text,
|
|
961
|
-
styles: {}
|
|
962
|
-
};
|
|
963
|
-
} else if (wordDiff.rejected) {
|
|
964
|
-
return null;
|
|
965
|
-
} else {
|
|
966
|
-
if (wordDiff.text.trim() === "") {
|
|
967
|
-
return {
|
|
968
|
-
type: "text",
|
|
969
|
-
text: wordDiff.text,
|
|
970
|
-
styles: { backgroundColor: "#dcfce7" }
|
|
971
|
-
};
|
|
972
|
-
} else {
|
|
973
|
-
const baseContent = {
|
|
974
|
-
type: "text",
|
|
975
|
-
text: wordDiff.text,
|
|
976
|
-
styles: { bold: true }
|
|
977
|
-
};
|
|
978
|
-
if (isLastOfGroup) {
|
|
979
|
-
return [
|
|
980
|
-
baseContent,
|
|
981
|
-
{
|
|
982
|
-
type: "diffActions",
|
|
983
|
-
props: { diffIds: wordDiff.diffId }
|
|
984
|
-
}
|
|
985
|
-
];
|
|
986
|
-
} else {
|
|
987
|
-
return baseContent;
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
case "removed":
|
|
992
|
-
if (wordDiff.accepted) {
|
|
993
|
-
return null;
|
|
994
|
-
} else if (wordDiff.rejected) {
|
|
995
|
-
return {
|
|
996
|
-
type: "text",
|
|
997
|
-
text: wordDiff.text,
|
|
998
|
-
styles: {}
|
|
999
|
-
};
|
|
1000
|
-
} else {
|
|
1001
|
-
if (wordDiff.text.trim() === "") {
|
|
1002
|
-
return {
|
|
1003
|
-
type: "text",
|
|
1004
|
-
text: wordDiff.text,
|
|
1005
|
-
styles: { strike: true }
|
|
1006
|
-
};
|
|
1007
|
-
} else {
|
|
1008
|
-
const baseContent = {
|
|
1009
|
-
type: "text",
|
|
1010
|
-
text: wordDiff.text,
|
|
1011
|
-
styles: { strike: true }
|
|
1012
|
-
};
|
|
1013
|
-
if (isLastOfGroup) {
|
|
1014
|
-
return [
|
|
1015
|
-
baseContent,
|
|
1016
|
-
{
|
|
1017
|
-
type: "diffActions",
|
|
1018
|
-
props: { diffIds: wordDiff.diffId }
|
|
1019
|
-
}
|
|
1020
|
-
];
|
|
1021
|
-
} else {
|
|
1022
|
-
return baseContent;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
case "unchanged":
|
|
1027
|
-
default:
|
|
1028
|
-
return {
|
|
1029
|
-
type: "text",
|
|
1030
|
-
text: wordDiff.text,
|
|
1031
|
-
styles: {}
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
static getBlockProps(block) {
|
|
1036
|
-
const baseProps = block.props || {};
|
|
1037
|
-
return baseProps;
|
|
1038
|
-
}
|
|
1039
|
-
static generateChangeSummary(diffBlocks) {
|
|
1040
|
-
let totalWords = 0;
|
|
1041
|
-
let addedWords = 0;
|
|
1042
|
-
let removedWords = 0;
|
|
1043
|
-
let acceptedChanges = 0;
|
|
1044
|
-
let rejectedChanges = 0;
|
|
1045
|
-
let pendingChanges = 0;
|
|
1046
|
-
const processBlock = /* @__PURE__ */ __name((block) => {
|
|
1047
|
-
if (block.wordDiffs) {
|
|
1048
|
-
block.wordDiffs.forEach((wordDiff) => {
|
|
1049
|
-
totalWords++;
|
|
1050
|
-
if (wordDiff.type === "added") {
|
|
1051
|
-
addedWords++;
|
|
1052
|
-
} else if (wordDiff.type === "removed") {
|
|
1053
|
-
removedWords++;
|
|
1054
|
-
}
|
|
1055
|
-
if (wordDiff.accepted) {
|
|
1056
|
-
acceptedChanges++;
|
|
1057
|
-
} else if (wordDiff.rejected) {
|
|
1058
|
-
rejectedChanges++;
|
|
1059
|
-
} else if (wordDiff.type !== "unchanged") {
|
|
1060
|
-
pendingChanges++;
|
|
1061
|
-
}
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
if (block.children) {
|
|
1065
|
-
block.children.forEach((child) => processBlock(child));
|
|
1066
|
-
}
|
|
1067
|
-
}, "processBlock");
|
|
1068
|
-
diffBlocks.forEach(processBlock);
|
|
1069
|
-
return {
|
|
1070
|
-
totalWords,
|
|
1071
|
-
addedWords,
|
|
1072
|
-
removedWords,
|
|
1073
|
-
acceptedChanges,
|
|
1074
|
-
rejectedChanges,
|
|
1075
|
-
pendingChanges
|
|
1076
|
-
};
|
|
1077
|
-
}
|
|
1078
|
-
};
|
|
1079
|
-
|
|
1080
|
-
// src/utils/icons.tsx
|
|
1081
|
-
import { jsx } from "react/jsx-runtime";
|
|
1082
|
-
var getIconByModule = /* @__PURE__ */ __name((params) => {
|
|
1083
|
-
const IconComponent = getLucideIconByModule({ module: params.module });
|
|
1084
|
-
if (!IconComponent) return null;
|
|
1085
|
-
return /* @__PURE__ */ jsx(IconComponent, { className: cn(``, params.className) });
|
|
1086
|
-
}, "getIconByModule");
|
|
1087
|
-
var getIcon = /* @__PURE__ */ __name((params) => {
|
|
1088
|
-
const IconComponent = getLucideIcon({ element: params.element });
|
|
1089
|
-
if (!IconComponent) return null;
|
|
1090
|
-
return /* @__PURE__ */ jsx(IconComponent, { className: cn(``, params.className) });
|
|
1091
|
-
}, "getIcon");
|
|
1092
|
-
var getIconByModuleName = /* @__PURE__ */ __name((params) => {
|
|
1093
|
-
return getIconByModule({ module: Modules.findByModelName(params.name), className: params.className });
|
|
1094
|
-
}, "getIconByModuleName");
|
|
1095
|
-
var getLucideIcon = /* @__PURE__ */ __name((params) => {
|
|
1096
|
-
if (params.element.type === "contents") {
|
|
1097
|
-
const contentType = params.element.contentType;
|
|
1098
|
-
if (!contentType) return null;
|
|
1099
|
-
return getLucideIconByModule({ module: Modules.findByModelName(contentType) });
|
|
1100
|
-
}
|
|
1101
|
-
return getLucideIconByModule({ module: Modules.findByName(params.element.type) });
|
|
1102
|
-
}, "getLucideIcon");
|
|
1103
|
-
var getLucideIconByModule = /* @__PURE__ */ __name((params) => {
|
|
1104
|
-
return params.module.icon ?? null;
|
|
1105
|
-
}, "getLucideIconByModule");
|
|
1106
|
-
var getLucideIconByModuleName = /* @__PURE__ */ __name((params) => {
|
|
1107
|
-
return getLucideIconByModule({ module: Modules.findByModelName(params.name) });
|
|
1108
|
-
}, "getLucideIconByModuleName");
|
|
1109
|
-
|
|
1110
|
-
export {
|
|
1111
|
-
cn,
|
|
1112
|
-
composeRefs,
|
|
1113
|
-
useComposedRefs,
|
|
1114
|
-
useIsMobile,
|
|
1115
|
-
formatDate,
|
|
1116
|
-
exists,
|
|
1117
|
-
TableOptions,
|
|
1118
|
-
getTableOptions,
|
|
1119
|
-
getTableComponents,
|
|
1120
|
-
userObjectSchema,
|
|
1121
|
-
entityObjectSchema,
|
|
1122
|
-
BlockNoteDiffUtil,
|
|
1123
|
-
BlockNoteWordDiffRendererUtil,
|
|
1124
|
-
getIconByModule,
|
|
1125
|
-
getIcon,
|
|
1126
|
-
getIconByModuleName,
|
|
1127
|
-
getLucideIcon,
|
|
1128
|
-
getLucideIconByModule,
|
|
1129
|
-
getLucideIconByModuleName
|
|
1130
|
-
};
|
|
1131
|
-
//# sourceMappingURL=chunk-JGFWIT2E.mjs.map
|