Skip to content

Commit 0219af1

Browse files
committed
chore: move from 'extensions' to 'extensionsIntegrated' dir
1 parent b22b4fa commit 0219af1

File tree

5 files changed

+34
-38
lines changed

5 files changed

+34
-38
lines changed

src/extensions/default/CSSColorPreview/package.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/extensions/default/DefaultExtensions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"CodeFolding",
77
"CSSAtRuleCodeHints",
88
"CSSCodeHints",
9-
"CSSColorPreview",
109
"CSSPseudoSelectorHints",
1110
"DebugCommands",
1211
"HandlebarsSupport",
File renamed without changes.

src/extensions/default/CSSColorPreview/main.js renamed to src/extensionsIntegrated/CSSColorPreview/main.js

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,30 @@
2525
define(function (require, exports, module) {
2626

2727
// Brackets modules.
28-
var _ = brackets.getModule("thirdparty/lodash"),
29-
EditorManager = brackets.getModule('editor/EditorManager'),
30-
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
31-
ColorUtils = brackets.getModule('utils/ColorUtils'),
32-
AppInit = brackets.getModule("utils/AppInit"),
33-
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
34-
Strings = brackets.getModule("strings"),
35-
36-
// Extension variables.
37-
COLOR_REGEX = ColorUtils.COLOR_REGEX, // used to match color
38-
gutterName = "CodeMirror-colorGutter";
28+
const _ = require("thirdparty/lodash"),
29+
EditorManager = require('editor/EditorManager'),
30+
ExtensionUtils = require("utils/ExtensionUtils"),
31+
ColorUtils = require('utils/ColorUtils'),
32+
AppInit = require("utils/AppInit"),
33+
PreferencesManager = require("preferences/PreferencesManager"),
34+
Strings = require("strings");
35+
36+
// Extension variables.
37+
const COLOR_REGEX = ColorUtils.COLOR_REGEX, // used to match color
38+
gutterName = "CodeMirror-colorGutter";
39+
3940

4041
ExtensionUtils.loadStyleSheet(module, "main.css");
4142

43+
// For preferences settings, to toggle this feature on/off
4244
const PREFERENCES_CSS_COLOR_PREVIEW = "CSSColorPreview";
43-
let enabled = true;
45+
let enabled = true; // by default:- on
4446

4547
PreferencesManager.definePreference(PREFERENCES_CSS_COLOR_PREVIEW, "boolean", enabled, {
4648
description: Strings.DESCRIPTION_CSS_COLOR_PREVIEW
4749
});
4850

49-
var CssColorPreview = {
51+
const CssColorPreview = {
5052

5153
// Get editor
5254
getEditor: function () {
@@ -61,27 +63,27 @@ define(function (require, exports, module) {
6163
return;
6264
}
6365

64-
var editor = CssColorPreview.getEditor();
66+
const editor = CssColorPreview.getEditor();
6567
if (editor) {
6668

67-
var cm = editor._codeMirror;
68-
var nLen = cm.lineCount();
69-
var aColors = [];
69+
const cm = editor._codeMirror;
70+
const nLen = cm.lineCount();
71+
const aColors = [];
7072

7173
// match colors and push into an array
72-
for (var i = 0; i < nLen; i++) {
73-
var lineText = cm.getLine(i);
74+
for (let i = 0; i < nLen; i++) {
75+
let lineText = cm.getLine(i);
7476

7577
if ((lineText.indexOf('/*') !== -1) || (lineText.indexOf('*/') !== -1)) {
7678
continue;
7779
} else {
78-
var regx = /:.*?;/g;
80+
let regx = /:.*?;/g;
7981
lineText = lineText.match(regx);
8082
if (lineText) {
81-
var tempColors = lineText[0].match(COLOR_REGEX);
83+
let tempColors = lineText[0].match(COLOR_REGEX);
8284
// Support up to 4 colors
8385
if (tempColors && tempColors.length > 0) {
84-
var colors = tempColors.slice(0, 4);
86+
let colors = tempColors.slice(0, 4);
8587
aColors.push({
8688
lineNumber: i,
8789
colorValues: colors
@@ -113,14 +115,14 @@ define(function (require, exports, module) {
113115
if (newEditor) {
114116
// Unbind the previous editor's change event if it exists
115117
if (oldEditor) {
116-
var oldCM = oldEditor._codeMirror;
118+
const oldCM = oldEditor._codeMirror;
117119
if (oldCM) {
118120
oldCM.off("change", CssColorPreview.onChanged);
119121
}
120122
}
121123

122124
// Bind change event to the new editor
123-
var cm = newEditor._codeMirror;
125+
const cm = newEditor._codeMirror;
124126
if (cm) {
125127
cm.on("change", CssColorPreview.onChanged);
126128
}
@@ -143,9 +145,9 @@ define(function (require, exports, module) {
143145

144146
initGutter: function (editor) {
145147

146-
var cm = editor._codeMirror;
147-
var gutters = cm.getOption("gutters").slice(0);
148-
var str = gutters.join('');
148+
const cm = editor._codeMirror;
149+
const gutters = cm.getOption("gutters").slice(0);
150+
let str = gutters.join('');
149151
if (str.indexOf(gutterName) === -1) {
150152
gutters.unshift(gutterName);
151153
cm.setOption("gutters", gutters);
@@ -155,7 +157,7 @@ define(function (require, exports, module) {
155157
showGutters: function (editor, _results) {
156158
if (editor && enabled) {
157159
CssColorPreview.initGutter(editor);
158-
var cm = editor._codeMirror;
160+
const cm = editor._codeMirror;
159161
cm.clearGutter(gutterName); // clear color markers
160162

161163
// Only add markers if enabled
@@ -206,16 +208,16 @@ define(function (require, exports, module) {
206208

207209
// Method to remove colors when disabled
208210
removeColorMarks: function () {
209-
var editor = CssColorPreview.getEditor();
211+
const editor = CssColorPreview.getEditor();
210212
if (editor) {
211-
var cm = editor._codeMirror;
213+
const cm = editor._codeMirror;
212214
cm.clearGutter(gutterName);
213215
}
214216
}
215217
};
216218

217219
function preferenceChanged() {
218-
let value = PreferencesManager.get(PREFERENCES_CSS_COLOR_PREVIEW);
220+
const value = PreferencesManager.get(PREFERENCES_CSS_COLOR_PREVIEW);
219221
enabled = value;
220222
if (!value) {
221223
CssColorPreview.removeColorMarks();

src/extensionsIntegrated/loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ define(function (require, exports, module) {
4242
require("./appUpdater/main");
4343
require("./HtmlTagSyncEdit/main");
4444
require("./indentGuides/main");
45+
require("./CSSColorPreview/main");
4546
});

0 commit comments

Comments
 (0)