first commit
This commit is contained in:
96
node_modules/vant/es/highlight/Highlight.d.ts
generated
vendored
Normal file
96
node_modules/vant/es/highlight/Highlight.d.ts
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
import { type ExtractPropTypes, type PropType } from 'vue';
|
||||
export declare const highlightProps: {
|
||||
autoEscape: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
caseSensitive: BooleanConstructor;
|
||||
highlightClass: StringConstructor;
|
||||
highlightTag: {
|
||||
type: PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
keywords: {
|
||||
type: PropType<string | string[]>;
|
||||
required: true;
|
||||
};
|
||||
sourceString: {
|
||||
type: PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
tag: {
|
||||
type: PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
unhighlightClass: StringConstructor;
|
||||
unhighlightTag: {
|
||||
type: PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
};
|
||||
export type HighlightProps = ExtractPropTypes<typeof highlightProps>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
autoEscape: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
caseSensitive: BooleanConstructor;
|
||||
highlightClass: StringConstructor;
|
||||
highlightTag: {
|
||||
type: PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
keywords: {
|
||||
type: PropType<string | string[]>;
|
||||
required: true;
|
||||
};
|
||||
sourceString: {
|
||||
type: PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
tag: {
|
||||
type: PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
unhighlightClass: StringConstructor;
|
||||
unhighlightTag: {
|
||||
type: PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
autoEscape: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
caseSensitive: BooleanConstructor;
|
||||
highlightClass: StringConstructor;
|
||||
highlightTag: {
|
||||
type: PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
keywords: {
|
||||
type: PropType<string | string[]>;
|
||||
required: true;
|
||||
};
|
||||
sourceString: {
|
||||
type: PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
tag: {
|
||||
type: PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
unhighlightClass: StringConstructor;
|
||||
unhighlightTag: {
|
||||
type: PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
}>> & Readonly<{}>, {
|
||||
tag: keyof HTMLElementTagNameMap;
|
||||
autoEscape: boolean;
|
||||
caseSensitive: boolean;
|
||||
highlightTag: keyof HTMLElementTagNameMap;
|
||||
sourceString: string;
|
||||
unhighlightTag: keyof HTMLElementTagNameMap;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
128
node_modules/vant/es/highlight/Highlight.mjs
generated
vendored
Normal file
128
node_modules/vant/es/highlight/Highlight.mjs
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
import { defineComponent, computed, createVNode as _createVNode } from "vue";
|
||||
import { createNamespace, makeRequiredProp, makeStringProp, truthProp } from "../utils/index.mjs";
|
||||
const [name, bem] = createNamespace("highlight");
|
||||
const highlightProps = {
|
||||
autoEscape: truthProp,
|
||||
caseSensitive: Boolean,
|
||||
highlightClass: String,
|
||||
highlightTag: makeStringProp("span"),
|
||||
keywords: makeRequiredProp([String, Array]),
|
||||
sourceString: makeStringProp(""),
|
||||
tag: makeStringProp("div"),
|
||||
unhighlightClass: String,
|
||||
unhighlightTag: makeStringProp("span")
|
||||
};
|
||||
var stdin_default = defineComponent({
|
||||
name,
|
||||
props: highlightProps,
|
||||
setup(props) {
|
||||
const highlightChunks = computed(() => {
|
||||
const {
|
||||
autoEscape,
|
||||
caseSensitive,
|
||||
keywords,
|
||||
sourceString
|
||||
} = props;
|
||||
const flags = caseSensitive ? "g" : "gi";
|
||||
const _keywords = Array.isArray(keywords) ? keywords : [keywords];
|
||||
let chunks = _keywords.filter((keyword) => keyword).reduce((chunks2, keyword) => {
|
||||
if (autoEscape) {
|
||||
keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
const regex = new RegExp(keyword, flags);
|
||||
let match;
|
||||
while (match = regex.exec(sourceString)) {
|
||||
const start = match.index;
|
||||
const end = regex.lastIndex;
|
||||
if (start >= end) {
|
||||
regex.lastIndex++;
|
||||
continue;
|
||||
}
|
||||
chunks2.push({
|
||||
start,
|
||||
end,
|
||||
highlight: true
|
||||
});
|
||||
}
|
||||
return chunks2;
|
||||
}, []);
|
||||
chunks = chunks.sort((a, b) => a.start - b.start).reduce((chunks2, currentChunk) => {
|
||||
const prevChunk = chunks2[chunks2.length - 1];
|
||||
if (!prevChunk || currentChunk.start > prevChunk.end) {
|
||||
const unhighlightStart = prevChunk ? prevChunk.end : 0;
|
||||
const unhighlightEnd = currentChunk.start;
|
||||
if (unhighlightStart !== unhighlightEnd) {
|
||||
chunks2.push({
|
||||
start: unhighlightStart,
|
||||
end: unhighlightEnd,
|
||||
highlight: false
|
||||
});
|
||||
}
|
||||
chunks2.push(currentChunk);
|
||||
} else {
|
||||
prevChunk.end = Math.max(prevChunk.end, currentChunk.end);
|
||||
}
|
||||
return chunks2;
|
||||
}, []);
|
||||
const lastChunk = chunks[chunks.length - 1];
|
||||
if (!lastChunk) {
|
||||
chunks.push({
|
||||
start: 0,
|
||||
end: sourceString.length,
|
||||
highlight: false
|
||||
});
|
||||
}
|
||||
if (lastChunk && lastChunk.end < sourceString.length) {
|
||||
chunks.push({
|
||||
start: lastChunk.end,
|
||||
end: sourceString.length,
|
||||
highlight: false
|
||||
});
|
||||
}
|
||||
return chunks;
|
||||
});
|
||||
const renderContent = () => {
|
||||
const {
|
||||
sourceString,
|
||||
highlightClass,
|
||||
unhighlightClass,
|
||||
highlightTag,
|
||||
unhighlightTag
|
||||
} = props;
|
||||
return highlightChunks.value.map((chunk) => {
|
||||
const {
|
||||
start,
|
||||
end,
|
||||
highlight
|
||||
} = chunk;
|
||||
const text = sourceString.slice(start, end);
|
||||
if (highlight) {
|
||||
return _createVNode(highlightTag, {
|
||||
"class": [bem("tag"), highlightClass]
|
||||
}, {
|
||||
default: () => [text]
|
||||
});
|
||||
}
|
||||
return _createVNode(unhighlightTag, {
|
||||
"class": unhighlightClass
|
||||
}, {
|
||||
default: () => [text]
|
||||
});
|
||||
});
|
||||
};
|
||||
return () => {
|
||||
const {
|
||||
tag
|
||||
} = props;
|
||||
return _createVNode(tag, {
|
||||
"class": bem()
|
||||
}, {
|
||||
default: () => [renderContent()]
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
export {
|
||||
stdin_default as default,
|
||||
highlightProps
|
||||
};
|
||||
1
node_modules/vant/es/highlight/index.css
generated
vendored
Normal file
1
node_modules/vant/es/highlight/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-highlight-tag-color: var(--van-primary-color)}.van-highlight__tag{color:var(--van-highlight-tag-color)}
|
||||
73
node_modules/vant/es/highlight/index.d.ts
generated
vendored
Normal file
73
node_modules/vant/es/highlight/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
export declare const Highlight: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
autoEscape: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
caseSensitive: BooleanConstructor;
|
||||
highlightClass: StringConstructor;
|
||||
highlightTag: {
|
||||
type: import("vue").PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
keywords: {
|
||||
type: import("vue").PropType<string | string[]>;
|
||||
required: true;
|
||||
};
|
||||
sourceString: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
tag: {
|
||||
type: import("vue").PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
unhighlightClass: StringConstructor;
|
||||
unhighlightTag: {
|
||||
type: import("vue").PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
autoEscape: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
caseSensitive: BooleanConstructor;
|
||||
highlightClass: StringConstructor;
|
||||
highlightTag: {
|
||||
type: import("vue").PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
keywords: {
|
||||
type: import("vue").PropType<string | string[]>;
|
||||
required: true;
|
||||
};
|
||||
sourceString: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
tag: {
|
||||
type: import("vue").PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
unhighlightClass: StringConstructor;
|
||||
unhighlightTag: {
|
||||
type: import("vue").PropType<keyof HTMLElementTagNameMap>;
|
||||
default: keyof HTMLElementTagNameMap;
|
||||
};
|
||||
}>> & Readonly<{}>, {
|
||||
tag: keyof HTMLElementTagNameMap;
|
||||
autoEscape: boolean;
|
||||
caseSensitive: boolean;
|
||||
highlightTag: keyof HTMLElementTagNameMap;
|
||||
sourceString: string;
|
||||
unhighlightTag: keyof HTMLElementTagNameMap;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default Highlight;
|
||||
export { highlightProps } from './Highlight';
|
||||
export type { HighlightProps } from './Highlight';
|
||||
export type { HighlightThemeVars } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
vanHighlight: typeof Highlight;
|
||||
}
|
||||
}
|
||||
10
node_modules/vant/es/highlight/index.mjs
generated
vendored
Normal file
10
node_modules/vant/es/highlight/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { withInstall } from "../utils/index.mjs";
|
||||
import _Highlight from "./Highlight.mjs";
|
||||
const Highlight = withInstall(_Highlight);
|
||||
var stdin_default = Highlight;
|
||||
import { highlightProps } from "./Highlight.mjs";
|
||||
export {
|
||||
Highlight,
|
||||
stdin_default as default,
|
||||
highlightProps
|
||||
};
|
||||
1
node_modules/vant/es/highlight/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/es/highlight/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
2
node_modules/vant/es/highlight/style/index.mjs
generated
vendored
Normal file
2
node_modules/vant/es/highlight/style/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import "../../style/base.css";
|
||||
import "../index.css";
|
||||
3
node_modules/vant/es/highlight/types.d.ts
generated
vendored
Normal file
3
node_modules/vant/es/highlight/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export type HighlightThemeVars = {
|
||||
highlightTagColor?: string;
|
||||
};
|
||||
0
node_modules/vant/es/highlight/types.mjs
generated
vendored
Normal file
0
node_modules/vant/es/highlight/types.mjs
generated
vendored
Normal file
Reference in New Issue
Block a user