Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/core",
"comment": "add chat preset",
"type": "minor"
}
],
"packageName": "@coze-editor/core",
"email": "stream-pipe@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/editor",
"comment": "add chat preset",
"type": "minor"
}
],
"packageName": "@coze-editor/editor",
"email": "stream-pipe@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/preset-chat",
"comment": "add chat preset",
"type": "minor"
}
],
"packageName": "@coze-editor/preset-chat",
"email": "stream-pipe@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/preset-chat",
"comment": "remove unmount",
"type": "patch"
}
],
"packageName": "@coze-editor/preset-chat",
"email": "stream-pipe@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/preset-chat",
"comment": "support customize element.toString",
"type": "minor"
}
],
"packageName": "@coze-editor/preset-chat",
"email": "stream-pipe@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/preset-chat",
"comment": "support array for attribute",
"type": "minor"
}
],
"packageName": "@coze-editor/preset-chat",
"email": "stream-pipe@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/preset-chat",
"comment": "ensure fully parsing",
"type": "patch"
}
],
"packageName": "@coze-editor/preset-chat",
"email": "stream-pipe@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/preset-chat",
"comment": "add options.validTagNames",
"type": "patch"
}
],
"packageName": "@coze-editor/preset-chat",
"email": "stream-pipe@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/preset-chat",
"comment": "skip if custom text is not in clipboard",
"type": "minor"
}
],
"packageName": "@coze-editor/preset-chat",
"email": "stream-pipe@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/react",
"comment": "add chat preset",
"type": "minor"
}
],
"packageName": "@coze-editor/react",
"email": "stream-pipe@users.noreply.github.com"
}
70 changes: 70 additions & 0 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/text-editor/dev/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createRoot } from 'react-dom/client';
import Page from './pages/highlight';
import Page from './pages/chat';
import './index.css';

createRoot(document.getElementById('app')!).render(<Page />);
91 changes: 91 additions & 0 deletions packages/text-editor/dev/src/pages/chat/code.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const code = `/** @flow */

import * as React from 'react';
import {forwardRef} from 'react';
import Bridge from 'react-devtools-shared/src/bridge';
import Store from 'react-devtools-shared/src/devtools/store';
import DevTools from 'react-devtools-shared/src/devtools/views/DevTools';
import {getSavedComponentFilters} from 'react-devtools-shared/src/utils';

import type {Wall} from 'react-devtools-shared/src/frontend/types';
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type {Props} from 'react-devtools-shared/src/devtools/views/DevTools';
import type {Config} from 'react-devtools-shared/src/devtools/store';

export function createStore(bridge: FrontendBridge, config?: Config): Store {
return new Store(bridge, {
checkBridgeProtocolCompatibility: true,
supportsTraceUpdates: true,
supportsTimeline: true,
...config,
});
}

export function createBridge(contentWindow: any, wall?: Wall): FrontendBridge {
if (wall == null) {
wall = {
listen(fn) {
// $FlowFixMe[missing-local-annot]
const onMessage = ({data}) => {
fn(data);
};
window.addEventListener('message', onMessage);
return () => {
window.removeEventListener('message', onMessage);
};
},
send(event: string, payload: any, transferable?: Array<any>) {
contentWindow.postMessage({event, payload}, '*', transferable);
},
};
}

return (new Bridge(wall): FrontendBridge);
}

export function initialize(
contentWindow: any,
{
bridge,
store,
}: {
bridge?: FrontendBridge,
store?: Store,
} = {},
): component(...props: Props) {
if (bridge == null) {
bridge = createBridge(contentWindow);
}

// Type refinement.
const frontendBridge = ((bridge: any): FrontendBridge);

if (store == null) {
store = createStore(frontendBridge);
}

const onGetSavedPreferences = () => {
// This is the only message we're listening for,
// so it's safe to cleanup after we've received it.
frontendBridge.removeListener('getSavedPreferences', onGetSavedPreferences);

const data = {
componentFilters: getSavedComponentFilters(),
};

// The renderer interface can't read saved preferences directly,
// because they are stored in localStorage within the context of the extension.
// Instead it relies on the extension to pass them through.
frontendBridge.send('savedPreferences', data);
};

frontendBridge.addListener('getSavedPreferences', onGetSavedPreferences);

const ForwardRef = forwardRef<Props, mixed>((props, ref) => (
<DevTools ref={ref} bridge={frontendBridge} store={store} {...props} />
));
ForwardRef.displayName = 'DevTools';

return ForwardRef;
}`
export default code
46 changes: 46 additions & 0 deletions packages/text-editor/dev/src/pages/chat/completion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from '@/components/ui/command'
import { SVGProps } from 'react'

function GravityUiCode(props: SVGProps<SVGSVGElement>) {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16" {...props}>{/* Icon from Gravity UI Icons by YANDEX LLC - https://github.com/gravity-ui/icons/blob/main/LICENSE */}<path fill="currentColor" fillRule="evenodd" d="M10.218 3.216a.75.75 0 0 0-1.436-.431l-3 10a.75.75 0 0 0 1.436.43zM4.53 4.97a.75.75 0 0 1 0 1.06L2.56 8l1.97 1.97a.75.75 0 0 1-1.06 1.06l-2.5-2.5a.75.75 0 0 1 0-1.06l2.5-2.5a.75.75 0 0 1 1.06 0m6.94 6.06a.75.75 0 0 1 0-1.06L13.44 8l-1.97-1.97a.75.75 0 0 1 1.06-1.06l2.5 2.5a.75.75 0 0 1 0 1.06l-2.5 2.5a.75.75 0 0 1-1.06 0" clipRule="evenodd" /></svg>
)
}

function GravityUiGhost(props: SVGProps<SVGSVGElement>) {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 16 16" {...props}>{/* Icon from Gravity UI Icons by YANDEX LLC - https://github.com/gravity-ui/icons/blob/main/LICENSE */}<path fill="currentColor" fillRule="evenodd" d="M13.277 11.702L13.5 12V8a5.5 5.5 0 1 0-11 0v4.547l1.956-1.63a1.8 1.8 0 0 1 2.537.231l1.935 2.323a.08.08 0 0 0 .125-.001l1.45-1.811a1.755 1.755 0 0 1 2.774.043m-3.052 2.705l.686-.859h.001l.144-.18l.618-.772a.255.255 0 0 1 .402.006l.593.79l.139.185v.001l.392.522a1 1 0 0 0 1.8-.6V8A7 7 0 1 0 1 8v5.399a1.101 1.101 0 0 0 1.806.846l2.61-2.175a.3.3 0 0 1 .424.038l1.936 2.323a1.58 1.58 0 0 0 2.449-.024M7 8a.75.75 0 0 0 .75-.75v-1a.75.75 0 0 0-1.5 0v1c0 .414.336.75.75.75m4 0a.75.75 0 0 0 .75-.75v-1a.75.75 0 0 0-1.5 0v1c0 .414.336.75.75.75" clipRule="evenodd" /></svg>
)
}

function Completion({ query = '' }: { query: string }) {
return <Command
className="rounded-lg min-w-[160px]"
>
<CommandInput value={query} />
<CommandList>
<CommandEmpty>No results found</CommandEmpty>
<CommandGroup>
<CommandItem>
<GravityUiCode className="text-[12px]" />
<span>files</span>
</CommandItem>
<CommandItem>
<GravityUiGhost className="text-[12px]" />
<span>chat</span>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
}

export {
Completion,
}
Loading