-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add json worker to monaco editor #3424
Merged
joshuarrrr
merged 30 commits into
opensearch-project:main
from
SuZhou-Joe:feature/alias-monaco-next
Mar 16, 2023
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
fba9d11
feat: add json worker and language implement in dashboards
SuZhou-Joe 48d3a91
feat: update changelog
SuZhou-Joe a3a9e1d
feat: reorder the import expression
SuZhou-Joe a85485c
feat: update
SuZhou-Joe e4c4d29
feat: update
SuZhou-Joe 2d311f6
feat: add example for json language
SuZhou-Joe 06ac508
feat: remove external link comment
SuZhou-Joe c225d1d
feat: modify uri
SuZhou-Joe f29b55f
Merge branch 'main' into main
SuZhou-Joe ffe75ca
feat: switch to new license header
SuZhou-Joe 095e493
Merge branch 'main' into main
SuZhou-Joe c6d5f85
feat: add package @osd/monaco-next
SuZhou-Joe 831bbb9
feat: make smaller changes
SuZhou-Joe 636adc3
feat: update CHANGELOG.md
SuZhou-Joe 2798a58
Merge branch 'main' into feature/alias-monaco-next
SuZhou-Joe 3b087fe
feat: update
SuZhou-Joe d80b42e
feat: remve useless code change
SuZhou-Joe 314d897
feat: modify changelog
SuZhou-Joe 4a0f855
Merge branch 'main' into feature/alias-monaco-next
SuZhou-Joe e009f2b
Merge branch 'main' into feature/alias-monaco-next
SuZhou-Joe 2cb7910
feat: some changes after code review
SuZhou-Joe a7189c5
Merge branch 'main' into feature/alias-monaco-next
SuZhou-Joe 4edbed9
feat: modify README
SuZhou-Joe cf47b3c
Merge branch 'main' into feature/alias-monaco-next
ananzh 7205379
Update packages/osd-monaco/README.md
SuZhou-Joe 823d1d2
Update CHANGELOG.md
SuZhou-Joe 0661707
Update packages/osd-monaco/src/xjson/README.md
SuZhou-Joe 95cfb9c
Merge branch 'main' into feature/alias-monaco-next
SuZhou-Joe 88b5159
Merge branch 'main' into feature/alias-monaco-next
ananzh e86afbf
Merge branch 'main' into feature/alias-monaco-next
SuZhou-Joe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { registerWorker } from '../worker_store'; | ||
// @ts-ignore | ||
import jsonWorkerSrc from '!!raw-loader!../../target/public/json.editor.worker.js'; | ||
|
||
registerWorker('json', jsonWorkerSrc); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
// @ts-ignore | ||
/* eslint-disable-next-line @osd/eslint/module_migration */ | ||
import 'monaco-editor/esm/vs/language/json/json.worker.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { getWorker } from './worker_store'; | ||
|
||
// @ts-ignore | ||
window.MonacoEnvironment = { | ||
getWorker: (module: string, languageId: string) => { | ||
const workerSrc = getWorker(languageId); | ||
if (workerSrc) { | ||
const blob = new Blob([workerSrc], { type: 'application/javascript' }); | ||
return new Worker(URL.createObjectURL(blob)); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
const workerStoreMap: Record<string, string> = {}; | ||
|
||
export const registerWorker = (workerId: string, worker: string) => { | ||
if (!workerStoreMap[workerId]) { | ||
workerStoreMap[workerId] = worker; | ||
return true; | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
export const getWorker = (workerId: string) => { | ||
return workerStoreMap[workerId]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the worker proxy service - but why did you choose not to use it for
json
?