How to use the @edtr-io/core.StateType.number function in @edtr-io/core

To help you get started, we’ve selected a few @edtr-io/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github edtr-io / edtr-io / packages / demo / __stories__ / index.tsx View on Github external
paramName: 'attachment[file]',
  maxFileSize: 2 * 1024 * 1024,
  allowedExtensions: ['gif', 'jpg', 'jpeg', 'png', 'svg'],
  getAdditionalFields: () => {
    return {
      type: 'file',
      csrf: ((window as unknown) as { csrf: string }).csrf
    }
  },
  getStateFromResponse: response => {
    return {
      src: response.files[0].location
    }
  }
}
const counterState = StateType.number(0)

const counterPlugin: StatefulPlugin = {
  // eslint-disable-next-line react/display-name
  Component: ({ editable, focused, state }) => {
    return (
      <div style="{{">
        {state.value}
        {editable &amp;&amp; (
          <button> {
              state.set(value =&gt; value + 1)
            }}</button></div>
github edtr-io / edtr-io / packages / plugin-image / src / index.ts View on Github external
import { StatefulPlugin, StateType } from '@edtr-io/core'

import { createImageEditor } from './editor'
import { UploadConfig } from './upload'

export const imageState = StateType.object({
  src: StateType.string(''),
  href: StateType.string(''),
  target: StateType.string(''),
  rel: StateType.string(''),
  description: StateType.string(''),
  maxWidth: StateType.number(0)
})
export const createImagePlugin = (
  config: ImagePluginConfig
): StatefulPlugin =&gt; {
  return {
    Component: createImageEditor(config),
    state: imageState,
    onPaste: (clipboardData: DataTransfer) =&gt; {
      const value = clipboardData.getData('text')

      if (/\.(jpe?g|png|bmp|gif|svg)$/.test(value)) {
        return {
          state: {
            src: value,
            href: '',
            target: '',