Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@markprompt/web

Package Overview
Dependencies
Maintainers
1
Versions
223
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markprompt/web - npm Package Compare versions

Comparing version 0.3.5 to 0.4.0

dist/init.d.ts

9

dist/index.d.ts

@@ -1,3 +0,8 @@

import 'client-only';
import './markprompt-content';
import { type MarkpromptOptions } from './types.js';
/**
* @param projectKey Your Markprompt project key
* @param container The element or selector to render Markprompt into
* @param options Options for customizing Markprompt
*/
export declare function markprompt(projectKey: string, container: HTMLElement | string, options?: MarkpromptOptions): void;
//# sourceMappingURL=index.d.ts.map
{
"name": "@markprompt/web",
"version": "0.3.5",
"version": "0.4.0",
"description": "A web component for adding GPT-4 powered search using the Markprompt API.",

@@ -13,27 +13,32 @@ "repository": {

"type": "module",
"exports": "./dist/index.js",
"exports": {
".": "./dist/index.js",
"./init": "./dist/init.js"
},
"main": "dist/index.js",
"files": [
"README.md",
"dist"
"dist/globals.*",
"dist/index.*",
"dist/init.*",
"dist/types.*"
],
"scripts": {
"build": "tsc --build --clean && tsc --build",
"dev": "tsc --build --watch",
"prepack": "tsc --build",
"vite": "vite"
"analyze": "node scripts/analyze.js",
"build": "node scripts/build.js",
"dev": "node scripts/dev.js",
"prepack": "node scripts/build.js"
},
"dependencies": {
"@markprompt/core": "0.4.1",
"lit": "^2.7.2",
"rehype-sanitize": "^5.0.1",
"rehype-stringify": "^9.0.3",
"remark-gfm": "^3.0.1",
"remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0",
"unified": "^10.1.2"
"@markprompt/core": "0.4.6"
},
"devDependencies": {
"typescript": "^5.0.4",
"vite": "^4.2.0"
"@markprompt/react": "0.4.0",
"@radix-ui/react-accessible-icon": "^1.0.3",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"esbuild": "^0.17.19",
"preact": "^10.15.1",
"react": "npm:@preact/compat",
"react-dom": "npm:@preact/compat",
"typescript": "^5.0.4"
},

@@ -40,0 +45,0 @@ "publishConfig": {

@@ -1,4 +0,4 @@

# Markprompt Web
# `@markprompt/web`
A Web Component component for building a prompt interface, based on the [Markprompt](https://markprompt.com) API.
A prebuilt version of the Markprompt dialog, based on `@markprompt/react`, built with Preact for bundle-size savings. Viable for use from vanilla JavaScript or any framework.

@@ -17,6 +17,6 @@ <br />

Add the following script tag to your HTML page:
Install the package from NPM:
```html
<script type="module" src="https://esm.sh/@markprompt/web@0.2.2-beta18" />
```sh
npm add @markprompt/web @markprompt/css
```

@@ -26,13 +26,109 @@

Then add the `markprompt-web` component anywhere on your page:
Include the CSS on your page, via a link tag or by importing it in your JavaScript:
```html
<markprompt-content projectKey="<project-key>" />
<!-- load from a CDN: -->
<link rel="stylesheet" href="https://esm.sh/@markprompt/css?css" />
```
where `project-key` can be obtained in your project settings.
```js
import '@markprompt/css';
```
Call the `markprompt` function with your project key:
```js
import { markprompt } from '@markprompt/web';
const markpromptEl = document.querySelector('#markprompt');
markprompt('<project-key>', markpromptEl, {
references: {
transformReferenceId: (referenceId) => ({
text: referenceId.replace('-', ' '),
href: `/docs/${referenceId}`,
}),
},
});
```
where `project-key` can be obtained in your project settings on [Markprompt.com](https://markprompt.com/).
Options are optional and allow you to configure texts the component to some extent. You will most likely want to pass `transformReferenceId` to transform your reference ids into links to your corresponding documentation.
```ts
type Options = {
/** Props for the close modal button */
close?: {
/** Aria-label for the close modal button */
label?: string;
};
/** Props for the description */
description?: {
/** Whether to hide the description, default: `true` */
hide?: boolean;
/** Text for the description */
text?: string;
};
/** Props for the prompt */
prompt?: {
/** Label for the prompt input, default: `Your prompt` */
label?: string;
/** Placeholder for the prompt input, default: `Ask me anything…` */
placeholder?: string;
};
references?: {
/** Callback to transform a reference id into an href and text */
transformReferenceId?: (referenceId: string) => {
href: string;
text: string;
};
/** Loading text, default: `Fetching relevant pages…` */
loadingText?: string;
/** References title, default: `Answer generated from the following sources:` */
referencesText?: string;
};
/** Props for the trigger */
trigger?: {
/** Aria-label for the trigger button */
label?: string;
};
/** Props for the title */
title?: {
/** Whether to hide the title, default: `true` */
hide?: boolean;
/** Text for the title: default `Ask me anything` */
text?: string;
};
};
```
Styles are easily overridable for customization via targeting classes. Additionally, see the [styling section](https://markprompt.com/docs#styling) in our documentation for a full list of variables.
## Usage via `<script>` tag
Besides initializing the Markprompt component yourselves from JavaScript, you can load the script from a CDN. You can attach the options for the Markprompt component to the window prior to loading our script:
```html
<link rel="stylesheet" href="https://esm.sh/@markprompt/css?css" />
<script>
window.markprompt = {
projectKey: `<your-project-key>`,
container: `#markprompt`,
options: {
references: {
transformReferenceId: (referenceId) => ({
text: referenceId.replace('-', ' '),
href: `/docs/${referenceId}`,
}),
},
},
};
</script>
<script async src="https://esm.sh/@markprompt/web"></script>
```
## Documentation
The full documentation for the component can be found on the [Markprompt docs](https://markprompt.com/docs#web-component).
The full documentation for `@markprompt/web` can be found on the [Markprompt docs](https://markprompt.com/docs#%40markprompt%2Fweb).

@@ -39,0 +135,0 @@ ## Community

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc