<commit_before>/*
 * paragraph.ts
 *
 * Copyright (C) 2020 by RStudio, PBC
 *
 * Unless you have received this program directly from RStudio pursuant
 * to the terms of a commercial license agreement with RStudio, then
 * this program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

import { Node as ProsemirrorNode, Schema } from 'prosemirror-model';

import { BlockCommand, EditorCommandId, ProsemirrorCommand } from '../api/command';
import { Extension } from '../api/extension';
import { PandocOutput, PandocTokenType } from '../api/pandoc';
import { insertParagraph } from '../api/paragraph';
import { EditorUI } from '../api/ui';
import { OmniInsertGroup } from '../api/omni_insert';

const extension: Extension = {
  nodes: [
    {
      name: 'paragraph',
      spec: {
        content: 'inline*',
        group: 'block list_item_block',
        parseDOM: [{ tag: 'p' }],
        toDOM() {
          return ['p', 0];
        },
      },
      pandoc: {
        readers: [
          { token: PandocTokenType.Para, block: 'paragraph' },
          { token: PandocTokenType.Plain, block: 'paragraph' },
        ],
        writer: (output: PandocOutput, node: ProsemirrorNode) => {
          output.writeToken(PandocTokenType.Para, () => {
            output.writeInlines(node.content);
          });
        },
      },
    },
  ],

  commands: (schema: Schema, ui: EditorUI) => {
    return [
      new BlockCommand(
        EditorCommandId.Paragraph,
        ['Mod-Alt-0'],
        schema.nodes.paragraph,
        schema.nodes.paragraph,
        {},
        {
          name: ui.context.translateText('Paragraph'),
          description: ui.context.translateText('Plain paragraph of text'),
          group: OmniInsertGroup.Blocks,
          priority: 10,
          image: () =>
            ui.prefs.darkMode() ? ui.images.omni_insert?.paragraph_dark! : ui.images.omni_insert?.paragraph!,
        },
      ),
      new InsertParagraphCommand(),
    ];
  },
};

class InsertParagraphCommand extends ProsemirrorCommand {
  constructor() {
    super(EditorCommandId.ParagraphInsert, [], insertParagraph);
  }
}

export default extension;<commit_msg>remove paragraph omni-insert<commit_after>/*
 * paragraph.ts
 *
 * Copyright (C) 2020 by RStudio, PBC
 *
 * Unless you have received this program directly from RStudio pursuant
 * to the terms of a commercial license agreement with RStudio, then
 * this program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

import { Node as ProsemirrorNode, Schema } from 'prosemirror-model';

import { BlockCommand, EditorCommandId, ProsemirrorCommand } from '../api/command';
import { Extension } from '../api/extension';
import { PandocOutput, PandocTokenType } from '../api/pandoc';
import { insertParagraph } from '../api/paragraph';
import { EditorUI } from '../api/ui';
import { OmniInsertGroup } from '../api/omni_insert';

const extension: Extension = {
  nodes: [
    {
      name: 'paragraph',
      spec: {
        content: 'inline*',
        group: 'block list_item_block',
        parseDOM: [{ tag: 'p' }],
        toDOM() {
          return ['p', 0];
        },
      },
      pandoc: {
        readers: [
          { token: PandocTokenType.Para, block: 'paragraph' },
          { token: PandocTokenType.Plain, block: 'paragraph' },
        ],
        writer: (output: PandocOutput, node: ProsemirrorNode) => {
          output.writeToken(PandocTokenType.Para, () => {
            output.writeInlines(node.content);
          });
        },
      },
    },
  ],

  commands: (schema: Schema) => {
    return [
      new BlockCommand(
        EditorCommandId.Paragraph,
        ['Mod-Alt-0'],
        schema.nodes.paragraph,
        schema.nodes.paragraph
      ),
      new InsertParagraphCommand(),
    ];
  },
};

class InsertParagraphCommand extends ProsemirrorCommand {
  constructor() {
    super(EditorCommandId.ParagraphInsert, [], insertParagraph);
  }
}

export default extension;
{'fraction_non_alphanumeric': 0.12401229148375768, 'fraction_numerical': 0.004389815627743635, 'mean_word_length': 2.6839126919967664, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3743969', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1295, 'n_words': 358}