Skip to content

Commit

Permalink
feat: handle move
Browse files Browse the repository at this point in the history
  • Loading branch information
buuhuu committed Feb 21, 2024
1 parent d8da0de commit 6a0708a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/editor-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ async function applyChanges(event) {
// redecorate default content and blocks on patches (in the properties rail)
const { detail } = event;

const resource = detail?.request?.target?.resource
|| detail?.request?.target?.container?.resource;
const resource = detail?.request?.target?.resource // update, patch components
|| detail?.request?.target?.container?.resource // update, patch, add to sections
|| detail?.request?.to?.container?.resource; // move in sections
if (!resource) return false;
const updates = detail?.response?.updates;
if (!updates.length) return false;
const { content } = updates[0];
if (!content) return false;

const parsedUpdate = new DOMParser().parseFromString(content, 'text/html');
const element = document.querySelector(`[data-aue-resource="${resource}"]`);
Expand Down Expand Up @@ -94,6 +96,7 @@ function attachEventListners(main) {
'aue:content-patch',
'aue:content-update',
'aue:content-add',
'aue:content-move',
].forEach((eventType) => main?.addEventListener(eventType, async (event) => {
event.stopPropagation();
const applied = await applyChanges(event);
Expand Down

0 comments on commit 6a0708a

Please sign in to comment.