-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev
- Loading branch information
Showing
264 changed files
with
2,772 additions
and
3,130 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
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 @@ | ||
import { useState, useCallback } from "react"; | ||
import { useIsMounted } from "./useIsMounted"; | ||
|
||
export function useStateIfMounted<T>( | ||
defaultState: T | ||
): [T, React.Dispatch<React.SetStateAction<T>>] { | ||
const [state, setState] = useState<T>(defaultState); | ||
const { isMounted } = useIsMounted(); | ||
|
||
const setStateIfMounted = useCallback( | ||
(state: React.SetStateAction<T>) => { | ||
if (isMounted()) { | ||
setState(state); | ||
} | ||
}, | ||
[isMounted] | ||
); | ||
|
||
return [state, setStateIfMounted]; | ||
} |
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
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
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
10 changes: 4 additions & 6 deletions
10
packages/app-page-builder/src/blockEditor/config/BlockEditorConfig.tsx
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
26 changes: 26 additions & 0 deletions
26
packages/app-page-builder/src/blockEditor/config/DefaultBlockEditorConfig.tsx
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,26 @@ | ||
import React from "react"; | ||
import { BlockEditorConfig } from "~/blockEditor/editorConfig/BlockEditorConfig"; | ||
import { BackButton } from "~/blockEditor/config/TopBar/BackButton"; | ||
import { Title } from "~/blockEditor/config/TopBar/Title"; | ||
import { SaveBlockButton } from "~/blockEditor/config/TopBar/SaveBlockButton"; | ||
import { BlockSettingsButton } from "~/blockEditor/config/TopBar/BlockSettings/BlockSettingsButton"; | ||
import { ElementSettingsDecorator } from "~/blockEditor/config/ElementSettingsTab"; | ||
|
||
const { TopBar, Toolbar } = BlockEditorConfig; | ||
|
||
export const DefaultBlockEditorConfig = () => { | ||
return ( | ||
<BlockEditorConfig> | ||
<TopBar.Element name={"buttonBack"} group={"left"} element={<BackButton />} /> | ||
<TopBar.Element name={"title"} group={"left"} element={<Title />} /> | ||
<TopBar.Action name={"buttonSaveBlock"} element={<SaveBlockButton />} /> | ||
<TopBar.Action | ||
name={"buttonBlockSettings"} | ||
element={<BlockSettingsButton />} | ||
before={"buttonSaveBlock"} | ||
/> | ||
<Toolbar.Element name={"savingIndicator"} remove /> | ||
<ElementSettingsDecorator /> | ||
</BlockEditorConfig> | ||
); | ||
}; |
35 changes: 35 additions & 0 deletions
35
packages/app-page-builder/src/blockEditor/config/ElementSettingsTab.tsx
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,35 @@ | ||
import React from "react"; | ||
import { plugins } from "@webiny/plugins"; | ||
import { useActiveElement } from "~/editor/hooks/useActiveElement"; | ||
import { ElementNotLinked } from "~/blockEditor/components/elementSettingsTab/ElementNotLinked"; | ||
import VariableSettings from "~/blockEditor/components/elementSettingsTab/VariableSettings"; | ||
import VariablesList from "~/blockEditor/components/elementSettingsTab/VariablesList"; | ||
import { PbBlockEditorCreateVariablePlugin } from "~/types"; | ||
import { EditorConfig } from "~/editor/config"; | ||
|
||
export const ElementSettingsDecorator = EditorConfig.Sidebar.Elements.createDecorator(Original => { | ||
const variablePlugins = plugins.byType<PbBlockEditorCreateVariablePlugin>( | ||
"pb-block-editor-create-variable" | ||
); | ||
|
||
return function ElementGroup(props) { | ||
const [element] = useActiveElement(); | ||
|
||
if (props.group !== "element") { | ||
return <Original {...props} />; | ||
} | ||
|
||
const canHaveVariable = | ||
element && variablePlugins.some(vp => vp.elementType === element.type); | ||
const hasVariable = element && element.data?.variableId; | ||
const isBlock = element && element.type === "block"; | ||
|
||
return ( | ||
<> | ||
{isBlock ? <VariablesList block={element} /> : <Original {...props} />} | ||
{canHaveVariable && !hasVariable && <ElementNotLinked />} | ||
{canHaveVariable && hasVariable && <VariableSettings element={element} />} | ||
</> | ||
); | ||
}; | ||
}); |
39 changes: 0 additions & 39 deletions
39
packages/app-page-builder/src/blockEditor/config/ElementSettingsTabContentPlugin.tsx
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
packages/app-page-builder/src/blockEditor/config/ToolbarActionsPlugin.tsx
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
packages/app-page-builder/src/blockEditor/config/TopBar/BackButton/BackButton.tsx
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 @@ | ||
import React, { useCallback } from "react"; | ||
import { css } from "emotion"; | ||
import { useLocation, useNavigate } from "@webiny/react-router"; | ||
import { IconButton } from "@webiny/ui/Button"; | ||
import { ReactComponent as BackIcon } from "./round-arrow_back-24px.svg"; | ||
import { useBlock } from "~/blockEditor/hooks/useBlock"; | ||
import { BlockEditorConfig } from "~/blockEditor/editorConfig/BlockEditorConfig"; | ||
|
||
const backStyles = css({ | ||
marginLeft: -10 | ||
}); | ||
|
||
export function BackButton() { | ||
const { key } = useLocation(); | ||
const navigate = useNavigate(); | ||
const [block] = useBlock(); | ||
|
||
const onClick = useCallback(() => { | ||
// If location.key is "default", then we are in a new tab. | ||
if (key === "default") { | ||
navigate(`/page-builder/page-blocks?category=${block.blockCategory}`); | ||
} else { | ||
navigate(-1); | ||
} | ||
}, [key, navigate]); | ||
|
||
return ( | ||
<> | ||
<IconButton | ||
data-testid="pb-editor-back-button" | ||
className={backStyles} | ||
onClick={onClick} | ||
icon={<BackIcon />} | ||
/> | ||
<BlockEditorConfig.TopBar.Divider /> | ||
</> | ||
); | ||
} |
File renamed without changes.
File renamed without changes
23 changes: 23 additions & 0 deletions
23
...ages/app-page-builder/src/blockEditor/config/TopBar/BlockSettings/BlockSettingsButton.tsx
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,23 @@ | ||
import React, { useCallback, useState } from "react"; | ||
import { IconButton } from "@webiny/ui/Button"; | ||
import { ReactComponent as SettingsIcon } from "./settings.svg"; | ||
import { BlockSettingsModal } from "./BlockSettingsModal"; | ||
|
||
export const BlockSettingsButton = () => { | ||
const [open, setState] = useState(false); | ||
|
||
const onClickHandler = useCallback(() => { | ||
setState(true); | ||
}, []); | ||
|
||
const onClose = useCallback(() => { | ||
setState(false); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<IconButton onClick={onClickHandler} icon={<SettingsIcon />} /> | ||
<BlockSettingsModal open={open} onClose={onClose} /> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.