How to use @edtr-io/plugin - 10 common examples

To help you get started, we’ve selected a few @edtr-io/plugin 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 / plugins / text / src / index.ts View on Github external
}
export interface BlockRendererProps {
  node: BlockJSON
}
export type NodeRendererProps = BlockRendererProps | InlineRendererProps

export type TextPlugin = Plugin &
  Rule & {
    // FIXME: This type should exist in slate somewhere...
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    commands?: { [key: string]: (editor: Editor, ...args: any[]) => Editor }
  }

export { isValueEmpty } from './factory'

const textState = scalar(emptyDocument)
export type TextState = typeof textState
export interface TextConfig {
  placeholder: string
  plugins: ((pluginClosure: SlatePluginClosure) => TextPlugin)[]
  registry: {
    name: string
    title?: string
    description?: string
  }[]
  theme: {
    backgroundColor: string
    color: string
    hoverColor: string
    active: {
      backgroundColor: string
      color: string
github edtr-io / edtr-io / packages / plugins / geogebra / src / index.tsx View on Github external
import { DeprecatedPlugin, string } from '@edtr-io/plugin'
import { createIcon, faCubes } from '@edtr-io/ui'
import * as React from 'react'

import { GeogebraEditor } from './editor'
import { GeogebraRenderer } from './renderer'

export const geogebraState = string()
export const geogebraPlugin: DeprecatedPlugin = {
  //eslint-disable-next-line react/display-name
  Component: props =>
    props.editable ? (
      
    ) : (
      
    ),
  state: geogebraState,
  title: 'Geogebra Applet',
  description: 'Binde Applets von Geogebratube via Link oder ID ein.',
  icon: createIcon(faCubes),
  onPaste(clipboardData: DataTransfer) {
    const value = clipboardData.getData('text')

    if (/geogebra\.org\/m\/(.+)/.test(value)) {
github edtr-io / edtr-io / packages / plugins / video / src / index.tsx View on Github external
import { Plugin, string, object, migratable } from '@edtr-io/plugin'
import { createIcon, faFilm } from '@edtr-io/ui'
import * as React from 'react'

import { VideoEditor } from './editor'
import { VideoRenderer } from './renderer'

const stateV0 = string()
const stateV1 = object({ src: string(), alt: string() })
export const videoState = migratable(stateV0).migrate(stateV1, src => {
  return { src, alt: '' }
})

export const videoPlugin: Plugin = {
  //eslint-disable-next-line react/display-name
  Component: props =>
    props.editable ?  : ,
  state: videoState,
  title: 'Video',
  description: 'Binde Videos von Youtube, Vimeo, Wikimedia und BR ein.',
  icon: createIcon(faFilm),
  onPaste(clipboardData: DataTransfer) {
    const value = clipboardData.getData('text')

    const regex = /^(https?:\/\/)?(.*?(youtube\.com\/watch\?(.*&)?v=.+|youtu\.be\/.+|vimeo\.com\/.+|upload\.wikimedia\.org\/.+(\.webm|\.ogg)?|br\.de\/.+))/
    if (regex.test(value)) {
github edtr-io / edtr-io / packages / plugins / serlo-injection / src / index.ts View on Github external
import { Plugin, string } from '@edtr-io/plugin'
import { createIcon, faNewspaper } from '@edtr-io/ui'

import { SerloInjectionEditor } from './editor'

export const serloInjectionState = string()

export const serloInjectionPlugin: Plugin = {
  Component: SerloInjectionEditor,
  state: serloInjectionState,
  title: 'Serlo Inhalt',
  description: 'Binde einen Inhalt von serlo.org via ID ein',
  icon: createIcon(faNewspaper)
}
github edtr-io / edtr-io / packages / plugins / video / src / index.tsx View on Github external
import { Plugin, string, object, migratable } from '@edtr-io/plugin'
import { createIcon, faFilm } from '@edtr-io/ui'
import * as React from 'react'

import { VideoEditor } from './editor'
import { VideoRenderer } from './renderer'

const stateV0 = string()
const stateV1 = object({ src: string(), alt: string() })
export const videoState = migratable(stateV0).migrate(stateV1, src => {
  return { src, alt: '' }
})

export const videoPlugin: Plugin = {
  //eslint-disable-next-line react/display-name
  Component: props =>
    props.editable ?  : ,
  state: videoState,
  title: 'Video',
  description: 'Binde Videos von Youtube, Vimeo, Wikimedia und BR ein.',
  icon: createIcon(faFilm),
  onPaste(clipboardData: DataTransfer) {
    const value = clipboardData.getData('text')
github edtr-io / edtr-io / packages / plugins / solution-steps / src / index.ts View on Github external
import { child, object, list, Plugin, string, boolean } from '@edtr-io/plugin'
import { createIcon, faCheckSquare } from '@edtr-io/ui'

import { SolutionStepsEditor } from './editor'

export const solutionStep = object({
  type: string('step'),
  isHalf: boolean(),
  content: child('rows')
})

export const solutionStepsState = object({
  introduction: child('text'),
  strategy: child('rows'),
  hasStrategy: boolean(),
  solutionSteps: list(solutionStep),
  additionals: child('rows'),
  hasAdditionals: boolean()
})

export const solutionStepsPlugin: Plugin = {
  Component: SolutionStepsEditor,
  state: solutionStepsState,
github edtr-io / edtr-io / packages / plugins / video / src / index.tsx View on Github external
import { Plugin, string, object, migratable } from '@edtr-io/plugin'
import { createIcon, faFilm } from '@edtr-io/ui'
import * as React from 'react'

import { VideoEditor } from './editor'
import { VideoRenderer } from './renderer'

const stateV0 = string()
const stateV1 = object({ src: string(), alt: string() })
export const videoState = migratable(stateV0).migrate(stateV1, src => {
  return { src, alt: '' }
})

export const videoPlugin: Plugin = {
  //eslint-disable-next-line react/display-name
  Component: props =>
    props.editable ?  : ,
  state: videoState,
  title: 'Video',
  description: 'Binde Videos von Youtube, Vimeo, Wikimedia und BR ein.',
  icon: createIcon(faFilm),
  onPaste(clipboardData: DataTransfer) {
    const value = clipboardData.getData('text')

    const regex = /^(https?:\/\/)?(.*?(youtube\.com\/watch\?(.*&)?v=.+|youtu\.be\/.+|vimeo\.com\/.+|upload\.wikimedia\.org\/.+(\.webm|\.ogg)?|br\.de\/.+))/
github edtr-io / edtr-io / packages / plugins / table / src / index.tsx View on Github external
import { Plugin, string } from '@edtr-io/plugin'
import * as React from 'react'
import ReactMarkdown from 'react-markdown'

import { createTableEditor } from './editor'

export const tableState = string()

export function createTablePlugin(
  config: TablePluginConfig
): Plugin {
  return {
    Component: createTableEditor(config),
    state: tableState,
    title: 'Tabelle',
    description: 'Erstelle eine Tabelle mit Markdown.'
  }
}

export const tablePlugin = createTablePlugin({
  renderMarkdown: function RenderMarkdown(markdown) {
    return 
  }
github edtr-io / edtr-io / packages / plugin-table / src / index.tsx View on Github external
import { string, StatefulPlugin } from '@edtr-io/plugin'
import * as React from 'react'
import ReactMarkdown from 'react-markdown'

import { createTableEditor } from './editor'

export const tableState = string()

export function createTablePlugin(
  config: TablePluginConfig
): StatefulPlugin {
  return {
    Component: createTableEditor(config),
    state: tableState,
    title: 'Tabelle',
    description: 'Erstelle eine Tabelle mit Markdown.'
  }
}

export const tablePlugin = createTablePlugin({
  renderMarkdown: function RenderMarkdown(markdown) {
    return 
  }
github edtr-io / edtr-io / packages / plugins / multimedia-explanation / src / index.ts View on Github external
export const multimediaExplanationState = (multimediaPlugins: PluginRegistry) =>
  object({
    explanation: child('rows'),
    multimedia: child(multimediaPlugins[0].name),
    illustrating: boolean(true),
    width: number(50) //percent
  })