pages_core 3.15.3 → 3.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/assets/builds/pages_core/admin-dist.js +1 -1
- data/app/assets/builds/pages_core/admin-dist.js.map +3 -3
- data/app/javascript/components/ImageCropper.tsx +16 -16
- data/app/javascript/components/PageForm.tsx +7 -0
- data/app/javascript/components/TagEditor/useTags.ts +4 -2
- data/app/javascript/types/Tags.ts +3 -4
- metadata +2 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, {
|
1
|
+
import React, { useCallback, useState } from "react";
|
2
2
|
|
3
3
|
import * as Crop from "../types/Crop";
|
4
4
|
|
@@ -24,28 +24,28 @@ function focalPoint(state: Crop.State): Crop.Position {
|
|
24
24
|
}
|
25
25
|
}
|
26
26
|
|
27
|
-
|
28
|
-
const containerRef = useRef<HTMLDivElement>();
|
27
|
+
function useContainerSize(): [(node?: HTMLDivElement) => void, Crop.Size] {
|
29
28
|
const [containerSize, setContainerSize] = useState<Crop.Size>();
|
30
29
|
|
31
|
-
const
|
32
|
-
const
|
33
|
-
if (elem) {
|
30
|
+
const ref = useCallback((node?: HTMLDivElement) => {
|
31
|
+
const measure = () => {
|
34
32
|
setContainerSize({
|
35
|
-
width:
|
36
|
-
height:
|
33
|
+
width: node.offsetWidth - 2,
|
34
|
+
height: node.offsetHeight - 2
|
37
35
|
});
|
36
|
+
};
|
37
|
+
if (node !== null) {
|
38
|
+
measure();
|
39
|
+
const observer = new ResizeObserver(measure);
|
40
|
+
observer.observe(node);
|
38
41
|
}
|
39
|
-
};
|
42
|
+
}, []);
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
return function cleanup() {
|
44
|
-
window.removeEventListener("resize", handleResize);
|
45
|
-
};
|
46
|
-
});
|
44
|
+
return [ref, containerSize];
|
45
|
+
}
|
47
46
|
|
48
|
-
|
47
|
+
export default function ImageCropper(props: Props) {
|
48
|
+
const [containerRef, containerSize] = useContainerSize();
|
49
49
|
|
50
50
|
const setAspect = (aspect: number) => {
|
51
51
|
props.dispatch({ type: "setAspect", payload: aspect });
|
@@ -107,6 +107,13 @@ export default function PageForm(props: Props) {
|
|
107
107
|
} else {
|
108
108
|
filesState.update(response.page_files);
|
109
109
|
imagesState.update(response.page_images);
|
110
|
+
tagsDispatch({
|
111
|
+
type: "update",
|
112
|
+
payload: {
|
113
|
+
tags: response.tags_and_suggestions,
|
114
|
+
enabled: response.enabled_tags
|
115
|
+
}
|
116
|
+
});
|
110
117
|
noticeToast("Your changes were saved");
|
111
118
|
}
|
112
119
|
})
|
@@ -32,15 +32,17 @@ function toggle(tag: string, state: Tags.State) {
|
|
32
32
|
|
33
33
|
function reducer(state: Tags.State, action: Tags.Action) {
|
34
34
|
const { type, payload } = action;
|
35
|
-
const normalized = normalize(payload, state);
|
36
35
|
switch (type) {
|
37
36
|
case "addTag":
|
37
|
+
const normalized = normalize(payload, state);
|
38
38
|
return {
|
39
39
|
tags: [...state.tags, normalized].filter(onlyUnique),
|
40
40
|
enabled: [...state.enabled, normalized].filter(onlyUnique)
|
41
41
|
};
|
42
42
|
case "toggleTag":
|
43
|
-
return toggle(
|
43
|
+
return toggle(normalize(payload, state), state);
|
44
|
+
case "update":
|
45
|
+
return payload;
|
44
46
|
default:
|
45
47
|
return state;
|
46
48
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pages_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.15.
|
4
|
+
version: 3.15.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inge Jørgensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|