Skip to content

Commit

Permalink
Merge branch 'develop' into feat/revise-set-payment-password
Browse files Browse the repository at this point in the history
  • Loading branch information
wlliaml authored May 17, 2024
2 parents df6fc7a + 74f0ef0 commit a9b507b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.container {
position: absolute;
top: calc(2rem / 2 * -1);
top: calc(2rem / 2 * -1 - 1px); /* 2rem is icon size, 1px for offset */
left: 0;
display: flex;
align-items: center;
Expand Down
12 changes: 8 additions & 4 deletions src/components/Editor/Article/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useApolloClient } from '@apollo/react-hooks'
import { EditorContent, useArticleEdtor } from '@matters/matters-editor'
import classNames from 'classnames'
import { useIntl } from 'react-intl'
import { useDebouncedCallback } from 'use-debounce'

Expand Down Expand Up @@ -57,6 +56,13 @@ export const ArticleEditor: React.FC<ArticleEditorProps> = ({
const content = editor.getHTML()
debouncedUpdate({ content })
},
// toggle body class
onFocus: () => {
document.body.classList.add('editor-focused')
},
onBlur: () => {
document.body.classList.remove('editor-focused')
},
mentionSuggestion: makeMentionSuggestion({ client }),
extensions: [
FigureEmbedLinkInput,
Expand All @@ -74,9 +80,7 @@ export const ArticleEditor: React.FC<ArticleEditorProps> = ({

return (
<div
className={classNames({
[styles.articleEditor]: true,
})}
className={styles.articleEditor}
id="editor" // anchor for mention plugin
>
<EditorTitle defaultValue={title || ''} update={update} />
Expand Down
25 changes: 19 additions & 6 deletions src/components/Editor/Article/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
.articleEditor {
position: relative;
padding-bottom: 4rem; /* bottom bar height */
height: calc(
100vh - 3rem -4rem - var(--sp16) * 2
); /* 3rem for header, 4rem for bottom bar */

height: calc(var(--vvh) * 100 - 3rem -4rem - var(--sp16) * 2);
overflow-x: hidden;
overflow-y: auto;

@media (--lg-up) {
height: auto;
padding-bottom: 0;
}

& :global(.ProseMirror),
& :global(.tiptap) {
min-height: 50vh;
min-height: calc(var(--vvh) * 50);
margin-bottom: var(var(--global-nav-height));

@media (--lg-up) {
margin-bottom: 0;
}

/* outline */
&:focus {
Expand Down Expand Up @@ -94,3 +96,14 @@
}
}
}

:global(body.editor-focused) {
& .articleEditor {
height: calc(100vh - 3rem - var(--sp16) * 2); /* 3rem for header */
height: calc(var(--vvh) * 100 - 3rem - var(--sp16) * 2);

@media (--lg-up) {
height: auto;
}
}
}
2 changes: 1 addition & 1 deletion src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const Main: React.FC<React.PropsWithChildren<MainProps>> & {
[styles.hasNavBar]: !isInArticleDetail && !isInDraftDetail,
})

const enbableSticky = !isInArticleDetailHistory && !isInEditor
const enbableSticky = !isInArticleDetailHistory

usePullToRefresh.Register('#ptr')
usePullToRefresh.Handler(() => window.location.reload())
Expand Down
7 changes: 6 additions & 1 deletion src/components/Layout/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@
.article {
position: relative;
grid-column: content;
min-height: calc(100vh + 1px);
min-height: 100vh;
min-height: calc(var(--vvh) * 100);

@media (--sm-up) {
grid-column: content;

/* FIXME: page scrollbar is showed on open dialog */
min-height: calc(100vh + 1px);
min-height: calc(var(--vvh) * 100 + 1px);
padding-bottom: 0;
}

Expand Down

0 comments on commit a9b507b

Please sign in to comment.