Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui/editor): fix position of the comment box when replying (#643) #648

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion ui/packages/artalk/src/editor/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default class EditorStateManager {
// invoke effect function and save unmount function
if (state !== 'normal' && payload) {
// move editor position
this.editor.getPlugs()?.get(Mover)?.move(payload.$comment)
let moveAfterEl = payload.$comment
if (!this.editor.conf.flatMode) moveAfterEl = moveAfterEl.querySelector<HTMLElement>('.atk-footer')!
this.editor.getPlugs()?.get(Mover)?.move(moveAfterEl)

const $relative = this.editor.ctx.conf.scrollRelativeTo && this.editor.ctx.conf.scrollRelativeTo()
Ui.scrollIntoView(this.editor.getUI().$el, true, $relative)
Expand Down
2 changes: 2 additions & 0 deletions ui/packages/artalk/src/plugins/editor/mover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export default class Mover extends EditorPlug {
$travelPlace.replaceWith(editorEl)

editorEl.classList.add('atk-fade-in') // 添加渐入动画
editorEl.classList.add('editor-traveling')
}

back() {
if (!this.isMoved) return
this.isMoved = false
this.kit.useGlobalCtx().$root.querySelector('.atk-editor-travel-placeholder')?.replaceWith(this.kit.useUI().$el)
this.kit.useUI().$el.classList.remove('editor-traveling')
}
}
12 changes: 5 additions & 7 deletions ui/packages/artalk/src/style/comment.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

.atk-comment {
display: block;
padding: 12px 10px;
padding: 10px;

& > .atk-avatar {
display: block;
Expand Down Expand Up @@ -239,23 +239,21 @@
}

& > .atk-footer {
margin-top: 12px;
margin-top: 5px;

.atk-actions {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
margin-bottom: -15px;

& > span {
color: var(--at-color-meta);
font-size: 13px;
line-height: 15px;
line-height: 25px;
display: inline-flex;
cursor: pointer;
user-select: none;
margin-bottom: 15px;

&.atk-error, &.atk-error:hover {
color: var(--at-color-red);
Expand Down Expand Up @@ -340,11 +338,11 @@
border-left: 1px dashed transparent;
border-bottom-color: transparent;
&:not(:last-child) {
margin-bottom: 5px;
margin-bottom: 10px;
}

& > .atk-comment {
padding: 4px 0;
padding: 0;

& > .atk-avatar img {
width: 36px;
Expand Down
5 changes: 5 additions & 0 deletions ui/packages/artalk/src/style/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
margin-bottom: 7px;
}

&.editor-traveling {
margin-top: 5px;
margin-bottom: 10px;
}

& > .atk-header {
display: flex;
flex-direction: row;
Expand Down