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

parmenu: Detect edit menu click on par side #3541

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions timApp/static/scripts/tim/document/editing/editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,10 +1010,15 @@ auto_number_headings: 0${CURSOR}
}

updateEditBarState() {
document.documentElement.style.setProperty(
"--editline-display",
this.viewctrl.editMenuOnLeft ? "block" : "none"
);
const body = document.body;

if (this.viewctrl.editMenuOnLeft) {
body.classList.add("editmenu-left");
body.classList.remove("editmenu-right");
} else {
body.classList.remove("editmenu-left");
body.classList.add("editmenu-right");
}
}

private getAddParagraphItem(pos: EditPosition) {
Expand Down
24 changes: 20 additions & 4 deletions timApp/static/scripts/tim/document/parmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ export class ParmenuHandler {
}
const editMenuLeft = this.viewctrl.editMenuOnLeft;
if ((editMenuLeft && !par.preamble) || !editMenuLeft) {
const parOffset = par.offset() ?? getEmptyCoords();
const badgeY = e.pageY - parOffset.top;
this.viewctrl.notesHandler.updateNoteBadge(par, badgeY);
this.updateBadgePosition(par, e);
}
if (!par.isActionable()) {
return;
Expand Down Expand Up @@ -124,9 +122,27 @@ export class ParmenuHandler {
true
);

onClick(".editline", this.openParMenu, true);
onClick(".editline", this.handleLeftEditAreaClick, true);
}

private updateBadgePosition(par: ParContext, e: OnClickArg) {
const parOffset = par.offset() ?? getEmptyCoords();
const badgeY = e.pageY - parOffset.top;
this.viewctrl.notesHandler.updateNoteBadge(par, badgeY);
}

handleLeftEditAreaClick = async (
$this: JQuery,
e: OnClickArg
): Promise<boolean | void> => {
const par = createParContextOrHelp(findParentPar($this));
if (!this.viewctrl.editMenuOnLeft && !par.isHelp) {
this.updateBadgePosition(par, e);
return;
}
await this.openParMenu($this, e);
};

openParMenu = async (
$this: JQuery,
e: OnClickArg
Expand Down
34 changes: 33 additions & 1 deletion timApp/static/stylesheets/stylesheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ a.timButton {
width: $editline-width;
height: 100%;
top: 0;
display: var(--editline-display, none);
display: block;

@media (max-width: 870px) { /* for ipdas because of outend headings */
left: -($editline-width / 2);
Expand All @@ -692,6 +692,38 @@ a.timButton {
}
}

.editmenu-right {
.editline {
--_overfill-width: #{$editline-width + $editline-extra};
width: var(--_overfill-width);
z-index: 1;

@media (max-width: 870px) { /* for ipdas because of outend headings */
--_overfill-width: #{$editline-width / 2};
}

@media (max-width: $screen-xs-max) {
--_overfill-width: #{$grid-gutter-width / 3 + $focus-bar-width};
}

&:hover, &.menuopen {
opacity: 0;
}

&:focus {
outline: none;
}
}

.parContent {
z-index: 2;
}

.edit-menu-button {
z-index: 3;
}
}

#pars.editmode {
.par.areacollapse, .par.areaexpand {
.editline {
Expand Down
Loading