Skip to content
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

[Feature Request] provide a util Function that convert value to codeString ? #3620

Closed
2 tasks done
vaynevayne opened this issue Mar 2, 2023 · 2 comments
Closed
2 tasks done
Labels
feature-request Request for new features or functionality

Comments

@vaynevayne
Copy link

Context

  • This issue is not a bug report. (please use a different template for reporting a bug)
  • This issue is not a duplicate of an existing issue. (please use the search to find existing issues)

Description

user can edit table columns in Monaco,the columns is defined in source code, and save it to server, then get it from server

const columns = [
{
title:'name',
cellStyle:()=>({color:'red' })
}
]
// important point is save `function`
const code = convertValueToCodeString(columns)
<Editor value={code} />

I try to complete it ,but it is not enought strong to used on production

const convertValueToCodeString = (input )=> {
let jsonString = JSON.stringify(input,(k,v)=> typeof y === 'function' ? v+'' :  v)

// remove  ""  before  and after the funciton
const code = jsonString.replace(/(?<=:\s*)"(?=\s*\()/g,'').replace(/(?<=\})"/,'')
return code 
}

// test1 
const codeString = convertValueToCodeString(columns) // '[{"title":"name"}]' ✅
// test2
const columns2 = [{compare:()=>0,cellStyle:()=>{
return {
color:'red'
}
}}]
const codeString2 = convertValueToCodeString(columns2) // '[{"title":"name"}]' ❌

I try to use https://github.com/vkiryukhin/jsonfn
, but it can breaking the code verification, formatting and other functions in the Editor, the user experience is very bad, I don't want to use it anymore

image

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

No response

@vaynevayne vaynevayne added the feature-request Request for new features or functionality label Mar 2, 2023
@hediet
Copy link
Member

hediet commented Mar 2, 2023

We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding, and happy coding!

@hediet hediet closed this as not planned Won't fix, can't repro, duplicate, stale Mar 2, 2023
@vaynevayne
Copy link
Author

i resolve it, If anyone needs it, you can contact me

@github-actions github-actions bot locked and limited conversation to collaborators Apr 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

2 participants