-
Notifications
You must be signed in to change notification settings - Fork 75
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
plugin-flow-builder: create contents with map #2863
Merged
Iru89
merged 10 commits into
master-lts
from
plugin-flow-builder/refactor-webview-context
Jul 9, 2024
Merged
plugin-flow-builder: create contents with map #2863
Iru89
merged 10 commits into
master-lts
from
plugin-flow-builder/refactor-webview-context
Jul 9, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asastre
requested changes
Jul 2, 2024
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.
Just a 1 change, the rest LGTM
packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts
Outdated
Show resolved
Hide resolved
Iru89
force-pushed
the
plugin-flow-builder/refactor-webview-context
branch
from
July 2, 2024 09:18
85e2146
to
3291c26
Compare
… contents with key: getTextContent(value)
…s or imageContents are filled
Iru89
force-pushed
the
plugin-flow-builder/refactor-webview-context
branch
from
July 8, 2024 07:35
da4335b
to
7a23d15
Compare
vanbasten17
approved these changes
Jul 8, 2024
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.
nice feature!
packages/botonic-plugin-flow-builder/src/webview/contents-context.ts
Outdated
Show resolved
Hide resolved
…g> to avoid errors if type is not passed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The functions
getTextContent
andgetImageSrc
return an empty string if it does not find the value.The
useWebviewContents
hook accept an object mapContents. This object relates the names the developer wants for each content to the contentID of each content. Using this object the hook returns a contents object with all the contents.Context
The hook useWebviewContents now returns a contents object which is like the mapContents passed as a parameter but with the relation
key: fetchedContent
An important point is to have the
contents
object typed the same as themapContents
Approach taken / Explain the design
To have the
contents
typed like themapContents
it is necessary createMyWebviewContentsContext
outside the webview component and export it to be able to use it inside the components.To create this
MyWebviewContentsContext
we use thecreateWebviewContentsContext
function that allows to pass the type of the used inmapContents
, by creating the type of this object or by passingtypeof mapContents
.This way when using
useContext(MyWebviewContentsContext)
we get the contents typed as themapContents
.To document / Usage example
In Step1 component you can read the contents from context like