mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-06 21:49:03 +00:00
toggle hotkey option + tab reload on changes
This commit is contained in:
parent
62ba127793
commit
69b73f6140
@ -19,24 +19,40 @@ env.name = 'extension';
|
||||
env.version = chrome.runtime.getManifest().version;
|
||||
env.openEnhancerMenu = () => chrome.runtime.sendMessage({ action: 'openEnhancerMenu' });
|
||||
env.focusNotion = () => chrome.runtime.sendMessage({ action: 'focusNotion' });
|
||||
env.reloadTabs = () => chrome.runtime.sendMessage({ action: 'reloadTabs' });
|
||||
|
||||
storage.get = (namespace, key = undefined, fallback = undefined) =>
|
||||
new Promise((res, rej) =>
|
||||
chrome.storage.sync.get([namespace], async (values) => {
|
||||
const defaults = await registry.defaults(namespace);
|
||||
values =
|
||||
values[namespace] && Object.getOwnPropertyNames(values[namespace]).length
|
||||
values[namespace] &&
|
||||
Object.getOwnPropertyNames(values[namespace]).length &&
|
||||
(!key || Object.getOwnPropertyNames(values[namespace]).includes(key))
|
||||
? values[namespace]
|
||||
: await registry.defaults(namespace);
|
||||
: defaults;
|
||||
res((key ? values[key] : values) ?? fallback);
|
||||
})
|
||||
);
|
||||
storage.set = (namespace, key, value) =>
|
||||
new Promise(async (res, rej) => {
|
||||
storage.set = (namespace, key, value) => {
|
||||
storage._onChangeListeners.forEach((listener) =>
|
||||
listener({ type: 'set', namespace, key, value })
|
||||
);
|
||||
return new Promise(async (res, rej) => {
|
||||
const values = await storage.get(namespace, undefined, {});
|
||||
chrome.storage.sync.set({ [namespace]: { ...values, [key]: value } }, res);
|
||||
});
|
||||
storage.reset = (namespace) =>
|
||||
new Promise((res, rej) => chrome.storage.sync.set({ [namespace]: undefined }, res));
|
||||
};
|
||||
storage.reset = (namespace) => {
|
||||
storage._onChangeListeners.forEach((listener) =>
|
||||
listener({ type: 'reset', namespace, key: undefined, value: undefined })
|
||||
);
|
||||
return new Promise((res, rej) => chrome.storage.sync.set({ [namespace]: undefined }, res));
|
||||
};
|
||||
storage._onChangeListeners = [];
|
||||
storage.onChange = (listener) => {
|
||||
storage._onChangeListeners.push(listener);
|
||||
};
|
||||
|
||||
fs.getJSON = (path) =>
|
||||
fetch(path.startsWith('https://') ? path : chrome.runtime.getURL(path)).then((res) =>
|
||||
@ -107,6 +123,7 @@ web.html = (html, ...templates) => html.map((str) => str + (templates.shift() ??
|
||||
* @param {function} callback
|
||||
*/
|
||||
web.hotkeyListener = (keys, callback) => {
|
||||
if (typeof keys === 'string') keys = keys.split('+');
|
||||
if (!web._hotkeyListener) {
|
||||
web._hotkeys = [];
|
||||
web._hotkeyListener = document.addEventListener('keyup', (event) => {
|
||||
|
@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "custom-inserts",
|
||||
"id": "2f914210-faae-4803-8e3d-f2bf358a5864",
|
||||
"version": "0.11.0",
|
||||
"description": "the enhancer's [graphical](https://github.com) menu, related buttons and shortcuts.",
|
||||
"preview": "https://raw.githubusercontent.com/notion-enhancer/notion-enhancer/dev/notion-enhancer%20v0.10.0%20banner.jpg",
|
||||
"tags": ["core"],
|
||||
"authors": [
|
||||
{
|
||||
"name": "dragonwocky",
|
||||
"email": "thedragonring.bod@gmail.com",
|
||||
"url": "https://dragonwocky.me/",
|
||||
"icon": "https://dragonwocky.me/avatar.jpg"
|
||||
}
|
||||
],
|
||||
"js": {},
|
||||
"options": [
|
||||
{
|
||||
"type": "toggle",
|
||||
"key": "toggle",
|
||||
"label": "toggle",
|
||||
"value": true,
|
||||
"tooltip": "a toggle"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"key": "select",
|
||||
"label": "select",
|
||||
"values": ["option a", "option b", "option c"],
|
||||
"tooltip": "a select"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "text",
|
||||
"label": "text",
|
||||
"value": "default",
|
||||
"tooltip": "a text input"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"key": "number",
|
||||
"label": "number",
|
||||
"value": 0,
|
||||
"tooltip": "a number input"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"key": "file",
|
||||
"label": "file picker (.css only)",
|
||||
"extensions": [".css"],
|
||||
"tooltip": "a file picker"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,333 +1 @@
|
||||
```js
|
||||
const check = (prop, value, condition) =>
|
||||
Promise.resolve(condition ? value : err(`invalid ${prop} ${JSON.stringify(value)}`)),
|
||||
validation = await registry.validate(mod, err, check);
|
||||
if (validation.every((condition) => condition !== ERROR)) registry._list.push(mod);
|
||||
```
|
||||
|
||||
# markdown tester
|
||||
|
||||
## table
|
||||
|
||||
| option | extended description | type | values/defaults | platform-specific details |
|
||||
| ---------------------------- | ---------------------------------------------------------------------------------------------------------- | ------------ | --------------- | ------------------------- |
|
||||
| height of frameless dragarea | the rectangle added at the top of a window in "integrated titlebar" mode, used to drag/move the window. | number input | 15 | macOS: forced to 0 |
|
||||
| width to wrap columns at | the size in pixels below which in-page columns are resized to appear full width so content isn't squished. | number input | 600 | |
|
||||
| integrated scrollbars | use scrollbars that fit better into notion's ui instead of the default chrome ones. | toggle | yes | |
|
||||
| snappy transitions | | toggle | no | |
|
||||
| thicker bold text | | toggle | yes | |
|
||||
| more readable line spacing | | toggle | no | |
|
||||
| hide help button | | toggle | no | |
|
||||
|
||||
# Markdown: Syntax
|
||||
|
||||
- [markdown tester](#markdown-tester)
|
||||
- [table](#table)
|
||||
- [Markdown: Syntax](#markdown-syntax)
|
||||
- [Overview](#overview)
|
||||
- [Philosophy](#philosophy)
|
||||
- [Block Elements](#block-elements)
|
||||
- [Paragraphs and Line Breaks](#paragraphs-and-line-breaks)
|
||||
- [Headers](#headers)
|
||||
- [Blockquotes](#blockquotes)
|
||||
- [Lists](#lists)
|
||||
- [Code Blocks](#code-blocks)
|
||||
- [Span Elements](#span-elements)
|
||||
- [Links](#links)
|
||||
- [Emphasis](#emphasis)
|
||||
- [Code](#code)
|
||||
|
||||
**Note:** This document is itself written using Markdown; you
|
||||
can [see the source for it by adding '.text' to the URL](/projects/markdown/syntax.text).
|
||||
|
||||
---
|
||||
|
||||
```css
|
||||
:root {
|
||||
--theme_dark--db_today-text: #fff;
|
||||
--theme_dark--timeline_divider_thin: rgba(255, 255, 255, 0.07);
|
||||
--theme_dark--timeline_arrow: rgb(47, 52, 55);
|
||||
}
|
||||
```
|
||||
|
||||
## Overview
|
||||
|
||||
### Philosophy
|
||||
|
||||
Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
|
||||
|
||||
Readability, however, is emphasized above all else. A Markdown-formatted
|
||||
document should be publishable as-is, as plain text, without looking
|
||||
like it's been marked up with tags or formatting instructions. While
|
||||
Markdown's syntax has been influenced by several existing text-to-HTML
|
||||
filters -- including [Setext](http://docutils.sourceforge.net/mirror/setext.html), [atx](http://www.aaronsw.com/2002/atx/), [Textile](http://textism.com/tools/textile/), [reStructuredText](http://docutils.sourceforge.net/rst.html),
|
||||
[Grutatext](http://www.triptico.com/software/grutatxt.html), and [EtText](http://ettext.taint.org/doc/) -- the single biggest source of
|
||||
inspiration for Markdown's syntax is the format of plain text email.
|
||||
|
||||
## Block Elements
|
||||
|
||||
### Paragraphs and Line Breaks
|
||||
|
||||
A paragraph is simply one or more consecutive lines of text, separated
|
||||
by one or more blank lines. (A blank line is any line that looks like a
|
||||
blank line -- a line containing nothing but spaces or tabs is considered
|
||||
blank.) Normal paragraphs should not be indented with spaces or tabs.
|
||||
|
||||
The implication of the "one or more consecutive lines of text" rule is
|
||||
that Markdown supports "hard-wrapped" text paragraphs. This differs
|
||||
significantly from most other text-to-HTML formatters (including Movable
|
||||
Type's "Convert Line Breaks" option) which translate every line break
|
||||
character in a paragraph into a `<br />` tag.
|
||||
|
||||
When you _do_ want to insert a `<br />` break tag using Markdown, you
|
||||
end a line with two or more spaces, then type return.
|
||||
|
||||
### Headers
|
||||
|
||||
Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
|
||||
|
||||
Optionally, you may "close" atx-style headers. This is purely
|
||||
cosmetic -- you can use this if you think it looks better. The
|
||||
closing hashes don't even need to match the number of hashes
|
||||
used to open the header. (The number of opening hashes
|
||||
determines the header level.)
|
||||
|
||||
### Blockquotes
|
||||
|
||||
Markdown uses email-style `>` characters for blockquoting. If you're
|
||||
familiar with quoting passages of text in an email message, then you
|
||||
know how to create a blockquote in Markdown. It looks best if you hard
|
||||
wrap the text and put a `>` before every line:
|
||||
|
||||
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
||||
> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
||||
> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
||||
>
|
||||
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
||||
> id sem consectetuer libero luctus adipiscing.
|
||||
|
||||
Markdown allows you to be lazy and only put the `>` before the first
|
||||
line of a hard-wrapped paragraph:
|
||||
|
||||
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
||||
> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
||||
> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
||||
|
||||
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
||||
> id sem consectetuer libero luctus adipiscing.
|
||||
|
||||
Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
|
||||
adding additional levels of `>`:
|
||||
|
||||
> This is the first level of quoting.
|
||||
>
|
||||
> > This is nested blockquote.
|
||||
>
|
||||
> Back to the first level.
|
||||
|
||||
Blockquotes can contain other Markdown elements, including headers, lists,
|
||||
and code blocks:
|
||||
|
||||
> ## This is a header.
|
||||
>
|
||||
> 1. This is the first list item.
|
||||
> 2. This is the second list item.
|
||||
>
|
||||
> Here's some example code:
|
||||
>
|
||||
> return shell_exec("echo $input | $markdown_script");
|
||||
|
||||
Any decent text editor should make email-style quoting easy. For
|
||||
example, with BBEdit, you can make a selection and choose Increase
|
||||
Quote Level from the Text menu.
|
||||
|
||||
### Lists
|
||||
|
||||
Markdown supports ordered (numbered) and unordered (bulleted) lists.
|
||||
|
||||
Unordered lists use asterisks, pluses, and hyphens -- interchangably
|
||||
-- as list markers:
|
||||
|
||||
- Red
|
||||
- Green
|
||||
- Blue
|
||||
|
||||
is equivalent to:
|
||||
|
||||
- Red
|
||||
- Green
|
||||
- Blue
|
||||
|
||||
and:
|
||||
|
||||
- Red
|
||||
- Green
|
||||
- Blue
|
||||
|
||||
Ordered lists use numbers followed by periods:
|
||||
|
||||
1. Bird
|
||||
2. McHale
|
||||
3. Parish
|
||||
|
||||
It's important to note that the actual numbers you use to mark the
|
||||
list have no effect on the HTML output Markdown produces. The HTML
|
||||
Markdown produces from the above list is:
|
||||
|
||||
If you instead wrote the list in Markdown like this:
|
||||
|
||||
1. Bird
|
||||
1. McHale
|
||||
1. Parish
|
||||
|
||||
or even:
|
||||
|
||||
3. Bird
|
||||
1. McHale
|
||||
1. Parish
|
||||
|
||||
you'd get the exact same HTML output. The point is, if you want to,
|
||||
you can use ordinal numbers in your ordered Markdown lists, so that
|
||||
the numbers in your source match the numbers in your published HTML.
|
||||
But if you want to be lazy, you don't have to.
|
||||
|
||||
To make lists look nice, you can wrap items with hanging indents:
|
||||
|
||||
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
||||
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
||||
viverra nec, fringilla in, laoreet vitae, risus.
|
||||
- Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
||||
Suspendisse id sem consectetuer libero luctus adipiscing.
|
||||
|
||||
But if you want to be lazy, you don't have to:
|
||||
|
||||
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
||||
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
||||
viverra nec, fringilla in, laoreet vitae, risus.
|
||||
- Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
||||
Suspendisse id sem consectetuer libero luctus adipiscing.
|
||||
|
||||
List items may consist of multiple paragraphs. Each subsequent
|
||||
paragraph in a list item must be indented by either 4 spaces
|
||||
or one tab:
|
||||
|
||||
1. This is a list item with two paragraphs. Lorem ipsum dolor
|
||||
sit amet, consectetuer adipiscing elit. Aliquam hendrerit
|
||||
mi posuere lectus.
|
||||
|
||||
Vestibulum enim wisi, viverra nec, fringilla in, laoreet
|
||||
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
|
||||
sit amet velit.
|
||||
|
||||
2. Suspendisse id sem consectetuer libero luctus adipiscing.
|
||||
|
||||
It looks nice if you indent every line of the subsequent
|
||||
paragraphs, but here again, Markdown will allow you to be
|
||||
lazy:
|
||||
|
||||
- This is a list item with two paragraphs.
|
||||
|
||||
This is the second paragraph in the list item. You're
|
||||
|
||||
only required to indent the first line. Lorem ipsum dolor
|
||||
sit amet, consectetuer adipiscing elit.
|
||||
|
||||
- Another item in the same list.
|
||||
|
||||
To put a blockquote within a list item, the blockquote's `>`
|
||||
delimiters need to be indented:
|
||||
|
||||
- A list item with a blockquote:
|
||||
|
||||
> This is a blockquote
|
||||
> inside a list item.
|
||||
|
||||
To put a code block within a list item, the code block needs
|
||||
to be indented _twice_ -- 8 spaces or two tabs:
|
||||
|
||||
- A list item with a code block:
|
||||
|
||||
<code goes here>
|
||||
|
||||
### Code Blocks
|
||||
|
||||
Pre-formatted code blocks are used for writing about programming or
|
||||
markup source code. Rather than forming normal paragraphs, the lines
|
||||
of a code block are interpreted literally. Markdown wraps a code block
|
||||
in both `<pre>` and `<code>` tags.
|
||||
|
||||
To produce a code block in Markdown, simply indent every line of the
|
||||
block by at least 4 spaces or 1 tab.
|
||||
|
||||
This is a normal paragraph:
|
||||
|
||||
This is a code block.
|
||||
|
||||
Here is an example of AppleScript:
|
||||
|
||||
tell application "Foo"
|
||||
beep
|
||||
end tell
|
||||
|
||||
A code block continues until it reaches a line that is not indented
|
||||
(or the end of the article).
|
||||
|
||||
Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
|
||||
are automatically converted into HTML entities. This makes it very
|
||||
easy to include example HTML source code using Markdown -- just paste
|
||||
it and indent it, and Markdown will handle the hassle of encoding the
|
||||
ampersands and angle brackets. For example, this:
|
||||
|
||||
```html
|
||||
<div class="footer">© 2004 Foo Corporation</div>
|
||||
```
|
||||
|
||||
Regular Markdown syntax is not processed within code blocks. E.g.,
|
||||
asterisks are just literal asterisks within a code block. This means
|
||||
it's also easy to use Markdown to write about Markdown's own syntax.
|
||||
|
||||
```
|
||||
tell application "Foo"
|
||||
beep
|
||||
end tell
|
||||
```
|
||||
|
||||
## Span Elements
|
||||
|
||||
### Links
|
||||
|
||||
Markdown supports two style of links: _inline_ and _reference_.
|
||||
|
||||
In both styles, the link text is delimited by [square brackets].
|
||||
|
||||
To create an inline link, use a set of regular parentheses immediately
|
||||
after the link text's closing square bracket. Inside the parentheses,
|
||||
put the URL where you want the link to point, along with an _optional_
|
||||
title for the link, surrounded in quotes. For example:
|
||||
|
||||
This is [an example](http://example.com/) inline link.
|
||||
|
||||
[This link](http://example.net/) has no title attribute.
|
||||
|
||||
### Emphasis
|
||||
|
||||
Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
|
||||
emphasis. Text wrapped with one `*` or `_` will be wrapped with an
|
||||
HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
|
||||
`<strong>` tag. E.g., this input:
|
||||
|
||||
_single asterisks_
|
||||
|
||||
_single underscores_
|
||||
|
||||
**double asterisks**
|
||||
|
||||
**double underscores**
|
||||
|
||||
### Code
|
||||
|
||||
To indicate a span of code, wrap it with backtick quotes (`` ` ``).
|
||||
Unlike a pre-formatted code block, a code span indicates code within a
|
||||
normal paragraph. For example:
|
||||
|
||||
Use the `printf()` function.
|
||||
# menu
|
||||
|
@ -45,4 +45,4 @@ web.whenReady([sidebarSelector]).then(async () => {
|
||||
setTheme();
|
||||
document.querySelector(sidebarSelector).appendChild($enhancerSidebarElement);
|
||||
});
|
||||
web.hotkeyListener(['Ctrl', 'Alt', 'E'], env.openEnhancerMenu);
|
||||
web.hotkeyListener(await storage.get(_id, 'hotkey.focustoggle'), env.openEnhancerMenu);
|
||||
|
@ -9,6 +9,8 @@
|
||||
word-break: break-word;
|
||||
text-size-adjust: 100%;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
font-size: inherit;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
html {
|
||||
@ -38,7 +40,7 @@ header {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
header > * {
|
||||
margin: 0 1.25rem 0 0;
|
||||
margin: 0 1.25rem 0.1em 0;
|
||||
font-size: var(--theme--font_heading1-size);
|
||||
}
|
||||
header h1 a:not([data-view-active]) {
|
||||
@ -138,6 +140,8 @@ main article img {
|
||||
.library--expand {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.53em;
|
||||
}
|
||||
.library--expand a {
|
||||
margin-left: auto;
|
||||
@ -149,6 +153,26 @@ main article img {
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
}
|
||||
.documentation--buttons .documentation--reload {
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
padding: 0.35rem 0.45rem;
|
||||
background: var(--theme--block_grey);
|
||||
color: var(--theme--block_grey-text);
|
||||
border: none;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transition: opacity 200ms ease-in-out;
|
||||
}
|
||||
.documentation--buttons .documentation--reload[data-triggered] {
|
||||
pointer-events: all;
|
||||
opacity: 1;
|
||||
}
|
||||
.documentation--buttons .documentation--reload[data-triggered]:hover {
|
||||
background: none;
|
||||
color: var(--theme--block_grey-text);
|
||||
box-shadow: var(--theme--block_grey) 0px 0px 0px 1px inset;
|
||||
}
|
||||
.documentation--buttons span,
|
||||
.library--expand span {
|
||||
color: var(--theme--text_property);
|
||||
|
@ -19,7 +19,7 @@ for (let mod of await registry.get()) {
|
||||
document
|
||||
.querySelector('img[data-view-target="notion"]')
|
||||
.addEventListener('click', env.focusNotion);
|
||||
web.hotkeyListener(['Ctrl', 'Alt', 'E'], env.focusNotion);
|
||||
web.hotkeyListener(await storage.get(_id, 'hotkey.focustoggle'), env.focusNotion);
|
||||
|
||||
const hovertip = {
|
||||
$el: document.querySelector('.tooltip'),
|
||||
@ -47,11 +47,13 @@ const hovertip = {
|
||||
const components = {};
|
||||
components.card = {
|
||||
preview: ({ preview = '' }) =>
|
||||
web.createElement(web.html`<img
|
||||
preview
|
||||
? web.createElement(web.html`<img
|
||||
alt=""
|
||||
class="library--preview"
|
||||
src="${web.escapeHtml(preview)}"
|
||||
/>`),
|
||||
/>`)
|
||||
: '',
|
||||
async name({ name, id, version }) {
|
||||
if (registry.CORE.includes(id))
|
||||
return web.createElement(web.html`<div class="library--title"><h2>
|
||||
@ -60,7 +62,7 @@ components.card = {
|
||||
<span class="library--version">v${web.escapeHtml(version)}</span>
|
||||
</span>
|
||||
</h2></div>`);
|
||||
const $name = web.createElement(web.html`<label
|
||||
const $el = web.createElement(web.html`<label
|
||||
for="enable--${web.escapeHtml(id)}"
|
||||
class="library--title library--toggle_label"
|
||||
>
|
||||
@ -74,10 +76,10 @@ components.card = {
|
||||
<span class="library--toggle"></span>
|
||||
</h2>
|
||||
</label>`);
|
||||
$name.addEventListener('change', async (event) =>
|
||||
$el.addEventListener('change', async (event) =>
|
||||
storage.set('_enabled', id, !(await storage.get('_enabled', id, false)))
|
||||
);
|
||||
return $name;
|
||||
return $el;
|
||||
},
|
||||
tags: ({ tags = [] }) =>
|
||||
web.createElement(web.html`<ul class="library--tags">
|
||||
@ -181,7 +183,10 @@ components.options = {
|
||||
</label>`);
|
||||
opt.querySelector('textarea').addEventListener('input', (event) => {
|
||||
event.target.style.removeProperty('--txt--scroll-height');
|
||||
event.target.style.setProperty('--txt--scroll-height', event.target.scrollHeight + 'px');
|
||||
event.target.style.setProperty(
|
||||
'--txt--scroll-height',
|
||||
event.target.scrollHeight + 1 + 'px'
|
||||
);
|
||||
});
|
||||
opt.addEventListener('change', (event) => storage.set(id, key, event.target.value));
|
||||
hovertip.add(opt, '[data-tooltip]', tooltip);
|
||||
@ -259,8 +264,9 @@ components.options = {
|
||||
},
|
||||
};
|
||||
components.documentation = {
|
||||
buttons: async ({ _dir }) =>
|
||||
web.createElement(web.html`<p class="documentation--buttons">
|
||||
_reloadTriggered: false,
|
||||
buttons({ _dir }) {
|
||||
const $el = web.createElement(web.html`<p class="documentation--buttons">
|
||||
<a href="?view=library">
|
||||
<span><i data-icon="fa/long-arrow-alt-left"></i></span>
|
||||
<span>back to library</span>
|
||||
@ -273,7 +279,21 @@ components.documentation = {
|
||||
<span><i data-icon="fa/code"></i></span>
|
||||
<span>view source code</span>
|
||||
</a>
|
||||
</p>`),
|
||||
<button class="documentation--reload"${this._reloadTriggered ? ' data-triggered' : ''}>
|
||||
<span><i data-icon="fa/redo"></i></span>
|
||||
<span>reload tabs to apply changes</span>
|
||||
</button>
|
||||
</p>`);
|
||||
storage.onChange(() => {
|
||||
const $reload = $el.querySelector('.documentation--reload');
|
||||
if (document.body.contains($el) && !$reload.dataset.triggered) {
|
||||
$reload.dataset.triggered = true;
|
||||
this._reloadTriggered = true;
|
||||
}
|
||||
});
|
||||
$el.querySelector('.documentation--reload').addEventListener('click', env.reloadTabs);
|
||||
return $el;
|
||||
},
|
||||
readme: async (mod) => {
|
||||
const readme = web.createElement(web.html`<article class="documentation--body markdown">
|
||||
${
|
||||
@ -386,7 +406,7 @@ const views = {
|
||||
async mod(mod) {
|
||||
document.body.dataset.view = 'mod';
|
||||
document.querySelector('header [data-view-target="library"]').dataset.active = true;
|
||||
this.$container.append(await components.documentation.buttons(mod));
|
||||
this.$container.append(components.documentation.buttons(mod));
|
||||
this.$container.append(await components.options._generate(mod));
|
||||
this.$container.append(await components.documentation.readme(mod));
|
||||
},
|
||||
|
@ -2,8 +2,7 @@
|
||||
"name": "menu",
|
||||
"id": "a6621988-551d-495a-97d8-3c568bca2e9e",
|
||||
"version": "0.11.0",
|
||||
"description": "the enhancer's [graphical](https://github.com) menu, related buttons and shortcuts.",
|
||||
"preview": "https://raw.githubusercontent.com/notion-enhancer/notion-enhancer/dev/notion-enhancer%20v0.10.0%20banner.jpg",
|
||||
"description": "the enhancer's graphical menu, related buttons and shortcuts.",
|
||||
"tags": ["core"],
|
||||
"authors": [
|
||||
{
|
||||
@ -23,38 +22,17 @@
|
||||
"options": [
|
||||
{
|
||||
"type": "toggle",
|
||||
"key": "toggle",
|
||||
"label": "toggle",
|
||||
"key": "themes.autoresolve",
|
||||
"label": "auto-resolve theme conflicts",
|
||||
"value": true,
|
||||
"tooltip": "a toggle"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"key": "select",
|
||||
"label": "select",
|
||||
"values": ["option a", "option b", "option c"],
|
||||
"tooltip": "a select"
|
||||
"tooltip": "when a theme is enabled any other themes of the same mode (light/dark) will be disabled"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "text",
|
||||
"label": "text",
|
||||
"value": "default",
|
||||
"tooltip": "a text input"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"key": "number",
|
||||
"label": "number",
|
||||
"value": 0,
|
||||
"tooltip": "a number input"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"key": "file",
|
||||
"label": "file picker (.css only)",
|
||||
"extensions": [".css"],
|
||||
"tooltip": "a file picker"
|
||||
"key": "hotkey.focustoggle",
|
||||
"label": "toggle hotkey",
|
||||
"value": "Ctrl+Alt+E",
|
||||
"tooltip": "toggles focus between notion & the enhancer menu"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -30,6 +30,19 @@ function focusNotion() {
|
||||
);
|
||||
}
|
||||
|
||||
function reloadTabs() {
|
||||
chrome.tabs.query({ url: 'https://*.notion.so/*' }, (tabs) => {
|
||||
(tabs || []).forEach((tab) => chrome.tabs.reload(tab.id));
|
||||
});
|
||||
chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT }, (tabs) => {
|
||||
const enhancerMenuURL = chrome.runtime.getURL(
|
||||
'repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.html'
|
||||
),
|
||||
enhancerMenuTabs = (tabs || []).filter((tab) => tab.url.startsWith(enhancerMenuURL));
|
||||
enhancerMenuTabs.forEach((tab) => chrome.tabs.reload(tab.id));
|
||||
});
|
||||
}
|
||||
|
||||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
switch (request.action) {
|
||||
case 'openEnhancerMenu':
|
||||
@ -38,6 +51,9 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
case 'focusNotion':
|
||||
focusNotion();
|
||||
break;
|
||||
case 'reloadTabs':
|
||||
reloadTabs();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user