fix: circular dependencies (#1040)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
export const reloadFont = (monospaceFont?: boolean) => {
|
||||
const root = document.querySelector(':root') as HTMLElement
|
||||
const propertyName = '--sn-stylekit-editor-font-family'
|
||||
if (monospaceFont) {
|
||||
root.style.setProperty(propertyName, 'var(--sn-stylekit-monospace-font)')
|
||||
} else {
|
||||
root.style.setProperty(propertyName, 'var(--sn-stylekit-sans-serif-font)')
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,7 @@ import {
|
||||
SNNote,
|
||||
ComponentArea,
|
||||
PrefKey,
|
||||
ComponentMutator,
|
||||
ComponentViewer,
|
||||
TransactionalMutation,
|
||||
ItemMutator,
|
||||
ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction,
|
||||
NoteViewController,
|
||||
PayloadEmitSource,
|
||||
@@ -33,6 +30,11 @@ import { PanelSide, PanelResizer, PanelResizeType } from '@/Components/PanelResi
|
||||
import { ElementIds } from '@/ElementIDs'
|
||||
import { ChangeEditorButton } from '@/Components/ChangeEditor/ChangeEditorButton'
|
||||
import { AttachedFilesButton } from '@/Components/AttachedFilesPopover/AttachedFilesButton'
|
||||
import {
|
||||
transactionForAssociateComponentWithCurrentNote,
|
||||
transactionForDisassociateComponentWithCurrentNote,
|
||||
} from './TransactionFunctions'
|
||||
import { reloadFont } from './FontFunctions'
|
||||
|
||||
const MINIMUM_STATUS_DURATION = 400
|
||||
const TEXTAREA_DEBOUNCE = 100
|
||||
@@ -47,40 +49,6 @@ function sortAlphabetically(array: SNComponent[]): SNComponent[] {
|
||||
return array.sort((a, b) => (a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1))
|
||||
}
|
||||
|
||||
export const transactionForAssociateComponentWithCurrentNote = (component: SNComponent, note: SNNote) => {
|
||||
const transaction: TransactionalMutation = {
|
||||
itemUuid: component.uuid,
|
||||
mutate: (m: ItemMutator) => {
|
||||
const mutator = m as ComponentMutator
|
||||
mutator.removeDisassociatedItemId(note.uuid)
|
||||
mutator.associateWithItem(note.uuid)
|
||||
},
|
||||
}
|
||||
return transaction
|
||||
}
|
||||
|
||||
export const transactionForDisassociateComponentWithCurrentNote = (component: SNComponent, note: SNNote) => {
|
||||
const transaction: TransactionalMutation = {
|
||||
itemUuid: component.uuid,
|
||||
mutate: (m: ItemMutator) => {
|
||||
const mutator = m as ComponentMutator
|
||||
mutator.removeAssociatedItemId(note.uuid)
|
||||
mutator.disassociateWithItem(note.uuid)
|
||||
},
|
||||
}
|
||||
return transaction
|
||||
}
|
||||
|
||||
export const reloadFont = (monospaceFont?: boolean) => {
|
||||
const root = document.querySelector(':root') as HTMLElement
|
||||
const propertyName = '--sn-stylekit-editor-font-family'
|
||||
if (monospaceFont) {
|
||||
root.style.setProperty(propertyName, 'var(--sn-stylekit-monospace-font)')
|
||||
} else {
|
||||
root.style.setProperty(propertyName, 'var(--sn-stylekit-sans-serif-font)')
|
||||
}
|
||||
}
|
||||
|
||||
type State = {
|
||||
availableStackComponents: SNComponent[]
|
||||
editorComponentViewer?: ComponentViewer
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { SNComponent, SNNote, ComponentMutator, TransactionalMutation, ItemMutator } from '@standardnotes/snjs'
|
||||
|
||||
export const transactionForAssociateComponentWithCurrentNote = (component: SNComponent, note: SNNote) => {
|
||||
const transaction: TransactionalMutation = {
|
||||
itemUuid: component.uuid,
|
||||
mutate: (m: ItemMutator) => {
|
||||
const mutator = m as ComponentMutator
|
||||
mutator.removeDisassociatedItemId(note.uuid)
|
||||
mutator.associateWithItem(note.uuid)
|
||||
},
|
||||
}
|
||||
return transaction
|
||||
}
|
||||
|
||||
export const transactionForDisassociateComponentWithCurrentNote = (component: SNComponent, note: SNNote) => {
|
||||
const transaction: TransactionalMutation = {
|
||||
itemUuid: component.uuid,
|
||||
mutate: (m: ItemMutator) => {
|
||||
const mutator = m as ComponentMutator
|
||||
mutator.removeAssociatedItemId(note.uuid)
|
||||
mutator.disassociateWithItem(note.uuid)
|
||||
},
|
||||
}
|
||||
return transaction
|
||||
}
|
||||
Reference in New Issue
Block a user