@codemirror-toolkit/react
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -5,3 +5,3 @@ import type { ReactNode } from 'react'; | ||
config?: ProvidedCodeMirrorConfig; | ||
children: ReactNode; | ||
children?: ReactNode; | ||
} | ||
@@ -8,0 +8,0 @@ export interface CodeMirrorProvider { |
@@ -13,14 +13,4 @@ import { useDebugValue, useEffect, useCallback, useRef, createContext, createElement, useContext } from "react"; | ||
return { | ||
request: (callback) => { | ||
cancelTask = runTask(() => { | ||
cancelTask = null; | ||
callback(); | ||
}); | ||
}, | ||
cancel: () => { | ||
if (cancelTask) { | ||
cancelTask(); | ||
cancelTask = null; | ||
} | ||
} | ||
request: (callback) => cancelTask = runTask(callback), | ||
cancel: () => cancelTask == null ? void 0 : cancelTask() | ||
}; | ||
@@ -124,7 +114,7 @@ } | ||
function toPascalCase(str) { | ||
return str.split(/[-_]/).map((word) => word[0].toUpperCase() + word.slice(1)).join(""); | ||
return str.split(/[-_]/).map((word) => word && word[0].toUpperCase() + word.slice(1)).join(""); | ||
} | ||
function useSingleton(instance) { | ||
const instanceRef = useRef(null); | ||
if (instanceRef.current === null) { | ||
if (instanceRef.current == null) { | ||
instanceRef.current = isFunction(instance) ? instance() : instance; | ||
@@ -131,0 +121,0 @@ } |
{ | ||
"name": "@codemirror-toolkit/react", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A small and flexible solution for binding CodeMirror 6 to React", | ||
@@ -68,5 +68,5 @@ "type": "module", | ||
"@codemirror/state": "^6.2.1", | ||
"@codemirror/view": "^6.15.0", | ||
"@codemirror/view": "^6.15.3", | ||
"@testing-library/react": "^14.0.0", | ||
"@types/react": "^18.2.15", | ||
"@types/react": "^18.2.17", | ||
"@types/react-dom": "^18.2.7", | ||
@@ -73,0 +73,0 @@ "@types/use-sync-external-store": "^0.0.3", |
@@ -19,3 +19,3 @@ import type { ReactNode } from 'react' | ||
config?: ProvidedCodeMirrorConfig | ||
children: ReactNode | ||
children?: ReactNode | ||
} | ||
@@ -22,0 +22,0 @@ |
@@ -15,17 +15,7 @@ type CancelTask = () => void | ||
export function createAsyncScheduler(): AsyncScheduler { | ||
let cancelTask: CancelTask | undefined | null | ||
let cancelTask: CancelTask | undefined | ||
return { | ||
request: (callback) => { | ||
cancelTask = runTask(() => { | ||
cancelTask = null | ||
callback() | ||
}) | ||
}, | ||
cancel: () => { | ||
if (cancelTask) { | ||
cancelTask() | ||
cancelTask = null | ||
} | ||
}, | ||
request: (callback) => (cancelTask = runTask(callback)), | ||
cancel: () => cancelTask?.(), | ||
} | ||
} |
export function toPascalCase(str: string): string { | ||
return str | ||
.split(/[-_]/) | ||
.map((word) => word[0].toUpperCase() + word.slice(1)) | ||
.map((word) => word && word[0].toUpperCase() + word.slice(1)) | ||
.join('') | ||
} |
@@ -7,3 +7,3 @@ import { useRef } from 'react' | ||
const instanceRef = useRef<T | null>(null) | ||
if (instanceRef.current === null) { | ||
if (instanceRef.current == null) { | ||
// https://github.com/microsoft/TypeScript/issues/37663 | ||
@@ -10,0 +10,0 @@ instanceRef.current = isFunction(instance) ? instance() : instance |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
75942
1000