Skip to content

Commit 2787625

Browse files
committed
render's activeHTML's elements in HTML Elements tab
1 parent 51b1015 commit 2787625

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/components/HomeQueue.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ import draggable from 'vuedraggable'
2525
import { mapState, mapActions } from 'vuex'
2626
import { setSelectedElementList, deleteSelectedElement, deleteFromComponentHtmlList, setActiveHTML } from '../store/types'
2727
28+
const breadthFirstSearch = (array, id) => {
29+
let queue = [...array.filter(el => typeof el === 'object')];
30+
while (queue.length) {
31+
let evaluated = queue.shift()
32+
if (evaluated.id === id) {
33+
return evaluated
34+
}
35+
else {
36+
if (evaluated.children.length) {
37+
queue.push(...evaluated.children)
38+
}
39+
}
40+
}
41+
console.log("We shouldn't be ever getting here, how did you even search an id that didn't exist?")
42+
}
43+
2844
export default {
2945
name: 'HomeQueue',
3046
props: {
@@ -41,12 +57,20 @@ export default {
4157
// }
4258
// },
4359
computed: {
44-
...mapState(['selectedElementList', 'componentMap', 'activeComponent', 'activeHTML']),
60+
...mapState(['selectedElementList', 'componentMap', 'activeComponent', 'activeHTML', 'activeLayer']),
4561
renderList: {
4662
get () {
4763
if (this.activeComponent === '') return this.selectedElementList.map((el, index) => [el.text, index, el.id])
4864
// change activeComponent's htmlList into an array of arrays ([element/component name, index in state])
49-
let sortedHTML = this.componentMap[this.activeComponent].htmlList.map((el, index) => [el.text, index, el.id]).filter(el => {
65+
if (this.activeComponent !== '' && this.activeLayer.id === '') {
66+
console.log('this works right?')
67+
let sortedHTML = this.componentMap[this.activeComponent].htmlList.map((el, index) => [el.text, index, el.id]).filter(el => {
68+
return el[0] !== undefined
69+
})
70+
return sortedHTML
71+
}
72+
let activeElement = breadthFirstSearch(this.componentMap[this.activeComponent].htmlList, this.activeLayer.id)
73+
let sortedHTML = activeElement.children.map((el, index) => [el.text, index, el.id]).filter(el => {
5074
return el[0] !== undefined
5175
})
5276
return sortedHTML

0 commit comments

Comments
 (0)