Path: blob/master/src/packages/frontend/editors/slate/elements/meta/index.tsx
1702 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/*67YAML metadata node, e.g., at the VERY top like this:89---10title: HW0211subtitle: Basic Rmd and Statistics12output:13html_document:14theme: spacelab15highlight: tango16toc: true17---181920*/2122import { CodeMirrorStatic } from "@cocalc/frontend/jupyter/codemirror-static";23import { register } from "../register";24import infoToMode from "../code-block/info-to-mode";25import { Meta, createMetaNode } from "./type";26export type { Meta };27export { createMetaNode };2829register({30slateType: "meta",3132toSlate: ({ token }) => {33return createMetaNode(token.content);34},3536StaticElement: ({ attributes, element }) => {37if (element.type != "meta") throw Error("bug");38return (39<div {...attributes}>40<code>---</code>41<CodeMirrorStatic42style={{ marginBottom: 0 }}43options={{ mode: infoToMode("yml"), lineWrapping: true }}44value={element.value}45/>46<code>---</code>47</div>48);49},50});515253