Editor mode vs action terminology
Editor mode vs action terminology
Loren Maxwell
Posts: 479Questions: 117Answers: 10
This is admittedly trivial, but I've been meaning to mention it and I'm virtually sitting in a boring staff meeting so I thought this might be a good time ![]()
The API has mode(), which is either create, edit, or remove.
But for events, such as open, the parameters are function( e, mode, action ), where the mode is main, inline, or bubble.
The action parameter is where the create, edit, or remove are found.
There have been a couple of times I've programed an event where I've done:
editor.on('open', function (e, mode, action) {
// Should be "action == 'edit'" but the
// api method "mode()" has thrown me off
if (mode == 'edit') {
...
}
});
The inconsistency always makes me wonder if it wouldn't be better to use the terminology from the event fields and have an action() method that will eventually replace the mode() method?
This question has an accepted answers - jump to answer
Answers
Hah - an excellent use for a meeting
.
Darn, I'd hoped to avoid an inconsistency in naming like that, but yes, I can see that it would be confusing there. I'll add an
action()method as you suggest and see about tidying up the event documentation.Thanks for flagging this up!
Allan
Thanks, @allan -- I haven't checked all the event documentation, but
action()would make it consistent with the few I checked.I think another possibility that would avoid additional programming and preserve backward compatibility would be to keep
mode()as is and change the parameters in the event documentation to something like:I know I can use the
(e, method, mode)or whatever else for the parameter names in my own code, but I usually use the ones from the event documentation to make sure I'm reminded of and passing the correct parameters.Either way, I trust you'll work out a solution!