This repository has been archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathwebEditingPlugin.js
168 lines (158 loc) · 5.17 KB
/
webEditingPlugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*******************************************************************************
* @license
* Copyright (c) 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*eslint-env browser, amd*/
define([
'orion/plugin',
'orion/util',
'i18n!orion/nls/messages'
], function(PluginProvider, util, messages) {
function connect() {
var headers = {
name: "Orion Web Editing Plugin",
version: "1.0",
description: "This plugin provides editor link support for the navigator."
};
var pluginProvider = new PluginProvider(headers);
registerServiceProviders(pluginProvider);
pluginProvider.connect();
}
function registerServiceProviders(provider) {
provider.registerService("orion.core.contenttype", {}, {
contentTypes:
// Text types
[{ id: "text/plain",
name: "Text",
extension: ["txt"],
imageClass: "file-sprite-text modelDecorationSprite"
},
{ id: "application/xml",
"extends": "text/plain",
name: "XML",
extension: ["xml"],
imageClass: "file-sprite-xml modelDecorationSprite"
},
{ id: "text/x-markdown",
"extends": "text/plain",
name: "Markdown",
extension: ["md"]
},
{ id: "text/conf",
"extends": "text/plain",
name: "Conf",
extension: ["conf"]
},
{ id: "application/x-sh",
"extends": "text/plain",
name: "sh",
extension: ["sh", "bash"]
},
{ id: "application/pdf",
"extends": "application/browser-renderable",
name: "PDF",
extension: ["pdf"]
},
// binary files
{ id: "application/octet-stream",
name: "octet-stream",
extension: ["exe", "bin", "doc", "ppt"]
},
{ id: "application/zip",
"extends": "application/octet-stream",
name: "ZIP",
extension: ["war", "jar", "zip", "rar"]
},
// Image types
{ id: "image/gif",
name: "GIF",
extension: ["gif"],
imageClass: "file-sprite-image modelDecorationSprite"
},
{ id: "image/jpeg",
name: "JPG",
extension: ["jpg", "jpeg", "jpe"],
imageClass: "file-sprite-image modelDecorationSprite"
},
{ id: "image/ico",
name: "ICO",
extension: ["ico"],
imageClass: "file-sprite-image modelDecorationSprite"
},
{ id: "image/png",
name: "PNG",
extension: ["png"],
imageClass: "file-sprite-image modelDecorationSprite"
},
{ id: "image/tiff",
name: "TIFF",
extension: ["tif", "tiff"],
imageClass: "file-sprite-image modelDecorationSprite"
},
{ id: "image/svg",
name: "SVG",
extension: ["svg"],
imageClass: "file-sprite-image modelDecorationSprite"
}]
});
provider.registerService("orion.edit.editor", {}, {
id: "orion.editor",
"default": true,
name: messages["Orion Editor"],
nls: "orion/nls/messages",
uriTemplate: "../edit/edit.html#{,Location,params*}",
orionTemplate: "../edit/edit.html#{,Location,params*}",
validationProperties: [{
source: "!Projects" // Filter out workspace;
}]});
// only providing excludedContentTypes for orion.editor because we want
// to attempt to open files with unknown content types with it for now
// e.g. A text file with no extension is currently of an unknown content
// type, we want to use the orion.editor to open it
provider.registerService("orion.navigate.openWith", {}, {
editor: "orion.editor",
excludedContentTypes: ["image/*", "application/zip"]});
var MARKDOWN_VIEWER_ID = "orion.viewer.markdown";
provider.registerService("orion.edit.editor", {}, {
id: MARKDOWN_VIEWER_ID,
name: messages["Orion Markdown Viewer"],
nls: "orion/nls/messages",
uriTemplate: "../edit/edit.html#{,Location,params*},editor=" + MARKDOWN_VIEWER_ID});
provider.registerService("orion.navigate.openWith", {}, {
editor: MARKDOWN_VIEWER_ID,
contentType: ["text/x-markdown"]});
var MARKDOWN_EDITOR_ID = "orion.editor.markdown";
provider.registerService("orion.edit.editor", {}, {
id: MARKDOWN_EDITOR_ID,
name: messages["Orion Markdown Editor"],
nls: "orion/nls/messages",
"default": true,
uriTemplate: "../edit/edit.html#{,Location,params*},editor=" + MARKDOWN_EDITOR_ID});
provider.registerService("orion.navigate.openWith", {}, {
editor: MARKDOWN_EDITOR_ID,
contentType: ["text/x-markdown"]});
// open file with browser, no associated orion.navigate.openWith command means that any content type is valid
if (!util.isElectron) {
provider.registerService("orion.edit.editor", {}, {
id: "orion.viewer.raw",
name: messages["Browser"],
nls: "orion/nls/messages",
uriTemplate: "{+Location}",
validationProperties: [
{source: "Directory", match: false} // Filter out workspace; Raw only applies to regular files.
]
});
}
}
return {
connect: connect,
registerServiceProviders: registerServiceProviders
};
});