{"version":3,"file":"options.mjs","sources":["../../../../src/slate-plugins/slate-prism/options.tsx"],"sourcesContent":["import { Record } from 'immutable';\nimport * as React from 'react';\nimport { Mark, Node, Decoration } from 'slate';\nimport { Editor } from 'slate-react';\n\nimport TOKEN_MARK from './TOKEN_MARK';\n\nexport interface OptionsFormat {\n  // Determine which node should be highlighted\n  onlyIn?: (node: Node) => boolean;\n  // Returns the syntax for a node that should be highlighted\n  getSyntax?: (node: Node) => string;\n  // Render a highlighting mark in a highlighted node\n  renderMark?: ({ mark, children }: { mark: Mark; children: React.ReactNode }) => void | React.ReactNode;\n}\n\n/**\n * Default filter for code blocks\n */\nfunction defaultOnlyIn(node: Node): boolean {\n  return node.object === 'block' && node.type === 'code_block';\n}\n\n/**\n * Default getter for syntax\n */\nfunction defaultGetSyntax(node: Node): string {\n  return 'javascript';\n}\n\n/**\n * Default rendering for decorations\n */\nfunction defaultRenderDecoration(\n  props: { children: React.ReactNode; decoration: Decoration },\n  editor: Editor,\n  next: () => any\n): void | React.ReactNode {\n  const { decoration } = props;\n  if (decoration.type !== TOKEN_MARK) {\n    return next();\n  }\n\n  const className = decoration.data.get('className');\n  return <span className={className}>{props.children}</span>;\n}\n\n/**\n * The plugin options\n */\nclass Options\n  extends Record({\n    onlyIn: defaultOnlyIn,\n    getSyntax: defaultGetSyntax,\n    renderDecoration: defaultRenderDecoration,\n  })\n  implements OptionsFormat\n{\n  declare readonly onlyIn: (node: Node) => boolean;\n  declare readonly getSyntax: (node: Node) => string;\n  declare readonly renderDecoration: (\n    {\n      decoration,\n      children,\n    }: {\n      decoration: Decoration;\n      children: React.ReactNode;\n    },\n    editor: Editor,\n    next: () => any\n  ) => void | React.ReactNode;\n\n  constructor(props: OptionsFormat) {\n    super(props);\n  }\n}\n\nexport default Options;\n"],"names":[],"mappings":";;;;AAmBA,SAAS,cAAc,IAAqB,EAAA;AAC1C,EAAA,OAAO,IAAK,CAAA,MAAA,KAAW,OAAW,IAAA,IAAA,CAAK,IAAS,KAAA,YAAA;AAClD;AAKA,SAAS,iBAAiB,IAAoB,EAAA;AAC5C,EAAO,OAAA,YAAA;AACT;AAKA,SAAS,uBAAA,CACP,KACA,EAAA,MAAA,EACA,IACwB,EAAA;AACxB,EAAM,MAAA,EAAE,YAAe,GAAA,KAAA;AACvB,EAAI,IAAA,UAAA,CAAW,SAAS,UAAY,EAAA;AAClC,IAAA,OAAO,IAAK,EAAA;AAAA;AAGd,EAAA,MAAM,SAAY,GAAA,UAAA,CAAW,IAAK,CAAA,GAAA,CAAI,WAAW,CAAA;AACjD,EAAA,uBAAQ,GAAA,CAAA,MAAA,EAAA,EAAK,SAAuB,EAAA,QAAA,EAAA,KAAA,CAAM,QAAS,EAAA,CAAA;AACrD;AAKA,MAAM,gBACI,MAAO,CAAA;AAAA,EACb,MAAQ,EAAA,aAAA;AAAA,EACR,SAAW,EAAA,gBAAA;AAAA,EACX,gBAAkB,EAAA;AACpB,CAAC,CAEH,CAAA;AAAA,EAeE,YAAY,KAAsB,EAAA;AAChC,IAAA,KAAA,CAAM,KAAK,CAAA;AAAA;AAEf;;;;"}