chore: deprecate collapsible-properties, global-block-links, weekly-view

This commit is contained in:
dragonwocky 2024-04-23 15:33:16 +10:00
parent 5f958726d9
commit 5b22ca9ff9
Signed by: dragonwocky
GPG Key ID: 7998D08F7D7BD7A8
13 changed files with 7 additions and 424 deletions

View File

@ -34,7 +34,7 @@ function Mod({
${thumbnail
? html`<img
src="${enhancerUrl(`${_src}/${thumbnail}`)}"
class="rounded-[4px] mr-[12px] h-[74px] my-auto"
class="rounded-[4px] mr-[12px] h-[74px] aspect-video my-auto"
/>`
: ""}
<div class="flex-(~ col) w-full">

View File

@ -1,56 +0,0 @@
/**
* notion-enhancer: collapse properties
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
#enhancer--collapse-properties {
display: flex;
background: var(--theme--ui_interactive-hover);
border: 1px solid transparent;
font-size: 14px;
border-radius: 3px;
line-height: 1.2;
font-weight: 600;
padding: 0.3em 0.5em;
margin: 1em 0;
width: 100%;
}
#enhancer--collapse-properties:focus,
#enhancer--collapse-properties:hover {
background: transparent;
border: 1px solid var(--theme--ui_interactive-hover);
}
#enhancer--collapse-properties:active {
background: var(--theme--ui_interactive-active);
}
#enhancer--collapse-properties > span {
text-align: left;
color: var(--theme--text);
}
#enhancer--collapse-properties > span:before {
content: 'Properties';
}
#enhancer--collapse-properties > svg {
fill: var(--theme--icon);
height: 0.8em;
width: 0.8em;
margin: auto 0.5em auto 0;
transition: transform 200ms ease-out 0s;
}
#enhancer--collapse-properties[data-collapsed='false'] > svg {
transform: rotateZ(180deg);
}
#enhancer--collapse-properties[data-collapsed='true'] > svg {
transform: rotateZ(90deg);
}
#enhancer--collapse-properties + div {
overflow: hidden;
}
#enhancer--collapse-properties[data-collapsed='true'] + div {
max-height: 0 !important;
opacity: 0;
}

View File

@ -1,35 +0,0 @@
/**
* notion-enhancer: collapse properties
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
'use strict';
export default function ({ web, notion }, db) {
const propertyListSelector =
'.notion-scroller.vertical [style*="env(safe-area-inset-left)"] > [style="width: 100%; font-size: 14px;"]',
$collapseButton = web.html`<button id="enhancer--collapse-properties">
<svg viewBox="0 0 100 100"><polygon points="5.9,88.2 50,11.8 94.1,88.2"></polygon></svg>
<span></span>
</button>`;
$collapseButton.addEventListener('click', async (event) => {
if ($collapseButton.dataset.collapsed === 'true') {
await db.set([notion.getPageID()], false);
$collapseButton.dataset.collapsed = false;
} else {
await db.set([notion.getPageID()], true);
$collapseButton.dataset.collapsed = true;
}
});
const insertButton = async () => {
if (document.contains($collapseButton)) return;
const $propertyList = document.querySelector(propertyListSelector);
if ($propertyList) {
$collapseButton.dataset.collapsed = await db.get([notion.getPageID()], true);
$propertyList.before($collapseButton);
}
};
web.addDocumentObserver(insertButton, [propertyListSelector]);
insertButton();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

View File

@ -1,23 +0,0 @@
{
"name": "collapsible properties",
"id": "4034a578-7dd3-4633-80c6-f47ac5b7b160",
"version": "0.3.0",
"description": "adds a button to quickly collapse/expand page properties that usually push down page content.",
"preview": "collapsible-properties.jpg",
"tags": ["extension", "layout"],
"authors": [
{
"name": "dragonwocky",
"email": "thedragonring.bod@gmail.com",
"homepage": "https://dragonwocky.me/",
"avatar": "https://dragonwocky.me/avatar.jpg"
}
],
"css": {
"client": ["client.css"]
},
"js": {
"client": ["client.mjs"]
},
"options": []
}

View File

@ -1,73 +0,0 @@
/**
* notion-enhancer: global block links
* (c) 2021 admiraldus (https://github.com/admiraldus)
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
.global_block_links--topbar_copy {
display: inline-flex;
align-items: center;
border-radius: 3px;
height: 28px;
min-width: 0px;
padding-right: 8px;
padding-left: 6px;
font-size: 14px;
line-height: 1.2;
color: var(--theme--text);
cursor: pointer;
transition: background 20ms ease-in 0s;
user-select: none;
}
.global_block_links--topbar_copy > svg {
display: block;
height: 16px;
width: 16px;
fill: var(--theme--icon);
}
.global_block_links--topbar_copy > span {
margin-left: 2px;
opacity: 1;
transition: opacity 0.4s ease;
}
.global_block_links--topbar_copy > svg + span {
margin-left: 6px;
}
.global_block_links--block_copy {
display: flex;
align-items: center;
height: 28px;
width: 100%;
font-size: 14px;
line-height: 1.2;
cursor: pointer;
transition: background 20ms ease-in 0s;
user-select: none;
}
.global_block_links--block_copy > svg {
display: block;
margin-left: 14px;
height: 17px;
width: 17px;
color: var(--theme--icon);
}
.global_block_links--block_copy > span {
margin-right: 14px;
margin-left: 8px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.global_block_links--topbar_copy:hover,
.global_block_links--block_copy:hover {
background: var(--theme--ui_interactive-hover);
}
.global_block_links--hidden {
position: absolute;
top: -9999px;
opacity: 0 !important;
}

View File

@ -1,109 +0,0 @@
/**
* notion-enhancer: global block links
* (c) 2021 admiraldus (https://github.com/admiraldus)
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
export default async function ({ web, components, notion }, db) {
const topbarShareSelector = '.notion-topbar-share-menu',
blockActionSelector =
'.notion-overlay-container .notion-scroller.vertical .notion-focusable > div > div > [style*="text-overflow: ellipsis;"]',
hoveredActionSelector =
'.notion-overlay-container .notion-scroller.vertical .notion-focusable[style*="background:"]',
topbarCopyClass = 'global_block_links--topbar_copy',
blockCopyClass = 'global_block_links--block_copy',
hiddenClass = 'global_block_links--hidden';
const topbarCopyIcon = await db.get(['topbar_copy_icon']),
topbarCopyText = await db.get(['topbar_copy_text']);
if (topbarCopyIcon || topbarCopyText) {
const $topbarCopyTemplate = web.render(
web.html`<div class="${topbarCopyClass}" role="button" tabindex="0"></div>`,
topbarCopyIcon
? web.html`<svg viewBox="0 0 30 30">
<path d="M2,12c0-3.309,2.691-6,6-6h8c3.309,0,6,2.691,6,6s-2.691,6-6,6h-6c0,0.736,
0.223,1.41,0.574,2H16c4.418,0,8-3.582,8-8 c0-4.418-3.582-8-8-8H8c-4.418,0-8,3.582-8,
8c0,2.98,1.634,5.575,4.051,6.951C4.021,18.638,4,18.321,4,18 c0-0.488,0.046-0.967,
0.115-1.436C2.823,15.462,2,13.827,2,12z M25.953,11.051C25.984,11.363,26,11.68,26,12
c0,0.489-0.047,0.965-0.117,1.434C27.176,14.536,28,16.172,28,18c0,3.309-2.691,6-6,6h-8c-3.309,
0-6-2.691-6-6s2.691-6,6-6h6 c0-0.731-0.199-1.413-0.545-2H14c-4.418,0-8,3.582-8,8c0,
4.418,3.582,8,8,8h8c4.418,0,8-3.582,8-8 C30,15.021,28.368,12.428,25.953,11.051z"></path>
</svg>`
: '',
topbarCopyText
? web.html`
<span data-copy>Copy link</span>
<span data-copied class="${hiddenClass}">Link copied!</span>
`
: ''
);
const insertTopbarCopy = () => {
const $btns = document.querySelectorAll(topbarShareSelector);
$btns.forEach(($btn) => {
if (!$btn.previousElementSibling?.classList?.contains?.(topbarCopyClass)) {
const $copy = $topbarCopyTemplate.cloneNode(true);
components.addTooltip($copy, '**Copy page link**');
$btn.before($copy);
let resetButtonDelay;
$copy.addEventListener('click', () => {
if (topbarCopyText) {
const $copyText = $copy.querySelector('[data-copy]'),
$copiedText = $copy.querySelector('[data-copied]');
$copyText.classList.add(hiddenClass);
$copiedText.classList.remove(hiddenClass);
clearTimeout(resetButtonDelay);
resetButtonDelay = setTimeout(() => {
$copyText.classList.remove(hiddenClass);
$copiedText.classList.add(hiddenClass);
}, 1250);
}
web.copyToClipboard(`https://notion.so/${notion.getPageID().replace(/-/g, '')}`);
});
}
});
};
insertTopbarCopy();
web.addDocumentObserver(insertTopbarCopy, [topbarShareSelector]);
}
const $blockCopyTemplate = web.html`
<div class="${blockCopyClass}" role="button" tabindex="0">
${await components.feather('globe')}
<span>Global link</span>
</div>`;
const getLinkButtons = () =>
[...document.querySelectorAll(blockActionSelector)]
.filter(($action) =>
['Copy link', '링크 복사', 'リンクをコピー'].includes($action.textContent)
)
.map(($action) => $action.closest('.notion-focusable')),
insertBlockCopy = () => {
const $btns = getLinkButtons();
$btns.forEach(($btn) => {
if (!$btn.previousElementSibling?.classList?.contains?.(blockCopyClass)) {
const $copy = $blockCopyTemplate.cloneNode(true);
$btn.before($copy);
$copy.addEventListener('mouseover', () => {
document.querySelectorAll(hoveredActionSelector).forEach(($action) => {
$action.style.background = '';
});
});
$copy.addEventListener('click', async () => {
$btn.click();
const link = await web.readFromClipboard(),
id = link.replace(/.+#(?=\w+)/, '');
web.copyToClipboard(id.length === 32 ? `https://notion.so/${id}` : link);
});
}
});
};
insertBlockCopy();
web.addDocumentObserver(insertBlockCopy, [blockActionSelector]);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -1,35 +0,0 @@
{
"name": "global block links",
"id": "74856af4-6970-455d-bd86-0a385a402dd1",
"version": "0.1.0",
"description": "easily copy the global link of a page or block.",
"preview": "global-block-links.jpg",
"tags": ["extension", "shortcut"],
"authors": [
{
"name": "admiraldus",
"homepage": "https://github.com/admiraldus",
"avatar": "https://raw.githubusercontent.com/admiraldus/admiraldus/main/module.gif"
}
],
"js": {
"client": ["client.mjs"]
},
"css": {
"client": ["client.css"]
},
"options": [
{
"key": "topbar_copy_icon",
"label": "copy page links from the topbar (icon)",
"type": "toggle",
"value": true
},
{
"key": "topbar_copy_text",
"label": "copy page links from the topbar (text)",
"type": "toggle",
"value": true
}
]
}

View File

@ -38,6 +38,12 @@
"description": "Hide the default <i class='i-file -mb-px'></i> page icons.",
"value": false
},
{
"type": "toggle",
"key": "hoverableTimelineTitles",
"description": "Shows the full title of a timeline item on hover if it has been truncated for being too long.",
"value": false
},
{
"type": "toggle",
"key": "snappyTransitions",

View File

@ -1,71 +0,0 @@
/**
* notion-enhancer: weekly view
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
'use strict';
export default async function ({ web }, db) {
const pageSelector = '.notion-page-content',
calendarSelector = '.notion-calendar-view',
viewSelector =
'.notion-page-content > .notion-selectable.notion-collection_view-block',
viewControlSelector = ':scope>div>div>div>div>div',
todaySelector = '.notion-calendar-view-day[style*="background"]',
weekSelector = '[style^="position: relative; display: flex; height: "]',
toolbarBtnSelector =
'.notion-calendar-view > :first-child > :first-child > :first-child > :nth-last-child(2)';
const transformCalendarView = () => {
const $page = document.querySelector(pageSelector);
document.querySelectorAll(viewSelector).forEach(async ($view) => {
let currentText;
// Get view controls children nodes, convert to array, filter out non-text
const $viewNodes = []
.slice.call($view.querySelector(viewControlSelector).children)
.filter(node => node.tagName.toLowerCase().match(/(div|span)/g));
// Find current view by analyzing children (which changes on viewport)
if ($viewNodes.length === 1)
{
// Mobile: Simple dropdown button (like legacy), text is current view
currentText = $viewNodes[0].innerText.toLowerCase();
} else {
// Wide/Desktop: Tabs listed, current view indicated by border style
currentText = $viewNodes
// Find selected view by border style (possibly fragile)
.filter(($e) => $e.children[0].style.borderBottomWidth.toString() === '2px')[0]
.innerText.toLowerCase();
}
if (currentText !== 'weekly') return;
const $calendar = $view.parentElement.parentElement.parentElement.parentElement;
if (!$calendar.querySelector(todaySelector)) {
$calendar.querySelector(toolbarBtnSelector).click();
}
await new Promise((res, rej) => requestAnimationFrame(res));
if ($page) {
for (const $week of $calendar.querySelectorAll(weekSelector)) {
if (!$week.querySelector(todaySelector)) {
$week.style.height = 0;
$week.style.visibility = 'hidden';
}
}
} else {
const $weekContainer = $calendar.querySelector(weekSelector).parentElement;
for (const $week of $calendar.querySelectorAll(weekSelector)) {
if ($week.querySelector(todaySelector)) {
$weekContainer.style.maxHeight = $week.style.height;
break;
} else {
$week.style.height = '0';
$week.style.visibility = 'hidden';
}
}
}
});
};
web.addDocumentObserver(transformCalendarView, [calendarSelector]);
}

View File

@ -1,21 +0,0 @@
{
"name": "weekly view",
"id": "4c7acaea-6596-4590-85e5-8ac5a1455e8f",
"version": "0.6.0",
"description": "calendar views named \"weekly\" will show only the current week.",
"preview": "weekly-view.jpg",
"tags": ["extension", "layout"],
"authors": [
{
"name": "dragonwocky",
"email": "thedragonring.bod@gmail.com",
"homepage": "https://dragonwocky.me/",
"avatar": "https://dragonwocky.me/avatar.jpg"
}
],
"js": {
"client": ["client.mjs"]
},
"css": {},
"options": []
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB