-
appId:
-
-
${app?.appId}
-
-
-
API demo:
-
-
- System current time: {time}
-
-
-
-
Protyle demo: id = {blockID}
-
-
-
-
diff --git a/src/icons.ts b/src/icons.ts
new file mode 100644
index 0000000..2189f92
--- /dev/null
+++ b/src/icons.ts
@@ -0,0 +1,43 @@
+import {Plugin} from 'siyuan';
+
+export class Icons {
+
+ constructor(p: Plugin) {
+ this.icons.forEach(icon =>
+ p.addIcons(icon)
+ )
+
+ }
+
+ private icons = [
+ // info - https://fonts.google.com/icons?selected=Material+Symbols+Outlined:info
+ `
+
+ `,
+ // spell check - https://fonts.google.com/icons?selected=Material+Symbols+Outlined:spellcheck
+ `
+
+ `,
+ // language - https://fonts.google.com/icons?selected=Material+Symbols+Outlined:language_chinese_quick
+ `
+
+ `,
+ // toggle - https://fonts.google.com/icons?selected=Material+Symbols+Outlined:toggle_on
+ `
+
+ `,
+ // autodetect - https://fonts.google.com/icons?selected=Material+Symbols+Outlined:network_intelligence
+ `
+
+ `,
+ // error - https://fonts.google.com/icons?selected=Material+Symbols+Outlined
+ `
+
+ `,
+ // add - https://fonts.google.com/icons?selected=Material+Symbols+Outlined:add
+ `
+
+ `
+ ]
+
+}
\ No newline at end of file
diff --git a/src/index.scss b/src/index.scss
deleted file mode 100644
index e69de29..0000000
diff --git a/src/index.ts b/src/index.ts
index 614e0a4..7227a9b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,1011 +1,122 @@
-import {
- Plugin,
- showMessage,
- confirm,
- Dialog,
- Menu,
- openTab,
- adaptHotkey,
- getFrontend,
- getBackend,
- // Setting,
- // fetchPost,
- Protyle,
- openWindow,
- IOperation,
- Constants,
- openMobileFileById,
- lockScreen,
- ICard,
- ICardData,
- Custom,
- exitSiYuan,
- getModelByDockType,
- getAllEditor,
- Files,
- platformUtils,
- openSetting,
- openAttributePanel,
- saveLayout
-} from "siyuan";
-import "./index.scss";
-import { IMenuItem } from "siyuan/types";
-
-import HelloExample from "@/hello.svelte";
-import SettingExample from "@/setting-example.svelte";
-
-import { SettingUtils } from "./libs/setting-utils";
-import { svelteDialog } from "./libs/dialog";
-
-const STORAGE_NAME = "menu-config";
-const TAB_TYPE = "custom_tab";
-const DOCK_TYPE = "dock_tab";
-
-export default class PluginSample extends Plugin {
-
- private custom: () => Custom;
- private isMobile: boolean;
- private blockIconEventBindThis = this.blockIconEvent.bind(this);
- private settingUtils: SettingUtils;
+import {Plugin, showMessage} from 'siyuan';
+import {ProtyleHelpers} from "@/protyleHelpers";
+import {Icons} from "@/icons";
+import {Settings} from "@/settings";
+import {SettingUtils} from "@/libs/setting-utils";
+import {Analytics} from "@/analytics";
+import {SuggestionEngine} from "@/suggestions";
+import {Menus} from "@/menus";
- updateProtyleToolbar(toolbar: Array
) {
- toolbar.push("|");
- toolbar.push({
- name: "insert-smail-emoji",
- icon: "iconEmoji",
- hotkey: "⇧⌘I",
- tipPosition: "n",
- tip: this.i18n.insertEmoji,
- click(protyle: Protyle) {
- protyle.insert("😊");
- }
- });
- return toolbar;
- }
+export default class SpellCheckPlugin extends Plugin {
+
+ private menus: Menus
+
+ public settingsUtil: SettingUtils;
+ public suggestions: SuggestionEngine
+ public analytics: Analytics
+ public i18nx: any; // This object is just a copy of i18n, but with type "any" to not trigger type errors
+
+ public static ENABLED_ATTR = 'custom-spellcheck-enable'
+ public static LANGUAGE_ATTR = 'custom-spellcheck-language'
async onload() {
- this.data[STORAGE_NAME] = { readonlyText: "Readonly" };
- console.log("loading plugin-sample", this.i18n);
+ this.i18nx = this.i18n
+ new Icons(this);
+ this.settingsUtil = await Settings.init(this)
+ this.analytics = new Analytics(this.settingsUtil.get('analytics'));
+ this.suggestions = new SuggestionEngine(this)
+ this.menus = new Menus(this)
- const frontEnd = getFrontend();
- this.isMobile = frontEnd === "mobile" || frontEnd === "browser-mobile";
- // 图标的制作参见帮助文档
- this.addIcons(`
-
-
-
-
-`);
+ void this.analytics.sendEvent('load')
- let tabDiv = document.createElement("div");
- let app = null;
- this.custom = this.addTab({
- type: TAB_TYPE,
- init() {
- app = new HelloExample({
- target: tabDiv,
- props: {
- app: this.app,
- blockID: this.data.blockID
- }
- });
- this.element.appendChild(tabDiv);
- console.log(this.element);
- },
- beforeDestroy() {
- console.log("before destroy tab:", TAB_TYPE);
- },
- destroy() {
- app?.$destroy();
- console.log("destroy tab:", TAB_TYPE);
- }
- });
+ 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);
- this.addCommand({
- langKey: "showDialog",
- hotkey: "⇧⌘O",
- callback: () => {
- this.showDialog();
- },
- });
-
- this.addCommand({
- langKey: "getTab",
- hotkey: "⇧⌘M",
- globalCallback: () => {
- console.log(this.getOpenedTab());
- },
- });
-
- this.addDock({
- config: {
- position: "LeftBottom",
- size: { width: 200, height: 0 },
- icon: "iconSaving",
- title: "Custom Dock",
- hotkey: "⌥⌘W",
- },
- data: {
- text: "This is my custom dock"
- },
- type: DOCK_TYPE,
- resize() {
- console.log(DOCK_TYPE + " resize");
- },
- update() {
- console.log(DOCK_TYPE + " update");
- },
- init: (dock) => {
- if (this.isMobile) {
- dock.element.innerHTML = `
-
- ${dock.data.text}
-
- `;
- } else {
- dock.element.innerHTML = `