@@ -77,6 +77,7 @@ function RemoteFunctions(config = {}) {
7777 "redraw" ,
7878 "onElementSelected" , // an item is selected in live preview
7979 "onElementCleanup" ,
80+ "onNonEditableElementClick" , // called when user clicks on a non-editable element
8081 "handleConfigChange" ,
8182 // below function gets called to render the dropdown when user clicks on the ... menu in the options box,
8283 // the handler should retrun html tor ender the dropdown item.
@@ -1420,7 +1421,6 @@ function RemoteFunctions(config = {}) {
14201421 dismissNodeMoreOptionsBox ( ) ;
14211422 dismissMoreOptionsDropdown ( ) ;
14221423 dismissNodeInfoBox ( ) ;
1423- dismissToastMessage ( ) ;
14241424 cleanupPreviousElementState ( ) ;
14251425
14261426 // this should also be there when users are in highlight mode
@@ -1430,10 +1430,13 @@ function RemoteFunctions(config = {}) {
14301430 return false ;
14311431 }
14321432
1433- // if element is not editable and user clicks on it, then we show a toast notification saying
1434- // that this element is not editable
1433+ // when user clicks on a non-editable element
14351434 if ( ! element . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ) {
1436- showToastMessage ( "notEditable" ) ;
1435+ getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
1436+ if ( handler . onNonEditableElementClick ) {
1437+ handler . onNonEditableElementClick ( element ) ;
1438+ }
1439+ } ) ;
14371440 }
14381441
14391442 // make sure that the element is actually visible to the user
@@ -2122,68 +2125,9 @@ function RemoteFunctions(config = {}) {
21222125 dismissNodeMoreOptionsBox ( ) ;
21232126 dismissMoreOptionsDropdown ( ) ;
21242127 dismissNodeInfoBox ( ) ;
2125- dismissToastMessage ( ) ;
21262128 getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => ( handler . dismiss && handler . dismiss ( ) ) ) ;
21272129 }
21282130
2129- let _toastTimeout = null ;
2130-
2131- const TOAST_TYPE_MAPPING = {
2132- notEditable : strings . toastNotEditable ,
2133- copyFirstTime : strings . toastCopyFirstTime
2134- } ;
2135-
2136- /**
2137- * this function is to show a toast notification at the bottom center of the screen
2138- * this toast message is used when user tries to edit a non-editable element
2139- * @param {String } toastType - toastType determines the message to display in the toast
2140- * @param {Number } duration - optional duration in milliseconds (default: 3000)
2141- */
2142- function showToastMessage ( toastType , duration = 3000 ) {
2143- // clear any existing toast & timer, if there are any
2144- dismissToastMessage ( ) ;
2145-
2146- // create a new fresh toast container
2147- const toast = window . document . createElement ( 'div' ) ;
2148- toast . id = 'phoenix-toast-notification' ;
2149- toast . setAttribute ( GLOBALS . PHCODE_INTERNAL_ATTR , "true" ) ;
2150- const shadow = toast . attachShadow ( { mode : 'open' } ) ;
2151-
2152- const styles = cssStyles . toastMessage ;
2153-
2154- const content = `
2155- <div class="toast-container">
2156- <div class="toast-message">${ TOAST_TYPE_MAPPING [ toastType ] } </div>
2157- </div>
2158- ` ;
2159-
2160- shadow . innerHTML = `<style>${ styles } </style>${ content } ` ;
2161- window . document . body . appendChild ( toast ) ;
2162-
2163- // Auto-dismiss after the given time
2164- _toastTimeout = setTimeout ( ( ) => {
2165- if ( toast && toast . parentNode ) {
2166- toast . remove ( ) ;
2167- }
2168- _toastTimeout = null ;
2169- } , duration ) ;
2170- }
2171-
2172- /**
2173- * this function is to dismiss the toast message
2174- * and clear its timeout (if any)
2175- */
2176- function dismissToastMessage ( ) {
2177- const toastMessage = window . document . getElementById ( 'phoenix-toast-notification' ) ;
2178- if ( toastMessage ) {
2179- toastMessage . remove ( ) ;
2180- }
2181- if ( _toastTimeout ) {
2182- clearTimeout ( _toastTimeout ) ;
2183- }
2184- _toastTimeout = null ;
2185- }
2186-
21872131 /**
21882132 * Helper function to cleanup previously clicked element highlighting and state
21892133 */
@@ -2312,7 +2256,6 @@ function RemoteFunctions(config = {}) {
23122256 "applyDOMEdits" : applyDOMEdits ,
23132257 "updateConfig" : updateConfig ,
23142258 "dismissUIAndCleanupState" : dismissUIAndCleanupState ,
2315- "showToastMessage" : showToastMessage ,
23162259 "escapeKeyPressInEditor" : _escapeKeyPressInEditor ,
23172260 "getMode" : function ( ) { return config . mode ; }
23182261 } ;
0 commit comments