Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FHL] Import model document #2509

Merged
merged 11 commits into from
Mar 18, 2024
Merged

[FHL] Import model document #2509

merged 11 commits into from
Mar 18, 2024

Conversation

juliaroldi
Copy link
Contributor

@juliaroldi juliaroldi commented Mar 15, 2024

Add "Import Button" control. This feature replaces the actual content-model with another model input by user.
ImportModel

@juliaroldi juliaroldi changed the title import model button [FHL] Import model Document Mar 18, 2024
@juliaroldi juliaroldi changed the title [FHL] Import model Document [FHL] Import model document Mar 18, 2024
@juliaroldi juliaroldi marked this pull request as ready for review March 18, 2024 14:04
).then(values => {
const importedModel = JSON.parse(values.model) as ContentModelDocument;
editor.formatContentModel(model => {
if (importedModel) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could we also add a type check to make sure the imported model contains blocks?

undefined /* onChange */,
10 /* rows */
).then(values => {
const importedModel = JSON.parse(values.model) as ContentModelDocument;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: JSON.parse can throw if we set the content that is not in JSON format. Maybe we can wrap all this function in a try catch

if (isBlockGroupOfType(importedModel, 'Document')) {
editor.formatContentModel(model => {
model.blocks = importedModel.blocks;
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also copy format from imported model.

@juliaroldi juliaroldi merged commit d55c892 into master Mar 18, 2024
7 checks passed
@juliaroldi juliaroldi deleted the u/juliaroldi/import-model branch March 18, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants