code.js 473 B

1234567891011121314151617
  1. import React from "react"
  2. import Action from "./action"
  3. export default function(props) {
  4. return (
  5. <Action execAction={insertCode} title={gettext("Insert code")} {...props}>
  6. <span className="material-icon">functions</span>
  7. </Action>
  8. )
  9. }
  10. export function insertCode(selection, replace) {
  11. const syntax = $.trim(
  12. prompt(gettext("Enter name of syntax of your code (optional)") + ":")
  13. )
  14. replace("\n\n```" + syntax + "\n" + selection + "\n```\n\n")
  15. }