Skip to content

Commit 7c394e6

Browse files
authored
feat: add activeLine option (#128)
1 parent 44b1aab commit 7c394e6

5 files changed

Lines changed: 34 additions & 16 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze-editor/preset-universal-code",
5+
"comment": "支持关闭activeLine",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@coze-editor/preset-universal-code",
10+
"email": "zhangyi.hanchayi@bytedance.com"
11+
}

packages/text-editor/dev/src/pages/highlight/index.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ import { useState } from 'react';
55
import { examples } from './examples';
66
import { createEditor } from '@coze-editor/editor/react';
77

8-
const CodeHighlight = createEditor([
9-
...universal,
10-
...universalCode,
11-
...autoLanguage,
12-
], {
13-
defaultOptions: {
14-
fontSize: 15,
15-
readOnly: true,
16-
editable: false,
17-
}
18-
})
8+
const CodeHighlight = createEditor(
9+
[...universal, ...universalCode, ...autoLanguage],
10+
{
11+
defaultOptions: {
12+
fontSize: 15,
13+
readOnly: true,
14+
editable: false,
15+
},
16+
},
17+
);
1918

2019
const HighlightPage = () => {
2120
const [code, setCode] = useState('const a = 1;');
@@ -49,6 +48,7 @@ const HighlightPage = () => {
4948
options={{
5049
value: code,
5150
path: path,
51+
activeLine: false,
5252
}}
5353
didMount={api => {
5454
console.log('didMount', api);

packages/text-editor/preset-universal-code/src/extension.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import {
66
drawSelection,
77
dropCursor,
88
EditorView,
9-
highlightActiveLine,
10-
highlightActiveLineGutter,
119
highlightSpecialChars,
1210
keymap,
1311
rectangularSelection,
@@ -34,7 +32,6 @@ import {
3432
} from '@codemirror/autocomplete';
3533

3634
export const basicSetup = (() => [
37-
highlightActiveLineGutter(),
3835
highlightSpecialChars(),
3936
history(),
4037
drawSelection(),
@@ -47,7 +44,6 @@ export const basicSetup = (() => [
4744
autocompletion(),
4845
rectangularSelection(),
4946
crosshairCursor(),
50-
highlightActiveLine(),
5147
keymap.of([
5248
...defaultKeymap,
5349
...closeBracketsKeymap,

packages/text-editor/preset-universal-code/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import {
1313
type InferEditorAPIFromPlugins,
1414
option,
1515
} from '@coze-editor/core';
16-
import { EditorView, lineNumbers } from '@codemirror/view';
16+
import {
17+
EditorView,
18+
highlightActiveLine,
19+
highlightActiveLineGutter,
20+
lineNumbers,
21+
} from '@codemirror/view';
1722
import { EditorState, Prec } from '@codemirror/state';
1823
import { foldGutter, indentUnit } from '@codemirror/language';
1924

@@ -47,6 +52,9 @@ const preset = [
4752
),
4853
]),
4954

55+
option('activeLine', (enable = true) =>
56+
enable ? [highlightActiveLineGutter(), highlightActiveLine()] : [],
57+
),
5058
option('tabSize', tabSize),
5159
option('height', height),
5260
option('minHeight', minHeight),

rush.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,16 +810,19 @@
810810
{
811811
"packageName": "@coze-editor/preset-universal-code",
812812
"projectFolder": "packages/text-editor/preset-universal-code",
813+
"shouldPublish": true,
813814
"tags": ["level-3"]
814815
},
815816
{
816817
"packageName": "@coze-editor/vscode-search",
817818
"projectFolder": "packages/text-editor/vscode-search",
819+
"shouldPublish": true,
818820
"tags": ["level-3"]
819821
},
820822
{
821823
"packageName": "@coze-editor/vscode-themes",
822824
"projectFolder": "packages/text-editor/vscode-themes",
825+
"shouldPublish": true,
823826
"tags": ["level-3"]
824827
},
825828
// {

0 commit comments

Comments
 (0)