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

Ability to rename history entries #967

Open
sidharthv96 opened this issue Aug 19, 2022 · 6 comments
Open

Ability to rename history entries #967

sidharthv96 opened this issue Aug 19, 2022 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed retained Will not be auto-closed

Comments

@sidharthv96
Copy link
Member

Is your feature request related to a problem? Please describe.
It's hard to keep track of history as the names are randomly generated.

Describe the solution you'd like
It should be possible to rename history entries

Describe alternatives you've considered
None

@sidharthv96 sidharthv96 added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Aug 19, 2022
@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days

@github-actions github-actions bot added the Stale label Nov 24, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2022
@yurenchen000
Copy link

yurenchen000 commented Mar 7, 2023

I search usage everywhere and found nothing.
Is it possible today?

wish meaningful name for saved entries.
otherwise is hard to pick out the right save-point.

Did I miss something?

history_timeline-

history_saved-

@sidharthv96 sidharthv96 reopened this Mar 7, 2023
@sidharthv96 sidharthv96 added retained Will not be auto-closed and removed Stale labels Mar 7, 2023
@yurenchen000
Copy link

yurenchen000 commented Mar 7, 2023

I temporarily wrote some code to implement the renaming of manually saved entries.
Usage:

  • setup: Expand the History Panel, Paste code to F12 console, Enter.
  • use: double click on item name to edit, Enter to commit, Esc to cancel
    //NOTE: changed localeStorage maybe need refresh page to reload.
// yurenchen: mermaid.live editor rename manual-save-enties
// - double click on name to edit
// - Enter to confirm
// - Esc to cancle

//rename save entry in localStorage
function manual_save_rename(old_name, new_name){
	var store = JSON.parse(localStorage.manualHistoryStore)
	var found = store.find(o => o.name==old_name)
	if(found){
		found.name = new_name
		localStorage.manualHistoryStore = JSON.stringify(store)
		return true
	}
}

//expand history list
$('#historyList') || $('#saveHistory').closest('.card > div').click()

//bind rename to dblclick & ESC / Enter
setTimeout( _=>{
document.querySelectorAll('#historyList > li .flex-1 .flex-col.text-base-content span:nth-child(1)').forEach( ele => {
	console.log('-', ele)
	ele.ondblclick = function(e){
		// console.log(e.srcElement.innerText)
		var o = e.srcElement
		o._old = o.innerText
		o.contentEditable = true
		o.focus()
	}
	ele.onkeydown=function(e){
		var o = e.srcElement;
		// console.log(e,e.key, e.key)
		switch(e.key){
		case 'Enter':
			o.contentEditable = false
			o.innerText = o.innerText.trim()
			console.log('--rename:', o._old, o.innerText)
			manual_save_rename(o._old, o.innerText)
			return false
		case 'Escape':
			console.log('--cancel:', o._old, o.innerText)
			o.contentEditable = false
			o.innerText = o._old
			return false
		}
	}
})
},500)

@sidharthv96
Copy link
Member Author

@yurenchen000 can you raise a PR to allow easy editing of history entries?

Maybe an edit button near the name, clicking it turns the label into a text box, which can be edited and saved.

@yurenchen000
Copy link

@yurenchen000 can you raise a PR to allow easy editing of history entries?

Maybe an edit button near the name, clicking it turns the label into a text box, which can be edited and saved.

I haven't read the Live Editor source code,
This is just a temporary rough implementation.

@Soleone
Copy link

Soleone commented Jun 8, 2023

Without names the history feature's usefulness is very limited.

An alternative approach to manual renaming (which is certainly useful) might be to automatically take the title of the diagram as the name. As a reminder you can have some custom markup at the top of the diagram like this to display a title in the diagram:

---
title: My diagram name
---
classDiagram
    class A

Rendered it looks like this:

---
title: My diagram name
---
classDiagram
    class A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed retained Will not be auto-closed
Projects
None yet
Development

No branches or pull requests

3 participants