itmar-block-packages 1.7.0 → 1.7.1
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 +101 -0
- package/build/index.asset.php +1 -1
- package/build/index.js +3 -3
- package/package.json +1 -1
- package/src/BlockPlace.js +88 -2
- package/src/blockStore.js +21 -0
- package/src/cssPropertes.js +6 -2
- package/src/index.js +13 -2
- package/src/mediaUpload.js +63 -0
package/README.md
CHANGED
|
@@ -14,6 +14,10 @@ import {関数名又はコンポーネント名} from "itmar-block-packages"
|
|
|
14
14
|
npm i @wordpress/scripts@^27.6.0 --save-dev
|
|
15
15
|
|
|
16
16
|
## 更新履歴
|
|
17
|
+
= 1.7.1 =
|
|
18
|
+
- serializeBlockTree,createBlockTreeをblockStore.jsに加えた。
|
|
19
|
+
- BlockPlace.jsでdesign-groupがフレックス要素の場合は主軸の大きさの設定がflex-grow,flex-shrink,flex-basisとなるよう修正した加えた。
|
|
20
|
+
|
|
17
21
|
= 1.7.0 =
|
|
18
22
|
- バリデーションチェック用の関数を集めるためのvalidationCheck.jsを新設し、URLの形式をチェックするisValidUrlWithUrlApiを加えた。
|
|
19
23
|
|
|
@@ -1071,6 +1075,103 @@ const flattenBlocks = (blocks) => {
|
|
|
1071
1075
|
|
|
1072
1076
|
---
|
|
1073
1077
|
|
|
1078
|
+
### `serializeBlockTree`
|
|
1079
|
+
|
|
1080
|
+
指定された Gutenberg ブロックオブジェクトを、**ネスト構造を保ったままプレーンな JSON 形式に変換(保存用)**します。
|
|
1081
|
+
|
|
1082
|
+
#### ✅ 使い方
|
|
1083
|
+
|
|
1084
|
+
```js
|
|
1085
|
+
import { serializeBlockTree } from '@your-scope/block-tree-utils';
|
|
1086
|
+
|
|
1087
|
+
const json = serializeBlockTree(block);
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
#### 📥 入力
|
|
1091
|
+
|
|
1092
|
+
- `block`: Gutenberg ブロックオブジェクト(`name`, `attributes`, `innerBlocks` を含む)
|
|
1093
|
+
|
|
1094
|
+
#### 📤 出力
|
|
1095
|
+
|
|
1096
|
+
```json
|
|
1097
|
+
{
|
|
1098
|
+
"blockName": "core/group",
|
|
1099
|
+
"attributes": { ... },
|
|
1100
|
+
"innerBlocks": [
|
|
1101
|
+
{
|
|
1102
|
+
"blockName": "core/paragraph",
|
|
1103
|
+
"attributes": { ... },
|
|
1104
|
+
"innerBlocks": []
|
|
1105
|
+
}
|
|
1106
|
+
]
|
|
1107
|
+
}
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
---
|
|
1111
|
+
|
|
1112
|
+
### `createBlockTree`
|
|
1113
|
+
|
|
1114
|
+
`serializeBlockTree` によって得られた JSON 構造を、**`createBlock()` に渡せる Gutenberg ブロックオブジェクトに再構築**します。
|
|
1115
|
+
|
|
1116
|
+
#### ✅ 使い方
|
|
1117
|
+
|
|
1118
|
+
```js
|
|
1119
|
+
import { createBlockTree } from '@your-scope/block-tree-utils';
|
|
1120
|
+
import { createBlock } from '@wordpress/blocks';
|
|
1121
|
+
|
|
1122
|
+
const wpBlock = createBlockTree(savedJson);
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
#### 📥 入力
|
|
1126
|
+
|
|
1127
|
+
- `savedJson`: `serializeBlockTree` で生成されたブロックデータ
|
|
1128
|
+
|
|
1129
|
+
#### 📤 出力
|
|
1130
|
+
|
|
1131
|
+
- `createBlock(name, attributes, innerBlocks)` の形で再帰的に構成された WP ブロックオブジェクト
|
|
1132
|
+
|
|
1133
|
+
---
|
|
1134
|
+
|
|
1135
|
+
### `flattenBlocks`
|
|
1136
|
+
|
|
1137
|
+
Gutenberg のネストされたブロック配列を、**1階層の配列としてフラットに展開**します。
|
|
1138
|
+
ブロック構成内にあるすべてのブロック(ネスト含む)を一括走査する際に便利です。
|
|
1139
|
+
|
|
1140
|
+
#### ✅ 使い方
|
|
1141
|
+
|
|
1142
|
+
```js
|
|
1143
|
+
import { flattenBlocks } from '@your-scope/block-tree-utils';
|
|
1144
|
+
|
|
1145
|
+
const flat = flattenBlocks(innerBlocks);
|
|
1146
|
+
```
|
|
1147
|
+
|
|
1148
|
+
#### 📥 入力
|
|
1149
|
+
|
|
1150
|
+
- `innerBlocks`: Gutenberg のブロック配列(`innerBlocks` を含む構造)
|
|
1151
|
+
|
|
1152
|
+
#### 📤 出力
|
|
1153
|
+
|
|
1154
|
+
- 平坦化されたブロック配列(元の構造は保持しない)
|
|
1155
|
+
|
|
1156
|
+
---
|
|
1157
|
+
|
|
1158
|
+
## 🧪 使用例
|
|
1159
|
+
|
|
1160
|
+
```js
|
|
1161
|
+
import {
|
|
1162
|
+
serializeBlockTree,
|
|
1163
|
+
createBlockTree,
|
|
1164
|
+
flattenBlocks,
|
|
1165
|
+
} from '@your-scope/block-tree-utils';
|
|
1166
|
+
|
|
1167
|
+
const savedData = blocks.map(serializeBlockTree);
|
|
1168
|
+
const restored = savedData.map(createBlockTree);
|
|
1169
|
+
const flatList = flattenBlocks(restored);
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
---
|
|
1173
|
+
|
|
1174
|
+
|
|
1074
1175
|
## 日本郵便番号から住所を取得するユーティリティ関数
|
|
1075
1176
|
### `fetchZipToAddress`
|
|
1076
1177
|
`fetchZipToAddress` は、[zipcloud](https://zipcloud.ibsnet.co.jp) API を使用して、日本の郵便番号から都道府県・市区町村・町域の住所を非同期で取得する JavaScript 関数です。
|
package/build/index.asset.php
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '
|
|
1
|
+
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'bfb1de347aca75e8028f');
|