+ // Always show as editable Monaco editor when editable=true
+ const code_block = editableBoolean ? (
+
+ setCode(value || '')}
+ language={language}
+ theme={colorMode === 'dark' ? 'vs-dark' : 'vs-light'}
+ height={`${Math.max(200, (code.split('\n').length + 2) * 19)}px`}
+ options={{
+ minimap: { enabled: false },
+ scrollBeyondLastLine: false,
+ fontSize: 14,
+ lineNumbers: showLineNumbers ? 'on' : 'off',
+ wordWrap: 'on',
+ automaticLayout: true,
+ tabSize: 2,
+ insertSpaces: true,
+ folding: false,
+ glyphMargin: false,
+ lineDecorationsWidth: 0,
+ lineNumbersMinChars: 3,
+ renderLineHighlight: 'line',
+ selectOnLineNumbers: true,
+ roundedSelection: false,
+ scrollbar: {
+ verticalScrollbarSize: 8,
+ horizontalScrollbarSize: 8
+ }
+ }}
+ />
+
+ ) : (
+ click_ui === 'true' ? (
+
+ {code}
+
+ ) : (
+
+ )
)
- const results = runnable ? (
+
+ const results = runnableBoolean ? (
- ): null
+ ) : null
return (
-
-
- { header }
- { code_block }
- { results }
-
-
-
-
+
+
+ {header}
+ {code_block}
+ {results}
+
+
)
}
-export default CodeViewer
+export default CodeViewer
\ No newline at end of file
diff --git a/src/components/KapaAI/KapaLink.tsx b/src/components/KapaAI/KapaLink.tsx
new file mode 100644
index 00000000000..f77c24f6b5e
--- /dev/null
+++ b/src/components/KapaAI/KapaLink.tsx
@@ -0,0 +1,22 @@
+import React from 'react';
+
+declare global {
+ interface Window {
+ Kapa?: (action: string, params?: any) => void;
+ }
+}
+
+export default function KapaLink({ children, query }) {
+ const handleClick = (e) => {
+ e.preventDefault();
+ if (window.Kapa) {
+ window.Kapa('open', query ? { query, submit: true } : {});
+ }
+ };
+
+ return (
+
+ {children}
+
+ );
+}
\ No newline at end of file
diff --git a/src/theme/CodeBlock/index.js b/src/theme/CodeBlock/index.js
index 1d523f36c26..d4b7408d5b3 100644
--- a/src/theme/CodeBlock/index.js
+++ b/src/theme/CodeBlock/index.js
@@ -18,7 +18,7 @@ function countLines(text = '') {
function parseMetaString(meta = '') {
const result = {}
- const implicit_settings = ['runnable', 'run', 'show_statistics', 'click_ui']
+ const implicit_settings = ['runnable', 'run', 'show_statistics', 'click_ui', 'editable']
meta.split(' ').forEach((part) => {
if (!part) return
diff --git a/src/theme/MDXComponents.js b/src/theme/MDXComponents.js
index 07b73d1081c..395d61909f3 100644
--- a/src/theme/MDXComponents.js
+++ b/src/theme/MDXComponents.js
@@ -6,10 +6,12 @@ import MDXComponents from '@theme-original/MDXComponents';
// Make sure the path matches your project structure
import VStepper from '@site/src/components/Stepper/Stepper';
import GlossaryTooltip from '@site/src/components/GlossaryTooltip/GlossaryTooltip';
+import KapaLink from '@site/src/components/KapaAI/KapaLink';
// Define the enhanced components
const enhancedComponents = {
...MDXComponents,
+ KapaLink,
GlossaryTooltip,
ul: (props) => ,
ol: (props) =>
,
diff --git a/yarn.lock b/yarn.lock
index a8ff506a886..351f6feaed5 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2700,6 +2700,20 @@
"@module-federation/runtime" "0.8.4"
"@module-federation/sdk" "0.8.4"
+"@monaco-editor/loader@^1.5.0":
+ version "1.5.0"
+ resolved "https://registry.yarnpkg.com/@monaco-editor/loader/-/loader-1.5.0.tgz#dcdbc7fe7e905690fb449bed1c251769f325c55d"
+ integrity sha512-hKoGSM+7aAc7eRTRjpqAZucPmoNOC4UUbknb/VNoTkEIkCPhqV8LfbsgM1webRM7S/z21eHEx9Fkwx8Z/C/+Xw==
+ dependencies:
+ state-local "^1.0.6"
+
+"@monaco-editor/react@^4.7.0":
+ version "4.7.0"
+ resolved "https://registry.yarnpkg.com/@monaco-editor/react/-/react-4.7.0.tgz#35a1ec01bfe729f38bfc025df7b7bac145602a60"
+ integrity sha512-cyzXQCtO47ydzxpQtCGSQGOC8Gk3ZUeBXFAxD+CWXYFo5OqZyZUonFl0DwUlTyAfRHntBfw2p3w4s9R6oe1eCA==
+ dependencies:
+ "@monaco-editor/loader" "^1.5.0"
+
"@napi-rs/wasm-runtime@^0.2.9":
version "0.2.9"
resolved "https://registry.yarnpkg.com/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.9.tgz#7278122cf94f3b36d8170a8eee7d85356dfa6a96"
@@ -13041,6 +13055,11 @@ srcset@^4.0.0:
resolved "https://registry.yarnpkg.com/srcset/-/srcset-4.0.0.tgz#336816b665b14cd013ba545b6fe62357f86e65f4"
integrity sha512-wvLeHgcVHKO8Sc/H/5lkGreJQVeYMm9rlmt8PuR1xE31rIuXhuzznUUqAt8MqLhB3MqJdFzlNAfpcWnxiFUcPw==
+state-local@^1.0.6:
+ version "1.0.7"
+ resolved "https://registry.yarnpkg.com/state-local/-/state-local-1.0.7.tgz#da50211d07f05748d53009bee46307a37db386d5"
+ integrity sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==
+
statuses@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63"