Skip to content

Commit

Permalink
refactor(portable-text-editor): rename prop
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin committed Sep 8, 2021
1 parent 25585b9 commit 97ba516
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/@sanity/portable-text-editor/src/editor/Editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const PortableTextEditable = (props: Props) => {
const {
change$,
isThrottling,
incomingPatche$,
incomingPatches$,
keyGenerator,
maxBlocks,
portableTextFeatures,
Expand Down Expand Up @@ -123,7 +123,7 @@ export const PortableTextEditable = (props: Props) => {
keyGenerator,
change$,
maxBlocks,
incomingPatche$,
incomingPatches$,
readOnly,
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Props = {
keyGenerator?: () => string
maxBlocks?: number | string
onChange: (change: EditorChange) => void
incomingPatche$?: PatchObservable
incomingPatches$?: PatchObservable
readOnly?: boolean
selection?: EditorSelection
type: Type | RawSchemaType
Expand Down Expand Up @@ -152,7 +152,7 @@ export class PortableTextEditor extends React.Component<Props, State> {
public keyGenerator: () => string
public maxBlocks: number | undefined
public readOnly: boolean
public incomingPatche$?: PatchObservable
public incomingPatches$?: PatchObservable

constructor(props: Props) {
super(props)
Expand Down Expand Up @@ -184,7 +184,7 @@ export class PortableTextEditor extends React.Component<Props, State> {
})
state = {...state, invalidValueResolution: validation.resolution}
}
this.incomingPatche$ = props.incomingPatche$
this.incomingPatches$ = props.incomingPatches$
this.maxBlocks =
typeof props.maxBlocks === 'undefined'
? undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function createWithPatches(
}: PatchFunctions,
change$: Subject<EditorChange>,
portableTextFeatures: PortableTextFeatures,
incomingPatche$?: PatchObservable
incomingPatches$?: PatchObservable
): (editor: PortableTextSlateEditor) => PortableTextSlateEditor {
const patchToOperations = createPatchToOperations(portableTextFeatures)
let previousChildren: (Node | Partial<Node>)[]
Expand All @@ -70,8 +70,8 @@ export function createWithPatches(
}, THROTTLE_EDITOR_MS)

// Inspect incoming patches and adjust editor selection accordingly.
if (incomingPatche$) {
incomingPatche$.subscribe((patch: Patch) => {
if (incomingPatches$) {
incomingPatches$.subscribe((patch: Patch) => {
previousChildren = editor.children
debug('Handling incoming patch', patch.type)
if (isThrottling) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const isSaving = (editor: Editor): boolean | undefined => {
return SAVING.get(editor)
}

export function createWithUndoRedo(incomingPatche$?: PatchObservable) {
export function createWithUndoRedo(incomingPatches$?: PatchObservable) {
// Subscribe to incoming patches
const incomingPatches: {patch: Patch; time: Date}[] = []
if (incomingPatche$) {
incomingPatche$.subscribe((patch) => {
if (incomingPatches$) {
incomingPatches$.subscribe((patch) => {
incomingPatches.push({patch: patch, time: new Date()})
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ export const withPortableText = <T extends Editor>(
keyGenerator,
change$,
maxBlocks,
incomingPatche$,
incomingPatches$,
readOnly,
} = options
const operationToPatches = createOperationToPatches(portableTextFeatures)
const withObjectKeys = createWithObjectKeys(portableTextFeatures, keyGenerator)
const withScemaTypes = createWithSchemaTypes(portableTextFeatures)
const withPatches = readOnly
? disablePlugin('withPatches')
: createWithPatches(operationToPatches, change$, portableTextFeatures, incomingPatche$)
: createWithPatches(operationToPatches, change$, portableTextFeatures, incomingPatches$)

const withMaxBlocks =
maxBlocks && maxBlocks > 0 ? createWithMaxBlocks(maxBlocks) : disablePlugin('withMaxBlocks')
const withPortableTextLists = createWithPortableTextLists(portableTextFeatures, change$)
const withUndoRedo = readOnly
? disablePlugin('withUndoRedo')
: createWithUndoRedo(incomingPatche$)
: createWithUndoRedo(incomingPatches$)
const withPortableTextMarkModel = createWithPortableTextMarkModel(
portableTextFeatures,
keyGenerator,
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/portable-text-editor/src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type createEditorOptions = {
change$: Subject<EditorChange>
maxBlocks?: number
hotkeys?: HotkeyOptions
incomingPatche$?: PatchObservable
incomingPatches$?: PatchObservable
readOnly: boolean
}

Expand Down

0 comments on commit 97ba516

Please sign in to comment.