npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mcnmo_math-editor_npm

v1.2.2

Published

Mathlive module for MCNMO projects.

Downloads

9

Readme

MathLive: Инициализация

import { MathField } from 'mcnmo_math-editor_npm';

const MyComponent = () => {
  return <MathField config={keyboardConfig} onChange={(val) => console.log(val)} />
}

Два вида конфига

Общие настройки конфигурации

const config =  {
  accessCode: ['KeyP', 'KeyO', 'Space'],
  accessKey: ['a', 'd', 'c'],
  toolbar: false,
  desk: {
    // Здесь определяется внешний вид контента клавиатур, т.е. как будет выглядеть кнопки
    customVirtualKeyboardLayers: {
      name: { ... }, // name - Название слоя клавиатуры
      trigonometricKeyboardLayer: { ... }, // например тригонометрическая клавиатура
      numericKeypadLayer: { ... } // например цифровая клавиатура
    },
    customVirtualKeyboards: { // описываются табы
      name1: {
        label: 'Название вкладки клавиатура name1, любой html текст, можно картинку',
        tooltip: 'Подсказка которая будет показываться при наведении',
        layer: 'name', // Название слоя клавиатуры которое мы определили в customVirtualKeyboardLayers
      },
      name2: {
        label: '<img src="https://..." width="20" height="20" />',
        tooltip: 'Тригонометрическая клавиатура',
        layer: 'trigonometricKeyboardLayer',
      },
      name3: {
        label: 'Цифровая клавиатура',
        layer: 'numericKeypadLayer'
      }
    },
    // Через запятую прописываем какие клавиатуры мы будем отображать
    virtualKeyboards: 'name2 name3'
  }
};

1. Базовый конфиг

const config = {
  mobile: {}, //...
  desk: {
    customVirtualKeyboardLayers: {
      nameKeyboardLayer: {
        // blocks это массив строк
        blocks: [
          // первая строка
          {
            // строка может быть разбира на колонки
            data: [
              // первая колонка в данном случае состоит из 7 кнопок
              {
                title: 'Арифметические операции',
                // цвет кнопок название взял из bootstrap
                type: 'primary',
                // Сами кнопки, это может быть или индетификатор кнопки если он записан в виде текста
                // Или это может быть команда, если передаётся в виде обьекта { latex: '$$a^{b}$$', insert: '{#?}^{#?}' }
                btns: ['+', '-', '/', '*', { latex: '$$a^{b}$$', insert: '{#?}^{#?}' }, 'sqrt{a}', '|a|'],
              },
              // 2 пустые кнопки
              {
                btns: ['', ''] // делаем отступ в 2 кнопки
              },
              {
                title: 'Группа, индекс',
                type: 'light',
                btns: ['(...)', 'x_{i}', ''],
              },
              {
                title: 'Переменные в задаче',
                type: 'warning',
                btns: ['x'],
              },
            ]
          }
        ]
      }
    }
  }
};

2. Блочный конфиг

const config = {
  mobile: {}, //...
  desk: {
    customVirtualKeyboardLayers: {
      nameKeyboardLayer: {
        // blocks это массив строк и колонок
        blocks: [
          {
            // цвет кнопок название взял из bootstrap
            type: 'primary',
            // 4-ре строки по одной колонкаме
            btns: [['+'], ['-'], ['*'], ['/']],
          },
          {
            type: 'light',
            // 4-ре строки по 3 колонки
            btns: [
              [1, 2, 3],
              [4, 5, 6],
              [7, 8, 9],
              [',', 0, '']
            ],
          },
          {
            type: 'success',
            btns: [
              ['|#?|', '(...)', '|#?|/|#?|'],
              ['^2', '^3', '^0'],
              ['sqrt[#?]', 'sqrt[#?]3', 'sqrt[#?]{#0}'],
              ['log', 'ln', 'lg']
            ],
          },
          {
            type: 'turquoise',
            // Сами кнопки, это может быть или индетификатор кнопки если он записан в виде текста
            // Или это может быть команда, если передаётся в виде обьекта { latex: '$$a^{b}$$', insert: '{#?}^{#?}' }
            btns: [
              [{ id: '(|#?|; |#?|)', size: '15' }, { id: '[|#?|; |#?|]', size: '15' }],
              [{ id: '[|#?|; |#?|)', size: '15' }, { id: '(|#?|; |#?|]', size: '15' }],
              [{ id: '-infty', size: '15' }, { id: '+infty', size: '15' }],
              ['union', '{#?}', 'emptyset']
            ],
          },
          {
            type: 'purple',
            btns: [
              ['sin', { id: 'arcsin', size: '15' }],
              ['cos', { id: 'arccos', size: '15' }],
              ['tg',  { id: 'arctg', size: '15' }],
              ['ctg', { id: 'arcctg', size: '15' }]
            ],
          },
        ]
      }
    }
  }
};

Описание кнопок

 operators = {
   'buttonId': {
     // Ввод команд например удалить последний символ command: ['performWithFeedback', 'deletePreviousChar']
     // Переключится на альтернативню клавиатуру command: ['toggleVirtualKeyboardAlt']
     command: ['performWithFeedback', 'deletePreviousChar'],
     // Команда которая будет вставленна когда будет нажата кнопка
     insert: '$$\\operatorname{arcsin}\\left( #0 \\right)$$',
     // Latex оператор который будет отображаться на кнопке и при вставке в поле ввода
     latex: '\\operatorname{arcsin}',
     // Добавляем к контенту кнопки тег <aside> и вставляем туда содержимое
     aside: 'доп. инф.',
     // Используется для вставки svg символов на кнопку
     shifted: '<svg><use xlink:href="#svg-angle-double-right" /></svg>',
     // Команда которая будет выполненна когда произойдёт нажатие на кнопку с символом из shifted
     shiftedCommand: ['toggleVirtualKeyboardAlt'],
     // Текст кнопки innerHTML, но если стоит зарезервированный класс, то innerHTML будет браться из latex, insert, content
     label: '<img src="https://..." width="20" height="20" />'
   },
   '*': {
     label: '•',
     insert: '*'
   },
   'a^{b}': {
     latex: '$$a^{b}$$',
     insert: '{#?}^{#?}'
   },
   'sqrt{a}': {
     latex: '\\sqrt{a}',
     insert: '$$\\sqrt{#0}$$'
   },
   '|a|': {
     latex: '\\left| a \\right|',
     insert: '$$\\left| #0 \\right|$$'
   },
   '(...)': {
     label: '(...)',
     insert: '$$\\left( #0 \\right)$$'
   },
   'x_{i}': {
     latex: 'x_{i}',
     insert: '{#?}_{#?}'
   },
   ...
 }