@blokkli/editor 1.3.1 → 1.3.2
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/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import MagicString from 'magic-string';
|
|
|
7
7
|
import { walk } from 'estree-walker-ts';
|
|
8
8
|
import { BK_VISIBLE_LANGUAGES, BK_HIDDEN_GLOBALLY } from '../dist/runtime/helpers/symbols.js';
|
|
9
9
|
|
|
10
|
-
const version = "1.3.
|
|
10
|
+
const version = "1.3.2";
|
|
11
11
|
|
|
12
12
|
function sortObjectKeys(obj) {
|
|
13
13
|
if (Array.isArray(obj)) {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
:proxy-mode="proxyMode"
|
|
18
18
|
:tag="tag"
|
|
19
19
|
:global-proxy-mode="!!isGlobalProxyMode"
|
|
20
|
+
:should-render-item="shouldRenderItem"
|
|
20
21
|
/>
|
|
21
22
|
<component
|
|
22
23
|
:is="tag"
|
|
@@ -146,6 +147,11 @@ const props = withDefaults(
|
|
|
146
147
|
* Renders proxy blocks during editing.
|
|
147
148
|
*/
|
|
148
149
|
proxyMode?: boolean
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Determine whether an item should be rendered.
|
|
153
|
+
*/
|
|
154
|
+
shouldRenderItem?: (item: FieldListItem | FieldListItemTyped) => boolean
|
|
149
155
|
}>(),
|
|
150
156
|
{
|
|
151
157
|
list: () => [],
|
|
@@ -155,6 +161,7 @@ const props = withDefaults(
|
|
|
155
161
|
nonEmptyClass: '',
|
|
156
162
|
allowedFragments: () => [],
|
|
157
163
|
dropAlignment: undefined,
|
|
164
|
+
shouldRenderItem: undefined,
|
|
158
165
|
},
|
|
159
166
|
)
|
|
160
167
|
|
|
@@ -171,11 +178,20 @@ const fieldKey = computed<string | undefined>(() => {
|
|
|
171
178
|
const fieldListType = computed(() => props.fieldListType)
|
|
172
179
|
|
|
173
180
|
function filterVisible(item?: FieldListItemTyped | FieldListItem): boolean {
|
|
181
|
+
if (!item) {
|
|
182
|
+
return false
|
|
183
|
+
}
|
|
184
|
+
|
|
174
185
|
// The block is always rendered during editing.
|
|
175
186
|
if (isEditing) {
|
|
176
187
|
return true
|
|
177
188
|
}
|
|
178
|
-
|
|
189
|
+
|
|
190
|
+
const isVisible = isVisibleByOptions(item, providerEntity.value.language)
|
|
191
|
+
const isVisibleCustom = props.shouldRenderItem
|
|
192
|
+
? props.shouldRenderItem(item)
|
|
193
|
+
: true
|
|
194
|
+
return isVisible && isVisibleCustom
|
|
179
195
|
}
|
|
180
196
|
|
|
181
197
|
const filteredList = computed<FieldListItemTyped[]>(() => {
|
|
@@ -103,6 +103,7 @@ const props = withDefaults(
|
|
|
103
103
|
tag?: string
|
|
104
104
|
language?: string
|
|
105
105
|
editLabel?: string
|
|
106
|
+
editPath?: string
|
|
106
107
|
|
|
107
108
|
/**
|
|
108
109
|
* When set to true, during editing, everything except the provider element will be hidden.
|
|
@@ -114,6 +115,7 @@ const props = withDefaults(
|
|
|
114
115
|
language: '',
|
|
115
116
|
editLabel: '',
|
|
116
117
|
entity: undefined,
|
|
118
|
+
editPath: undefined,
|
|
117
119
|
},
|
|
118
120
|
)
|
|
119
121
|
|
|
@@ -145,7 +147,7 @@ const showIndicator = computed(
|
|
|
145
147
|
|
|
146
148
|
function edit() {
|
|
147
149
|
router.push({
|
|
148
|
-
path: route.path,
|
|
150
|
+
path: props.editPath || route.path,
|
|
149
151
|
query: {
|
|
150
152
|
blokkliEditing: props.entityUuid,
|
|
151
153
|
language: props.language,
|
|
@@ -98,6 +98,7 @@ import {
|
|
|
98
98
|
INJECT_FIELD_PROXY_MODE,
|
|
99
99
|
INJECT_IS_EDITING,
|
|
100
100
|
} from '#blokkli/helpers/symbols'
|
|
101
|
+
import type { FieldListItemTyped } from '#blokkli/generated-types'
|
|
101
102
|
|
|
102
103
|
const { dom, types, runtimeConfig, selection } = useBlokkli()
|
|
103
104
|
|
|
@@ -118,12 +119,14 @@ const props = withDefaults(
|
|
|
118
119
|
proxyMode?: boolean
|
|
119
120
|
globalProxyMode?: boolean
|
|
120
121
|
nestingLevel: number
|
|
122
|
+
shouldRenderItem?: (item: FieldListItem | FieldListItemTyped) => boolean
|
|
121
123
|
}>(),
|
|
122
124
|
{
|
|
123
125
|
tag: 'div',
|
|
124
126
|
allowedFragments: undefined,
|
|
125
127
|
dropAlignment: undefined,
|
|
126
128
|
language: undefined,
|
|
129
|
+
shouldRenderItem: undefined,
|
|
127
130
|
},
|
|
128
131
|
)
|
|
129
132
|
|
|
@@ -195,7 +198,16 @@ const fieldAttributes = computed(() => {
|
|
|
195
198
|
// Ideally this is handled as an overlay on top of the blocks, similar to how
|
|
196
199
|
// selection or multi-select works.
|
|
197
200
|
function isMuted(item?: FieldListItem) {
|
|
198
|
-
|
|
201
|
+
if (!item) {
|
|
202
|
+
return true
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const isVisible = isVisibleByOptions(item, props.language)
|
|
206
|
+
const isVisibleCustom = props.shouldRenderItem
|
|
207
|
+
? props.shouldRenderItem(item)
|
|
208
|
+
: true
|
|
209
|
+
|
|
210
|
+
return !(isVisible && isVisibleCustom)
|
|
199
211
|
}
|
|
200
212
|
|
|
201
213
|
watch(root, function (newRoot) {
|