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
dbb544dc
Unverified
Commit
dbb544dc
authored
Apr 26, 2023
by
Max Malm
Committed by
GitHub
Apr 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: read content from search params (#1607)
parent
3fad7188
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
MemoEditor.tsx
web/src/components/MemoEditor.tsx
+7
-1
utils.ts
web/src/helpers/utils.ts
+15
-0
No files found.
web/src/components/MemoEditor.tsx
View file @
dbb544dc
...
@@ -14,6 +14,7 @@ import ResourceIcon from "./ResourceIcon";
...
@@ -14,6 +14,7 @@ import ResourceIcon from "./ResourceIcon";
import
showResourcesSelectorDialog
from
"./ResourcesSelectorDialog"
;
import
showResourcesSelectorDialog
from
"./ResourcesSelectorDialog"
;
import
showCreateResourceDialog
from
"./CreateResourceDialog"
;
import
showCreateResourceDialog
from
"./CreateResourceDialog"
;
import
"@/less/memo-editor.less"
;
import
"@/less/memo-editor.less"
;
import
{
clearContentQueryParam
,
getContentQueryParam
}
from
"@/helpers/utils"
;
const
listItemSymbolList
=
[
"- [ ] "
,
"- [x] "
,
"- [X] "
,
"* "
,
"- "
];
const
listItemSymbolList
=
[
"- [ ] "
,
"- [x] "
,
"- [X] "
,
"* "
,
"- "
];
const
emptyOlReg
=
/^
(\d
+
)\.
$/
;
const
emptyOlReg
=
/^
(\d
+
)\.
$/
;
...
@@ -22,6 +23,10 @@ const getEditorContentCache = (): string => {
...
@@ -22,6 +23,10 @@ const getEditorContentCache = (): string => {
return
storage
.
get
([
"editorContentCache"
]).
editorContentCache
??
""
;
return
storage
.
get
([
"editorContentCache"
]).
editorContentCache
??
""
;
};
};
const
getInitialContent
=
():
string
=>
{
return
getContentQueryParam
()
??
getEditorContentCache
();
};
const
setEditorContentCache
=
(
content
:
string
)
=>
{
const
setEditorContentCache
=
(
content
:
string
)
=>
{
storage
.
set
({
storage
.
set
({
editorContentCache
:
content
,
editorContentCache
:
content
,
...
@@ -286,6 +291,7 @@ const MemoEditor = () => {
...
@@ -286,6 +291,7 @@ const MemoEditor = () => {
editorStore
.
clearResourceList
();
editorStore
.
clearResourceList
();
setEditorContentCache
(
""
);
setEditorContentCache
(
""
);
editorRef
.
current
?.
setContent
(
""
);
editorRef
.
current
?.
setContent
(
""
);
clearContentQueryParam
();
};
};
const
handleCancelEdit
=
()
=>
{
const
handleCancelEdit
=
()
=>
{
...
@@ -378,7 +384,7 @@ const MemoEditor = () => {
...
@@ -378,7 +384,7 @@ const MemoEditor = () => {
const
editorConfig
=
useMemo
(
const
editorConfig
=
useMemo
(
()
=>
({
()
=>
({
className
:
`memo-editor`
,
className
:
`memo-editor`
,
initialContent
:
get
EditorContentCache
(),
initialContent
:
get
InitialContent
(),
placeholder
:
t
(
"editor.placeholder"
),
placeholder
:
t
(
"editor.placeholder"
),
fullscreen
:
state
.
fullscreen
,
fullscreen
:
state
.
fullscreen
,
onContentChange
:
handleContentChange
,
onContentChange
:
handleContentChange
,
...
...
web/src/helpers/utils.ts
View file @
dbb544dc
...
@@ -105,3 +105,18 @@ export const formatBytes = (bytes: number) => {
...
@@ -105,3 +105,18 @@ export const formatBytes = (bytes: number) => {
i
=
Math
.
floor
(
Math
.
log
(
bytes
)
/
Math
.
log
(
k
));
i
=
Math
.
floor
(
Math
.
log
(
bytes
)
/
Math
.
log
(
k
));
return
parseFloat
((
bytes
/
Math
.
pow
(
k
,
i
)).
toFixed
(
dm
))
+
" "
+
sizes
[
i
];
return
parseFloat
((
bytes
/
Math
.
pow
(
k
,
i
)).
toFixed
(
dm
))
+
" "
+
sizes
[
i
];
};
};
export
const
getContentQueryParam
=
():
string
|
undefined
=>
{
const
urlParams
=
new
URLSearchParams
(
window
.
location
.
search
);
return
urlParams
.
get
(
"content"
)
??
undefined
;
};
export
const
clearContentQueryParam
=
()
=>
{
const
urlParams
=
new
URLSearchParams
(
window
.
location
.
search
);
urlParams
.
delete
(
"content"
);
let
url
=
window
.
location
.
pathname
;
if
(
urlParams
.
toString
())
{
url
+=
`?
${
urlParams
.
toString
()}
`
;
}
window
.
history
.
replaceState
({},
""
,
url
);
};
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