0.36.2 • Published 6 days ago

@markprompt/web v0.36.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

Markprompt Web

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.

Installation

Install the package from NPM:

npm add @markprompt/web @markprompt/css

Usage

Include the CSS on your page, via a link tag or by importing it in your JavaScript:

<!-- load from a CDN: -->
<link rel="stylesheet" href="https://esm.sh/@markprompt/css@0.30.1?css" />
import '@markprompt/css';

Call the markprompt function with your project key:

import { markprompt } from '@markprompt/web';

const markpromptEl = document.querySelector('#markprompt');

markprompt('YOUR-PROJECT-KEY', markpromptEl, {
  references: {
    getHref: (reference) => reference.file.path.replace(/\.[^.]+$/, '');
    getLabel: (reference) => {
      return reference.meta?.leadHeading?.value || reference.file?.title;
    }
  },
});

where YOUR-PROJECT-KEY can be obtained in your project settings on Markprompt.com.

Options are optional and allow you to configure the texts and links used in the component to some extent. You will most likely want to pass references.getHref and reference.getLabel to transform your prompt references into links to your corresponding documentation, and search.getHref to transform search result paths into links to your documentation.

Styles are easily overridable for customization via targeting classes. Additionally, see the theming section 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:

<link rel="stylesheet" href="https://esm.sh/@markprompt/css@latest?css" />
<script>
  window.markprompt = {
    projectKey: `YOUR-PROJECT-KEY`,
    container: `#markprompt`,
    options: {
      references: {
        getHref: (reference) => reference.file?.path?.replace(/\.[^.]+$/, ''),
        getLabel: (reference) => {
          return reference.meta?.leadHeading?.value || reference.file?.title;
        },
      },
    },
  };
</script>
<script type="module" src="https://esm.sh/@markprompt/web@latest/init"></script>

<div id="markprompt"></div>

!IMPORTANT Consider locking the versions of your dependencies to avoid breaking changes. Always use versions that have been published at the same time.

API

markprompt(projectKey, container, options?)

Render a Markprompt dialog button.

Arguments

  • projectKey (string): Your Markprompt project key.
  • container (HTMLElement | string): The element or selector to render Markprompt into.
  • options (object): Options for customizing Markprompt, see above.

When rendering the Markprompt component, it will render a search input-like button by default. You have two other options:

  • set trigger.floating = true to render a floating button
  • set trigger.customElement = true, then import { openMarkprompt } from '@markprompt/react' and call openMarkprompt() from your code. This gives you the flexibility to render your own trigger element and attach whatever event handlers you would like and/or open the Markprompt dialog programmatically.

markpromptOpen()

Open the Markprompt dialog programmatically.

markpromptClose()

Close the Markprompt dialog programmatically.

markpromptChat(projectKey, container, options?)

Render the Markprompt chat view standalone, outside of a dialog.

  • projectKey (string): Your Markprompt project key.
  • container (HTMLElement | string): The element or selector to render Markprompt into.
  • options (object): Options for customizing Markprompt.

ticketDeflectionForm(container, options)

Renders a standalone ticket deflection form into the provided container.

  • container (HTMLElement | string): The element or selector to render the form into.
  • options (object): Options for customizing the form, see below.

Documentation

Find the full documentation and implementation examples for the SDK on the Markprompt docs.

Community

Authors

This library is created by the team behind Markprompt (@markprompt).

License

MIT © Markprompt

0.36.2

6 days ago

0.36.1

7 days ago

0.36.0

7 days ago

0.34.3

7 days ago

0.34.2

8 days ago

0.35.0

7 days ago

0.34.1

11 days ago

0.34.0

15 days ago

0.33.0

25 days ago

0.32.0

26 days ago

0.31.0

1 month ago

0.30.7

2 months ago

0.30.6

2 months ago

0.30.5

2 months ago

0.30.4

2 months ago

0.30.3

2 months ago

0.30.2

3 months ago

0.30.1

3 months ago

0.30.0

3 months ago

0.29.0

3 months ago

0.28.7

3 months ago

0.28.6

3 months ago

0.28.5

3 months ago

0.28.4

3 months ago

0.28.3

3 months ago

0.28.2

3 months ago

0.28.1

3 months ago

0.27.0

3 months ago

0.28.0

3 months ago

0.26.2

3 months ago

0.26.1

3 months ago

0.26.0

3 months ago

0.25.2

4 months ago

0.25.1

4 months ago

0.25.0

4 months ago

0.24.0

4 months ago

0.23.0

4 months ago

0.22.0

4 months ago

0.21.9

4 months ago

0.21.8

4 months ago

0.21.7

5 months ago

0.21.6

5 months ago

0.21.5

5 months ago

0.21.4

5 months ago

0.21.3

5 months ago

0.21.2

5 months ago

0.21.1

5 months ago

0.21.0

5 months ago

0.20.8

6 months ago

0.20.7

6 months ago

0.8.8

11 months ago

0.8.5

11 months ago

0.8.4

11 months ago

0.8.7

11 months ago

0.8.6

11 months ago

0.20.1

7 months ago

0.20.0

7 months ago

0.13.6

10 months ago

0.13.7

10 months ago

0.13.8

10 months ago

0.13.0

10 months ago

0.13.1

10 months ago

0.13.2

10 months ago

0.13.3

10 months ago

0.17.0

9 months ago

0.13.4

10 months ago

0.13.5

10 months ago

0.9.4

11 months ago

0.9.3

11 months ago

0.9.6

11 months ago

0.9.5

11 months ago

0.18.1

8 months ago

0.18.2

8 months ago

0.14.0

10 months ago

0.14.1

10 months ago

0.14.2

10 months ago

0.14.3

10 months ago

0.18.0

8 months ago

0.10.0

11 months ago

0.8.3

11 months ago

0.19.8

7 months ago

0.19.9

7 months ago

0.19.0

8 months ago

0.19.1

8 months ago

0.19.2

8 months ago

0.19.3

8 months ago

0.19.4

8 months ago

0.19.5

8 months ago

0.19.6

8 months ago

0.19.7

7 months ago

0.11.0

11 months ago

0.15.0

10 months ago

0.9.0

11 months ago

0.9.2

11 months ago

0.9.1

11 months ago

0.12.0

10 months ago

0.12.1

10 months ago

0.12.2

10 months ago

0.16.0

9 months ago

0.16.1

9 months ago

0.19.10

7 months ago

0.20.6

6 months ago

0.20.5

7 months ago

0.20.4

7 months ago

0.20.3

7 months ago

0.20.2

7 months ago

0.8.1

11 months ago

0.8.0

11 months ago

0.8.2

11 months ago

0.5.0

11 months ago

0.7.0

11 months ago

0.4.1

12 months ago

0.4.0

12 months ago

0.6.0

11 months ago

0.3.5

1 year ago

0.3.4

1 year ago

0.3.3-beta1

1 year ago

0.3.3

1 year ago

0.3.2-beta8

1 year ago

0.3.2-beta7

1 year ago

0.3.2-beta6

1 year ago

0.3.2-beta5

1 year ago

0.3.2-beta4

1 year ago

0.3.2-beta3

1 year ago

0.3.2-beta2

1 year ago

0.3.2-beta1

1 year ago

0.3.2

1 year ago

0.3.1-beta4

1 year ago

0.3.1-beta3

1 year ago

0.3.1-beta2

1 year ago

0.3.1-beta1

1 year ago

0.2.3

1 year ago

0.2.2-beta44

1 year ago

0.2.2-beta43

1 year ago

0.2.2-beta42

1 year ago

0.2.2-beta41

1 year ago

0.2.2-beta40

1 year ago

0.2.2-beta39

1 year ago

0.2.2-beta38

1 year ago

0.2.2-beta37

1 year ago

0.2.2-beta35

1 year ago

0.2.2-beta34

1 year ago

0.2.2-beta33

1 year ago

0.2.2-beta32

1 year ago

0.2.2-beta31

1 year ago

0.2.2-beta30

1 year ago

0.2.2-beta29

1 year ago

0.2.2-beta28

1 year ago

0.2.2-beta27

1 year ago

0.2.2-beta26

1 year ago

0.2.2-beta25

1 year ago

0.2.2-beta24

1 year ago

0.2.2-beta23

1 year ago

0.2.2-beta21

1 year ago

0.2.2-beta20

1 year ago

0.2.2-beta19

1 year ago

0.2.2-beta18

1 year ago

0.2.2-beta17

1 year ago

0.2.2-beta16

1 year ago

0.2.2-beta15

1 year ago

0.2.2-beta14

1 year ago

0.2.2-beta13

1 year ago

0.2.2-beta12

1 year ago

0.2.2-beta11

1 year ago

0.2.2-beta10

1 year ago

0.2.2-beta9

1 year ago

0.2.2-beta8

1 year ago

0.2.2-beta7

1 year ago

0.2.2-beta6

1 year ago

0.2.2-beta5

1 year ago

0.2.2-beta4

1 year ago

0.2.2-beta3

1 year ago

0.2.2-beta2

1 year ago

0.2.2-beta1

1 year ago

0.2.1-beta5

1 year ago

0.2.1-beta4

1 year ago

0.2.1-beta3

1 year ago

0.2.1-beta2

1 year ago

0.2.1-beta1

1 year ago

0.2.1-beta.1

1 year ago

0.2.0

1 year ago