Files
calculator/src/getTextPlugin.ts
2023-11-15 23:14:17 +03:00

11 lines
318 B
TypeScript

import { ViewPlugin, ViewUpdate } from '@codemirror/view'
export const getTextPlugin = (callback: (text: string) => void) =>
ViewPlugin.define(() => ({
update(update: ViewUpdate) {
if (update.docChanged) {
callback(update.state.doc.toString())
}
},
}))