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

@hongtangyun/puzzle-libs

v0.2.12

Published

``` import {TestPaper, TypeEnum} from '@hongtangyun/puzzle-libs' import '@hongtangyun/puzzle-libs/dist/styles.css'

Downloads

18

Readme

import {TestPaper, TypeEnum} from '@hongtangyun/puzzle-libs'
import '@hongtangyun/puzzle-libs/dist/styles.css'

1. 编辑组件

1. 题目编辑

import { HTMLEditorLibs } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';

<HTMLEditorLibs.EditorQ
  upConfig={upConfig}
  data={initData}
  bigQType={initData?.type ? initData?.type : undefined}
  onOk={async (data) => {
    await handleSave(data);
  }}
  onCancel={() => {
    
  }}
  onGetUpConfig={async () => {
    const _up = await getStorageConfig('COS');
    return {
      type: _up.type,
      cosCof: {
        bucket: _up.data.bucket,
        region: _up.data.region,
        startTime: _up.data.startTime,
        expiredTime: _up.data.expiredTime,
        prefix: _up.data.prefix,
        tmpSecretKey: _up.data.credentials.tmpSecretKey,
        tmpSecretId: _up.data.credentials.tmpSecretId,
        sessionToken: _up.data.credentials.sessionToken,
      },
    };
  }}
/>

2. 题目预览


import { HtmlPaperLibs } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';

<HtmlPaperLibs.ExpandedRowRenderQ
  data={record.sourceData}
/>

3. 试卷编辑


import { EditorPaper } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';

<EditorPaper
  type="HTML"
  config={{
    initData: initData,
    onGetUpConfig: async () => {
      const _up = await getStorageConfig('COS');
      return {
        type: _up.type,
        cosCof: {
          bucket: _up.data.bucket,
          region: _up.data.region,
          startTime: _up.data.startTime,
          expiredTime: _up.data.expiredTime,
          prefix: _up.data.prefix,
          tmpSecretKey: _up.data.credentials.tmpSecretKey,
          tmpSecretId: _up.data.credentials.tmpSecretId,
          sessionToken: _up.data.credentials.sessionToken,
        },
      };
    },
    onChagne: (data) => {
      setEditorData(data);
    },
    getTopicList: async (page, pageSize, params?: any) => {
      return await getPuzzlesTopic({
        ...params,
        page,
        pageSize,
      });
    },
    onTopicTags: async (page, pageSize, params?: any) => {
      return await getPuzzlesTagsTopic({
        ...params,
        page,
        pageSize,
      });
    },
  }}
/>

4. 试卷预览


import { TestPaper, TypeEnum } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';

<TestPaper
  layout="all"
  answer={
    {
      // '2ec9b9c187beaae90fc558a056ebbc30': ['ccc'],
      // '5b576156cc3228a511ded14589ea859b': ['xxx'],
      // '3fee91715e83e61acbffad2889bbde0a': ['1234'],
      // '54c8a4770e2d88d19644a3d6163ef5c9': [
      //   'https://hongtangyun-1252095557.cos.ap-chengdu.myqcloud.com/hongtangyun_access/room/625e56bef7e409145c6d882b/1/2022_12_07_18/ac64cf03820a8b8b55f681020938b170.wav',
      // ],
    }
  }
  watermark="测试用户-预览"
  width={windowSize.width}
  height={windowSize.height}
  currentPaper={initData}
  readonly={true}
  showTip={true}
  onChange={async (changeValue, allValue, paperInfo) => {}}
  onSubmit={async (data) => {
    console.log('onSubmit: ', data);
  }}
  onBack={() => {}}
/>

5. 试卷做答


import { TestPaper, TypeEnum } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';

<TestPaper
  layout="all"
  answer={
    {
      // '2ec9b9c187beaae90fc558a056ebbc30': ['ccc'],
      // '5b576156cc3228a511ded14589ea859b': ['xxx'],
      // '3fee91715e83e61acbffad2889bbde0a': ['1234'],
      // '54c8a4770e2d88d19644a3d6163ef5c9': [
      //   'https://hongtangyun-1252095557.cos.ap-chengdu.myqcloud.com/hongtangyun_access/room/625e56bef7e409145c6d882b/1/2022_12_07_18/ac64cf03820a8b8b55f681020938b170.wav',
      // ],
    }
  }
  watermark="测试用户-预览"
  width={windowSize.width}
  height={windowSize.height}
  currentPaper={initData}
  readonly={false}
  showTip={false}
  onChange={async (changeValue, allValue, paperInfo) => {}}
  onSubmit={async (data) => {
    console.log('onSubmit: ', data);
  }}
  onBack={() => {}}
/>

6. 试卷阅卷


import { TestPaper, TypeEnum } from '@hongtangyun/puzzle-libs';
import '@hongtangyun/puzzle-libs/dist/styles.css';

<TestPaper
  layout="all"
  /**
   * 批改试卷
   */
  isCorrection?: boolean;
  /**
   * 批改试卷回调
   * @param data
   * @returns
   */
  onCorrection?: (
    data:
      | Array<{ score: number; question: SubItem }>
      | { score: number; question: SubItem },
  ) => Promise<boolean>;
  /**
   * 获取当前用户批改试卷分数
   * @param id 题目id
   * @returns
   */
  onGetCorrectionScore?: (id: string) => Promise<number | undefined>;
  answer={
    {
      // '2ec9b9c187beaae90fc558a056ebbc30': ['ccc'],
      // '5b576156cc3228a511ded14589ea859b': ['xxx'],
      // '3fee91715e83e61acbffad2889bbde0a': ['1234'],
      // '54c8a4770e2d88d19644a3d6163ef5c9': [
      //   'https://hongtangyun-1252095557.cos.ap-chengdu.myqcloud.com/hongtangyun_access/room/625e56bef7e409145c6d882b/1/2022_12_07_18/ac64cf03820a8b8b55f681020938b170.wav',
      // ],
    }
  }
  watermark="测试用户-预览"
  width={windowSize.width}
  height={windowSize.height}
  currentPaper={initData}
  readonly={true}
  showTip={true}
  onChange={async (changeValue, allValue, paperInfo) => {}}
  onSubmit={async (data) => {
    console.log('onSubmit: ', data);
  }}
  onBack={() => {}}
/>

7. 参数

upConfig = {
  type: _up.type,
  cosCof: {
    bucket: _up.data.bucket,
    region: _up.data.region,
    startTime: _up.data.startTime,
    expiredTime: _up.data.expiredTime,
    prefix: _up.data.prefix,
    tmpSecretKey: _up.data.credentials.tmpSecretKey,
    tmpSecretId: _up.data.credentials.tmpSecretId,
    sessionToken: _up.data.credentials.sessionToken,
  },
}

utils

import { utils } from '@hongtangyun/puzzle-libs';
// class100题目导入
utils.class100QInput
// class100题目导出 
utils.class100QExport
// class100试卷导入
utils.class100PaperInput
// class100试卷导出 
utils.class100PaperExport
// 编辑器试卷转class100试卷
utils.editorPaperToClass100Paper
// 试卷值转class100值
utils.editorValuesToClass100Values
// 试卷标记转class100标记
utils.editorFlagsToClass100Flags
// 提交试卷 - 检测 必答是否完成
utils.checkPaperAnswerInComplete
// class100提交试卷 - 检测 必答是否完成
utils.checkPaperAnswerIsCompleteForClass100
// 判断富文本为空
utils.isContentEmpty