@edifice.io/react 2.5.15-develop-enabling.20260326100838 → 2.5.15-develop-pedago.20260327124327
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/components/AddAttachments/AddAttachments.d.ts +6 -3
- package/dist/components/AddAttachments/AddAttachments.js +17 -29
- package/dist/components/AddAttachments/hooks/useFileToAttachment.d.ts +3 -0
- package/dist/components/AddAttachments/hooks/useFileToAttachment.js +16 -0
- package/dist/components/AddAttachments/models/attachment.d.ts +1 -0
- package/dist/components/Card/Card.js +1 -1
- package/dist/components/Combobox/Combobox.js +1 -1
- package/dist/components/Dropdown/Dropdown.js +1 -1
- package/dist/components/Form/FormControl.js +1 -1
- package/dist/components/Layout/components/WidgetApps.js +1 -1
- package/dist/components/Modal/Modal.js +1 -1
- package/dist/components/PreventPropagation/PreventPropagation.js +1 -1
- package/dist/components/PromotionCard/PromotionCard.js +1 -1
- package/dist/components/SearchBar/SearchBar.d.ts +2 -2
- package/dist/components/Table/components/Table.js +1 -1
- package/dist/components/Tree/components/SortableTree.js +4 -3
- package/dist/components/Tree/components/Tree.js +4 -3
- package/dist/components/UserRightsList/SaveBookmark.d.ts +5 -0
- package/dist/components/UserRightsList/SaveBookmark.js +29 -0
- package/dist/components/UserRightsList/UserRightsBookmarkRow.d.ts +11 -0
- package/dist/components/UserRightsList/UserRightsBookmarkRow.js +30 -0
- package/dist/components/UserRightsList/UserRightsItem.d.ts +13 -0
- package/dist/components/UserRightsList/UserRightsItem.js +36 -0
- package/dist/components/UserRightsList/UserRightsList.d.ts +19 -0
- package/dist/components/UserRightsList/UserRightsList.js +94 -0
- package/dist/components/UserRightsList/helpers/rightsHelpers.d.ts +9 -0
- package/dist/components/UserRightsList/helpers/rightsHelpers.js +53 -0
- package/dist/components/UserRightsList/hooks/useBookmarkEntries.d.ts +19 -0
- package/dist/components/UserRightsList/hooks/useBookmarkEntries.js +58 -0
- package/dist/components/UserRightsList/hooks/useSharingItems.d.ts +20 -0
- package/dist/components/UserRightsList/hooks/useSharingItems.js +57 -0
- package/dist/components/UserRightsList/index.d.ts +2 -0
- package/dist/components/UserRightsList/types/types.d.ts +34 -0
- package/dist/components/UserRightsList/types/types.js +6 -0
- package/dist/components/UserSearch/UserSearch.d.ts +7 -0
- package/dist/components/UserSearch/UserSearch.js +82 -0
- package/dist/components/UserSearch/index.d.ts +3 -0
- package/dist/components/UserSearch/types/types.d.ts +24 -0
- package/dist/components/UserSearch/types/visible.d.ts +24 -0
- package/dist/components/UserSearch/types/visible.js +4 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/hooks/useConf/useConf.d.ts +1 -1
- package/dist/hooks/useDirectory/useDirectory.d.ts +3 -2
- package/dist/hooks/useDropdown/useDropdown.js +0 -2
- package/dist/hooks/useDropzone/useDropzone.js +4 -4
- package/dist/hooks/useSession/useSession.d.ts +1 -1
- package/dist/hooks/useThumbnail/useThumbnail.d.ts +1 -1
- package/dist/hooks/useThumbnail/useThumbnail.js +1 -5
- package/dist/hooks/useUpload/useUpload.js +5 -2
- package/dist/hooks/useWorkspaceFolders/useWorkspaceFolders.js +1 -1
- package/dist/icons.js +180 -176
- package/dist/index.js +10 -0
- package/dist/modules/editor/components/Editor/EditorPreview.js +1 -1
- package/dist/modules/icons/components/IconParcoursCitoyen.d.ts +7 -0
- package/dist/modules/icons/components/IconParcoursCitoyen.js +14 -0
- package/dist/modules/icons/components/IconParcoursSecours.d.ts +7 -0
- package/dist/modules/icons/components/IconParcoursSecours.js +14 -0
- package/dist/modules/icons/components/index.d.ts +2 -0
- package/dist/modules/modals/ResourceModal/ResourceModal.d.ts +1 -1
- package/dist/modules/modals/ResourceModal/ResourceModal.js +1 -1
- package/dist/modules/modals/ResourceModal/hooks/useUpdateMutation.d.ts +1 -1
- package/dist/modules/modals/ShareModal/ShareResources.d.ts +53 -4
- package/dist/modules/modals/ShareModal/apps/ShareBlog.d.ts +1 -1
- package/dist/modules/modals/ShareModal/hooks/useShareBookmark.js +1 -2
- package/dist/modules/modals/ShareModal/hooks/useShareMutation.d.ts +1 -1
- package/dist/modules/multimedia/FileCard/FileCard._.d.ts +17 -0
- package/dist/modules/multimedia/ImageEditor/components/ImageEditor.js +10 -24
- package/dist/modules/multimedia/ImageEditor/effects/blur.d.ts +5 -7
- package/dist/modules/multimedia/ImageEditor/effects/blur.js +18 -26
- package/dist/modules/multimedia/ImageEditor/effects/crop.d.ts +5 -4
- package/dist/modules/multimedia/ImageEditor/effects/crop.js +26 -42
- package/dist/modules/multimedia/ImageEditor/effects/misc.d.ts +16 -10
- package/dist/modules/multimedia/ImageEditor/effects/misc.js +12 -27
- package/dist/modules/multimedia/ImageEditor/effects/resize.d.ts +7 -3
- package/dist/modules/multimedia/ImageEditor/effects/resize.js +22 -31
- package/dist/modules/multimedia/ImageEditor/effects/rotate.js +3 -2
- package/dist/modules/multimedia/ImageEditor/hooks/useHistoryTool.js +41 -40
- package/dist/modules/multimedia/ImageEditor/hooks/useImageEditor.d.ts +1 -1
- package/dist/modules/multimedia/ImageEditor/hooks/useImageEditor.js +3 -9
- package/dist/modules/multimedia/ImageEditor/hooks/useImageEffects.js +1 -4
- package/dist/modules/multimedia/Linker/InternalLinker/InternalLinker.d.ts +3 -1
- package/dist/modules/multimedia/Linker/InternalLinker/InternalLinker.js +2 -1
- package/dist/modules/multimedia/LinkerCard/LinkerCard._.d.ts +1 -1
- package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +0 -1
- package/dist/modules/multimedia/UploadCard/UploadCard._.d.ts +1 -1
- package/dist/modules/multimedia/UploadFiles/UploadFiles.js +4 -4
- package/dist/providers/EdificeClientProvider/EdificeClientProvider.context.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/sharing.d.ts +8 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/react-query/react-query-utils.d.ts +1 -1
- package/dist/utilities/rotate-transition-style/get-rotate-transition-style.d.ts +5 -0
- package/dist/utilities/rotate-transition-style/get-rotate-transition-style.js +12 -0
- package/dist/utilities/rotate-transition-style/index.d.ts +1 -0
- package/package.json +54 -53
- package/dist/hooks/useWorkspaceFolders/useWorkspaceFolders.d.ts +0 -12
- package/dist/modules/multimedia/ImageEditor/effects/constants.d.ts +0 -2
- package/dist/modules/multimedia/ImageEditor/effects/constants.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PutShareResponse, ShareRight } from '@edifice.io/client';
|
|
2
|
-
import { UseMutationOptions, UseMutationResult } from '
|
|
2
|
+
import { UseMutationOptions, UseMutationResult } from '../../../../../node_modules/@tanstack/react-query';
|
|
3
3
|
declare const useShareMutation: ({ application, options, }: {
|
|
4
4
|
application: string;
|
|
5
5
|
options?: UseMutationOptions<PutShareResponse, Error, {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { default as FileCard } from './FileCard';
|
|
3
|
+
declare const meta: Meta<typeof FileCard>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof FileCard>;
|
|
6
|
+
export declare const Base: Story;
|
|
7
|
+
export declare const AudioFile: Story;
|
|
8
|
+
export declare const ImageFile: Story;
|
|
9
|
+
export declare const VideoFile: Story;
|
|
10
|
+
export declare const TextFile: Story;
|
|
11
|
+
export declare const DocFile: Story;
|
|
12
|
+
export declare const PptFile: Story;
|
|
13
|
+
export declare const PdfFile: Story;
|
|
14
|
+
export declare const ZipFile: Story;
|
|
15
|
+
export declare const CsvFile: Story;
|
|
16
|
+
export declare const XlsFile: Story;
|
|
17
|
+
export declare const MdFile: Story;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState
|
|
3
|
-
import
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Stage } from "@pixi/react";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
5
|
import useImageEditor from "../hooks/useImageEditor.js";
|
|
6
6
|
import ImageEditorToolbar from "./ImageEditorToolbar.js";
|
|
@@ -21,11 +21,7 @@ const ImageEditor = ({
|
|
|
21
21
|
}) => {
|
|
22
22
|
const {
|
|
23
23
|
t
|
|
24
|
-
} = useTranslation(), [currentOperation, setCurrentOperation] = useState(void 0), [isSaving, setSaving] = useState(!1), [altText, setAltText] = useState(altTextParam ?? ""), [legend, setLegend] = useState(legendParam ?? ""), [dirty, setDirty] = useState(!1)
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
setAltText(altTextParam ?? ""), setLegend(legendParam ?? ""), setDirty(!1);
|
|
27
|
-
}, [altTextParam, legendParam]);
|
|
28
|
-
const {
|
|
24
|
+
} = useTranslation(), [currentOperation, setCurrentOperation] = useState(void 0), [isSaving, setSaving] = useState(!1), [altText, setAltText] = useState(altTextParam ?? ""), [legend, setLegend] = useState(legendParam ?? ""), [dirty, setDirty] = useState(!1), {
|
|
29
25
|
toBlob,
|
|
30
26
|
setApplication,
|
|
31
27
|
startBlur,
|
|
@@ -40,21 +36,7 @@ const ImageEditor = ({
|
|
|
40
36
|
loading
|
|
41
37
|
} = useImageEditor({
|
|
42
38
|
imageSrc
|
|
43
|
-
}),
|
|
44
|
-
if (node && !appRef.current) {
|
|
45
|
-
const app = new PIXI.Application();
|
|
46
|
-
appRef.current = app, app.init({
|
|
47
|
-
backgroundAlpha: 0,
|
|
48
|
-
resolution: 1,
|
|
49
|
-
preserveDrawingBuffer: !0
|
|
50
|
-
}).then(() => {
|
|
51
|
-
appRef.current === app && (node.appendChild(app.canvas), setApplication(app));
|
|
52
|
-
}).catch(() => {
|
|
53
|
-
appRef.current === app && (appRef.current = null);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
!node && appRef.current && (appRef.current.destroy(!0), appRef.current = null);
|
|
57
|
-
}, [setApplication]), stopAll = () => {
|
|
39
|
+
}), stopAll = () => {
|
|
58
40
|
stopBlur(), stopCrop(currentOperation === "CROP"), stopResize(currentOperation === "RESIZE");
|
|
59
41
|
}, handleSave = async () => {
|
|
60
42
|
try {
|
|
@@ -101,8 +83,12 @@ const ImageEditor = ({
|
|
|
101
83
|
/* @__PURE__ */ jsx(Modal.Body, { className: "d-flex flex-column align-items-center", children: /* @__PURE__ */ jsxs("div", { className: "d-flex flex-column gap-12 w-100 flex-grow-1", children: [
|
|
102
84
|
/* @__PURE__ */ jsx(ImageEditorToolbar, { handle: handleOperation, historyCount }),
|
|
103
85
|
/* @__PURE__ */ jsxs("div", { className: "position-relative d-flex flex-column align-items-center justify-content-center flex-grow-1 w-100 image-editor", children: [
|
|
104
|
-
/* @__PURE__ */ jsx(
|
|
105
|
-
|
|
86
|
+
/* @__PURE__ */ jsx(Stage, { onMount: (app) => setApplication(app), options: {
|
|
87
|
+
preserveDrawingBuffer: !0,
|
|
88
|
+
backgroundAlpha: 0,
|
|
89
|
+
resolution: 1
|
|
90
|
+
} }),
|
|
91
|
+
!!loading && /* @__PURE__ */ jsx("div", { className: "position-absolute top-0 start-0 bottom-0 end-0 m-10 d-flex align-items-center justify-content-center bg-black opacity-25", children: /* @__PURE__ */ jsx(LoadingScreen, {}) })
|
|
106
92
|
] }),
|
|
107
93
|
/* @__PURE__ */ jsxs("div", { className: "d-flex flex-column flex-md-row m-10 gap-12 w-100", children: [
|
|
108
94
|
/* @__PURE__ */ jsxs(FormControl, { id: "alt", className: "flex-grow-1", children: [
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import * as PIXI from 'pixi.js';
|
|
2
2
|
/**
|
|
3
|
-
* This function
|
|
3
|
+
* This function start the blur controler
|
|
4
4
|
* - drawing cursor
|
|
5
5
|
* - listening mouse move to move cursor
|
|
6
|
-
* - listening
|
|
6
|
+
* - listening
|
|
7
7
|
*
|
|
8
|
-
* @param application
|
|
9
|
-
* @param
|
|
8
|
+
* @param application
|
|
9
|
+
* @param param1
|
|
10
10
|
*/
|
|
11
11
|
export declare function start(application: PIXI.Application, { spriteName }: {
|
|
12
12
|
spriteName: string;
|
|
13
13
|
}): void;
|
|
14
14
|
/**
|
|
15
|
-
* This function
|
|
16
|
-
* The blur layer is kept on stage so it gets captured by toBlob/generateTexture
|
|
17
|
-
* when the image is saved or another operation is applied.
|
|
15
|
+
* This function remove cursor and all mouse event listeners
|
|
18
16
|
*
|
|
19
17
|
* @param application the PIXI.Application context
|
|
20
18
|
*/
|
|
@@ -1,53 +1,45 @@
|
|
|
1
1
|
import * as PIXI from "pixi.js";
|
|
2
2
|
import { aggregate } from "../utilities/aggregate.js";
|
|
3
|
-
import { BLUR_LAYER_NAME } from "./constants.js";
|
|
4
3
|
import { getApplicationScale } from "./misc.js";
|
|
5
4
|
const BRUSH_SIZE = 20, DEBOUNCE = 50, CURSOR_NAME = "BRUSH_CURSOR";
|
|
6
|
-
function getOrCreateBlurLayer(application) {
|
|
7
|
-
let layer = application.stage.getChildByLabel(BLUR_LAYER_NAME);
|
|
8
|
-
return layer || (layer = new PIXI.Container(), layer.label = BLUR_LAYER_NAME, application.stage.addChild(layer)), layer;
|
|
9
|
-
}
|
|
10
5
|
function drawBrush(points, scale) {
|
|
11
6
|
const container = new PIXI.Graphics();
|
|
12
7
|
for (const point of points)
|
|
13
|
-
point && (container.
|
|
14
|
-
color: 16777215,
|
|
15
|
-
alpha: 1
|
|
16
|
-
}));
|
|
8
|
+
point && (container.beginFill(16777215, 1), container.drawCircle(point.x, point.y, BRUSH_SIZE / scale), container.lineStyle(0), container.endFill());
|
|
17
9
|
return container;
|
|
18
10
|
}
|
|
19
11
|
function drawBlurListener(application, {
|
|
20
12
|
spriteName
|
|
21
13
|
}) {
|
|
22
14
|
return aggregate(DEBOUNCE, (event) => application.stage.toLocal(event.global), (points) => {
|
|
23
|
-
const child = application.stage.
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
newSprite.filters = [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
const child = application.stage.getChildByName(spriteName), scale = getApplicationScale(application);
|
|
16
|
+
if (child == null) return;
|
|
17
|
+
const newSprite = new PIXI.Sprite(child.texture);
|
|
18
|
+
newSprite.filters = [
|
|
19
|
+
new PIXI.BlurFilter(
|
|
20
|
+
8,
|
|
21
|
+
// PIXI Default value for strength of the blur effect
|
|
22
|
+
4,
|
|
23
|
+
// Quality of the blur effect depending on the scale (4 is the PIXI default value)
|
|
24
|
+
Math.min(scale, 1)
|
|
25
|
+
)
|
|
26
|
+
// Resolution of the blur effect depending on the scale
|
|
27
|
+
], newSprite.width = child.width, newSprite.height = child.height, newSprite.scale = new PIXI.Point(1, 1), newSprite.anchor = child.anchor, newSprite.mask = drawBrush(points, scale), child.addChild(newSprite);
|
|
33
28
|
});
|
|
34
29
|
}
|
|
35
30
|
function drawCursor(application) {
|
|
36
31
|
removeCursor(application);
|
|
37
32
|
const scale = getApplicationScale(application), circle = new PIXI.Graphics();
|
|
38
|
-
return circle.circle(0, 0, BRUSH_SIZE / scale), circle.
|
|
39
|
-
width: Math.max(1, 1 / scale),
|
|
40
|
-
color: 16711680
|
|
41
|
-
}), circle.label = CURSOR_NAME, application.stage.addChild(circle), circle;
|
|
33
|
+
return circle.lineStyle(Math.max(1, 1 / scale), 16711680), circle.drawCircle(0, 0, BRUSH_SIZE / scale), circle.endFill(), circle.name = CURSOR_NAME, application.stage.addChild(circle), circle;
|
|
42
34
|
}
|
|
43
35
|
function removeCursor(application) {
|
|
44
|
-
const child = application.stage.
|
|
36
|
+
const child = application.stage.getChildByName(CURSOR_NAME);
|
|
45
37
|
child && child.removeFromParent();
|
|
46
38
|
}
|
|
47
39
|
function moveCursorListener(application) {
|
|
48
40
|
return (event) => {
|
|
49
41
|
if (!application) return;
|
|
50
|
-
const point = application.stage.toLocal(event.global), child = application.stage.
|
|
42
|
+
const point = application.stage.toLocal(event.global), child = application.stage.getChildByName(CURSOR_NAME, !0);
|
|
51
43
|
child && (child.position.x = point.x, child.position.y = point.y);
|
|
52
44
|
};
|
|
53
45
|
}
|
|
@@ -61,7 +53,7 @@ function start(application, {
|
|
|
61
53
|
spriteName
|
|
62
54
|
});
|
|
63
55
|
application.stage.on("pointerdown", () => {
|
|
64
|
-
application.stage.
|
|
56
|
+
application.stage.on("pointermove", blurListener);
|
|
65
57
|
});
|
|
66
58
|
const stopListening = () => {
|
|
67
59
|
var _a;
|
|
@@ -7,7 +7,7 @@ export type CornerType = 'TOP_LEFT' | 'TOP_RIGHT' | 'BOTTOM_LEFT' | 'BOTTOM_RIGH
|
|
|
7
7
|
* - A mask applied to the original image
|
|
8
8
|
*
|
|
9
9
|
* @param application The PIXI.Application context
|
|
10
|
-
* @param spriteName The sprite name identifying the original image
|
|
10
|
+
* @param {spriteName:string} {spriteName} The sprite name identifying the original image
|
|
11
11
|
*/
|
|
12
12
|
export declare function start(application: PIXI.Application, { spriteName }: {
|
|
13
13
|
spriteName: string;
|
|
@@ -19,9 +19,10 @@ export declare function start(application: PIXI.Application, { spriteName }: {
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function stop(application: PIXI.Application): void;
|
|
21
21
|
/**
|
|
22
|
-
* This function
|
|
22
|
+
* This function apply a crop to the imageSrc and return the result as a PIXI.Sprite object
|
|
23
23
|
*
|
|
24
|
-
* @param application
|
|
25
|
-
* @
|
|
24
|
+
* @param application
|
|
25
|
+
* @param imageSrc a string URI of the image to crop
|
|
26
|
+
* @returns a PIXI.Sprite with a imageSrc cropped or undefined if the image has not been cropped
|
|
26
27
|
*/
|
|
27
28
|
export declare function save(application: PIXI.Application): PIXI.Sprite | undefined;
|
|
@@ -8,25 +8,17 @@ function drawBackground(application, {
|
|
|
8
8
|
spriteName
|
|
9
9
|
}) {
|
|
10
10
|
removeBackground(application);
|
|
11
|
-
const sprite = application.stage.
|
|
12
|
-
if (
|
|
13
|
-
const spriteBounds = sprite.getBounds(), stageTexture = application.renderer.generateTexture(application.stage), clonedStage = new PIXI.Sprite(stageTexture);
|
|
11
|
+
const sprite = application.stage.getChildByName(spriteName);
|
|
12
|
+
if (sprite == null) return;
|
|
13
|
+
const spriteBounds = sprite.getBounds(), stageTexture = application.renderer.generateTexture(application.stage).clone(), clonedStage = new PIXI.Sprite(stageTexture);
|
|
14
14
|
clonedStage.height = spriteBounds.height, clonedStage.width = spriteBounds.width, clonedStage.position = new PIXI.Point(0, 0);
|
|
15
|
-
const background = new PIXI.
|
|
16
|
-
background.
|
|
17
|
-
const backdrop = new PIXI.Graphics();
|
|
18
|
-
backdrop.rect(0, 0, spriteBounds.width, spriteBounds.height), backdrop.fill({
|
|
19
|
-
color: 16777215,
|
|
20
|
-
alpha: 0.5
|
|
21
|
-
});
|
|
15
|
+
const background = new PIXI.Graphics();
|
|
16
|
+
background.beginFill(16777215, 0.5), background.drawRect(0, 0, spriteBounds.width, spriteBounds.height), background.endFill(), background.name = CROP_BACKGROUND_NAME, background.position = new PIXI.Point(spriteBounds.x, spriteBounds.y);
|
|
22
17
|
const rectMask = new PIXI.Graphics();
|
|
23
|
-
rectMask.
|
|
24
|
-
color: 0,
|
|
25
|
-
alpha: 1
|
|
26
|
-
}), rectMask.position = new PIXI.Point(PADDING, PADDING), rectMask.label = CROP_MASK_NAME, clonedStage.mask = rectMask, application.stage.addChild(background), background.addChild(backdrop), background.addChild(rectMask), background.addChild(clonedStage);
|
|
18
|
+
rectMask.beginFill(0, 1), rectMask.drawRect(0, 0, spriteBounds.width - 2 * PADDING, spriteBounds.height - 2 * PADDING), rectMask.endFill(), rectMask.position = new PIXI.Point(PADDING, PADDING), rectMask.name = CROP_MASK_NAME, clonedStage.mask = rectMask, application.stage.addChild(background), background.addChild(rectMask), background.addChild(clonedStage);
|
|
27
19
|
}
|
|
28
20
|
function removeBackground(application) {
|
|
29
|
-
const child = application.stage.
|
|
21
|
+
const child = application.stage.getChildByName(CROP_BACKGROUND_NAME, !0);
|
|
30
22
|
child == null || child.removeFromParent();
|
|
31
23
|
}
|
|
32
24
|
function computeCornerPosition(cornerType, bounds) {
|
|
@@ -62,10 +54,10 @@ function computeCornerPosition(cornerType, bounds) {
|
|
|
62
54
|
}
|
|
63
55
|
}
|
|
64
56
|
function refreshCorners(application) {
|
|
65
|
-
const mask = application.stage.
|
|
66
|
-
mask && CORNERS.forEach((cornerType) => {
|
|
67
|
-
const corner = application.stage.
|
|
68
|
-
if (
|
|
57
|
+
const mask = application.stage.getChildByName(CROP_MASK_NAME, !0);
|
|
58
|
+
mask != null && CORNERS.forEach((cornerType) => {
|
|
59
|
+
const corner = application.stage.getChildByName(getCornerName(cornerType), !0);
|
|
60
|
+
if (corner == null) return;
|
|
69
61
|
const position = computeCornerPosition(cornerType, {
|
|
70
62
|
height: mask.height,
|
|
71
63
|
width: mask.width,
|
|
@@ -78,10 +70,10 @@ function refreshCorners(application) {
|
|
|
78
70
|
function drawCorner(application, cornerType, {
|
|
79
71
|
spriteName
|
|
80
72
|
}) {
|
|
81
|
-
const previous = application.stage.
|
|
73
|
+
const previous = application.stage.getChildByName(getCornerName(cornerType), !0), scale = getApplicationScale(application);
|
|
82
74
|
previous == null || previous.removeFromParent();
|
|
83
|
-
const background = application.stage.
|
|
84
|
-
if (
|
|
75
|
+
const background = application.stage.getChildByName(CROP_BACKGROUND_NAME, !0), mask = application.stage.getChildByName(CROP_MASK_NAME, !0), sprite = application.stage.getChildByName(spriteName);
|
|
76
|
+
if (sprite == null || background === null || background === void 0 || mask === void 0 || mask === null)
|
|
85
77
|
return;
|
|
86
78
|
const position = computeCornerPosition(cornerType, {
|
|
87
79
|
height: mask.height,
|
|
@@ -89,17 +81,13 @@ function drawCorner(application, cornerType, {
|
|
|
89
81
|
x: mask.x,
|
|
90
82
|
y: mask.y
|
|
91
83
|
}), corner = new PIXI.Graphics();
|
|
92
|
-
corner.arc(0, 0, POINT_RADIUS / scale, position.start, position.end), corner.lineTo(0, 0), corner.
|
|
93
|
-
color: 4960213,
|
|
94
|
-
alpha: 1
|
|
95
|
-
}), corner.position = new PIXI.Point(position.x, position.y), corner.label = getCornerName(cornerType), corner.interactive = !0;
|
|
84
|
+
corner.beginFill(4960213, 1), corner.arc(0, 0, POINT_RADIUS / scale, position.start, position.end), corner.lineTo(0, 0), corner.endFill(), corner.position = new PIXI.Point(position.x, position.y), corner.name = getCornerName(cornerType), corner.interactive = !0;
|
|
96
85
|
let enable = !1;
|
|
97
|
-
|
|
98
|
-
if (!
|
|
86
|
+
application.stage.on("pointermove", (event) => {
|
|
87
|
+
if (enable === !1) return;
|
|
99
88
|
const localPosition = background.toLocal(event.global);
|
|
100
89
|
corner.position.x = localPosition.x, corner.position.y = localPosition.y, moveMask(application, cornerType, localPosition);
|
|
101
|
-
};
|
|
102
|
-
application.stage.on("pointermove", handlePointerMove);
|
|
90
|
+
});
|
|
103
91
|
const handlePointerDown = () => {
|
|
104
92
|
enable = !0;
|
|
105
93
|
};
|
|
@@ -108,12 +96,12 @@ function drawCorner(application, cornerType, {
|
|
|
108
96
|
enable = !1;
|
|
109
97
|
};
|
|
110
98
|
globalThis.addEventListener("pointerup", handlePointerUp), corner.once("destroyed", () => {
|
|
111
|
-
corner.off("pointerdown"),
|
|
99
|
+
corner.off("pointerdown"), globalThis.removeEventListener("pointerup", handlePointerUp);
|
|
112
100
|
}), background.addChild(corner);
|
|
113
101
|
}
|
|
114
102
|
function moveMask(application, cornerType, position) {
|
|
115
|
-
const mask = application.stage.
|
|
116
|
-
if (
|
|
103
|
+
const mask = application.stage.getChildByName(CROP_MASK_NAME, !0);
|
|
104
|
+
if (mask == null) return;
|
|
117
105
|
const right = mask.position.x + mask.width, bottom = mask.position.y + mask.height;
|
|
118
106
|
switch (cornerType) {
|
|
119
107
|
case "TOP_LEFT": {
|
|
@@ -154,15 +142,11 @@ function stop(application) {
|
|
|
154
142
|
removeBackground(application), application.stage.off("pointermove"), application.render();
|
|
155
143
|
}
|
|
156
144
|
function save(application) {
|
|
157
|
-
const mask = application.stage.
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
target: application.stage,
|
|
163
|
-
frame
|
|
164
|
-
});
|
|
165
|
-
return removeBackground(application), application.stage.off("pointermove"), new PIXI.Sprite(croppedTexture);
|
|
145
|
+
const mask = application.stage.getChildByName(CROP_MASK_NAME, !0);
|
|
146
|
+
if (mask == null) return;
|
|
147
|
+
stop(application);
|
|
148
|
+
const stageTexture = application.renderer.generateTexture(application.stage).clone(), clonedStage = new PIXI.Sprite(stageTexture), maskBounds = mask.getBounds(), bounds = new PIXI.Rectangle(Math.floor(maskBounds.x), Math.floor(maskBounds.y), Math.floor(maskBounds.width), Math.floor(maskBounds.height)), cropped = new PIXI.Texture(clonedStage.texture.baseTexture, bounds);
|
|
149
|
+
return new PIXI.Sprite(cropped);
|
|
166
150
|
}
|
|
167
151
|
export {
|
|
168
152
|
save,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as PIXI from 'pixi.js';
|
|
2
2
|
export declare const DEFAULT_SPRITE_NAME = "image";
|
|
3
3
|
/**
|
|
4
|
-
* A structure that
|
|
5
|
-
*
|
|
4
|
+
* A structure that define all setting of an image
|
|
5
|
+
* - positon
|
|
6
|
+
* - scale
|
|
7
|
+
* - size
|
|
8
|
+
* - size of the stage
|
|
6
9
|
*/
|
|
7
10
|
export interface ImageSettings {
|
|
8
11
|
stage: {
|
|
@@ -36,12 +39,13 @@ export interface ImageSettings {
|
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
|
-
*
|
|
42
|
+
* This function update the image content using Blob datasource
|
|
40
43
|
*
|
|
41
44
|
* @param application the PIXI.Application context
|
|
42
45
|
* @param param.spriteName the name of the sprite in the context
|
|
43
|
-
* @param param.imgDatasource the
|
|
44
|
-
* @param param.
|
|
46
|
+
* @param param.imgDatasource the img data could be one of: string url, HTMLImageElement, PIXI.Sprite
|
|
47
|
+
* @param param.stageSize?: { width: number; height: number };
|
|
48
|
+
* @param param.spriteSize?: { width: number; height: number };
|
|
45
49
|
*/
|
|
46
50
|
export declare function updateImageFromBlob(application: PIXI.Application, { spriteName, imgDatasource, settings, }: {
|
|
47
51
|
spriteName: string;
|
|
@@ -49,12 +53,13 @@ export declare function updateImageFromBlob(application: PIXI.Application, { spr
|
|
|
49
53
|
settings?: ImageSettings;
|
|
50
54
|
}): Promise<PIXI.Sprite | null>;
|
|
51
55
|
/**
|
|
52
|
-
*
|
|
56
|
+
* This function update the image content for the sprite in the PIXI.Application context
|
|
53
57
|
*
|
|
54
58
|
* @param application the PIXI.Application context
|
|
55
59
|
* @param param.spriteName the name of the sprite in the context
|
|
56
|
-
* @param param.imgDatasource the
|
|
57
|
-
* @param param.
|
|
60
|
+
* @param param.imgDatasource the img data could be one of: string url, HTMLImageElement, PIXI.Sprite
|
|
61
|
+
* @param param.spriteSize
|
|
62
|
+
* @param param.stageSize
|
|
58
63
|
*/
|
|
59
64
|
export declare function updateImage(application: PIXI.Application, { spriteName, imgDatasource, settings, }: {
|
|
60
65
|
spriteName: string;
|
|
@@ -99,9 +104,10 @@ export declare function saveAsBlob(application: PIXI.Application): Promise<Blob>
|
|
|
99
104
|
*/
|
|
100
105
|
export declare function saveAsDataURL(application: PIXI.Application): string | undefined;
|
|
101
106
|
/**
|
|
102
|
-
* Calculates the scale
|
|
107
|
+
* Calculates the scale percentage for a PIXI.Sprite or the application view based on the parent container's dimensions.
|
|
103
108
|
* @param application - The PIXI.Application instance.
|
|
104
|
-
* @
|
|
109
|
+
* @param sprite - The PIXI.Sprite instance (optional).
|
|
110
|
+
* @returns The scale percentage.
|
|
105
111
|
*/
|
|
106
112
|
export declare function getApplicationScale(application: PIXI.Application): number;
|
|
107
113
|
export declare function toBlob(application: PIXI.Application): Promise<Blob>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as PIXI from "pixi.js";
|
|
2
|
-
import { BLUR_LAYER_NAME } from "./constants.js";
|
|
3
2
|
const MIN_HEIGHT = 100, MIN_WIDTH = 100, MODAL_VERTICAL_PADDING = 450, MODAL_HORIZONTAL_PADDING = 64, DEFAULT_QUALITY = 0.5, DEFAULT_SPRITE_NAME = "image";
|
|
4
3
|
function updateImageFromBlob(application, {
|
|
5
4
|
spriteName,
|
|
@@ -7,17 +6,15 @@ function updateImageFromBlob(application, {
|
|
|
7
6
|
settings
|
|
8
7
|
}) {
|
|
9
8
|
const imageUrl = URL.createObjectURL(imgDatasource), image = new Image();
|
|
10
|
-
return image.src = imageUrl, new Promise((resolve
|
|
9
|
+
return image.src = imageUrl, new Promise((resolve) => {
|
|
11
10
|
image.onload = async () => {
|
|
12
|
-
|
|
11
|
+
await updateImage(application, {
|
|
13
12
|
spriteName,
|
|
14
13
|
imgDatasource: image,
|
|
15
14
|
settings
|
|
16
15
|
});
|
|
17
|
-
const newSprite = application == null ? void 0 : application.stage.
|
|
16
|
+
const newSprite = application == null ? void 0 : application.stage.getChildByName(spriteName, !0);
|
|
18
17
|
resolve(newSprite);
|
|
19
|
-
}, image.onerror = () => {
|
|
20
|
-
URL.revokeObjectURL(imageUrl), reject(new Error("Failed to load image from Blob"));
|
|
21
18
|
};
|
|
22
19
|
});
|
|
23
20
|
}
|
|
@@ -28,22 +25,10 @@ async function updateImage(application, {
|
|
|
28
25
|
}) {
|
|
29
26
|
if (application === void 0 || application.stage === null)
|
|
30
27
|
return;
|
|
31
|
-
const previous = application.stage.
|
|
28
|
+
const previous = application.stage.getChildByName(spriteName, !0);
|
|
32
29
|
previous == null || previous.removeFromParent();
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
let sprite;
|
|
36
|
-
if (imgDatasource instanceof PIXI.Sprite)
|
|
37
|
-
sprite = imgDatasource;
|
|
38
|
-
else if (imgDatasource instanceof HTMLImageElement)
|
|
39
|
-
sprite = new PIXI.Sprite(PIXI.Texture.from(imgDatasource));
|
|
40
|
-
else {
|
|
41
|
-
const img = new Image();
|
|
42
|
-
img.crossOrigin = "anonymous", img.src = imgDatasource, await new Promise((resolve, reject) => {
|
|
43
|
-
img.complete ? resolve() : (img.onload = () => resolve(), img.onerror = reject);
|
|
44
|
-
}), sprite = new PIXI.Sprite(PIXI.Texture.from(img));
|
|
45
|
-
}
|
|
46
|
-
if (sprite.interactive = !0, sprite.label = spriteName, settings) {
|
|
30
|
+
const texture = imgDatasource instanceof HTMLImageElement ? PIXI.Texture.from(imgDatasource) : imgDatasource instanceof PIXI.Sprite ? imgDatasource : await PIXI.Texture.fromURL(imgDatasource), sprite = texture instanceof PIXI.Sprite ? texture : PIXI.Sprite.from(texture, {});
|
|
31
|
+
if (sprite.interactive = !0, sprite.name = spriteName, settings) {
|
|
47
32
|
const {
|
|
48
33
|
sprite: {
|
|
49
34
|
anchor,
|
|
@@ -63,7 +48,7 @@ async function updateImage(application, {
|
|
|
63
48
|
}
|
|
64
49
|
function autoResize(application, sprite) {
|
|
65
50
|
var _a;
|
|
66
|
-
const parent = application.
|
|
51
|
+
const parent = application.view.parentNode, maxMobileWidth = window.innerWidth - MODAL_HORIZONTAL_PADDING, parentWidth = Math.max((parent == null ? void 0 : parent.offsetWidth) ?? 0, MIN_WIDTH), newSize = constraintSize({
|
|
67
52
|
width: sprite.width,
|
|
68
53
|
height: sprite.height
|
|
69
54
|
}, {
|
|
@@ -79,7 +64,7 @@ function autoResize(application, sprite) {
|
|
|
79
64
|
height: newHeight,
|
|
80
65
|
width: newWidth
|
|
81
66
|
} = newSize;
|
|
82
|
-
(_a = application.
|
|
67
|
+
(_a = application.view) != null && _a.style && (application.view.style.width = `${newWidth}px`, application.view.style.height = `${newHeight}px`);
|
|
83
68
|
}
|
|
84
69
|
function constraintSize(size, constraints) {
|
|
85
70
|
const {
|
|
@@ -98,22 +83,22 @@ function constraintSize(size, constraints) {
|
|
|
98
83
|
function saveAsBlob(application) {
|
|
99
84
|
return new Promise((resolve, reject) => {
|
|
100
85
|
var _a;
|
|
101
|
-
(_a = application == null ? void 0 : application.
|
|
86
|
+
(_a = application == null ? void 0 : application.view) != null && _a.toBlob ? application.view.toBlob((blob) => {
|
|
102
87
|
blob ? resolve(blob) : reject("EXTRACT_FAILED");
|
|
103
88
|
}, "image/jpeg", DEFAULT_QUALITY) : reject("EXTRACT_FAILED");
|
|
104
89
|
});
|
|
105
90
|
}
|
|
106
91
|
function saveAsDataURL(application) {
|
|
107
92
|
var _a, _b;
|
|
108
|
-
return (_b = (_a = application.
|
|
93
|
+
return (_b = (_a = application.view).toDataURL) == null ? void 0 : _b.call(_a);
|
|
109
94
|
}
|
|
110
95
|
function getApplicationScale(application) {
|
|
111
|
-
return application.
|
|
96
|
+
return application.view.getBoundingClientRect ? application.view.getBoundingClientRect().width / application.view.width : 1;
|
|
112
97
|
}
|
|
113
98
|
function toBlob(application) {
|
|
114
99
|
return new Promise((resolve, reject) => {
|
|
115
100
|
var _a, _b;
|
|
116
|
-
(_b = (_a = application.
|
|
101
|
+
(_b = (_a = application.view).toBlob) == null || _b.call(_a, (blob) => {
|
|
117
102
|
blob ? resolve(blob) : reject("EXTRACT_FAIL");
|
|
118
103
|
}, "image/png", 1);
|
|
119
104
|
});
|
|
@@ -7,15 +7,19 @@ import * as PIXI from 'pixi.js';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function start(application: PIXI.Application, spriteName: string): void;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* If {saveChanges} is true remove all graphical controls then resize the sprite
|
|
11
|
+
* If {saveChanges} is false remove all graphical controls and keep original size
|
|
11
12
|
*
|
|
12
13
|
* @param application the PIXI.Application context
|
|
14
|
+
* @param param.saveChanges true if we should save the resize
|
|
15
|
+
* @param param.spriteName the name of the sprite representing the original image
|
|
13
16
|
*/
|
|
14
17
|
export declare function stop(application: PIXI.Application): void;
|
|
15
18
|
/**
|
|
16
|
-
* Apply the resize and return the result as a PIXI.Sprite
|
|
17
19
|
*
|
|
18
20
|
* @param application the PIXI.Application context
|
|
19
|
-
* @
|
|
21
|
+
* @param spriteName the name of the sprite representing the image
|
|
22
|
+
* @param size the target size of the image {width, height}
|
|
23
|
+
* @returns a PIXI.Sprite with a image resized or undefined if not found
|
|
20
24
|
*/
|
|
21
25
|
export declare function save(application: PIXI.Application): PIXI.Sprite | undefined;
|
|
@@ -42,8 +42,8 @@ function resizeContainer(application, {
|
|
|
42
42
|
position,
|
|
43
43
|
spriteName
|
|
44
44
|
}) {
|
|
45
|
-
const sprite = application.stage.
|
|
46
|
-
if (
|
|
45
|
+
const sprite = application.stage.getChildByName(spriteName, !0);
|
|
46
|
+
if (sprite == null) return;
|
|
47
47
|
const isRotated = sprite.rotation % Math.PI !== 0, spriteWidth = isRotated ? sprite.height : sprite.width, spriteHeight = isRotated ? sprite.width : sprite.height;
|
|
48
48
|
switch (cornerType) {
|
|
49
49
|
case "TOP_LEFT": {
|
|
@@ -68,23 +68,20 @@ function resizeContainer(application, {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
function removeCorner(application, cornerType) {
|
|
71
|
-
const previous = application.stage.
|
|
71
|
+
const previous = application.stage.getChildByName(getCornerName(cornerType), !0);
|
|
72
72
|
previous == null || previous.removeFromParent();
|
|
73
73
|
}
|
|
74
74
|
function drawCorner(application, cornerType, {
|
|
75
75
|
spriteName
|
|
76
76
|
}) {
|
|
77
77
|
removeCorner(application, cornerType);
|
|
78
|
-
const sprite = application.stage.
|
|
79
|
-
if (
|
|
78
|
+
const sprite = application.stage.getChildByName(spriteName, !0), container = application.stage.getChildByName(CONTROL_NAME, !0);
|
|
79
|
+
if (sprite == null || container === null || container === void 0) return;
|
|
80
80
|
const position = computeCornerPosition(cornerType, container), corner = new PIXI.Graphics();
|
|
81
|
-
corner.arc(0, 0, POINT_RADIUS, position.start, position.end), corner.lineTo(0, 0), corner.
|
|
82
|
-
color: 4960213,
|
|
83
|
-
alpha: 1
|
|
84
|
-
}), corner.position = new PIXI.Point(position.x, position.y), corner.label = getCornerName(cornerType), corner.interactive = !0;
|
|
81
|
+
corner.beginFill(4960213, 1), corner.arc(0, 0, POINT_RADIUS, position.start, position.end), corner.lineTo(0, 0), corner.endFill(), corner.position = new PIXI.Point(position.x, position.y), corner.name = getCornerName(cornerType), corner.interactive = !0;
|
|
85
82
|
let enable = !1;
|
|
86
|
-
|
|
87
|
-
if (!
|
|
83
|
+
application.stage.on("pointermove", (event) => {
|
|
84
|
+
if (enable === !1) return;
|
|
88
85
|
const localPosition = application.stage.toLocal(event.global);
|
|
89
86
|
resizeContainer(application, {
|
|
90
87
|
cornerType,
|
|
@@ -92,37 +89,31 @@ function drawCorner(application, cornerType, {
|
|
|
92
89
|
container,
|
|
93
90
|
spriteName
|
|
94
91
|
});
|
|
95
|
-
};
|
|
96
|
-
application.stage.on("pointermove", handlePointerMove);
|
|
97
|
-
const handlePointerDown = () => {
|
|
98
|
-
enable = !0;
|
|
99
|
-
};
|
|
100
|
-
corner.on("pointerdown", handlePointerDown);
|
|
92
|
+
});
|
|
101
93
|
const handlePointerUp = () => {
|
|
102
94
|
enable = !1;
|
|
103
95
|
};
|
|
104
96
|
globalThis.addEventListener("pointerup", handlePointerUp), corner.once("destroyed", () => {
|
|
105
|
-
corner.off("pointerdown"),
|
|
106
|
-
})
|
|
97
|
+
corner.off("pointerdown"), globalThis.removeEventListener("pointerup", handlePointerUp);
|
|
98
|
+
});
|
|
99
|
+
const handlePointerDown = () => {
|
|
100
|
+
enable = !0;
|
|
101
|
+
};
|
|
102
|
+
corner.on("pointerdown", handlePointerDown), container.addChild(corner);
|
|
107
103
|
}
|
|
108
104
|
function drawContainer(application, spriteName) {
|
|
109
105
|
removeContainer(application);
|
|
110
|
-
const sprite = application.stage.
|
|
111
|
-
if (
|
|
106
|
+
const sprite = application.stage.getChildByName(spriteName, !0);
|
|
107
|
+
if (sprite == null) return;
|
|
112
108
|
const stageTexture = application.renderer.generateTexture(application.stage), clonedStage = new PIXI.Sprite(stageTexture);
|
|
113
109
|
application.stage.children.forEach((child) => {
|
|
114
110
|
child.alpha = 0;
|
|
115
111
|
});
|
|
116
|
-
const container = new PIXI.
|
|
117
|
-
container.
|
|
118
|
-
const bounds = new PIXI.Graphics();
|
|
119
|
-
bounds.rect(0, 0, sprite.width, sprite.height), bounds.fill({
|
|
120
|
-
color: 0,
|
|
121
|
-
alpha: 0
|
|
122
|
-
}), application.stage.interactive = !0, application.stage.interactiveChildren = !0, application.stage.addChild(container), container.addChild(bounds), container.addChild(clonedStage);
|
|
112
|
+
const container = new PIXI.Graphics();
|
|
113
|
+
container.drawRect(0, 0, sprite.width, sprite.height), container.name = CONTROL_NAME, container.interactive = !0, container.interactiveChildren = !0, application.stage.interactive = !0, application.stage.interactiveChildren = !0, application.stage.addChild(container), container.addChild(clonedStage);
|
|
123
114
|
}
|
|
124
115
|
function removeContainer(application) {
|
|
125
|
-
const container = application.stage.
|
|
116
|
+
const container = application.stage.getChildByName(CONTROL_NAME, !0);
|
|
126
117
|
container == null || container.removeFromParent(), application.stage.children.forEach((child) => {
|
|
127
118
|
child.alpha = 1;
|
|
128
119
|
});
|
|
@@ -149,12 +140,12 @@ function stop(application) {
|
|
|
149
140
|
}
|
|
150
141
|
function save(application) {
|
|
151
142
|
var _a;
|
|
152
|
-
const container = (_a = application == null ? void 0 : application.stage) == null ? void 0 : _a.
|
|
143
|
+
const container = (_a = application == null ? void 0 : application.stage) == null ? void 0 : _a.getChildByName(CONTROL_NAME, !0), size = container ? {
|
|
153
144
|
height: container.height,
|
|
154
145
|
width: container.width
|
|
155
146
|
} : void 0;
|
|
156
147
|
if (removeControl(application), size) {
|
|
157
|
-
const stageTexture = application.renderer.generateTexture(application.stage), clonedStage = new PIXI.Sprite(stageTexture);
|
|
148
|
+
const stageTexture = application.renderer.generateTexture(application.stage).clone(), clonedStage = new PIXI.Sprite(stageTexture);
|
|
158
149
|
return clonedStage.width = size.width, clonedStage.height = size.height, clonedStage;
|
|
159
150
|
} else
|
|
160
151
|
return;
|