-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature:
neos.guestFrame.findElementByNode(node)
the global `window.neos` object is extended by this package and exposes under `guestFrame` this function, which makes it possible to get the dom element by node object.
- Loading branch information
Showing
5 changed files
with
40 additions
and
13 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
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,20 @@ | ||
// https://github.com/neos/neos-ui/blob/7ede460ec1bb8dd4455fc636b875c137d112e89d/packages/neos-ui-guest-frame/src/dom.js#L76 | ||
import {findNodeInGuestFrame } from '@neos-project/neos-ui-guest-frame' | ||
|
||
// use it like neos.guestFrame.findElementByNode(node) | ||
export const addGuestFrameLibrary = () => { | ||
if (window.neos === undefined) { | ||
throw new Error(`Could not add library to Neos API, because 'window.neos' is not defined.`); | ||
} | ||
|
||
const alias = 'guestFrame'; | ||
if (window.neos[alias] !== undefined) { | ||
throw new Error(`Could not initialize API, because ${alias} is already defined.`); | ||
} | ||
window.neos[alias] = { | ||
findElementByNode: (node) => { | ||
const {contextPath} = node; | ||
return findNodeInGuestFrame(contextPath); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import manifest from '@neos-project/neos-ui-extensibility'; | ||
import onNodeChangeSendEvent from './onNodeChangeSendEvent' | ||
import onNodeChangeSendEvent from './onNodeChangeSendEvent'; | ||
import {addGuestFrameLibrary} from "./initializeJsAPI"; | ||
|
||
manifest('MhsDesign.LiveInspectorJsEvents:JsEvents', {}, globalRegistry => { | ||
addGuestFrameLibrary(); | ||
const sagasRegistry = globalRegistry.get('sagas'); | ||
sagasRegistry.set('MhsDesign.LiveInspectorJsEvents/JsEvents', {saga: onNodeChangeSendEvent}); | ||
}); |
Oops, something went wrong.