mirror of
https://github.com/gra0007/obsidian-css-inlay-colors.git
synced 2026-07-22 05:18:59 +00:00
Use the editorLivePreviewField state field
This commit is contained in:
parent
f115da2d6d
commit
f6ce7a3430
2 changed files with 7 additions and 2 deletions
5
.changes/state-field.md
Normal file
5
.changes/state-field.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"obsidian-css-inlay-colors": patch:fix
|
||||
---
|
||||
|
||||
Use the provided Obsidian state field to determine if the editor is in live preview mode
|
||||
|
|
@ -10,6 +10,7 @@ import {
|
|||
} from '@codemirror/view'
|
||||
import type { NodeProp } from '@lezer/common'
|
||||
import { type Color, formatHex, parse } from 'culori'
|
||||
import { editorLivePreviewField } from 'obsidian'
|
||||
import { formatColor } from './formatColor'
|
||||
|
||||
export const inlayExtension = (colorPickerEnabled: boolean) => {
|
||||
|
|
@ -92,8 +93,7 @@ class CSSColorInlayWidget extends WidgetType {
|
|||
|
||||
const createColorWidgets = (view: EditorView, colorPickerEnabled: boolean) => {
|
||||
// Only create widgets in live preview mode
|
||||
if (!view.dom.parentElement?.classList.contains('is-live-preview'))
|
||||
return Decoration.none
|
||||
if (!view.state.field(editorLivePreviewField)) return Decoration.none
|
||||
|
||||
const widgets: Range<Decoration>[] = []
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue