Skip to content

Commit a72cb0a

Browse files
committed
Feat: Support for local regions.
1 parent c4f2e29 commit a72cb0a

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

module/index.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function defineSaveProcess(url, params, lock, contentFunc) {
8686

8787
export function init(
8888
baseURL='/',
89-
baseFlowURL='/',
89+
baseBlueprintURL='/',
9090
baseParams={},
9191
updateSignalKey=null
9292
) {
@@ -183,7 +183,7 @@ export function init(
183183
flowMgr.init(
184184
'[data-cf-flow]',
185185
new FlowAPI(
186-
baseFlowURL,
186+
baseBlueprintURL,
187187
baseParams,
188188
updateSignalKey
189189
)
@@ -203,7 +203,7 @@ export function init(
203203
editor.addEventListener(
204204
'saved',
205205
defineSaveProcess(
206-
`${baseFlowURL}update-flow-contents`,
206+
`${baseBlueprintURL}update-flow-contents`,
207207
baseParams,
208208
lock,
209209
(regions) => {
@@ -231,6 +231,35 @@ export function init(
231231
)
232232
)
233233

234+
// Local regions
235+
editor.addEventListener(
236+
'saved',
237+
defineSaveProcess(
238+
`${baseBlueprintURL}update-contents`,
239+
baseParams,
240+
lock,
241+
(regions) => {
242+
const contents = {}
243+
244+
for (let k of Object.keys(regions)) {
245+
let v = regions[k]
246+
247+
// Check the region belongs to a snippet
248+
if(k.startsWith('local:')) {
249+
250+
// Extract the snippet Id and region name
251+
const [_, regionName] = k.split(':')
252+
253+
// Add the region's content to the snippet
254+
contents[regionName] = v
255+
}
256+
}
257+
258+
return contents
259+
}
260+
)
261+
)
262+
234263
// Global regions
235264
editor.addEventListener(
236265
'saved',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "manhattan-content",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Content editing for the manhattan web framework",
55
"engines": {
66
"node": ">=8.9.4"

0 commit comments

Comments
 (0)