Quellcode durchsuchen

:fire: removing the block parser | removing the block components

tags/0.9.0
j vor 4 Jahren
Ursprung
Commit
81fa2c74a5

+ 0
- 5
plugins/cia-endpoints/includes/class.make-endpoint.php Datei anzeigen

@@ -69,11 +69,6 @@ class Make_Endpoint_For extends WP_REST_Controller {
69 69
         foreach( get_posts($args) as $item ) {
70 70
             $filtered = default_post_format( $item, false );
71 71
 
72
-            // Get those Block!
73
-            $filtered[blocks] = get_rearrange_blocks(
74
-                parse_blocks($item->post_content)
75
-            );
76
-
77 72
             $filtered[galleries] = get_ids_from_gallery_block(
78 73
                 parse_blocks($item->post_content)
79 74
             );

+ 0
- 14
plugins/cia-endpoints/includes/reformat-blocks.php Datei anzeigen

@@ -1,18 +1,4 @@
1 1
 <?php
2
-    function get_rearrange_blocks($blocks) {
3
-        $parsed_blocks = array();
4
-        foreach( $blocks as $block ) {
5
-            // Don't include whole galleries
6
-            if ($block[innerHTML] !== "\n\n") {
7
-                array_push($parsed_blocks, [$block]);
8
-            } elseif ($block[innerHTML] === "\n\n") {
9
-                // Don't do anything!
10
-            } else {
11
-                array_push($parsed_blocks, $block[innerBlocks]);
12
-            }
13
-        }
14
-        return $parsed_blocks;
15
-    }
16 2
     function get_ids_from_gallery_block($blocks){
17 3
         $parsed_blocks = array();
18 4
         foreach ($blocks as $block) {

+ 0
- 98
vue-theme/src/components/content-block/block-recursive.vue Datei anzeigen

@@ -1,98 +0,0 @@
1
-<template lang="pug">
2
-.block.recursive(:id="`block-${this.$.uid}`")
3
-</template>
4
-
5
-<script>
6
-let treeToAppend = null
7
-
8
-export default {
9
-    name: 'rblock',
10
-    props: {
11
-        block: { required: true }
12
-    },
13
-    data() {
14
-        return {
15
-            isLoading: true,
16
-            id: null,
17
-            root: null,
18
-            treeDepth: 0,
19
-            currentParentNode: null,
20
-            prevDepth: 0,
21
-            ancestors: []
22
-        }
23
-    },
24
-    methods: {
25
-        toEl(html) {
26
-            var template = document.createElement('template')
27
-            html = html.trim() // Never return a text node of whitespace as the result
28
-            template.innerHTML = html
29
-            return template.content.firstChild
30
-        },
31
-        processBlock(block, root) {
32
-            this.treeDepth++
33
-
34
-            if(this.treeDepth === 1) {
35
-                // Add the base nodes
36
-                // Don't forget that this is recursive (see line: 49)
37
-                this.currentParentNode = this.toEl(block.innerHTML)
38
-                this.ancestors.push(this.currentParentNode)
39
-                root.appendChild(this.currentParentNode)
40
-            } else {
41
-            
42
-                // You need to create a REFERENCE to this node
43
-                // So you can target it later as a parent
44
-                // If you don't create a reference then you'll
45
-                // be creating a new <el> and will lose all
46
-                // parent-child relationship
47
-                if(this.treeDepth > this.prevDepth) {
48
-                    this.ancestors.push(this.currentParentNode)
49
-                } else {
50
-                    this.ancestors.pop()
51
-                }
52
-
53
-                this.currentParentNode = this.toEl(block.innerHTML)
54
-                this.ancestors[this.ancestors.length - 1].appendChild(this.currentParentNode)
55
-            }
56
-            
57
-            if(!block.innerBlocks) return
58
-            
59
-            this.prevDepth = this.treeDepth
60
-
61
-            // !: Process any children recursively
62
-            for(let childBlock of block.innerBlocks) {
63
-                this.processBlock(childBlock, this.currentParentNode)
64
-            }
65
-
66
-            this.treeDepth--
67
-        },
68
-        buildBlocks() {
69
-            if(typeof this.block !== 'object' || this.block.hasOwnProperty('gallery')) return
70
-
71
-            // Add the top-level blocks to the document tree
72
-            treeToAppend = new DocumentFragment()
73
-            this.root = document.createElement('div')
74
-            this.root.classList.add('wp-block-columns')
75
-            treeToAppend.appendChild(this.root)
76
-
77
-            // Loop over all the nodes and append children
78
-            for(const block of this.block) {
79
-                this.processBlock(block, this.root)
80
-            }
81
-        },
82
-    },
83
-    mounted() {
84
-        this.buildBlocks()
85
-        // Append the final product to DOM
86
-        document.getElementById(`block-${this.$.uid}`).innerHTML = ''
87
-        document.getElementById(`block-${this.$.uid}`).appendChild(treeToAppend)
88
-    },
89
-    watch: {
90
-        block(newVal, oldVal) {
91
-            this.buildBlocks()
92
-            document.getElementById(`block-${this.$.uid}`).innerHTML = ''
93
-            document.getElementById(`block-${this.$.uid}`).appendChild(treeToAppend)
94
-        }
95
-    }
96
-}
97
-</script>
98
-

+ 0
- 64
vue-theme/src/components/content-block/block.vue Datei anzeigen

@@ -1,64 +0,0 @@
1
-<template lang="pug">
2
-figure.block.embed(v-if="block[0].blockName == 'core/embed'")
3
-    figure.youtube(v-if="block[0].attrs.providerNameSlug == 'youtube'").is-provider-youtube.wp-block-youtube
4
-        iframe(
5
-            :src="fixYoutubeUrl(block[0].attrs.url)"
6
-            title="YouTube video player"
7
-            frameborder="0"
8
-            allowfullscreen
9
-        ).embed--player
10
-    .not-youtube(v-else)
11
-        p not youtube: {{ block[0].attrs }}
12
-
13
-//- Block clicking on certain block elements
14
-//- so we can choose when to open the gallery
15
-rblock(:block="block" @click.prevent.stop="openGallery")
16
-
17
-//- .block.single(v-else)
18
-//-     .single--content(v-html="block")
19
-</template>
20
-
21
-<script>
22
-import rblock from './block-recursive'
23
-
24
-export default {
25
-    components: { rblock },
26
-    props: {
27
-        block: { required: true }
28
-    },
29
-    emits: ['openGallery'],
30
-    methods: {
31
-        fixYoutubeUrl(url) {
32
-            let videoUid = url.split('https://youtu.be/')[1]
33
-
34
-            if(!videoUid) {
35
-                videoUid = url.split('https://www.youtube.com/watch?v=')[1]
36
-            }
37
-
38
-            return `https://www.youtube.com/embed/${videoUid}`
39
-        },
40
-        openGallery(e) {
41
-            if(e.target.tagName === 'IMG') {
42
-                this.$emit('open-gallery', e.target)
43
-            } else if(e.target.dataset.type === 'URL') {
44
-                window.open(e.target.href)
45
-            }
46
-        }
47
-    },
48
-    data() {
49
-        return {
50
-        }
51
-    },
52
-    computed: {
53
-    }
54
-}
55
-</script>
56
-
57
-<style lang="postcss">
58
-.block
59
-    &.embed
60
-        min-height: 40vh
61
-        > figure.youtube, > figure.youtube iframe
62
-            height: 40vh
63
-            width: 100%
64
-</style>

+ 3
- 7
vue-theme/src/pages/single.vue Datei anzeigen

@@ -19,10 +19,7 @@
19 19
                 p start: {{ dateFrom(post.start) }}
20 20
                 p end: {{ dateFrom(post.end) }}
21 21
 
22
-        .content(v-html="post.content")
23
-        //- ul
24
-        //-     li(v-for="(block, index) in post.blocks" :key="`block-${index}`" class="post-single block-wrapper")
25
-        //-         block(:block="block" @open-gallery="openGallery")
22
+        section.content(v-html="post.content")
26 23
 
27 24
         //- related artists section example layout
28 25
         section(v-if="type === 'episodes' && post" :post="post")
@@ -40,7 +37,6 @@
40 37
 import card from '@/components/card.vue'
41 38
 import sidebar from '@/components/sidebars/sidebar'
42 39
 import gallery from '@/components/gallery/'
43
-import block from '@/components/content-block/block'
44 40
 import credits from '@/components/credits'
45 41
 
46 42
 import { postTypeGetters, scrollTop } from './mixin-post-types'
@@ -48,7 +44,7 @@ import { postTypeGetters, scrollTop } from './mixin-post-types'
48 44
 import { convertTitleCase, dePluralize, typeFromRoute } from '@/utils/helpers'
49 45
  
50 46
 export default {
51
-    components: { sidebar, gallery, block, credits, card },
47
+    components: { sidebar, gallery, credits, card },
52 48
     props: {
53 49
         sidebar: { type: Boolean },
54 50
         id: { type: Number }
@@ -212,7 +208,7 @@ export default {
212 208
     article
213 209
         h3.breadcrumb
214 210
             color: yellow
215
-        ul
211
+        > ul
216 212
             /* grid-gap: $ms-0 */
217 213
             list-style: none
218 214
             /* change to a 1/3 width of the article*/

Laden…
Abbrechen
Speichern