Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/components/EditorContent/utils/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const buildHeaderLinks = editorContentNode => {
const usedIds = new Map();

headerTags.forEach(heading => {
if (heading.getAttribute('data-link') === 'false') {
if (heading.getAttribute("data-link") === "false") {
return;
}

Expand All @@ -48,12 +48,16 @@ export const buildHeaderLinks = editorContentNode => {

heading.setAttribute("id", headingId);

const wrapper = document.createElement("div");
const anchor = document.createElement("a");

wrapper.classList.add("header-wrapper");
anchor.setAttribute("href", `#${headingId}`);
anchor.classList.add("header-wrapper-link");
anchor.classList.add("header-wrapper__link");
anchor.appendChild(buildLinkSVG());
anchor.appendChild(heading.cloneNode(true));

heading.replaceWith(anchor);
wrapper.appendChild(heading.cloneNode(true));
wrapper.appendChild(anchor);
heading.replaceWith(wrapper);
});
};
16 changes: 6 additions & 10 deletions src/styles/editor/editor-content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,14 @@
}

// header anchor tags
.header-wrapper-link {
.header-wrapper {
position: relative;

&__link {
position: absolute;
top: 50%;
}

h1,
h2,
h3,
Expand Down Expand Up @@ -470,15 +475,6 @@
}

&:hover {
h1,
h2,
h3,
h4,
h5,
h6 {
color: rgb(var(--neeto-editor-accent-800));
}

.header-link-icon-wrapper {
opacity: 1;
}
Expand Down
Loading