Skip to content

Commit 3f99e0e

Browse files
committed
deploy: 606b7d0
1 parent d1e4251 commit 3f99e0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2388
-84
lines changed

appConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ window.AppConfig = {
2626
"app_notification_url": "assets/notifications/dev/",
2727
"app_update_url": "https://updates.phcode.io/tauri/update-latest-experimental-build.json",
2828
"linting.enabled_by_default": true,
29-
"build_timestamp": "2024-11-30T08:26:33.102Z",
29+
"build_timestamp": "2024-11-30T08:30:14.323Z",
3030
"googleAnalyticsID": "G-P4HJFPDB76",
3131
"googleAnalyticsIDDesktop": "G-VE5BXWJ0HF",
3232
"mixPanelID": "49c4d164b592be2350fc7af06a259bf3",
@@ -38,7 +38,7 @@ window.AppConfig = {
3838
"bugsnagEnv": "development"
3939
},
4040
"name": "Phoenix Code",
41-
"version": "3.11.0-20687",
41+
"version": "3.11.0-20694",
4242
"apiVersion": "3.11.0",
4343
"homepage": "https://core.ai",
4444
"issues": {

assets/default-project/en.zip

0 Bytes
Binary file not shown.

assets/sample-projects/HTML5.zip

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

assets/sample-projects/explore.zip

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

brackets-min.js

Lines changed: 259 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33113,6 +33113,262 @@ define("extensibility/registry_utils", function (require, exports, module) {
3311333113
};
3311433114
});
3311533115

33116+
/*
33117+
* GNU AGPL-3.0 License
33118+
*
33119+
* Copyright (c) 2021 - present core.ai . All rights reserved.
33120+
* Original work Copyright (c) 2024 [cmgddd](https://github.com/cmgddd/Brackets-css-color-preview). All rights reserved.
33121+
*
33122+
* This program is free software: you can redistribute it and/or modify it
33123+
* under the terms of the GNU Affero General Public License as published by
33124+
* the Free Software Foundation, either version 3 of the License, or
33125+
* (at your option) any later version.
33126+
*
33127+
* This program is distributed in the hope that it will be useful, but WITHOUT
33128+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
33129+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
33130+
* for more details.
33131+
*
33132+
* You should have received a copy of the GNU Affero General Public License
33133+
* along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
33134+
*
33135+
*/
33136+
33137+
33138+
/* Displays a color preview in the gutter for any file containing color values */
33139+
/* Styles on `styles/brackets.less` file */
33140+
33141+
define("extensionsIntegrated/CSSColorPreview/main", function (require, exports, module) {
33142+
33143+
// Brackets modules.
33144+
const _ = require("thirdparty/lodash"),
33145+
EditorManager = require('editor/EditorManager'),
33146+
ColorUtils = require('utils/ColorUtils'),
33147+
AppInit = require("utils/AppInit"),
33148+
PreferencesManager = require("preferences/PreferencesManager"),
33149+
Strings = require("strings");
33150+
33151+
// Extension variables.
33152+
const COLOR_REGEX = ColorUtils.COLOR_REGEX, // used to match color
33153+
gutterName = "CodeMirror-colorGutter";
33154+
33155+
33156+
// For preferences settings, to toggle this feature on/off
33157+
const PREFERENCES_CSS_COLOR_PREVIEW = "CSSColorPreview";
33158+
let enabled = true; // by default:- on
33159+
33160+
PreferencesManager.definePreference(PREFERENCES_CSS_COLOR_PREVIEW, "boolean", enabled, {
33161+
description: Strings.DESCRIPTION_CSS_COLOR_PREVIEW
33162+
});
33163+
33164+
/**
33165+
* Gets all the colors that are to be displayed
33166+
*
33167+
* Makes sure that the feature is enabled and editor is active, if yes:
33168+
* Calls showGutter function to display the color marks on the gutter
33169+
*/
33170+
function showColorMarks() {
33171+
if (!enabled) {
33172+
removeColorMarks();
33173+
return;
33174+
}
33175+
33176+
const editor = EditorManager.getActiveEditor();
33177+
if (editor) {
33178+
33179+
const cm = editor._codeMirror;
33180+
const nLen = cm.lineCount();
33181+
const aColors = [];
33182+
33183+
// match colors and push into an array
33184+
for (let i = 0; i < nLen; i++) {
33185+
let lineText = cm.getLine(i);
33186+
33187+
if ((lineText.indexOf('/*') !== -1) || (lineText.indexOf('*/') !== -1)) {
33188+
continue;
33189+
} else {
33190+
let regx = /:[^;]*;/g;
33191+
33192+
lineText = lineText.match(regx);
33193+
if (lineText) {
33194+
let tempColors = lineText[0].match(COLOR_REGEX);
33195+
// Support up to 4 colors
33196+
if (tempColors && tempColors.length > 0) {
33197+
let colors = tempColors.slice(0, 4);
33198+
aColors.push({
33199+
lineNumber: i,
33200+
colorValues: colors
33201+
});
33202+
}
33203+
}
33204+
}
33205+
}
33206+
33207+
showGutters(editor, aColors);
33208+
}
33209+
}
33210+
33211+
/**
33212+
* To remove the color marks from the gutter
33213+
*/
33214+
function removeColorMarks() {
33215+
const editor = EditorManager.getActiveEditor();
33216+
if (editor) {
33217+
const cm = editor._codeMirror;
33218+
cm.clearGutter(gutterName);
33219+
}
33220+
}
33221+
33222+
/**
33223+
* To display the color marks on the gutter
33224+
* @param {activeEditor} editor
33225+
* @param {Array.<object>} _results An array of objects which stores
33226+
* all the line numbers and the colors to be displayed on that line.
33227+
*/
33228+
function showGutters(editor, _results) {
33229+
if (editor && enabled) {
33230+
initGutter(editor);
33231+
const cm = editor._codeMirror;
33232+
cm.clearGutter(gutterName); // clear color markers
33233+
33234+
// Only add markers if enabled
33235+
if (enabled) {
33236+
cm.colorGutters = _.sortBy(_results, "lineNumber");
33237+
33238+
cm.colorGutters.forEach(function (obj) {
33239+
let $marker;
33240+
33241+
if (obj.colorValues.length === 1) {
33242+
// Single color preview
33243+
$marker = $("<i>")
33244+
.addClass("ico-cssColorPreview")
33245+
.css('background-color', obj.colorValues[0]);
33246+
33247+
cm.setGutterMarker(obj.lineNumber, gutterName, $marker[0]);
33248+
} else {
33249+
// Multiple colors preview
33250+
$marker = $("<div>").addClass("ico-multiple-cssColorPreview");
33251+
33252+
// Positions for up to 4 colors in grid
33253+
const positions = [
33254+
{ top: 0, left: 0 },
33255+
{ top: 0, right: 0 },
33256+
{ bottom: 0, right: 0 },
33257+
{ bottom: 0, left: 0 }
33258+
];
33259+
33260+
obj.colorValues.forEach((color, index) => {
33261+
if (index < 4) {
33262+
const $colorBox = $("<div>")
33263+
.addClass("color-box")
33264+
.css({
33265+
'background-color': color,
33266+
...positions[index]
33267+
});
33268+
$marker.append($colorBox);
33269+
}
33270+
});
33271+
33272+
cm.setGutterMarker(obj.lineNumber, gutterName, $marker[0]);
33273+
}
33274+
});
33275+
}
33276+
33277+
}
33278+
}
33279+
33280+
33281+
/**
33282+
* Initialize the gutter
33283+
* @param {activeEditor} editor
33284+
*/
33285+
function initGutter(editor) {
33286+
33287+
const cm = editor._codeMirror;
33288+
const gutters = cm.getOption("gutters").slice(0);
33289+
let str = gutters.join('');
33290+
if (str.indexOf(gutterName) === -1) {
33291+
gutters.unshift(gutterName);
33292+
cm.setOption("gutters", gutters);
33293+
}
33294+
}
33295+
33296+
/**
33297+
* Register all the required handlers
33298+
*/
33299+
function registerHandlers() {
33300+
// Remove previous listeners to avoid multiple binding issue
33301+
EditorManager.off("activeEditorChange", onChanged);
33302+
33303+
// Add listener for all editor changes
33304+
EditorManager.on("activeEditorChange", function (event, newEditor, oldEditor) {
33305+
if (newEditor) {
33306+
// Unbind the previous editor's change event if it exists
33307+
if (oldEditor) {
33308+
const oldCM = oldEditor._codeMirror;
33309+
if (oldCM) {
33310+
oldCM.off("change", onChanged);
33311+
}
33312+
}
33313+
33314+
// Bind change event to the new editor
33315+
const cm = newEditor._codeMirror;
33316+
if (cm) {
33317+
cm.on("change", onChanged);
33318+
}
33319+
33320+
showColorMarks();
33321+
}
33322+
});
33323+
33324+
// Handle the currently active editor at initialization
33325+
const activeEditor = EditorManager.getActiveEditor();
33326+
if (activeEditor) {
33327+
const cm = activeEditor._codeMirror;
33328+
if (cm) {
33329+
cm.on("change", onChanged);
33330+
}
33331+
showColorMarks();
33332+
}
33333+
33334+
}
33335+
33336+
/**
33337+
* Checks for preference changes, to enable/disable the feature
33338+
*/
33339+
function preferenceChanged() {
33340+
const value = PreferencesManager.get(PREFERENCES_CSS_COLOR_PREVIEW);
33341+
enabled = value;
33342+
if (!value) {
33343+
removeColorMarks();
33344+
} else {
33345+
showColorMarks();
33346+
}
33347+
}
33348+
33349+
/**
33350+
* Function that gets triggered when any change occurs on the editor
33351+
*/
33352+
function onChanged() {
33353+
showColorMarks();
33354+
}
33355+
33356+
/**
33357+
* Driver function, runs at the start of the program
33358+
*/
33359+
function init() {
33360+
showColorMarks();
33361+
registerHandlers();
33362+
}
33363+
33364+
// init after appReady
33365+
AppInit.appReady(function () {
33366+
PreferencesManager.on("change", PREFERENCES_CSS_COLOR_PREVIEW, preferenceChanged);
33367+
init();
33368+
});
33369+
});
33370+
33371+
3311633372
/*
3311733373
* GNU AGPL-3.0 License
3311833374
*
@@ -43954,6 +44210,7 @@ define("extensionsIntegrated/loader", function (require, exports, module) {
4395444210
require("./appUpdater/main");
4395544211
require("./HtmlTagSyncEdit/main");
4395644212
require("./indentGuides/main");
44213+
require("./CSSColorPreview/main");
4395744214
});
4395844215

4395944216
/*
@@ -92532,7 +92789,8 @@ define("nls/root/strings", {
9253292789
"BEAUTIFY_OPTION_PRINT_TRAILING_COMMAS": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures",
9253392790
// indent guides extension
9253492791
"DESCRIPTION_INDENT_GUIDES_ENABLED": "true to show indent guide lines, else false.",
92535-
"DESCRIPTION_HIDE_FIRST": "true to show the first Indent Guide line else false."
92792+
"DESCRIPTION_HIDE_FIRST": "true to show the first Indent Guide line else false.",
92793+
"DESCRIPTION_CSS_COLOR_PREVIEW": "true to display color previews in the gutter, else false."
9253692794
});
9253792795

9253892796
/*

0 commit comments

Comments
 (0)