more fixes
This commit is contained in:
@@ -23,3 +23,37 @@ document.querySelectorAll('[data-avatar-uploader="true"]').forEach((element) =>
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
const storyEditorRoot = document.getElementById('story-editor-react-root');
|
||||
|
||||
if (storyEditorRoot) {
|
||||
const mode = storyEditorRoot.getAttribute('data-mode') || 'create';
|
||||
const storyRaw = storyEditorRoot.getAttribute('data-story') || '{}';
|
||||
const storyTypesRaw = storyEditorRoot.getAttribute('data-story-types') || '[]';
|
||||
const endpointsRaw = storyEditorRoot.getAttribute('data-endpoints') || '{}';
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '';
|
||||
|
||||
let initialStory = {};
|
||||
let storyTypes = [];
|
||||
let endpoints = {};
|
||||
|
||||
try {
|
||||
initialStory = JSON.parse(storyRaw);
|
||||
storyTypes = JSON.parse(storyTypesRaw);
|
||||
endpoints = JSON.parse(endpointsRaw);
|
||||
} catch (_) {
|
||||
// If parsing fails, the editor falls back to empty defaults in the component.
|
||||
}
|
||||
|
||||
void import('./components/editor/StoryEditor').then(({ default: StoryEditor }) => {
|
||||
createRoot(storyEditorRoot).render(
|
||||
React.createElement(StoryEditor, {
|
||||
mode,
|
||||
initialStory,
|
||||
storyTypes,
|
||||
endpoints,
|
||||
csrfToken,
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user