Skip to content

Commit

Permalink
chore: remove Obsidian word
Browse files Browse the repository at this point in the history
  • Loading branch information
imfenghuang committed Jul 16, 2024
1 parent 1ac75bc commit a57f7f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type { Settings } from './config'
type EmptyObject = Record<string, unknown>
// type CacheMap = Map<string, string[]>;

type ObsidianMagicMoveType = {
type MagicMoveType = {
// $cache: CacheMap;
$vue: {
createApp: typeof createApp
Expand Down Expand Up @@ -62,7 +62,7 @@ type ObsidianMagicMoveType = {

declare global {
interface Window {
ObsidianMagicMove?: ObsidianMagicMoveType
MagicMove?: MagicMoveType
}
}

Expand All @@ -71,7 +71,7 @@ interface HTMLElementExtend extends HTMLElement {
$insertCallback?: () => void
}

export default class ObsidianMagicMovePlugin extends Plugin {
export default class MagicMovePlugin extends Plugin {
settings: Ref<Settings>
settingTab: SettingTab
$t: LocaleType
Expand Down Expand Up @@ -126,15 +126,15 @@ export default class ObsidianMagicMovePlugin extends Plugin {

codeElm.classList.add(queryClass)

window?.ObsidianMagicMove?.$observerIns?.observe?.(codeElm)
window?.MagicMove?.$observerIns?.observe?.(codeElm)

codeElm['$insertCallback'] = () => {
if (codeElm.classList.contains('is-scripted')) {
return
}

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
window!.ObsidianMagicMove!.$codeElements[queryClass] = codeElm
window!.MagicMove!.$codeElements[queryClass] = codeElm

const textContent = this.makeTextContent(
queryClass,
Expand All @@ -152,7 +152,7 @@ export default class ObsidianMagicMovePlugin extends Plugin {
script.classList.add(queryScriptClass)
script.textContent = textContent

window?.ObsidianMagicMove?.$observerIns?.unobserve?.(codeElm)
window?.MagicMove?.$observerIns?.unobserve?.(codeElm)
codeElm.classList.add('is-scripted')
}
}
Expand All @@ -170,7 +170,7 @@ export default class ObsidianMagicMovePlugin extends Plugin {

makeTextContent(queryClass: string, mountClass: string, tempClass: string) {
return `
const $omm = window.ObsidianMagicMove
const $omm = window.MagicMove
const $app = $omm.$app
const el = $omm.$codeElements['${queryClass}']
Expand Down Expand Up @@ -320,9 +320,9 @@ $omm?.$observerIns?.observe(div)

this.scriptWrap.remove()

window?.ObsidianMagicMove?.$observerIns?.disconnect?.()
window?.ObsidianMagicMove?.$highlighterSetting?.$highlighter?.dispose?.()
delete window['ObsidianMagicMove']
window?.MagicMove?.$observerIns?.disconnect?.()
window?.MagicMove?.$highlighterSetting?.$highlighter?.dispose?.()
delete window['MagicMove']

console.log('unload Magic Move plugin')
}
Expand All @@ -345,7 +345,7 @@ $omm?.$observerIns?.observe(div)
langs: Object.keys(bundledLanguages),
})

window.ObsidianMagicMove = {
window.MagicMove = {
$app: this.app,
$codeElements: {},
$observerIns: null,
Expand Down Expand Up @@ -392,7 +392,7 @@ $omm?.$observerIns?.observe(div)

observer() {
;(
window?.ObsidianMagicMove?.$observerIns as IntersectionObserver
window?.MagicMove?.$observerIns as IntersectionObserver
)?.disconnect?.()

const options = {
Expand All @@ -415,7 +415,7 @@ $omm?.$observerIns?.observe(div)
}

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
window!.ObsidianMagicMove!.$observerIns = new IntersectionObserver(
window!.MagicMove!.$observerIns = new IntersectionObserver(
callback,
options
)
Expand All @@ -430,7 +430,7 @@ $omm?.$observerIns?.observe(div)
Object.assign({}, defaultSettings, await this.loadData())
)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
window!.ObsidianMagicMove!.$setting = this.settings
window!.MagicMove!.$setting = this.settings
}

async saveSettings() {
Expand Down
4 changes: 2 additions & 2 deletions src/setting.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App, PluginSettingTab, Component, Setting } from 'obsidian'
import { defaultThemes } from './config'
import ObsidianMagicMovePlugin from './main'
import MagicMovePlugin from './main'
import { getLocal } from './locale'
import type { LocaleType } from './locale'

Expand All @@ -11,7 +11,7 @@ export class SettingTab extends PluginSettingTab {

constructor(
app: App,
public plugin: ObsidianMagicMovePlugin
public plugin: MagicMovePlugin
) {
super(app, plugin)
this.component = new Component()
Expand Down

0 comments on commit a57f7f3

Please sign in to comment.