CpsFlowDefinition currently just passes its content through a Groovy compiler. This is not very useful if you are editing Declarative. You would want to know if your agent block is right, etc.
If it can detect that the script is Declarative (I suppose just look for pipeline as a top-level element, or what?), it should invoke the Declarative instead.