-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8940157
commit 19d7541
Showing
28 changed files
with
4,752 additions
and
872 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.app { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
flex-direction: column; | ||
align-content: center; | ||
align-items: center; | ||
} | ||
|
||
.playground { | ||
width: 1328px; | ||
|
||
margin-top: 30px; | ||
} | ||
|
||
.tabs { | ||
width: fit-content; | ||
} | ||
|
||
.editor { | ||
} |
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,59 @@ | ||
import {useCallback, useState, useEffect} from 'react'; | ||
|
||
import './index.scss'; | ||
import {useTabs} from "src/useTabs"; | ||
import { Tabs } from 'node_modules/@gravity-ui/uikit/build/esm/index'; | ||
import SplitViewEditor from "src/SplitViewEditor"; | ||
import PageConstructorEditor from "src/PageConstructorEditor"; | ||
import WYSIWYGEditor from "src/WYSIWYGEditor"; | ||
import Header from "src/Header"; | ||
|
||
|
||
const App = () => { | ||
return( | ||
<> | ||
<Header/> | ||
<Playground persistRestore={true} /> | ||
</>) | ||
}; | ||
|
||
export type PlaygroundProperties = { | ||
content?: string; | ||
persistRestore?: boolean; | ||
} | ||
|
||
enum EditorType { | ||
SPLIT = 'SPLIT_VIEW', | ||
WYSIWYG = 'WYSIWYG', | ||
PC = 'PC' | ||
|
||
} | ||
|
||
function Playground(props: PlaygroundProperties) { | ||
const [editorType, setEditorType] = useState(EditorType.SPLIT); | ||
|
||
const [ | ||
items, | ||
activeTab, | ||
handleSetInputAreaTabActive | ||
] = useTabs({ | ||
items: [ | ||
{ id: EditorType.SPLIT, title: 'Split view', node: <SplitViewEditor/> }, | ||
{ id: EditorType.WYSIWYG, title: 'WYSIWYG', node: <WYSIWYGEditor/> }, | ||
{ id: EditorType.PC, title: 'Page constructor', node: <PageConstructorEditor/> } | ||
], | ||
initial: EditorType.SPLIT, | ||
}); | ||
|
||
return ( | ||
<div className="playground"> | ||
<Tabs className="tabs" activeTab={activeTab} items={items} onSelectTab={handleSetInputAreaTabActive}/> | ||
<div className="editor"> | ||
{items?.find(el => el.id === activeTab).node} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export {App, Playground}; | ||
export default {App, Playground}; |
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,15 @@ | ||
.header { | ||
display: flex; | ||
align-content: center; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
|
||
height: 64px; | ||
width: 100%; | ||
|
||
box-shadow: inset 0 -1px 0 var(--g-color-line-generic); | ||
} | ||
|
||
.logo { | ||
width: 1328px; | ||
} |
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,17 @@ | ||
import React from 'react'; | ||
import {Icon} from '@gravity-ui/uikit'; | ||
|
||
import './header.scss'; | ||
|
||
function Header() { | ||
return ( | ||
<div className='header'> | ||
<div className='logo'> | ||
<img | ||
src="https://storage.yandexcloud.net/diplodoc-www-assets/navigation/diplodoc-logo.svg"/> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Header |
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,66 @@ | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "header-block", | ||
"title": "Lorem ipsum dolor sit amet, consectetur adipiscing elit", | ||
"description": "**Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.", | ||
"buttons": [ | ||
{ | ||
"text": "Button\r", | ||
"theme": "action", | ||
"url": "https://example.com" | ||
}, | ||
{ | ||
"text": "Button", | ||
"theme": "outlined", | ||
"url": "https://example.com" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "slider-block", | ||
"title": { | ||
"text": "Slider", | ||
"url": "https://example.com" | ||
}, | ||
"children": [ | ||
{ | ||
"type": "basic-card", | ||
"url": "https://example.com", | ||
"title": "Lorem ipsum dolor sit amet", | ||
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", | ||
"icon": "https://preview.gravity-ui.com/page-constructor/story-assets/icon_1_light.svg" | ||
}, | ||
{ | ||
"type": "basic-card", | ||
"url": "https://example.com", | ||
"title": "Lorem ipsum dolor sit amet", | ||
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", | ||
"icon": "https://preview.gravity-ui.com/page-constructor/story-assets/icon_2_light.svg" | ||
}, | ||
{ | ||
"type": "basic-card", | ||
"url": "https://example.com", | ||
"title": "Lorem ipsum dolor sit amet", | ||
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", | ||
"icon": "https://preview.gravity-ui.com/page-constructor/story-assets/icon_3_light.svg" | ||
}, | ||
{ | ||
"type": "basic-card", | ||
"url": "https://example.com", | ||
"title": "Lorem ipsum dolor sit amet", | ||
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", | ||
"icon": "https://preview.gravity-ui.com/page-constructor/story-assets/icon_4_light.svg" | ||
}, | ||
{ | ||
"type": "basic-card", | ||
"url": "https://example.com", | ||
"title": "Lorem ipsum dolor sit amet", | ||
"text": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", | ||
"icon": "https://preview.gravity-ui.com/page-constructor/story-assets/icon_1_light.svg" | ||
} | ||
] | ||
} | ||
], | ||
"animated": false | ||
} |
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,34 @@ | ||
import React, {useCallback, useState} from 'react'; | ||
|
||
|
||
import {ContentTransformer, Editor,} from '@gravity-ui/page-constructor/editor'; | ||
import { PageContent } from 'node_modules/@gravity-ui/page-constructor/build/esm/index'; | ||
import data from './data.json'; | ||
import {contentTransformer} from "@gravity-ui/page-constructor/server"; | ||
import {memoizeLast} from "src/PageConstructorEditor/utils"; | ||
|
||
interface MyAppEditorProps { | ||
initialContent: PageContent; | ||
transformContent: ContentTransformer; | ||
onChange: (content: PageContent) => void; | ||
} | ||
|
||
const contentTransformerMemoized = memoizeLast(contentTransformer); | ||
|
||
|
||
function PageConstructorEditor () { | ||
const [input, setInput] = useState(data) | ||
const lang = 'ru' | ||
|
||
const transformContent = useCallback( | ||
(content: PageContent) => ({ | ||
...content, | ||
...contentTransformerMemoized({content, options: {lang}}), | ||
}), | ||
[lang], | ||
); | ||
|
||
return <Editor content={input} onChange={setInput} transformContent={transformContent} /> | ||
} | ||
|
||
export default PageConstructorEditor |
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,22 @@ | ||
import isEqual from 'lodash/isEqual'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const memoizeLast = (fn: (...args: any[]) => any) => { | ||
let cacheKey: Parameters<typeof fn>; | ||
let cacheResult: ReturnType<typeof fn>; | ||
|
||
return (...params: Parameters<typeof fn>) => { | ||
if (!isEqual(params, cacheKey)) { | ||
try { | ||
const result = fn(...params); | ||
|
||
cacheResult = result; | ||
cacheKey = params; | ||
} catch { | ||
return cacheResult; | ||
} | ||
} | ||
|
||
return cacheResult; | ||
}; | ||
}; |
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,51 @@ | ||
.split-view { | ||
display: flex; | ||
|
||
gap: 30px | ||
} | ||
|
||
.area__card { | ||
padding: var(--g-text-body-1-font-size); | ||
|
||
& > section { | ||
height: var(--diplodoc-playground-height) !important; | ||
min-height: var(--diplodoc-playground-height) !important; | ||
max-height: var(--diplodoc-playground-height) !important; | ||
background-color: red; | ||
overflow-y: scroll; | ||
overflow-x: hidden; | ||
|
||
padding: 0; | ||
} | ||
} | ||
|
||
/* yfm preview */ | ||
.area__yfm { | ||
border-radius: 2px !important; | ||
|
||
height: calc(var(--diplodoc-playground-height) + 26px); | ||
min-height: calc(var(--diplodoc-playground-height) + 26px); | ||
max-height: calc(var(--diplodoc-playground-height) + 26px); | ||
|
||
overflow-y: scroll; | ||
overflow-x: hidden; | ||
} | ||
|
||
.area-card__editor { | ||
border-radius: 2px !important; | ||
padding-right: 0px; | ||
} | ||
|
||
.area__tabs { | ||
text-transform: uppercase; | ||
} | ||
|
||
.input { | ||
width: 50%; | ||
|
||
margin-top: 39px; | ||
} | ||
|
||
.output { | ||
width: 50%; | ||
} |
Oops, something went wrong.