Skip to content

Commit

Permalink
feat: add sdk feature detection object in core
Browse files Browse the repository at this point in the history
  • Loading branch information
ryunsong-contentful committed May 24, 2024
1 parent 4443695 commit 76801b2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const OUTGOING_EVENTS = {
ComponentMoveStarted: 'componentMoveStarted',
ComponentMoveEnded: 'componentMoveEnded',
OutsideCanvasClick: 'outsideCanvasClick',
SDKFeatures: 'sdkFeatures',
};

export const INCOMING_EVENTS = {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/definitions/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './components';
export * from './styles';
export * from './sdkFeatures';
1 change: 1 addition & 0 deletions packages/core/src/definitions/sdkFeatures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const features = {};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useRef, useState } from 'react';
import {
doesMismatchMessageSchema,
features,
sendMessage,
tryParseMessage,
} from '@contentful/experiences-core';
Expand Down Expand Up @@ -42,6 +43,7 @@ export const useDetectEditorMode = ({ isClientSide = false }: UseDetectEditorMod
if (typeof window !== 'undefined' && !window.__EB__?.isEditorMode) {
window.addEventListener('message', onMessage);
sendMessage(OUTGOING_EVENTS.Connected);
sendMessage(OUTGOING_EVENTS.SDKFeatures, { features });

setTimeout(() => {
if (!receivedMessage.current) {
Expand Down

0 comments on commit 76801b2

Please sign in to comment.