generated from mirrors/plugin-sample-vite-svelte
Cleanup
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 1m5s
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 1m5s
This commit is contained in:
parent
dce511ae97
commit
d2ae1f3fe7
2 changed files with 27 additions and 26 deletions
26
src/index.ts
26
src/index.ts
|
|
@ -1,6 +1,6 @@
|
||||||
import {IProtyle, Plugin, showMessage} from 'siyuan';
|
import {IProtyle, Plugin, showMessage} from 'siyuan';
|
||||||
import {ProtyleHelper} from "@/protyleHelper";
|
import {ProtyleHelper} from "@/protyleHelper";
|
||||||
import {Icons} from "@/icons";
|
import {Style} from "@/style";
|
||||||
import {Settings} from "@/settings";
|
import {Settings} from "@/settings";
|
||||||
import {SettingUtils} from "@/libs/setting-utils";
|
import {SettingUtils} from "@/libs/setting-utils";
|
||||||
import {Analytics} from "@/analytics";
|
import {Analytics} from "@/analytics";
|
||||||
|
|
@ -31,38 +31,16 @@ export default class SpellCheckPlugin extends Plugin {
|
||||||
async onload() {
|
async onload() {
|
||||||
|
|
||||||
this.i18nx = this.i18n
|
this.i18nx = this.i18n
|
||||||
new Icons(this);
|
new Style(this);
|
||||||
|
|
||||||
this.settingsUtil = await Settings.init(this)
|
this.settingsUtil = await Settings.init(this)
|
||||||
this.analytics = new Analytics(this.settingsUtil.get('analytics'));
|
this.analytics = new Analytics(this.settingsUtil.get('analytics'));
|
||||||
this.suggestions = new SuggestionEngine(this)
|
this.suggestions = new SuggestionEngine(this)
|
||||||
this.menus = new Menus(this)
|
this.menus = new Menus(this)
|
||||||
|
|
||||||
await this.prepareSpellCheckers()
|
await this.prepareSpellCheckers()
|
||||||
|
|
||||||
void this.analytics.sendEvent('load')
|
void this.analytics.sendEvent('load')
|
||||||
|
|
||||||
const style = document.createElement('style');
|
|
||||||
style.innerHTML = `
|
|
||||||
.underline-overlay {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
|
||||||
.error-underline {
|
|
||||||
position: absolute;
|
|
||||||
height: 2px;
|
|
||||||
background-image:
|
|
||||||
radial-gradient(circle at 2px 1px, #ff4444 1px, transparent 1px),
|
|
||||||
radial-gradient(circle at 6px 1px, #ff4444 1px, transparent 1px);
|
|
||||||
background-size: 8px 2px;
|
|
||||||
background-repeat: repeat-x;
|
|
||||||
background-position: 0 bottom;
|
|
||||||
}`
|
|
||||||
window.document.head.appendChild(style);
|
|
||||||
|
|
||||||
if (window.siyuan.config.editor.spellcheck) {
|
if (window.siyuan.config.editor.spellcheck) {
|
||||||
showMessage(this.i18nx.errors.builtInEnabled, -1, 'error')
|
showMessage(this.i18nx.errors.builtInEnabled, -1, 'error')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import {Plugin} from 'siyuan';
|
import {Plugin} from 'siyuan';
|
||||||
|
|
||||||
export class Icons {
|
export class Style {
|
||||||
|
|
||||||
constructor(p: Plugin) {
|
constructor(p: Plugin) {
|
||||||
this.icons.forEach(icon =>
|
this.icons.forEach(icon =>
|
||||||
p.addIcons(icon)
|
p.addIcons(icon)
|
||||||
)
|
)
|
||||||
|
this.applyStyle()
|
||||||
}
|
}
|
||||||
|
|
||||||
private icons = [
|
private icons = [
|
||||||
|
|
@ -40,4 +40,27 @@ export class Icons {
|
||||||
</symbol>`
|
</symbol>`
|
||||||
]
|
]
|
||||||
|
|
||||||
|
private applyStyle() {
|
||||||
|
const style = document.createElement('style');
|
||||||
|
style.innerHTML = `
|
||||||
|
.underline-overlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
.error-underline {
|
||||||
|
position: absolute;
|
||||||
|
height: 2px;
|
||||||
|
background-image:
|
||||||
|
radial-gradient(circle at 2px 1px, #ff4444 1px, transparent 1px),
|
||||||
|
radial-gradient(circle at 6px 1px, #ff4444 1px, transparent 1px);
|
||||||
|
background-size: 8px 2px;
|
||||||
|
background-repeat: repeat-x;
|
||||||
|
background-position: 0 bottom;
|
||||||
|
}`
|
||||||
|
window.document.head.appendChild(style);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue