Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tidbcloud/codemirror-extension-save-helper

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tidbcloud/codemirror-extension-save-helper

codemiror extension to help save editor content

  • 0.0.6
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@tidbcloud/codemirror-extension-save-helper

A codemirror extension listens the editor doc changes, if changes, it will call the save handler in delay time, or, you can press the defined hotkey (default is Mod-s) to call save handler immediately.

Try it

  • Full Featured Playground
  • Simple Example

Installation

npm install @tidbcloud/codemirror-extension-save-helper

You need to install its peer dependencies as well:

npm install @codemirror/view @codemirror/state

Usage

import { EditorView } from '@codemirror/view'
import { EditorState } from '@codemirror/state'
import { saveHelper } from '@tidbcloud/codemirror-extension-save-helper'

const editorView = new EditorView({
  state: EditorState.create({
    doc,
    extensions: [
      saveHelper({
        save: (view: EditorView) => {
          // call save file api
          saveFile(view.state.doc.toString())
        }
      })
    ]
  })
})

API

type SaveHelperOptions = {
  /* in milliseconds, default 5000 */
  delay?: number
  /* default is true */
  auto?: boolean
  /* default is Mod-s */
  hotkey?: string
  /* save handler */
  save: (view: EditorView) => void
}

function saveHelper(options: SaveHelperOptions): Extension

Keywords

FAQs

Package last updated on 09 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc