itmar-block-packages 1.3.16 → 1.3.18
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 +38 -9
- package/build/index.asset.php +1 -1
- package/build/index.js +3 -3
- package/package.json +1 -1
- package/src/BlockPlace.js +114 -138
- package/src/cssPropertes.js +7 -7
- package/src/customFooks.js +24 -0
- package/src/index.js +4 -1
- package/src/wordpressApi.js +43 -4
package/package.json
CHANGED
package/src/BlockPlace.js
CHANGED
|
@@ -45,10 +45,10 @@ const vert_around = <Icon icon={justifySpaceBetween} className="rotate-icon" />;
|
|
|
45
45
|
export default function BlockPlace(props) {
|
|
46
46
|
const { attributes, clientId, blockRef, isMobile, isSubmenu, isParallax } =
|
|
47
47
|
props;
|
|
48
|
-
const { positionType, isPosCenter,
|
|
48
|
+
const { positionType, isPosCenter, default_val, mobile_val } = attributes;
|
|
49
49
|
|
|
50
50
|
//モバイルかデスクトップか
|
|
51
|
-
const sel_pos = isMobile ?
|
|
51
|
+
const sel_pos = isMobile ? mobile_val : default_val;
|
|
52
52
|
|
|
53
53
|
//配置アイコンの選択
|
|
54
54
|
const start_icon = sel_pos.direction === "vertical" ? upper : justifyLeft;
|
|
@@ -186,15 +186,23 @@ export default function BlockPlace(props) {
|
|
|
186
186
|
/>
|
|
187
187
|
)}
|
|
188
188
|
</ToolbarItem>
|
|
189
|
+
{(sel_pos.direction === "horizen" ||
|
|
190
|
+
sel_pos.direction === "vertical") && (
|
|
191
|
+
<PanelRow className="position_row">
|
|
192
|
+
<ToggleControl
|
|
193
|
+
label={__("reverse", "block-collections")}
|
|
194
|
+
checked={sel_pos.reverse}
|
|
195
|
+
onChange={(checked) => props.onReverseChange(checked)}
|
|
196
|
+
/>
|
|
197
|
+
<ToggleControl
|
|
198
|
+
label={__("wrap", "block-collections")}
|
|
199
|
+
checked={sel_pos.wrap}
|
|
200
|
+
onChange={(checked) => props.onWrapChange(checked)}
|
|
201
|
+
/>
|
|
202
|
+
</PanelRow>
|
|
203
|
+
)}
|
|
189
204
|
</ToolbarGroup>
|
|
190
|
-
|
|
191
|
-
sel_pos.direction === "vertical") && (
|
|
192
|
-
<ToggleControl
|
|
193
|
-
label={__("reverse", "block-collections")}
|
|
194
|
-
checked={sel_pos.reverse}
|
|
195
|
-
onChange={(checked) => props.onReverseChange(checked)}
|
|
196
|
-
/>
|
|
197
|
-
)}
|
|
205
|
+
|
|
198
206
|
{sel_pos.direction !== "block" && sel_pos.direction !== "grid" && (
|
|
199
207
|
<>
|
|
200
208
|
{isMobile ? (
|
|
@@ -262,15 +270,14 @@ export default function BlockPlace(props) {
|
|
|
262
270
|
</>
|
|
263
271
|
)}
|
|
264
272
|
|
|
265
|
-
{!
|
|
266
|
-
!isSubmenu &&
|
|
273
|
+
{!isSubmenu &&
|
|
267
274
|
(isMobile ? (
|
|
268
275
|
<p>{__("Block alignment(Mobile)", "block-collections")}</p>
|
|
269
276
|
) : (
|
|
270
277
|
<p>{__("Block alignment(DeskTop)", "block-collections")}</p>
|
|
271
278
|
))}
|
|
272
279
|
|
|
273
|
-
{!
|
|
280
|
+
{!isSubmenu && (
|
|
274
281
|
<ToolbarGroup>
|
|
275
282
|
<ToolbarItem>
|
|
276
283
|
{(itemProps) => (
|
|
@@ -310,9 +317,9 @@ export default function BlockPlace(props) {
|
|
|
310
317
|
{isContainer && (
|
|
311
318
|
<>
|
|
312
319
|
{isMobile ? (
|
|
313
|
-
<p>{__("
|
|
320
|
+
<p>{__("Alignment in container(Mobile)", "block-collections")}</p>
|
|
314
321
|
) : (
|
|
315
|
-
<p>{__("
|
|
322
|
+
<p>{__("Alignment in container(DeskTop)", "block-collections")}</p>
|
|
316
323
|
)}
|
|
317
324
|
|
|
318
325
|
<ToolbarGroup>
|
|
@@ -385,114 +392,22 @@ export default function BlockPlace(props) {
|
|
|
385
392
|
</>
|
|
386
393
|
)}
|
|
387
394
|
|
|
388
|
-
<
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
/>
|
|
398
|
-
)}
|
|
399
|
-
</ToolbarItem>
|
|
400
|
-
<ToolbarItem>
|
|
401
|
-
{(itemProps) => (
|
|
402
|
-
<Button
|
|
403
|
-
{...itemProps}
|
|
404
|
-
isPressed={sel_pos.width_val === "fit"}
|
|
405
|
-
onClick={() => props.onWidthChange("fit")}
|
|
406
|
-
text="fit"
|
|
407
|
-
/>
|
|
408
|
-
)}
|
|
409
|
-
</ToolbarItem>
|
|
410
|
-
<ToolbarItem>
|
|
411
|
-
{(itemProps) => (
|
|
412
|
-
<Button
|
|
413
|
-
{...itemProps}
|
|
414
|
-
isPressed={sel_pos.width_val === "wideSize"}
|
|
415
|
-
onClick={() => props.onWidthChange("wideSize")}
|
|
416
|
-
icon={stretchWide}
|
|
417
|
-
label={__("Wide Size", "block-collections")}
|
|
418
|
-
/>
|
|
419
|
-
)}
|
|
420
|
-
</ToolbarItem>
|
|
421
|
-
<ToolbarItem>
|
|
422
|
-
{(itemProps) => (
|
|
423
|
-
<Button
|
|
424
|
-
{...itemProps}
|
|
425
|
-
isPressed={sel_pos.width_val === "contentSize"}
|
|
426
|
-
onClick={() => props.onWidthChange("contentSize")}
|
|
427
|
-
icon={positionCenter}
|
|
428
|
-
label={__("Content Size", "block-collections")}
|
|
429
|
-
/>
|
|
430
|
-
)}
|
|
431
|
-
</ToolbarItem>
|
|
432
|
-
<ToolbarItem>
|
|
433
|
-
{(itemProps) => (
|
|
434
|
-
<Button
|
|
435
|
-
{...itemProps}
|
|
436
|
-
isPressed={sel_pos.width_val === "free"}
|
|
437
|
-
onClick={() => props.onWidthChange("free")}
|
|
438
|
-
text="free"
|
|
439
|
-
/>
|
|
440
|
-
)}
|
|
441
|
-
</ToolbarItem>
|
|
442
|
-
</ToolbarGroup>
|
|
443
|
-
|
|
444
|
-
{sel_pos.width_val === "free" && (
|
|
445
|
-
<UnitControl
|
|
446
|
-
dragDirection="e"
|
|
447
|
-
onChange={(newValue) => props.onFreeWidthChange(newValue)}
|
|
448
|
-
value={sel_pos.free_width}
|
|
449
|
-
/>
|
|
450
|
-
)}
|
|
395
|
+
<BlockWidth
|
|
396
|
+
attributes={attributes}
|
|
397
|
+
isMobile={isMobile}
|
|
398
|
+
isSubmenu={isSubmenu}
|
|
399
|
+
onWidthChange={(key, widthVal) => props.onWidthChange(key, widthVal)}
|
|
400
|
+
onFreeWidthChange={(key, freeVal) =>
|
|
401
|
+
props.onFreeWidthChange(key, freeVal)
|
|
402
|
+
}
|
|
403
|
+
/>
|
|
451
404
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
<ToolbarItem>
|
|
459
|
-
{(itemProps) => (
|
|
460
|
-
<Button
|
|
461
|
-
{...itemProps}
|
|
462
|
-
isPressed={sel_pos.height_val === "full"}
|
|
463
|
-
onClick={() => props.onHeightChange("full")}
|
|
464
|
-
text="full"
|
|
465
|
-
/>
|
|
466
|
-
)}
|
|
467
|
-
</ToolbarItem>
|
|
468
|
-
<ToolbarItem>
|
|
469
|
-
{(itemProps) => (
|
|
470
|
-
<Button
|
|
471
|
-
{...itemProps}
|
|
472
|
-
isPressed={sel_pos.height_val === "fit"}
|
|
473
|
-
onClick={() => props.onHeightChange("fit")}
|
|
474
|
-
text="fit"
|
|
475
|
-
/>
|
|
476
|
-
)}
|
|
477
|
-
</ToolbarItem>
|
|
478
|
-
<ToolbarItem>
|
|
479
|
-
{(itemProps) => (
|
|
480
|
-
<Button
|
|
481
|
-
{...itemProps}
|
|
482
|
-
isPressed={sel_pos.height_val === "free"}
|
|
483
|
-
onClick={() => props.onHeightChange("free")}
|
|
484
|
-
text="free"
|
|
485
|
-
/>
|
|
486
|
-
)}
|
|
487
|
-
</ToolbarItem>
|
|
488
|
-
</ToolbarGroup>
|
|
489
|
-
{sel_pos.height_val === "free" && (
|
|
490
|
-
<UnitControl
|
|
491
|
-
dragDirection="e"
|
|
492
|
-
onChange={(newValue) => props.onFreeHeightChange(newValue)}
|
|
493
|
-
value={sel_pos.free_height}
|
|
494
|
-
/>
|
|
495
|
-
)}
|
|
405
|
+
<BlockHeight
|
|
406
|
+
attributes={attributes}
|
|
407
|
+
isMobile={isMobile}
|
|
408
|
+
onHeightChange={(heightVal) => props.onHeightChange(heightVal)}
|
|
409
|
+
onFreeHeightChange={(freeVal) => props.onFreeHeightChange(freeVal)}
|
|
410
|
+
/>
|
|
496
411
|
|
|
497
412
|
{sel_pos.direction === "grid" && (
|
|
498
413
|
<>
|
|
@@ -675,25 +590,19 @@ export function BlockWidth(props) {
|
|
|
675
590
|
);
|
|
676
591
|
const blockWidthDesktop = __("Block Width(DeskTop)", "block-collections");
|
|
677
592
|
|
|
678
|
-
//
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
? blockMaxWidthMobile
|
|
682
|
-
: blockWidthMobile
|
|
683
|
-
: isSubmenu
|
|
684
|
-
? blockMaxWidthDesktop
|
|
685
|
-
: blockWidthDesktop;
|
|
686
|
-
|
|
593
|
+
// ラベル
|
|
594
|
+
const widthLabel = isMobile ? blockWidthMobile : blockWidthDesktop;
|
|
595
|
+
const maxWidthLabel = isMobile ? blockMaxWidthMobile : blockMaxWidthDesktop;
|
|
687
596
|
return (
|
|
688
597
|
<>
|
|
689
|
-
<p>{
|
|
598
|
+
<p>{widthLabel}</p>
|
|
690
599
|
<ToolbarGroup>
|
|
691
600
|
<ToolbarItem>
|
|
692
601
|
{(itemProps) => (
|
|
693
602
|
<Button
|
|
694
603
|
{...itemProps}
|
|
695
604
|
isPressed={sel_pos.width_val === "full"}
|
|
696
|
-
onClick={() => props.onWidthChange("full")}
|
|
605
|
+
onClick={() => props.onWidthChange("width_val", "full")}
|
|
697
606
|
text="full"
|
|
698
607
|
/>
|
|
699
608
|
)}
|
|
@@ -703,7 +612,7 @@ export function BlockWidth(props) {
|
|
|
703
612
|
<Button
|
|
704
613
|
{...itemProps}
|
|
705
614
|
isPressed={sel_pos.width_val === "fit"}
|
|
706
|
-
onClick={() => props.onWidthChange("fit")}
|
|
615
|
+
onClick={() => props.onWidthChange("width_val", "fit")}
|
|
707
616
|
text="fit"
|
|
708
617
|
/>
|
|
709
618
|
)}
|
|
@@ -713,7 +622,7 @@ export function BlockWidth(props) {
|
|
|
713
622
|
<Button
|
|
714
623
|
{...itemProps}
|
|
715
624
|
isPressed={sel_pos.width_val === "wideSize"}
|
|
716
|
-
onClick={() => props.onWidthChange("wideSize")}
|
|
625
|
+
onClick={() => props.onWidthChange("width_val", "wideSize")}
|
|
717
626
|
icon={stretchWide}
|
|
718
627
|
label={__("Wide Size", "block-collections")}
|
|
719
628
|
/>
|
|
@@ -724,7 +633,7 @@ export function BlockWidth(props) {
|
|
|
724
633
|
<Button
|
|
725
634
|
{...itemProps}
|
|
726
635
|
isPressed={sel_pos.width_val === "contentSize"}
|
|
727
|
-
onClick={() => props.onWidthChange("contentSize")}
|
|
636
|
+
onClick={() => props.onWidthChange("width_val", "contentSize")}
|
|
728
637
|
icon={positionCenter}
|
|
729
638
|
label={__("Content Size", "block-collections")}
|
|
730
639
|
/>
|
|
@@ -735,7 +644,7 @@ export function BlockWidth(props) {
|
|
|
735
644
|
<Button
|
|
736
645
|
{...itemProps}
|
|
737
646
|
isPressed={sel_pos.width_val === "free"}
|
|
738
|
-
onClick={() => props.onWidthChange("free")}
|
|
647
|
+
onClick={() => props.onWidthChange("width_val", "free")}
|
|
739
648
|
text="free"
|
|
740
649
|
/>
|
|
741
650
|
)}
|
|
@@ -745,10 +654,77 @@ export function BlockWidth(props) {
|
|
|
745
654
|
{sel_pos.width_val === "free" && (
|
|
746
655
|
<UnitControl
|
|
747
656
|
dragDirection="e"
|
|
748
|
-
onChange={(newValue) =>
|
|
657
|
+
onChange={(newValue) =>
|
|
658
|
+
props.onFreeWidthChange("free_width", newValue)
|
|
659
|
+
}
|
|
749
660
|
value={sel_pos.free_width}
|
|
750
661
|
/>
|
|
751
662
|
)}
|
|
663
|
+
<p>{maxWidthLabel}</p>
|
|
664
|
+
<ToolbarGroup>
|
|
665
|
+
<ToolbarItem>
|
|
666
|
+
{(itemProps) => (
|
|
667
|
+
<Button
|
|
668
|
+
{...itemProps}
|
|
669
|
+
isPressed={sel_pos.max_width === "full"}
|
|
670
|
+
onClick={() => props.onWidthChange("max_width", "full")}
|
|
671
|
+
text="full"
|
|
672
|
+
/>
|
|
673
|
+
)}
|
|
674
|
+
</ToolbarItem>
|
|
675
|
+
<ToolbarItem>
|
|
676
|
+
{(itemProps) => (
|
|
677
|
+
<Button
|
|
678
|
+
{...itemProps}
|
|
679
|
+
isPressed={sel_pos.max_width === "fit"}
|
|
680
|
+
onClick={() => props.onWidthChange("max_width", "fit")}
|
|
681
|
+
text="fit"
|
|
682
|
+
/>
|
|
683
|
+
)}
|
|
684
|
+
</ToolbarItem>
|
|
685
|
+
<ToolbarItem>
|
|
686
|
+
{(itemProps) => (
|
|
687
|
+
<Button
|
|
688
|
+
{...itemProps}
|
|
689
|
+
isPressed={sel_pos.max_width === "wideSize"}
|
|
690
|
+
onClick={() => props.onWidthChange("max_width", "wideSize")}
|
|
691
|
+
icon={stretchWide}
|
|
692
|
+
label={__("Wide Size", "block-collections")}
|
|
693
|
+
/>
|
|
694
|
+
)}
|
|
695
|
+
</ToolbarItem>
|
|
696
|
+
<ToolbarItem>
|
|
697
|
+
{(itemProps) => (
|
|
698
|
+
<Button
|
|
699
|
+
{...itemProps}
|
|
700
|
+
isPressed={sel_pos.max_width === "contentSize"}
|
|
701
|
+
onClick={() => props.onWidthChange("max_width", "contentSize")}
|
|
702
|
+
icon={positionCenter}
|
|
703
|
+
label={__("Content Size", "block-collections")}
|
|
704
|
+
/>
|
|
705
|
+
)}
|
|
706
|
+
</ToolbarItem>
|
|
707
|
+
<ToolbarItem>
|
|
708
|
+
{(itemProps) => (
|
|
709
|
+
<Button
|
|
710
|
+
{...itemProps}
|
|
711
|
+
isPressed={sel_pos.max_width === "free"}
|
|
712
|
+
onClick={() => props.onWidthChange("max_width", "free")}
|
|
713
|
+
text="free"
|
|
714
|
+
/>
|
|
715
|
+
)}
|
|
716
|
+
</ToolbarItem>
|
|
717
|
+
</ToolbarGroup>
|
|
718
|
+
|
|
719
|
+
{sel_pos.max_width === "free" && (
|
|
720
|
+
<UnitControl
|
|
721
|
+
dragDirection="e"
|
|
722
|
+
onChange={(newValue) =>
|
|
723
|
+
props.onFreeWidthChange("max_free_width", newValue)
|
|
724
|
+
}
|
|
725
|
+
value={sel_pos.max_free_width}
|
|
726
|
+
/>
|
|
727
|
+
)}
|
|
752
728
|
</>
|
|
753
729
|
);
|
|
754
730
|
}
|
package/src/cssPropertes.js
CHANGED
|
@@ -69,14 +69,14 @@ export const position_prm = (pos, type) => {
|
|
|
69
69
|
export const max_width_prm = (width, free_val) => {
|
|
70
70
|
const ret_width_prm =
|
|
71
71
|
width === "wideSize"
|
|
72
|
-
? "
|
|
72
|
+
? "max-width: var(--wp--style--global--wide-size);"
|
|
73
73
|
: width === "contentSize"
|
|
74
|
-
? "
|
|
74
|
+
? "max-width: var(--wp--style--global--content-size);"
|
|
75
75
|
: width === "free"
|
|
76
|
-
? `
|
|
76
|
+
? `max-width: ${free_val};`
|
|
77
77
|
: width === "full"
|
|
78
|
-
? "
|
|
79
|
-
: "
|
|
78
|
+
? "max-width: 100%;"
|
|
79
|
+
: "max-width: fit-content;";
|
|
80
80
|
return ret_width_prm;
|
|
81
81
|
};
|
|
82
82
|
|
|
@@ -110,8 +110,8 @@ export const align_prm = (align, camelFLg = false) => {
|
|
|
110
110
|
align === "center"
|
|
111
111
|
? "margin-left: auto; margin-right: auto;"
|
|
112
112
|
: align === "right"
|
|
113
|
-
? "margin-left: auto; margin-right: 0"
|
|
114
|
-
: "margin-right: auto; margin-left: 0";
|
|
113
|
+
? "margin-left: auto; margin-right: 0;"
|
|
114
|
+
: "margin-right: auto; margin-left: 0;";
|
|
115
115
|
//インナースタイル用
|
|
116
116
|
const camel_align_prm =
|
|
117
117
|
align === "center"
|
package/src/customFooks.js
CHANGED
|
@@ -109,6 +109,30 @@ export function useElementBackgroundColor(blockRef, style) {
|
|
|
109
109
|
return baseColor;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
//ブロックのスタイルを取得し、コールバック関数を返すカスタムフック
|
|
113
|
+
export function useElementStyleObject(blockRef, style) {
|
|
114
|
+
const [styleObject, setStyleObject] = useState("");
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (blockRef.current && style) {
|
|
118
|
+
//レンダリング結果に基づくスタイルの取得
|
|
119
|
+
const computedStyles = getComputedStyle(blockRef.current);
|
|
120
|
+
// styleオブジェクトのキーに基づいてnewStyleObjectを生成
|
|
121
|
+
const newStyleObject = Object.keys(style).reduce((acc, key) => {
|
|
122
|
+
if (computedStyles[key]) {
|
|
123
|
+
// computedStylesにキーが存在するか確認
|
|
124
|
+
acc[key] = computedStyles[key];
|
|
125
|
+
}
|
|
126
|
+
return acc;
|
|
127
|
+
}, {});
|
|
128
|
+
|
|
129
|
+
setStyleObject(JSON.stringify(newStyleObject));
|
|
130
|
+
}
|
|
131
|
+
}, [blockRef, style]);
|
|
132
|
+
// styleObjectをオブジェクトとして返す
|
|
133
|
+
return styleObject;
|
|
134
|
+
}
|
|
135
|
+
|
|
112
136
|
//たくさんの要素をもつオブジェクトや配列の内容の変化で発火するuseEffect
|
|
113
137
|
export function useDeepCompareEffect(callback, dependencies) {
|
|
114
138
|
const dependenciesRef = useRef();
|
package/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export {
|
|
3
3
|
useIsIframeMobile,
|
|
4
4
|
useElementBackgroundColor,
|
|
5
|
+
useElementStyleObject,
|
|
5
6
|
useElementWidth,
|
|
6
7
|
useIsMobile,
|
|
7
8
|
useDeepCompareEffect,
|
|
@@ -14,8 +15,10 @@ export {
|
|
|
14
15
|
export {
|
|
15
16
|
fetchPagesOptions,
|
|
16
17
|
fetchArchiveOptions,
|
|
18
|
+
restFetchData,
|
|
17
19
|
restTaxonomies,
|
|
18
|
-
|
|
20
|
+
restFieldes,
|
|
21
|
+
termToDispObj,
|
|
19
22
|
PageSelectControl,
|
|
20
23
|
ArchiveSelectControl,
|
|
21
24
|
TermChoiceControl,
|
package/src/wordpressApi.js
CHANGED
|
@@ -9,9 +9,9 @@ import apiFetch from "@wordpress/api-fetch";
|
|
|
9
9
|
|
|
10
10
|
//const _ = require("lodash");
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const restFetchData = async (path) => {
|
|
13
13
|
try {
|
|
14
|
-
const ret_data = await
|
|
14
|
+
const ret_data = await apiFetch({ path: path });
|
|
15
15
|
return ret_data;
|
|
16
16
|
} catch (error) {
|
|
17
17
|
console.error("Error fetching data:", error.message);
|
|
@@ -149,6 +149,7 @@ const ChoiceControl = (props) => {
|
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
151
|
};
|
|
152
|
+
|
|
152
153
|
return (
|
|
153
154
|
<div className={`${type}_section`}>
|
|
154
155
|
{type === "taxonomy" &&
|
|
@@ -171,7 +172,7 @@ const ChoiceControl = (props) => {
|
|
|
171
172
|
onChange={(checked) => {
|
|
172
173
|
const target = {
|
|
173
174
|
taxonomy: choice.slug,
|
|
174
|
-
term: { id: term.id, slug: term.slug },
|
|
175
|
+
term: { id: term.id, slug: term.slug, name: term.name },
|
|
175
176
|
};
|
|
176
177
|
const newChoiceTerms = handleChoiceChange(
|
|
177
178
|
checked,
|
|
@@ -187,6 +188,18 @@ const ChoiceControl = (props) => {
|
|
|
187
188
|
})}
|
|
188
189
|
{type === "field" &&
|
|
189
190
|
choices.map((choice, index) => {
|
|
191
|
+
//metaの対象カスタムフィールドが含まれるかのフラグ
|
|
192
|
+
const metaFlg =
|
|
193
|
+
choice.meta &&
|
|
194
|
+
!Object.keys(choice.meta).every(
|
|
195
|
+
(key) => key === "_acf_changed" || key === "footnotes"
|
|
196
|
+
);
|
|
197
|
+
//acfの対象カスタムフィールドが含まれるかのフラグ
|
|
198
|
+
const acfFlg =
|
|
199
|
+
choice.acf &&
|
|
200
|
+
typeof choice.acf === "object" &&
|
|
201
|
+
!Array.isArray(choice.acf);
|
|
202
|
+
|
|
190
203
|
return (
|
|
191
204
|
<div key={index} className="field_section">
|
|
192
205
|
{choice.title && (
|
|
@@ -250,7 +263,7 @@ const ChoiceControl = (props) => {
|
|
|
250
263
|
}}
|
|
251
264
|
/>
|
|
252
265
|
)}
|
|
253
|
-
{(
|
|
266
|
+
{(metaFlg || acfFlg) && (
|
|
254
267
|
<>
|
|
255
268
|
<div className="custom_field_label">
|
|
256
269
|
{__("Custom Field", "block-collections")}
|
|
@@ -368,6 +381,32 @@ export const restTaxonomies = async (post_type) => {
|
|
|
368
381
|
return taxonomyObjects;
|
|
369
382
|
};
|
|
370
383
|
|
|
384
|
+
//タームの文字列化
|
|
385
|
+
export const termToDispObj = (terms, connectString) => {
|
|
386
|
+
// taxonomyごとにterm.nameをまとめる
|
|
387
|
+
const result = terms.reduce((acc, item) => {
|
|
388
|
+
const taxonomy = item.taxonomy;
|
|
389
|
+
const termName = item.term.name;
|
|
390
|
+
|
|
391
|
+
// taxonomyがまだ存在しない場合は初期化
|
|
392
|
+
if (!acc[taxonomy]) {
|
|
393
|
+
acc[taxonomy] = [];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// term.nameを配列に追加
|
|
397
|
+
acc[taxonomy].push(termName);
|
|
398
|
+
|
|
399
|
+
return acc;
|
|
400
|
+
}, {});
|
|
401
|
+
|
|
402
|
+
// 各taxonomyの配列を connectString でつなげて文字列化
|
|
403
|
+
for (const taxonomy in result) {
|
|
404
|
+
result[taxonomy] = result[taxonomy].join(connectString);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return result;
|
|
408
|
+
};
|
|
409
|
+
|
|
371
410
|
//フィールド情報取得RestAPI関数
|
|
372
411
|
export const restFieldes = async (rest_base) => {
|
|
373
412
|
//投稿データに以下のフィールドが含まれているかを調べる
|