returnTPromise.wrapError<void>('Invalid editor input. IFrame editor requires a model instance of IFrameEditorModel.');
}
// Assert that the current input is still the one we expect. This prevents a race condition when loading takes long and another input was set meanwhile
'var ignoredKeys = [9 /* tab */, 32 /* space */, 33 /* page up */, 34 /* page down */, 38 /* up */, 40 /* down */];',
'var ignoredCtrlCmdKeys = [65 /* a */, 67 /* c */];',
'var ignoredShiftKeys = [9 /* tab */];',
'window.document.body.addEventListener("keydown", function(event) {',// Listen to keydown events in the iframe
' try {',
' if (ignoredKeys.some(function(i) { return i === event.keyCode; })) {',
' if (!event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey) {',
' return;',// we want some single keys to be supported (e.g. Page Down for scrolling)
' }',
' }',
'',
' if (ignoredCtrlCmdKeys.some(function(i) { return i === event.keyCode; })) {',
' if (event.ctrlKey || event.metaKey) {',
' return;',// we want some ctrl/cmd keys to be supported (e.g. Ctrl+C for copy)
' }',
' }',
'',
' if (ignoredShiftKeys.some(function(i) { return i === event.keyCode; })) {',
' if (event.shiftKey) {',
' return;',// we want some shift keys to be supported (e.g. Shift+Tab for copy)
' }',
' }',
'',
' event.preventDefault();',// very important to not get duplicate actions when this one bubbles up!
'',
' var fakeEvent = document.createEvent("KeyboardEvent");',// create a keyboard event
' Object.defineProperty(fakeEvent, "keyCode", {',// we need to set some properties that Chrome wants
' get : function() {',
' return event.keyCode;',
' }',
' });',
' Object.defineProperty(fakeEvent, "which", {',
' get : function() {',
' return event.keyCode;',
' }',
' });',
' Object.defineProperty(fakeEvent, "target", {',
' get : function() {',
' return window && window.parent.document.body;',
' }',
' });',
'',
' fakeEvent.initKeyboardEvent("keydown", true, true, document.defaultView, null, null, event.ctrlKey, event.altKey, event.shiftKey, event.metaKey);',// the API shape of this method is not clear to me, but it works ;)
'',
' window.parent.document.dispatchEvent(fakeEvent);',// dispatch the event onto the parent
' } catch (error) {}',
'});',
// disable dropping into iframe!
'window.document.addEventListener("dragover", function (e) {',
' e.preventDefault();',
'});',
'window.document.addEventListener("drop", function (e) {',
' e.preventDefault();',
'});',
'window.document.body.addEventListener("dragover", function (e) {',
' e.preventDefault();',
'});',
'window.document.body.addEventListener("drop", function (e) {',
workbenchActionsRegistry.registerWorkbenchAction(newSyncActionDescriptor(OpenPreviewToSideAction,OpenPreviewToSideAction.ID,OpenPreviewToSideAction.LABEL,{primary:KeyMod.chord(KeyMod.CtrlCmd|KeyCode.KEY_K,KeyCode.KEY_V)}),'Markdown: Open Preview to the Side',category);
// Create a new promise here to be able to return this model even in case of an error
returnnewTPromise<EditorModel>((c,e)=>{
// On Error: Show error to user as rendered HTML
letonError=(error:Error)=>{
try{
lettheme=this.themeService.getTheme();
letusesLightTheme=isLightTheme(theme);
letmarkdownError=nls.localize('markdownError',"Unable to open '{0}' for Markdown rendering. Please make sure the file exists and that it is a valid Markdown file.",paths.basename(this.resource.fsPath));