<commit_before>/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */

/*
Edit description of a single task
*/

import { Button } from "antd";
import { useCallback } from "react";
import { useDebouncedCallback } from "use-debounce";
import MarkdownInput from "@cocalc/frontend/editors/markdown-input/multimode";
import { Icon } from "@cocalc/frontend/components/icon";
import { TaskActions } from "./actions";
import { SAVE_DEBOUNCE_MS } from "@cocalc/frontend/frame-editors/code-editor/const";
import ColorPicker from "@cocalc/frontend/components/color-picker";

interface Props {
  actions: TaskActions;
  task_id: string;
  desc: string;
  font_size: number; // used only to cause refresh
  color?: string;
}

export default function DescriptionEditor({
  actions,
  task_id,
  desc,
  font_size,
  color,
}: Props) {
  const commit = useDebouncedCallback(() => {
    actions.commit();
  }, SAVE_DEBOUNCE_MS);

  const saveAndClose = useCallback(() => {
    actions.commit();
    actions.enable_key_handler();
    actions.stop_editing_desc(task_id);
  }, []);

  return (
    <div style={{ border: "1px solid #40a9ff", padding: "0 15px 15px 15px" }}>
      <MarkdownInput
        cacheId={task_id}
        value={desc}
        onChange={(desc) => {
          actions.set_desc(task_id, desc, false);
          commit();
        }}
        fontSize={font_size}
        onShiftEnter={saveAndClose}
        onFocus={actions.disable_key_handler}
        enableUpload={true}
        enableMentions={true}
        height={"auto"}
        placeholder={"Enter description..."}
        lineWrapping={true}
        autoFocus<commit_msg>slight tweak to tasks border<commit_after>/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */

/*
Edit description of a single task
*/

import { Button } from "antd";
import { useCallback } from "react";
import { useDebouncedCallback } from "use-debounce";
import MarkdownInput from "@cocalc/frontend/editors/markdown-input/multimode";
import { Icon } from "@cocalc/frontend/components/icon";
import { TaskActions } from "./actions";
import { SAVE_DEBOUNCE_MS } from "@cocalc/frontend/frame-editors/code-editor/const";
import ColorPicker from "@cocalc/frontend/components/color-picker";

interface Props {
  actions: TaskActions;
  task_id: string;
  desc: string;
  font_size: number; // used only to cause refresh
  color?: string;
}

export default function DescriptionEditor({
  actions,
  task_id,
  desc,
  font_size,
  color,
}: Props) {
  const commit = useDebouncedCallback(() => {
    actions.commit();
  }, SAVE_DEBOUNCE_MS);

  const saveAndClose = useCallback(() => {
    actions.commit();
    actions.enable_key_handler();
    actions.stop_editing_desc(task_id);
  }, []);

  return (
    <div style={{ border: "1px solid #40a9ff", padding: "5px 15px" }}>
      <MarkdownInput
        cacheId={task_id}
        value={desc}
        onChange={(desc) => {
          actions.set_desc(task_id, desc, false);
          commit();
        }}
        fontSize={font_size}
        onShiftEnter={saveAndClose}
        onFocus={actions.disable_key_handler}
        enableUpload={true}
        enableMentions={true}
        height={"auto"}
        placeholder={"Enter description..."}
        lineWrapping={true}
        autoFocus
{'fraction_non_alphanumeric': 0.13027042744984008, 'fraction_numerical': 0.008141901715615005, 'mean_word_length': 3.3489254108723134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1459787', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1088, 'n_words': 257}