PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
← All changes | renderer/Migrations/BlockContentMigrator.php +36 -3 1.0.21.1.5 View file →
@@ -111,14 +111,15 @@
111 111 if (!is_array($block)) {
112 112 continue;
113 113 }
114 114
115 - if (
115 + $is_table_block =
116 116 isset($block['blockName']) &&
117 117 $block['blockName'] === 'tableberg/table' &&
118 118 isset($block['attrs']) &&
119 - is_array($block['attrs'])
120 - ) {
119 + is_array($block['attrs']);
120 +
121 + if ($is_table_block) {
121 122 $migrated_attrs = $this->migrate_table_block_attrs(
122 123 $block['attrs'],
123 124 $block
124 125 );
@@ -126,8 +127,22 @@
126 127 if ($migrated_attrs !== $block['attrs']) {
127 128 $blocks[$index]['attrs'] = $migrated_attrs;
128 129 $did_migrate = true;
129 130 }
131 +
132 + // Editor path only: materialize the v4 native-blocks tree
133 + // from v3 attrs so the editor opens real blocks. Replaces
134 + // the whole block, so skip the generic inner-blocks
135 + // recursion below. (The frontend render_block_data path
136 + // stays attrs-only — non-resaved posts keep rendering.)
137 + $v4_block = $this->migrate_table_block_to_native(
138 + $blocks[$index]
139 + );
140 + if ($v4_block !== $blocks[$index]) {
141 + $blocks[$index] = $v4_block;
142 + $did_migrate = true;
143 + continue;
144 + }
130 145 }
131 146
132 147 if (isset($block['innerBlocks']) && is_array($block['innerBlocks'])) {
133 148 list($inner_blocks, $inner_migrated) = $this->migrate_blocks(
@@ -138,8 +153,26 @@
138 153 }
139 154 }
140 155
141 156 return [$blocks, $did_migrate];
157 + }
158 +
159 + /**
160 + * @param array $block Parsed tableberg/table block (attrs already at v3).
161 + * @return array
162 + */
163 + private function migrate_table_block_to_native($block) {
164 + $version = isset($block['attrs']['version']) && is_numeric($block['attrs']['version'])
165 + ? (int) $block['attrs']['version']
166 + : 0;
167 +
168 + if ($version !== 3) {
169 + return $block;
170 + }
171 +
172 + $migrator = new TableBlockMigratorV3ToV4();
173 +
174 + return $migrator->migrate_block($block);
142 175 }
143 176
144 177 private function migrate_table_block_attrs($attrs, $block) {
145 178 $table_block_migrator = new TableBlockMigrator();