-
-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce context provider in view component
- Loading branch information
Showing
6 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,6 @@ editcomponent | |
block-style-wrapper | ||
extensions | ||
ssr | ||
viewcontext | ||
core/index | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
myst: | ||
html_meta: | ||
"description": "Sharing a context between blocks" | ||
"property=og:description": "Sharing a context between blocks" | ||
"property=og:title": "context of view" | ||
"keywords": "Volto, React, blocks, view, context" | ||
--- | ||
|
||
(viewcontext-label)= | ||
|
||
# context of `View` | ||
|
||
```{versionadded} Volto 18.0.0-alpha.48 | ||
``` | ||
|
||
Sharing a context between blocks. | ||
|
||
Volto provides a context of the `View` component for the case that blocks need to know about each other. | ||
|
||
Example: tooltips generated from a glossary show up only on the first occurrence on a page. | ||
|
||
Initialize the context for your add-on: | ||
|
||
```js | ||
config.views.viewContext["volto-slate-glossary"] = []; | ||
``` | ||
|
||
Get the context and use it: | ||
|
||
```js | ||
import { getViewContext } from '@plone/volto/components/theme/View/View'; | ||
|
||
|
||
let matchedGlossaryTerms = getViewContext("volto-slate-glossary"); | ||
``` | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Introduce context provider in view component. @ksuess |
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
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
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