@@ -215,28 +215,42 @@ define(function (require, exports, module) {
215215 */
216216 function _initializeMode ( ) {
217217 const savedMode = PreferencesManager . get ( PREFERENCE_LIVE_PREVIEW_MODE ) || "preview" ;
218+ const isEditFeaturesActive = LiveDevelopment . isLPEditFeaturesActive ;
219+
220+ // If user has edit mode saved but edit features are not active, default to preview
221+ let effectiveMode = savedMode ;
222+ if ( savedMode === "edit" && ! isEditFeaturesActive ) {
223+ effectiveMode = "preview" ;
224+ // Update the preference to reflect the actual mode being used
225+ PreferencesManager . set ( PREFERENCE_LIVE_PREVIEW_MODE , "preview" ) ;
226+ }
218227
219- // apply the saved
220- if ( savedMode === "highlight" ) {
228+ // apply the effective mode
229+ if ( effectiveMode === "highlight" ) {
221230 _LPHighlightMode ( ) ;
222- } else if ( savedMode === "edit" ) {
231+ } else if ( effectiveMode === "edit" && isEditFeaturesActive ) {
223232 _LPEditMode ( ) ;
224233 } else {
225234 _LPPreviewMode ( ) ;
226235 }
227236
228- _updateModeButton ( savedMode ) ;
237+ _updateModeButton ( effectiveMode ) ;
229238 }
230239
231240 function _showModeSelectionDropdown ( event ) {
241+ const isEditFeaturesActive = LiveDevelopment . isLPEditFeaturesActive ;
232242 const items = [
233243 Strings . LIVE_PREVIEW_MODE_PREVIEW ,
234244 Strings . LIVE_PREVIEW_MODE_HIGHLIGHT ,
235- Strings . LIVE_PREVIEW_MODE_EDIT ,
236- "---" ,
237- Strings . LIVE_PREVIEW_EDIT_HIGHLIGHT_ON
245+ Strings . LIVE_PREVIEW_MODE_EDIT
238246 ] ;
239247
248+ // Only add edit highlight option if edit features are active
249+ if ( isEditFeaturesActive ) {
250+ items . push ( "---" ) ;
251+ items . push ( Strings . LIVE_PREVIEW_EDIT_HIGHLIGHT_ON ) ;
252+ }
253+
240254 const rawMode = PreferencesManager . get ( PREFERENCE_LIVE_PREVIEW_MODE ) || "preview" ;
241255 // this is to take care of invalid values in the pref file
242256 const currentMode = [ "preview" , "highlight" , "edit" ] . includes ( rawMode ) ? rawMode : "preview" ;
@@ -248,7 +262,12 @@ define(function (require, exports, module) {
248262 } else if ( item === Strings . LIVE_PREVIEW_MODE_HIGHLIGHT ) {
249263 return currentMode === "highlight" ? `✓ ${ item } ` : `${ '\u00A0' . repeat ( 4 ) } ${ item } ` ;
250264 } else if ( item === Strings . LIVE_PREVIEW_MODE_EDIT ) {
251- return currentMode === "edit" ? `✓ ${ item } ` : `${ '\u00A0' . repeat ( 4 ) } ${ item } ` ;
265+ const checkmark = currentMode === "edit" ? "✓ " : `${ '\u00A0' . repeat ( 4 ) } ` ;
266+ const crownIcon = ! isEditFeaturesActive ? ' <span style="color: #FBB03B; border: 1px solid #FBB03B; padding: 2px 4px; border-radius: 10px; font-size: 9px; margin-left: 12px;"><i class="fas fa-crown"></i> Pro</span>' : '' ;
267+ return {
268+ html : `${ checkmark } ${ item } ${ crownIcon } ` ,
269+ enabled : isEditFeaturesActive
270+ } ;
252271 } else if ( item === Strings . LIVE_PREVIEW_EDIT_HIGHLIGHT_ON ) {
253272 const isHoverMode = PreferencesManager . get ( PREFERENCE_PROJECT_ELEMENT_HIGHLIGHT ) !== "click" ;
254273 if ( isHoverMode ) {
@@ -288,6 +307,10 @@ define(function (require, exports, module) {
288307 } else if ( index === 2 ) {
289308 PreferencesManager . set ( PREFERENCE_LIVE_PREVIEW_MODE , "edit" ) ;
290309 } else if ( item === Strings . LIVE_PREVIEW_EDIT_HIGHLIGHT_ON ) {
310+ // Don't allow edit highlight toggle if edit features are not active
311+ if ( ! isEditFeaturesActive ) {
312+ return ;
313+ }
291314 // Toggle between hover and click
292315 const currentMode = PreferencesManager . get ( PREFERENCE_PROJECT_ELEMENT_HIGHLIGHT ) ;
293316 const newMode = currentMode !== "click" ? "click" : "hover" ;
@@ -984,16 +1007,26 @@ define(function (require, exports, module) {
9841007 PreferencesManager . on ( "change" , PREFERENCE_LIVE_PREVIEW_MODE , function ( ) {
9851008 // Get the current preference value directly
9861009 const newMode = PreferencesManager . get ( PREFERENCE_LIVE_PREVIEW_MODE ) ;
1010+ const isEditFeaturesActive = LiveDevelopment . isLPEditFeaturesActive ;
1011+
1012+ // If user tries to set edit mode but edit features are not active, default to preview
1013+ let effectiveMode = newMode ;
1014+ if ( newMode === "edit" && ! isEditFeaturesActive ) {
1015+ effectiveMode = "preview" ;
1016+ // Update the preference to reflect the actual mode being used
1017+ PreferencesManager . set ( PREFERENCE_LIVE_PREVIEW_MODE , "preview" ) ;
1018+ return ; // Return to avoid infinite loop
1019+ }
9871020
988- if ( newMode === "highlight" ) {
1021+ if ( effectiveMode === "highlight" ) {
9891022 _LPHighlightMode ( ) ;
990- } else if ( newMode === "edit" ) {
1023+ } else if ( effectiveMode === "edit" && isEditFeaturesActive ) {
9911024 _LPEditMode ( ) ;
9921025 } else {
9931026 _LPPreviewMode ( ) ;
9941027 }
9951028
996- _updateModeButton ( newMode ) ;
1029+ _updateModeButton ( effectiveMode ) ;
9971030 } ) ;
9981031
9991032 // Handle element highlight preference changes from this extension
0 commit comments