Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
4d2b953e
Unverified
Commit
4d2b953e
authored
Jul 02, 2024
by
Johnny
Committed by
GitHub
Jul 02, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add enable link preview setting to memo related settings (#3647)
parent
b57b6bae
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
121 additions
and
206 deletions
+121
-206
apidocs.swagger.yaml
docs/apidocs.swagger.yaml
+67
-201
workspace_setting_service.proto
proto/api/v1/workspace_setting_service.proto
+2
-0
workspace_setting_service.pb.go
proto/gen/api/v1/workspace_setting_service.pb.go
+14
-2
workspace_setting.pb.go
proto/gen/store/workspace_setting.pb.go
+14
-2
workspace_setting.proto
proto/store/workspace_setting.proto
+2
-0
workspace_setting_service.go
server/router/api/v1/workspace_setting_service.go
+2
-0
package.json
web/package.json
+2
-1
Link.tsx
web/src/components/MemoContent/Link.tsx
+11
-0
MemoRelatedSettings.tsx
web/src/components/Settings/MemoRelatedSettings.tsx
+7
-0
No files found.
docs/apidocs.swagger.yaml
View file @
4d2b953e
This diff is collapsed.
Click to expand it.
proto/api/v1/workspace_setting_service.proto
View file @
4d2b953e
...
...
@@ -92,6 +92,8 @@ message WorkspaceMemoRelatedSetting {
bool
enable_auto_compact
=
4
;
// enable_double_click_edit enables editing on double click.
bool
enable_double_click_edit
=
5
;
// enable_link_preview enables links preview.
bool
enable_link_preview
=
6
;
}
message
GetWorkspaceSettingRequest
{
...
...
proto/gen/api/v1/workspace_setting_service.pb.go
View file @
4d2b953e
...
...
@@ -417,6 +417,8 @@ type WorkspaceMemoRelatedSetting struct {
EnableAutoCompact
bool
`protobuf:"varint,4,opt,name=enable_auto_compact,json=enableAutoCompact,proto3" json:"enable_auto_compact,omitempty"`
// enable_double_click_edit enables editing on double click.
EnableDoubleClickEdit
bool
`protobuf:"varint,5,opt,name=enable_double_click_edit,json=enableDoubleClickEdit,proto3" json:"enable_double_click_edit,omitempty"`
// enable_link_preview enables links preview.
EnableLinkPreview
bool
`protobuf:"varint,6,opt,name=enable_link_preview,json=enableLinkPreview,proto3" json:"enable_link_preview,omitempty"`
}
func
(
x
*
WorkspaceMemoRelatedSetting
)
Reset
()
{
...
...
@@ -486,6 +488,13 @@ func (x *WorkspaceMemoRelatedSetting) GetEnableDoubleClickEdit() bool {
return
false
}
func
(
x
*
WorkspaceMemoRelatedSetting
)
GetEnableLinkPreview
()
bool
{
if
x
!=
nil
{
return
x
.
EnableLinkPreview
}
return
false
}
type
GetWorkspaceSettingRequest
struct
{
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
...
...
@@ -749,7 +758,7 @@ var file_api_v1_workspace_setting_service_proto_rawDesc = []byte{
0x1c
,
0x0a
,
0x18
,
0x53
,
0x54
,
0x4f
,
0x52
,
0x41
,
0x47
,
0x45
,
0x5f
,
0x54
,
0x59
,
0x50
,
0x45
,
0x5f
,
0x55
,
0x4e
,
0x53
,
0x50
,
0x45
,
0x43
,
0x49
,
0x46
,
0x49
,
0x45
,
0x44
,
0x10
,
0x00
,
0x12
,
0x0c
,
0x0a
,
0x08
,
0x44
,
0x41
,
0x54
,
0x41
,
0x42
,
0x41
,
0x53
,
0x45
,
0x10
,
0x01
,
0x12
,
0x09
,
0x0a
,
0x05
,
0x4c
,
0x4f
,
0x43
,
0x41
,
0x4c
,
0x10
,
0x02
,
0x12
,
0x06
,
0x0a
,
0x02
,
0x53
,
0x33
,
0x10
,
0x03
,
0x22
,
0x
a
9
,
0x4f
,
0x43
,
0x41
,
0x4c
,
0x10
,
0x02
,
0x12
,
0x06
,
0x0a
,
0x02
,
0x53
,
0x33
,
0x10
,
0x03
,
0x22
,
0x
d
9
,
0x02
,
0x0a
,
0x1b
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x52
,
0x65
,
0x6c
,
0x61
,
0x74
,
0x65
,
0x64
,
0x53
,
0x65
,
0x74
,
0x74
,
0x69
,
0x6e
,
0x67
,
0x12
,
0x36
,
0x0a
,
0x17
,
0x64
,
0x69
,
0x73
,
0x61
,
0x6c
,
0x6c
,
0x6f
,
0x77
,
0x5f
,
0x70
,
0x75
,
0x62
,
0x6c
,
0x69
,
...
...
@@ -768,7 +777,10 @@ var file_api_v1_workspace_setting_service_proto_rawDesc = []byte{
0x74
,
0x12
,
0x37
,
0x0a
,
0x18
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x5f
,
0x64
,
0x6f
,
0x75
,
0x62
,
0x6c
,
0x65
,
0x5f
,
0x63
,
0x6c
,
0x69
,
0x63
,
0x6b
,
0x5f
,
0x65
,
0x64
,
0x69
,
0x74
,
0x18
,
0x05
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x15
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x44
,
0x6f
,
0x75
,
0x62
,
0x6c
,
0x65
,
0x43
,
0x6c
,
0x69
,
0x63
,
0x6b
,
0x45
,
0x64
,
0x69
,
0x74
,
0x22
,
0x36
,
0x0a
,
0x1a
,
0x47
,
0x65
,
0x65
,
0x43
,
0x6c
,
0x69
,
0x63
,
0x6b
,
0x45
,
0x64
,
0x69
,
0x74
,
0x12
,
0x2e
,
0x0a
,
0x13
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x5f
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x5f
,
0x70
,
0x72
,
0x65
,
0x76
,
0x69
,
0x65
,
0x77
,
0x18
,
0x06
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x11
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x50
,
0x72
,
0x65
,
0x76
,
0x69
,
0x65
,
0x77
,
0x22
,
0x36
,
0x0a
,
0x1a
,
0x47
,
0x65
,
0x74
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x53
,
0x65
,
0x74
,
0x74
,
0x69
,
0x6e
,
0x67
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x74
,
0x12
,
0x18
,
0x0a
,
0x04
,
0x6e
,
0x61
,
0x6d
,
0x65
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x42
,
0x04
,
0xe2
,
0x41
,
0x01
,
0x02
,
0x52
,
0x04
,
0x6e
,
0x61
,
...
...
proto/gen/store/workspace_setting.pb.go
View file @
4d2b953e
...
...
@@ -614,6 +614,8 @@ type WorkspaceMemoRelatedSetting struct {
EnableAutoCompact
bool
`protobuf:"varint,4,opt,name=enable_auto_compact,json=enableAutoCompact,proto3" json:"enable_auto_compact,omitempty"`
// enable_double_click_edit enables editing on double click.
EnableDoubleClickEdit
bool
`protobuf:"varint,5,opt,name=enable_double_click_edit,json=enableDoubleClickEdit,proto3" json:"enable_double_click_edit,omitempty"`
// enable_link_preview enables links preview.
EnableLinkPreview
bool
`protobuf:"varint,6,opt,name=enable_link_preview,json=enableLinkPreview,proto3" json:"enable_link_preview,omitempty"`
}
func
(
x
*
WorkspaceMemoRelatedSetting
)
Reset
()
{
...
...
@@ -683,6 +685,13 @@ func (x *WorkspaceMemoRelatedSetting) GetEnableDoubleClickEdit() bool {
return
false
}
func
(
x
*
WorkspaceMemoRelatedSetting
)
GetEnableLinkPreview
()
bool
{
if
x
!=
nil
{
return
x
.
EnableLinkPreview
}
return
false
}
var
File_store_workspace_setting_proto
protoreflect
.
FileDescriptor
var
file_store_workspace_setting_proto_rawDesc
=
[]
byte
{
...
...
@@ -773,7 +782,7 @@ var file_store_workspace_setting_proto_rawDesc = []byte{
0x16
,
0x0a
,
0x06
,
0x72
,
0x65
,
0x67
,
0x69
,
0x6f
,
0x6e
,
0x18
,
0x04
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x06
,
0x72
,
0x65
,
0x67
,
0x69
,
0x6f
,
0x6e
,
0x12
,
0x16
,
0x0a
,
0x06
,
0x62
,
0x75
,
0x63
,
0x6b
,
0x65
,
0x74
,
0x18
,
0x05
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x06
,
0x62
,
0x75
,
0x63
,
0x6b
,
0x65
,
0x74
,
0x22
,
0x
a
9
,
0x02
,
0x0a
,
0x1b
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x4d
,
0x65
,
0x6d
,
0x
d
9
,
0x02
,
0x0a
,
0x1b
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x52
,
0x65
,
0x6c
,
0x61
,
0x74
,
0x65
,
0x64
,
0x53
,
0x65
,
0x74
,
0x74
,
0x69
,
0x6e
,
0x67
,
0x12
,
0x36
,
0x0a
,
0x17
,
0x64
,
0x69
,
0x73
,
0x61
,
0x6c
,
0x6c
,
0x6f
,
0x77
,
0x5f
,
0x70
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x5f
,
0x76
,
0x69
,
0x73
,
0x69
,
0x62
,
0x6c
,
0x65
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x08
,
...
...
@@ -791,7 +800,10 @@ var file_store_workspace_setting_proto_rawDesc = []byte{
0x63
,
0x74
,
0x12
,
0x37
,
0x0a
,
0x18
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x5f
,
0x64
,
0x6f
,
0x75
,
0x62
,
0x6c
,
0x65
,
0x5f
,
0x63
,
0x6c
,
0x69
,
0x63
,
0x6b
,
0x5f
,
0x65
,
0x64
,
0x69
,
0x74
,
0x18
,
0x05
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x15
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x44
,
0x6f
,
0x75
,
0x62
,
0x6c
,
0x65
,
0x43
,
0x6c
,
0x69
,
0x63
,
0x6b
,
0x45
,
0x64
,
0x69
,
0x74
,
0x2a
,
0x73
,
0x0a
,
0x13
,
0x57
,
0x6c
,
0x65
,
0x43
,
0x6c
,
0x69
,
0x63
,
0x6b
,
0x45
,
0x64
,
0x69
,
0x74
,
0x12
,
0x2e
,
0x0a
,
0x13
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x5f
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x5f
,
0x70
,
0x72
,
0x65
,
0x76
,
0x69
,
0x65
,
0x77
,
0x18
,
0x06
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x11
,
0x65
,
0x6e
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x50
,
0x72
,
0x65
,
0x76
,
0x69
,
0x65
,
0x77
,
0x2a
,
0x73
,
0x0a
,
0x13
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x53
,
0x65
,
0x74
,
0x74
,
0x69
,
0x6e
,
0x67
,
0x4b
,
0x65
,
0x79
,
0x12
,
0x25
,
0x0a
,
0x21
,
0x57
,
0x4f
,
0x52
,
0x4b
,
0x53
,
0x50
,
0x41
,
0x43
,
0x45
,
0x5f
,
0x53
,
0x45
,
0x54
,
0x54
,
0x49
,
0x4e
,
0x47
,
0x5f
,
0x4b
,
0x45
,
0x59
,
0x5f
,
0x55
,
0x4e
,
0x53
,
0x50
,
...
...
proto/store/workspace_setting.proto
View file @
4d2b953e
...
...
@@ -88,4 +88,6 @@ message WorkspaceMemoRelatedSetting {
bool
enable_auto_compact
=
4
;
// enable_double_click_edit enables editing on double click.
bool
enable_double_click_edit
=
5
;
// enable_link_preview enables links preview.
bool
enable_link_preview
=
6
;
}
server/router/api/v1/workspace_setting_service.go
View file @
4d2b953e
...
...
@@ -219,6 +219,7 @@ func convertWorkspaceMemoRelatedSettingFromStore(setting *storepb.WorkspaceMemoR
ContentLengthLimit
:
setting
.
ContentLengthLimit
,
EnableAutoCompact
:
setting
.
EnableAutoCompact
,
EnableDoubleClickEdit
:
setting
.
EnableDoubleClickEdit
,
EnableLinkPreview
:
setting
.
EnableLinkPreview
,
}
}
...
...
@@ -232,5 +233,6 @@ func convertWorkspaceMemoRelatedSettingToStore(setting *v1pb.WorkspaceMemoRelate
ContentLengthLimit
:
setting
.
ContentLengthLimit
,
EnableAutoCompact
:
setting
.
EnableAutoCompact
,
EnableDoubleClickEdit
:
setting
.
EnableDoubleClickEdit
,
EnableLinkPreview
:
setting
.
EnableLinkPreview
,
}
}
web/package.json
View file @
4d2b953e
...
...
@@ -70,5 +70,6 @@
"protobufjs"
:
"^7.3.2"
,
"typescript"
:
"^5.5.2"
,
"vite"
:
"^5.3.1"
}
},
"packageManager"
:
"pnpm@9.3.0+sha512.ee7b93e0c2bd11409c6424f92b866f31d3ea1bef5fbe47d3c7500cdc3c9668833d2e55681ad66df5b640c61fa9dc25d546efa54d76d7f8bf54b13614ac293631"
}
web/src/components/MemoContent/Link.tsx
View file @
4d2b953e
import
{
Link
as
MLink
,
Tooltip
}
from
"@mui/joy"
;
import
{
useState
}
from
"react"
;
import
{
markdownServiceClient
}
from
"@/grpcweb"
;
import
{
useWorkspaceSettingStore
}
from
"@/store/v1"
;
import
{
LinkMetadata
}
from
"@/types/proto/api/v1/markdown_service"
;
import
{
WorkspaceMemoRelatedSetting
}
from
"@/types/proto/api/v1/workspace_setting_service"
;
import
{
WorkspaceSettingKey
}
from
"@/types/proto/store/workspace_setting"
;
interface
Props
{
url
:
string
;
...
...
@@ -18,11 +21,19 @@ const getFaviconWithGoogleS2 = (url: string) => {
};
const
Link
:
React
.
FC
<
Props
>
=
({
text
,
url
}:
Props
)
=>
{
const
workspaceSettingStore
=
useWorkspaceSettingStore
();
const
workspaceMemoRelatedSetting
=
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
MEMO_RELATED
).
memoRelatedSetting
||
WorkspaceMemoRelatedSetting
.
fromPartial
({});
const
[
initialized
,
setInitialized
]
=
useState
<
boolean
>
(
false
);
const
[
showTooltip
,
setShowTooltip
]
=
useState
<
boolean
>
(
false
);
const
[
linkMetadata
,
setLinkMetadata
]
=
useState
<
LinkMetadata
|
undefined
>
();
const
handleMouseEnter
=
async
()
=>
{
if
(
!
workspaceMemoRelatedSetting
.
enableLinkPreview
)
{
return
;
}
setShowTooltip
(
true
);
if
(
!
initialized
)
{
try
{
...
...
web/src/components/Settings/MemoRelatedSettings.tsx
View file @
4d2b953e
...
...
@@ -53,6 +53,13 @@ const MemoRelatedSettings = () => {
onChange=
{
(
event
)
=>
updatePartialSetting
({
enableAutoCompact
:
event
.
target
.
checked
})
}
/>
</
div
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
span
>
Enable link preview
</
span
>
<
Switch
checked=
{
memoRelatedSetting
.
enableLinkPreview
}
onChange=
{
(
event
)
=>
updatePartialSetting
({
enableLinkPreview
:
event
.
target
.
checked
})
}
/>
</
div
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
span
>
{
t
(
"setting.system-section.enable-double-click-to-edit"
)
}
</
span
>
<
Switch
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment