-
Notifications
You must be signed in to change notification settings - Fork 157
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
Conversation
).then(values => { | ||
const importedModel = JSON.parse(values.model) as ContentModelDocument; | ||
editor.formatContentModel(model => { | ||
if (importedModel) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
…oft/roosterjs into u/juliaroldi/import-model
if (isBlockGroupOfType(importedModel, 'Document')) { | ||
editor.formatContentModel(model => { | ||
model.blocks = importedModel.blocks; | ||
return true; |
There was a problem hiding this comment.
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.
…oft/roosterjs into u/juliaroldi/import-model
Add "Import Button" control. This feature replaces the actual content-model with another model input by user.