Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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/code-language-typescript",
"comment": "remote ts dependency",
"type": "patch"
}
],
"packageName": "@coze-editor/code-language-typescript",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze-editor/preset-code",
"comment": "preset code",
"type": "minor"
}
],
"packageName": "@coze-editor/preset-code",
"email": "[email protected]"
}
28 changes: 28 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.

4 changes: 1 addition & 3 deletions packages/text-editor/code-language-typescript/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
} from 'vscode-languageserver-types';
import {
type CompletionEntryDetails,
DiagnosticCategory,
displayPartsToString,
type FormatCodeSettings,
} from 'typescript';
import mitt from 'mitt';
Expand All @@ -29,7 +27,7 @@ import type {
TransactionSpec,
} from '@codemirror/state';

import { tagToString } from './utils';
import { DiagnosticCategory, displayPartsToString, tagToString } from './utils';
import type { InitializeOptions, ITypeScriptWorker } from './types';
import { asCompletionItemKind } from './as';

Expand Down
17 changes: 16 additions & 1 deletion packages/text-editor/code-language-typescript/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: MIT

import type ts from 'typescript';
import { type SymbolDisplayPart } from 'typescript';

function tagToString(tag: ts.JSDocTagInfo): string {
let tagLabel = `*@${tag.name}*`;
Expand All @@ -19,4 +20,18 @@ function tagToString(tag: ts.JSDocTagInfo): string {
return tagLabel;
}

export { tagToString };
function displayPartsToString(displayParts?: SymbolDisplayPart[]) {
if (displayParts) {
return displayParts.map(displayPart2 => displayPart2.text).join('');
}
return '';
}

enum DiagnosticCategory {
Warning = 0,
Error = 1,
Suggestion = 2,
Message = 3,
}

export { tagToString, displayPartsToString, DiagnosticCategory };
2 changes: 2 additions & 0 deletions packages/text-editor/preset-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"@coze-editor/vscode": "workspace:*",
"@lezer/highlight": "~1.2.0",
"@nozbe/microfuzz": "^1.0.0",
"@shikijs/langs": "~3.12.0",
"@shikijs/themes": "~3.12.0",
"codemirror-shiki": "^0.2.2",
"marked": "^15.0.7",
"marked-shiki": "^1.2.0",
Expand Down
23 changes: 19 additions & 4 deletions packages/text-editor/preset-code/src/highlighter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
// Copyright (c) 2025 coze-dev
// SPDX-License-Identifier: MIT

import { createHighlighter } from 'shiki';
import { createOnigurumaEngine } from 'shiki/engine/oniguruma';
import { createHighlighterCore } from 'shiki/core';

const highlighterPromise = createHighlighter({
langs: ['md', 'js', 'ts', 'python'],
themes: ['github-dark', 'one-dark-pro'],
// const highlighterPromise = createHighlighter({
// langs: ['md', 'js', 'ts', 'python'],
// themes: ['github-dark', 'one-dark-pro'],
// });

const highlighterPromise = createHighlighterCore({
langs: [
() => import('@shikijs/langs/markdown'),
() => import('@shikijs/langs/javascript'),
() => import('@shikijs/langs/typescript'),
() => import('@shikijs/langs/python'),
],
themes: [
() => import('@shikijs/themes/github-dark'),
() => import('@shikijs/themes/one-dark-pro'),
],
engine: createOnigurumaEngine(import('shiki/wasm')),
});

export { highlighterPromise };