mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-03 18:54:21 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f2c745b553 |
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix UX issue about highlighting the search term in search result sections
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix three small visual issues
|
||||||
|
|
||||||
|
- Fix sidebar showing on `no-toc` pages in the gradient theme
|
||||||
|
- Fix variant selector truncating incorrectly in header when sections are present
|
||||||
|
- Fix page cover alignment on `lg` screens without TOC
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Respect fullWidth and defaultWidth for images
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Hide scrollbar on sections
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add docs.testgitbook.com to ADAPTIVE_CONTENT_HOSTS list
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix nested a tag causing hydration error
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix href being empty in TOC
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix navigation between sections/variants when previewing a site in v2
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for inline icons.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix revision id for computed content
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add circular corners and depth styling
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix crash when integration script fails to render block.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add authorization header for OAuth2
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"gitbook": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Display MCP tool calls in AI chat.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve support for OAuth2 security type
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Adds Columns layout block to GBO
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Support dark-mode specific page cover image
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Update Models page styling
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Show scrollbars
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Optimize performances by using a smarter per-request cache arround data cached functions
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
add a force-revalidate api route to force bust the cache in case of errors
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for icons in buttons.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix rendering of ogimage with SVG logos.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Best effort at preserving current variant when navigating between sections by matching the pathname against site spaces in the new section.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix crash when integration is triggering invalid requests.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Optimize the fetch of revision files by using only the getRevision cache.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
encode customization header
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Rework full-width layout, add support for full-width page option
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix CodeBlock layout
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Scroll to active TOC when clicking a link
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix ISR on preview env
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for text alignment for headings and paragraphs.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix concurrent execution in Vercel causing pages to not be attached to the proper tags.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@gitbook/react-contentkit": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add basic error handling when transitioning between states.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Generate a llms-full.txt version of the docs site
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Don't crash ogimage generation on RTL text, as a workaround until we can support it.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for site customization option to change how external links open.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@gitbook/fonts": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Initial version of the package
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix rendering of ogimage when logo or icon are AVIF images.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add margin to adjacent buttons
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix ogimage generation failing with some JPEG images.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix page group not expanded by default
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Don't cache unexpected API errors for more than a few minutes.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix an issue where PDF export URLs were not keeping their query params.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix markdown page generation for groups
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
add a global error boundary
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"gitbook": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix links to other spaces within a section.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Indent JSON python code sample
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"gitbook": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add support for cover repositioning
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Handle nullish OpenAPI mediaTypeObject
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix missing title on button to close the announcement banner.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Make icons for page groups more contrasting
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"gitbook": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add AI chat
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Ignore case while highlighting search results.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Consistently show variant selector in section bar if site has sections
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'gitbook': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Include page group children under the .md route
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Make TOC height dynamic based on visible header and footer elements
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Clicking an active TOC item toggles its descendants
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix viewing a page from a revision
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix InlineLinkTooltip having a negative impact on performance, especially on larger pages.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/openapi-parser': patch
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Optional label in OpenAPI x-codeSamples
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix bold header links hover color
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
cache fonts and static image used in OGImage in memory
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix border being added to cards
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add metadata for adding site to Apple devices home
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Handle nested deprecated properties in generateSchemaExample
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix crash during rendering of ogimage for VA sites with default icon.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add `urlObject.hash` to `linker.toLinkForContent` to pass through URL fragment identifiers, used in search
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Allow to zoom images on mobile if relevant
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
apply customization for dynamic context
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Reverse order of feedback smileys
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Deduplicate path parameters from OpenAPI spec
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix ogimage using incorrect Google Font depending on language.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
gitbook: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
remove trailing slash from linker
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
name: 'Setup Playwright'
|
||||||
|
description: 'Install Playwright and dependencies'
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
# Run npm ci and get Playwright version
|
||||||
|
- name: 🏗 Prepare Playwright env
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
PLAYWRIGHT_VERSION=$(npm ls --json @playwright/test | jq --raw-output '.dependencies["gitbook"].dependencies["@playwright/test"].version')
|
||||||
|
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Cache browser binaries, cache key is based on Playwright version and OS
|
||||||
|
- name: 🧰 Cache Playwright browser binaries
|
||||||
|
uses: actions/cache@v4
|
||||||
|
id: playwright-cache
|
||||||
|
with:
|
||||||
|
path: '~/.cache/ms-playwright'
|
||||||
|
key: '${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}'
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-playwright-
|
||||||
|
|
||||||
|
# Install browser binaries & OS dependencies if cache missed
|
||||||
|
- name: 🏗 Install Playwright browser binaries & OS dependencies
|
||||||
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||||
|
shell: bash
|
||||||
|
working-directory: packages/gitbook
|
||||||
|
run: |
|
||||||
|
bun x playwright install --with-deps chromium
|
||||||
|
|
||||||
|
# Install only the OS dependencies if cache hit
|
||||||
|
- name: 🏗 Install Playwright OS dependencies
|
||||||
|
if: steps.playwright-cache.outputs.cache-hit == 'true'
|
||||||
|
shell: bash
|
||||||
|
working-directory: packages/gitbook
|
||||||
|
run: |
|
||||||
|
bun x playwright install-deps
|
||||||
@@ -102,7 +102,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Visual Testing v2
|
name: Visual Testing v2
|
||||||
needs: deploy-v2-vercel
|
needs: deploy-v2-vercel
|
||||||
timeout-minutes: 15
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -110,8 +110,8 @@ jobs:
|
|||||||
uses: ./.github/composite/setup-bun
|
uses: ./.github/composite/setup-bun
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
- name: Setup Playwright
|
||||||
PUPPETEER_SKIP_DOWNLOAD: 1
|
uses: ./.github/actions/setup-playwright
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
run: bun e2e
|
run: bun e2e
|
||||||
env:
|
env:
|
||||||
@@ -123,7 +123,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Visual Testing v2 (Cloudflare)
|
name: Visual Testing v2 (Cloudflare)
|
||||||
needs: deploy-v2-cloudflare
|
needs: deploy-v2-cloudflare
|
||||||
timeout-minutes: 15
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -131,8 +131,8 @@ jobs:
|
|||||||
uses: ./.github/composite/setup-bun
|
uses: ./.github/composite/setup-bun
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
- name: Setup Playwright
|
||||||
PUPPETEER_SKIP_DOWNLOAD: 1
|
uses: ./.github/actions/setup-playwright
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
run: bun e2e
|
run: bun e2e
|
||||||
env:
|
env:
|
||||||
@@ -144,7 +144,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Visual Testing Customers v2
|
name: Visual Testing Customers v2
|
||||||
needs: deploy-v2-vercel
|
needs: deploy-v2-vercel
|
||||||
timeout-minutes: 15
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -152,8 +152,8 @@ jobs:
|
|||||||
uses: ./.github/composite/setup-bun
|
uses: ./.github/composite/setup-bun
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
- name: Setup Playwright
|
||||||
PUPPETEER_SKIP_DOWNLOAD: 1
|
uses: ./.github/actions/setup-playwright
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
run: bun e2e-customers
|
run: bun e2e-customers
|
||||||
env:
|
env:
|
||||||
@@ -165,7 +165,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Visual Testing Customers v2 (Cloudflare)
|
name: Visual Testing Customers v2 (Cloudflare)
|
||||||
needs: deploy-v2-cloudflare
|
needs: deploy-v2-cloudflare
|
||||||
timeout-minutes: 15
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -173,8 +173,8 @@ jobs:
|
|||||||
uses: ./.github/composite/setup-bun
|
uses: ./.github/composite/setup-bun
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
env:
|
- name: Setup Playwright
|
||||||
PUPPETEER_SKIP_DOWNLOAD: 1
|
uses: ./.github/actions/setup-playwright
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
run: bun e2e-customers
|
run: bun e2e-customers
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ To run a local version of this project, please follow these simple steps.
|
|||||||
|
|
||||||
- Node.js (Version: >=20.6)
|
- Node.js (Version: >=20.6)
|
||||||
- Use nvm for easy Node management
|
- Use nvm for easy Node management
|
||||||
- [Bun](https://bun.sh/) (Version: >=1.2.15)
|
- Bun (Version: >=1.2.1)
|
||||||
- We use a text-based lockfile which isn't supported below 1.2.15
|
- We use a text-based lockfile which isn't supported below 1.2.1
|
||||||
|
|
||||||
### Set up
|
### Set up
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -18,12 +18,10 @@
|
|||||||
"**/.vercel/**/*",
|
"**/.vercel/**/*",
|
||||||
"**/.cache/**/*",
|
"**/.cache/**/*",
|
||||||
"**/.wrangler/**/*",
|
"**/.wrangler/**/*",
|
||||||
"packages/embed/standalone/**/*",
|
|
||||||
"packages/openapi-parser/src/fixtures/**/*",
|
"packages/openapi-parser/src/fixtures/**/*",
|
||||||
"packages/emoji-codepoints/index.ts",
|
"packages/emoji-codepoints/index.ts",
|
||||||
"packages/icons/src/data/*.json",
|
"packages/icons/src/data/*.json",
|
||||||
"packages/gitbook/worker-configuration.d.ts",
|
"packages/gitbook/worker-configuration.d.ts"
|
||||||
"**/*.css"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"formatter": {
|
"formatter": {
|
||||||
|
|||||||
+1
-2
@@ -34,8 +34,7 @@
|
|||||||
"workspaces": {
|
"workspaces": {
|
||||||
"packages": ["packages/*"],
|
"packages": ["packages/*"],
|
||||||
"catalog": {
|
"catalog": {
|
||||||
"@gitbook/api": "^0.136.0",
|
"@gitbook/api": "^0.125.0"
|
||||||
"bidc": "^0.0.2"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
dist/
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# @gitbook/browser-types
|
|
||||||
|
|
||||||
## 0.1.0
|
|
||||||
|
|
||||||
### Minor Changes
|
|
||||||
|
|
||||||
- cbc71a5: First version of the public package for typing script integrations.
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 854c448: Custom assistants followup
|
|
||||||
- Updated dependencies [25e2b40]
|
|
||||||
- @gitbook/icons@0.3.0
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# `@gitbook/browser-types`
|
|
||||||
|
|
||||||
Typescript types for the global variables available in a GitBook website. These types can be used by integrations embedding scripts.
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@gitbook/browser-types",
|
|
||||||
"description": "Typescript types for the global variables available in a GitBook website. These types can be used by integrations embedding scripts.",
|
|
||||||
"type": "module",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./dist/index.d.ts",
|
|
||||||
"default": "./dist/index.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"version": "0.1.0",
|
|
||||||
"dependencies": {
|
|
||||||
"@gitbook/api": "catalog:",
|
|
||||||
"@gitbook/icons": "workspace:"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"typescript": "^5.5.3"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "tsc",
|
|
||||||
"typecheck": "tsc --noEmit"
|
|
||||||
},
|
|
||||||
"files": ["dist", "README.md", "CHANGELOG.md"]
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
import type { AIToolCallResult, AIToolDefinition } from '@gitbook/api';
|
|
||||||
import type { IconName } from '@gitbook/icons';
|
|
||||||
|
|
||||||
export type GitBookIntegrationEvent = 'load' | 'unload';
|
|
||||||
|
|
||||||
export type GitBookIntegrationEventCallback = (...args: any[]) => void;
|
|
||||||
|
|
||||||
export type GitBookIntegrationTool = AIToolDefinition & {
|
|
||||||
/**
|
|
||||||
* Confirmation action to be displayed to the user before executing the tool.
|
|
||||||
*/
|
|
||||||
confirmation?: {
|
|
||||||
icon?: IconName;
|
|
||||||
label: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback when the tool is executed.
|
|
||||||
* The input is provided by the AI assistant following the input schema of the tool.
|
|
||||||
*/
|
|
||||||
execute: (input: object) => Promise<Pick<AIToolCallResult, 'output' | 'summary'>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GitBookAssistant = {
|
|
||||||
/**
|
|
||||||
* Name of the assistant displayed in the UI.
|
|
||||||
*/
|
|
||||||
label: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Icon of the assistant displayed in the UI.
|
|
||||||
* Any FontAwesome icon name is supported.
|
|
||||||
* @example 'sparkle'
|
|
||||||
*/
|
|
||||||
icon: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback when the assistant is opened.
|
|
||||||
*/
|
|
||||||
open: (query?: string) => void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to display the triggers for this assistant in the UI.
|
|
||||||
* @default true
|
|
||||||
*/
|
|
||||||
ui?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GitBookGlobal = {
|
|
||||||
/**
|
|
||||||
* Register an event listener.
|
|
||||||
*/
|
|
||||||
addEventListener: (
|
|
||||||
type: GitBookIntegrationEvent,
|
|
||||||
func: GitBookIntegrationEventCallback
|
|
||||||
) => void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove an event listener.
|
|
||||||
*/
|
|
||||||
removeEventListener: (
|
|
||||||
type: GitBookIntegrationEvent,
|
|
||||||
func: GitBookIntegrationEventCallback
|
|
||||||
) => void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a custom tool to be exposed to the AI assistant.
|
|
||||||
*/
|
|
||||||
registerTool: (tool: GitBookIntegrationTool) => void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a custom assistant to be available on the site.
|
|
||||||
*/
|
|
||||||
registerAssistant: (assistant: GitBookAssistant) => () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
interface Window {
|
|
||||||
/**
|
|
||||||
* Global `window.GitBook` object accessible by integrations.
|
|
||||||
*/
|
|
||||||
GitBook?: GitBookGlobal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "esnext",
|
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
|
||||||
"allowJs": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"strict": true,
|
|
||||||
"noEmit": false,
|
|
||||||
"declaration": true,
|
|
||||||
"outDir": "dist",
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"module": "esnext",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"incremental": true,
|
|
||||||
"types": [
|
|
||||||
"bun-types" // add Bun global
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
||||||
"exclude": ["node_modules"]
|
|
||||||
}
|
|
||||||
@@ -90,7 +90,7 @@ export function getCacheTag(
|
|||||||
| {
|
| {
|
||||||
tag: 'translation';
|
tag: 'translation';
|
||||||
organization: string;
|
organization: string;
|
||||||
translation: string;
|
translationSettings: string;
|
||||||
}
|
}
|
||||||
): string {
|
): string {
|
||||||
switch (spec.tag) {
|
switch (spec.tag) {
|
||||||
@@ -115,7 +115,7 @@ export function getCacheTag(
|
|||||||
case 'openapi':
|
case 'openapi':
|
||||||
return `organization:${spec.organization}:openapi:${spec.openAPISpec}`;
|
return `organization:${spec.organization}:openapi:${spec.openAPISpec}`;
|
||||||
case 'translation':
|
case 'translation':
|
||||||
return `organization:${spec.organization}:translation:${spec.translation}`;
|
return `organization:${spec.organization}:translation:${spec.translationSettings}`;
|
||||||
default:
|
default:
|
||||||
assertNever(spec);
|
assertNever(spec);
|
||||||
}
|
}
|
||||||
@@ -144,10 +144,6 @@ export function getComputedContentSourceCacheTags(
|
|||||||
) {
|
) {
|
||||||
const tags: string[] = [];
|
const tags: string[] = [];
|
||||||
|
|
||||||
if (!('dependencies' in source)) {
|
|
||||||
return tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We add the dependencies as tags, to ensure that the computed content is invalidated
|
// We add the dependencies as tags, to ensure that the computed content is invalidated
|
||||||
// when the dependencies are updated.
|
// when the dependencies are updated.
|
||||||
const dependencies = Object.values(source.dependencies ?? {});
|
const dependencies = Object.values(source.dependencies ?? {});
|
||||||
@@ -171,12 +167,12 @@ export function getComputedContentSourceCacheTags(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'translation':
|
case 'translation-language':
|
||||||
tags.push(
|
tags.push(
|
||||||
getCacheTag({
|
getCacheTag({
|
||||||
tag: 'translation',
|
tag: 'translation',
|
||||||
organization: inContext.organizationId,
|
organization: inContext.organizationId,
|
||||||
translation: dependency.ref.translation,
|
translationSettings: dependency.ref.translationSettings,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
dist/
|
|
||||||
standalone/
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# @gitbook/embed
|
|
||||||
|
|
||||||
## 0.1.0
|
|
||||||
|
|
||||||
### Minor Changes
|
|
||||||
|
|
||||||
- 81a6bd7: Improve API to control the GitBook embed
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 8927e8f: Initial version of the embed SDK.
|
|
||||||
- Updated dependencies [25e2b40]
|
|
||||||
- @gitbook/icons@0.3.0
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
# `@gitbook/embed`
|
|
||||||
|
|
||||||
Embed the GitBook Docs Assistant in your product or website.
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
## As a script from your docs site
|
|
||||||
|
|
||||||
All GitBook docs site includes a script to easily embed the docs assistant as a widget on your website.
|
|
||||||
|
|
||||||
The script is served at `https://docs.company.com/~gitbook/embed/script.js`.
|
|
||||||
|
|
||||||
You can find the embed script from your docs site settings, or you can copy the following and replace the `docs.company.com` by your docs site hostname.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="https://docs.company.com/~gitbook/embed/script.js"></script>
|
|
||||||
<script>
|
|
||||||
window.GitBook('show');
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
## As a package from NPM
|
|
||||||
|
|
||||||
Install the package: `npm install @gitbook/embed` and import it in your web application:
|
|
||||||
|
|
||||||
```tsx
|
|
||||||
import { createGitBook } from '@gitbook/embed';
|
|
||||||
|
|
||||||
const gitbook = createGitBook({
|
|
||||||
siteURL: 'https://docs.company.com'
|
|
||||||
});
|
|
||||||
|
|
||||||
const iframe = document.createElement('iframe');
|
|
||||||
iframe.src = gitbook.getFrameURL();
|
|
||||||
|
|
||||||
const frame = gitbook.createFrame(iframe);
|
|
||||||
```
|
|
||||||
|
|
||||||
## As React components
|
|
||||||
|
|
||||||
After installing the NPM package, you can import prebuilt React components:
|
|
||||||
|
|
||||||
```tsx
|
|
||||||
import { GitBookProvider, GitBookAssistantFrame } from '@gitbook/embed/react';
|
|
||||||
|
|
||||||
<GitBookProvider siteURL="https://docs.company.com">
|
|
||||||
<GitBookAssistantFrame />
|
|
||||||
</GitBookProvider>
|
|
||||||
```
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@gitbook/embed",
|
|
||||||
"description": "Embeddable components for GitBook",
|
|
||||||
"type": "module",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./dist/index.d.ts",
|
|
||||||
"default": "./dist/index.js",
|
|
||||||
"standalone": "./dist/standalone/index.js",
|
|
||||||
"react": "./dist/react/index.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"version": "0.1.0",
|
|
||||||
"dependencies": {
|
|
||||||
"@gitbook/api": "catalog:",
|
|
||||||
"@gitbook/icons": "workspace:",
|
|
||||||
"bidc": "catalog:"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"react": "^18.0.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"typescript": "^5.5.3",
|
|
||||||
"react": "^19.0.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "tsc && bun build src/standalone/index.ts --bundle --minify --outdir=standalone",
|
|
||||||
"typecheck": "tsc --noEmit"
|
|
||||||
},
|
|
||||||
"files": ["dist", "README.md", "CHANGELOG.md", "standalone"]
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
import { type GitBookFrameClient, createGitBookFrame } from './createGitBookFrame';
|
|
||||||
|
|
||||||
export type CreateGitBookOptions = {
|
|
||||||
/**
|
|
||||||
* URL of the GitBook site to embed.
|
|
||||||
*/
|
|
||||||
siteURL: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GetFrameURLOptions = {
|
|
||||||
/**
|
|
||||||
* Authentication to use for the frame.
|
|
||||||
*/
|
|
||||||
visitor?: {
|
|
||||||
/**
|
|
||||||
* Signed JWT token for Adaptive Content or Visitor Authentication to use.
|
|
||||||
*/
|
|
||||||
token?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unsigned claims to pass to the frame.
|
|
||||||
* You can use these claims in dynamic expressions using `visitor.claims.unsigned.<claim-name>`.
|
|
||||||
*/
|
|
||||||
unsignedClaims?: Record<string, unknown>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GitBookClient = {
|
|
||||||
/**
|
|
||||||
* Get the URL for a GitBook frame.
|
|
||||||
*/
|
|
||||||
getFrameURL: (options: GetFrameURLOptions) => string;
|
|
||||||
/**
|
|
||||||
* Create a new GitBook frame.
|
|
||||||
*/
|
|
||||||
createFrame: (iframe: HTMLIFrameElement) => GitBookFrameClient;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function createGitBook(options: CreateGitBookOptions) {
|
|
||||||
const client: GitBookClient = {
|
|
||||||
getFrameURL: (frameOptions) => {
|
|
||||||
const url = new URL(options.siteURL);
|
|
||||||
url.pathname = `${url.pathname.endsWith('/') ? url.pathname : `${url.pathname}/`}~gitbook/embed/assistant`;
|
|
||||||
|
|
||||||
if (frameOptions.visitor?.token) {
|
|
||||||
url.searchParams.set('token', frameOptions.visitor.token);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frameOptions.visitor?.unsignedClaims) {
|
|
||||||
Object.entries(frameOptions.visitor.unsignedClaims).forEach(([key, value]) => {
|
|
||||||
url.searchParams.set(`visitor.${key}`, String(value));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return url.toString();
|
|
||||||
},
|
|
||||||
createFrame: (iframe) => createGitBookFrame(iframe),
|
|
||||||
};
|
|
||||||
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
import { createChannel } from 'bidc';
|
|
||||||
import type {
|
|
||||||
FrameToParentMessage,
|
|
||||||
GitBookEmbeddableConfiguration,
|
|
||||||
ParentToFrameMessage,
|
|
||||||
} from './protocol';
|
|
||||||
|
|
||||||
export type GitBookFrameClient = {
|
|
||||||
/**
|
|
||||||
* Navigate to a page by its path.
|
|
||||||
*/
|
|
||||||
navigateToPage: (path: string) => void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Navigate to the assistant.
|
|
||||||
*/
|
|
||||||
navigateToAssistant: () => void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Post a message to the chat.
|
|
||||||
*/
|
|
||||||
postUserMessage: (message: string) => void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear the chat.
|
|
||||||
*/
|
|
||||||
clearChat: () => void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the placeholder settings.
|
|
||||||
*/
|
|
||||||
configure: (settings: Partial<GitBookEmbeddableConfiguration>) => void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register an event listener.
|
|
||||||
*/
|
|
||||||
on: (event: string, listener: (...args: any[]) => void) => () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a client to communicate with the GitBook Assistant frame.
|
|
||||||
*/
|
|
||||||
export function createGitBookFrame(iframe: HTMLIFrameElement): GitBookFrameClient {
|
|
||||||
if (!iframe.contentWindow) {
|
|
||||||
throw new Error('Iframe must have a content window');
|
|
||||||
}
|
|
||||||
const channel = createChannel(iframe.contentWindow);
|
|
||||||
|
|
||||||
channel.receive((message: FrameToParentMessage) => {
|
|
||||||
console.log('[gitbook:embed] received message', message);
|
|
||||||
if (message.type === 'close') {
|
|
||||||
const listeners = events.get('close') || [];
|
|
||||||
if (listeners) {
|
|
||||||
listeners.forEach((listener) => listener());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const sendToFrame = (message: ParentToFrameMessage) => {
|
|
||||||
console.log('[gitbook:embed] send message', message);
|
|
||||||
channel.send(message);
|
|
||||||
};
|
|
||||||
|
|
||||||
const events = new Map<string, Array<(...args: any[]) => void>>();
|
|
||||||
|
|
||||||
const configuration: GitBookEmbeddableConfiguration = {
|
|
||||||
buttons: [],
|
|
||||||
welcomeMessage: '',
|
|
||||||
suggestions: [],
|
|
||||||
tools: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
navigateToPage: (pagePath) => {
|
|
||||||
sendToFrame({ type: 'navigateToPage', pagePath });
|
|
||||||
},
|
|
||||||
navigateToAssistant: () => {
|
|
||||||
sendToFrame({ type: 'navigateToAssistant' });
|
|
||||||
},
|
|
||||||
postUserMessage: (message) => sendToFrame({ type: 'postUserMessage', message }),
|
|
||||||
configure: (settings) => {
|
|
||||||
Object.assign(configuration, settings);
|
|
||||||
sendToFrame({ type: 'configure', settings: configuration });
|
|
||||||
},
|
|
||||||
clearChat: () => sendToFrame({ type: 'clearChat' }),
|
|
||||||
on: (event, listener) => {
|
|
||||||
const listeners = events.get(event) || [];
|
|
||||||
listeners.push(listener);
|
|
||||||
events.set(event, listeners);
|
|
||||||
return () => {
|
|
||||||
events.set(
|
|
||||||
event,
|
|
||||||
listeners.filter((l) => l !== listener)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export * from './createGitBook';
|
|
||||||
export * from './createGitBookFrame';
|
|
||||||
export * from './protocol';
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import type { AIToolCallResult, AIToolDefinition } from '@gitbook/api';
|
|
||||||
import type { IconName } from '@gitbook/icons';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom tool definition to be passed to the AI assistant.
|
|
||||||
*/
|
|
||||||
export type GitBookToolDefinition = AIToolDefinition & {
|
|
||||||
/**
|
|
||||||
* Confirmation action to be displayed to the user before executing the tool.
|
|
||||||
*/
|
|
||||||
confirmation?: {
|
|
||||||
icon?: IconName;
|
|
||||||
label: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback when the tool is executed.
|
|
||||||
* The input is provided by the AI assistant following the input schema of the tool.
|
|
||||||
*/
|
|
||||||
execute: (input: object) => Promise<Pick<AIToolCallResult, 'output' | 'summary'>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom button definition to be passed to the embeddable GitBook.
|
|
||||||
*/
|
|
||||||
export type GitBookEmbeddableButtonDefinition = {
|
|
||||||
/**
|
|
||||||
* Icon to be displayed in the button.
|
|
||||||
*/
|
|
||||||
icon: IconName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Label to be displayed in the button.
|
|
||||||
*/
|
|
||||||
label: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback when the button is clicked.
|
|
||||||
*/
|
|
||||||
onClick: () => void | Promise<void>;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overall configuration for the layout of the embeddable GitBook.
|
|
||||||
*/
|
|
||||||
export type GitBookEmbeddableConfiguration = {
|
|
||||||
/**
|
|
||||||
* Buttons to be displayed in the header of the embeddable GitBook.
|
|
||||||
*/
|
|
||||||
buttons: GitBookEmbeddableButtonDefinition[];
|
|
||||||
|
|
||||||
/** Message to be displayed in the welcome page. */
|
|
||||||
welcomeMessage: string;
|
|
||||||
|
|
||||||
/** Suggestions of questions to be displayed in the welcome page. */
|
|
||||||
suggestions: string[];
|
|
||||||
|
|
||||||
/** Tools to be provided to the assistant. */
|
|
||||||
tools: GitBookToolDefinition[];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Messages sent from the parent to the frame.
|
|
||||||
*/
|
|
||||||
export type ParentToFrameMessage =
|
|
||||||
| {
|
|
||||||
type: 'postUserMessage';
|
|
||||||
message: string;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: 'clearChat';
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: 'configure';
|
|
||||||
settings: GitBookEmbeddableConfiguration;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: 'navigateToPage';
|
|
||||||
pagePath: string;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: 'navigateToAssistant';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Messages sent from the frame to the parent.
|
|
||||||
*/
|
|
||||||
export type FrameToParentMessage = {
|
|
||||||
type: 'close';
|
|
||||||
};
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export * from './client';
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import type {
|
|
||||||
GetFrameURLOptions,
|
|
||||||
GitBookEmbeddableConfiguration,
|
|
||||||
GitBookFrameClient,
|
|
||||||
} from '../client';
|
|
||||||
import { useGitBook } from './GitBookProvider';
|
|
||||||
|
|
||||||
export type GitBookFrameProps = {
|
|
||||||
className?: string;
|
|
||||||
} & GetFrameURLOptions &
|
|
||||||
GitBookEmbeddableConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render a frame with the GitBook Assistant in it.
|
|
||||||
*/
|
|
||||||
export function GitBookFrame(props: GitBookFrameProps) {
|
|
||||||
const { className, visitor, buttons, welcomeMessage, suggestions, tools } = props;
|
|
||||||
|
|
||||||
const frameRef = React.useRef<HTMLIFrameElement>(null);
|
|
||||||
const gitbook = useGitBook();
|
|
||||||
const [gitbookFrame, setGitbookFrame] = React.useState<GitBookFrameClient | null>(null);
|
|
||||||
|
|
||||||
const frameURL = React.useMemo(() => gitbook.getFrameURL({ visitor }), [gitbook, visitor]);
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (frameRef.current) {
|
|
||||||
setGitbookFrame(gitbook.createFrame(frameRef.current));
|
|
||||||
}
|
|
||||||
}, [gitbook]);
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
gitbookFrame?.configure({
|
|
||||||
buttons,
|
|
||||||
welcomeMessage,
|
|
||||||
suggestions,
|
|
||||||
tools,
|
|
||||||
});
|
|
||||||
}, [gitbookFrame, buttons, welcomeMessage, suggestions, tools]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<iframe
|
|
||||||
title="GitBook"
|
|
||||||
ref={frameRef}
|
|
||||||
src={frameURL}
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
className={className}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import * as React from 'react';
|
|
||||||
import { type CreateGitBookOptions, createGitBook } from '../client';
|
|
||||||
import { GitBookContext } from './context';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provider for the GitBook client.
|
|
||||||
*/
|
|
||||||
export function GitBookProvider(props: React.PropsWithChildren<CreateGitBookOptions>) {
|
|
||||||
const { siteURL, children } = props;
|
|
||||||
|
|
||||||
const options = React.useMemo(
|
|
||||||
() => ({
|
|
||||||
siteURL,
|
|
||||||
}),
|
|
||||||
[siteURL]
|
|
||||||
);
|
|
||||||
|
|
||||||
const client = React.useMemo(() => createGitBook(options), [options]);
|
|
||||||
|
|
||||||
return <GitBookContext.Provider value={client}>{children}</GitBookContext.Provider>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook to access the GitBook client.
|
|
||||||
*/
|
|
||||||
export function useGitBook() {
|
|
||||||
const context = React.useContext(GitBookContext);
|
|
||||||
|
|
||||||
if (!context) {
|
|
||||||
throw new Error('This component must be used within a <GitBookProvider />');
|
|
||||||
}
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import * as React from 'react';
|
|
||||||
import type { GitBookClient } from '../client';
|
|
||||||
|
|
||||||
export const GitBookContext = React.createContext<GitBookClient | null>(null);
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
export * from './GitBookProvider';
|
|
||||||
export * from './GitBookFrame';
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user