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

v-code-diff-oxr

v1.0.0

Published

A based from Shimada666/[email protected] 去除默认导入主题 添加主题导入 api importTheme(function(){import('XXXX')} || null) 默认导入适配的yaml theme monaco, 使用 importTheme 后覆盖,支持 highlight 的主题包

Downloads

2

Readme

v-code-diff

NPM version License: MIT Downloads

A code diff display plugin, available for Vue2 / Vue3.

Old Version:

0.x version, latest version 0.3.12 (traditional version, improved based on vue-code-diff, is no longer maintained. We will try to align the functionality of 0.x version in 1.x version and minimize migration cost as much as possible). This project references the following projects, and I would like to express my gratitude to the original authors!

Introductio

based from Shimada666/v-code-diff 去除默认导入主题 添加主题导入 api importTheme(function(){import('XXXX')} || null) 默认导入 theme monaco, 使用 importTheme 后覆盖,支持 highlight 的主题包

// 例
import("highlight.js/scss/monokai-sublime.scss");

Contents

Install

install v-code-diff

# npm
npm i v-code-diff

# yarn
yarn add v-code-diff

# pnpm
pnpm add v-code-diff

Vue2 developers need install composition-api

pnpm add @vue/composition-api

Getting Started

Vue3

Register globally

import { createApp } from "vue";
import CodeDiff from "v-code-diff";

app.use(CodeDiff).mount("#app");

then

<template>
  <code-diff
    :old-string="'12345'"
    :new-string="'3456'"
    output-format="side-by-side"
  />
</template>

Register locally

Not recommended, but the relevant capabilities are retained to facilitate migration for 0.x users.

Vue2

Register globally

import Vue from "vue";
import CodeDiff from "v-code-diff";

Vue.use(CodeDiff);

Register locally

Not recommended, but the relevant capabilities are retained to facilitate migration for 0.x users.

Props

| Prop | Description | Type | Optional Values | Default Value | | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------------------------- | ------------- | | language | Code language, such as typescript, defaults to plain text. View all supported languages | string | - | plaintext | | oldString | Old string | string | - | - | | newString | New string | string | - | - | | context | The number of lines to separate different parts so that they are not hidden | number | - | 10 | | outputFormat | Display mode | string | line-by-line,side-by-side | line-by-line | | diffStyle | Difference style, word-level differences or letter-level differences | string | word, char | word | | trim | Remove blank characters at the beginning and end of the string | boolean | - | false | | noDiffLineFeed | Don't diff Windows line feed (CRLF) and Linux line feed (LF) | boolean | - | false | | maxHeight | Maximum height of component, for example: 300px | string | - | undefined | | filename | Filename | string | - | undefined |

Extend languages

In order to reduce the size of the packaged file, the system only supports the following commonly used languages by default.

  • plaintext
  • xml/html
  • javascript
  • json
  • yaml
  • python
  • java
  • bash
  • sql

If the language you need is not included, you can manually import the relevant language highlighting module.

pnpm add highlight.js
import CodeDiff from "v-code-diff";
// Extend C language
import c from "highlight.js/lib/languages/c";

CodeDiff.hljs.registerLanguage("c", c);

Migrate from 0.x version

The v-code-diff 1.x version has features such as reduced packaging size and improved performance compared to the 0.x version. And we will try to align the functions with the 0.x version as much as possible to reduce your migration cost.

Key points:

  • In the 1.x version, language recognition and highlighting will no longer be automatically performed, you need to manually specify the language type, such as language="python", if not specified, it will default to plaintext and will not be highlighted.
  • In the 1.x version, due to the fact that rendering and highlighting are performed at the same time, the component events have been removed.
  • In the 1.x version, the following component properties (Prop) have been changed:
    • highlight - removed
    • drawFileList - removed
    • fileName - rename to "filename"

Below is a detailed comparison of the two versions, you can refer to it to complete the migration.

The difference of event.

The component events are no longer provided in the 1.x version as rendering and highlighting are carried out simultaneously.

| Event Name | Change Status | | ------------- | ------------------ | | before-render | No longer provided | | after-render | No longer provided |

The difference of prop.

| Prop | Description | Change Status | | ---------------------- | --------------------------------------------------------------------------- | ----------------------------------------------- | | highlight | Control code highlighting | Removed in version 1.x | | language | Code language | None | | oldString | Old string | None | | newString | New string | None | | context | The number of lines to separate different parts so that they are not hidden | None | | output-format | Display mode | None | | diffStyle | Difference style, word-level differences or letter-level differences | None | | drawFileList | Display file comparison list | Removed in version 1.x | | renderNothingWhenEmpty | Do not render when there is no comparison | Removed in version 1.x | | fileName | File name | To be determined, not under development | | isShowNoChange | Display source code when there is no comparison | Removed as it became the default in version 1.x | | trim | Remove blank characters at the beginning and end of the string | None | | noDiffLineFeed | Don't diff Windows line feed (CRLF) and Linux line feed (LF) | None |