Skip to content

Commit

Permalink
Merge branch 'develop' into template-page
Browse files Browse the repository at this point in the history
  • Loading branch information
surajshetty3416 committed Mar 26, 2024
2 parents b742a1c + c4c713f commit 7a77fb6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 43 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Expand Up @@ -7,6 +7,4 @@ node_modules
builder/public/frontend
builder/public/page_scripts
builder/public/page_styles
builder/www/index.html
builder/www/p.html
builder/www/builder.html
builder/www/builder.html
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -5,7 +5,7 @@ fail_fast: false

repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or:
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Expand Up @@ -24,7 +24,7 @@
"ace-builds": "^1.22.0",
"autoprefixer": "^10.4.2",
"feather-icons": "^4.28.0",
"frappe-ui": "^0.1.36",
"frappe-ui": "^0.1.43",
"pinia": "^2.0.28",
"postcss": "^8.4.5",
"tailwindcss": "^3.3.2",
Expand Down
42 changes: 25 additions & 17 deletions frontend/src/pages/PageBuilder.vue
Expand Up @@ -273,31 +273,39 @@ useEventListener(document, "paste", async (e) => {
return;
} else {
// try pasting figma text styles
if (blockController.isText() && text.includes(":") && !store.editableBlock) {
if (text.includes(":") && !store.editableBlock) {
e.preventDefault();
// strip out all comments: line-height: 115%; /* 12.65px */ -> line-height: 115%;
const strippedText = text.replace(/\/\*.*?\*\//g, "");
const strippedText = text.replace(/\/\*.*?\*\//g, "").replace(/\n/g, "");
const styleObj = strippedText.split(";").reduce((acc: BlockStyleMap, curr) => {
const [key, value] = curr.split(":").map((item) => (item ? item.trim() : "")) as [
styleProperty,
StyleValue
];
if (
[
"font-family",
"font-size",
"font-weight",
"line-height",
"letter-spacing",
"text-align",
"text-transform",
"color",
].includes(key)
) {
acc[key] = value;
if (key === "font-family" && String(value).toLowerCase().includes("inter")) {
acc["font-family"] = "";
if (blockController.isText()) {
if (
[
"font-family",
"font-size",
"font-weight",
"line-height",
"letter-spacing",
"text-align",
"text-transform",
"color",
].includes(key)
) {
if (key === "font-family") {
acc[key] = (value + "").replace(/['"]+/g, "");
if (String(value).toLowerCase().includes("inter")) {
acc["font-family"] = "";
}
} else {
acc[key] = value;
}
}
} else if (["width", "height", "box-shadow", "background", "border-radius"].includes(key)) {
acc[key] = value;
}
return acc;
}, {});
Expand Down
23 changes: 3 additions & 20 deletions frontend/vite.config.js
@@ -1,25 +1,21 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import { webserver_port } from "../../../sites/common_site_config.json";
import frappeui from "frappe-ui/vite";

// https://vitejs.dev/config/
export default defineConfig({
define: {
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false,
},
plugins: [vue()],
server: {
port: 8080,
proxy: getProxyOptions({ port: webserver_port }),
},
plugins: [frappeui({ source: "^/(app|login|api|assets|files|pages)" }), vue()],
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
build: {
outDir: `../${path.basename(path.resolve(".."))}/public/frontend`,
outDir: `../builder/public/frontend`,
emptyOutDir: true,
target: "es2015",
sourcemap: true,
Expand All @@ -28,16 +24,3 @@ export default defineConfig({
include: ["frappe-ui > feather-icons", "showdown", "engine.io-client"],
},
});

function getProxyOptions({ port }) {
return {
"^/(app|login|api|assets|files|pages)": {
target: `http://127.0.0.1:${port}`,
ws: true,
router: function (req) {
const site_name = req.headers.host.split(":")[0];
return `http://${site_name}:${port}`;
},
},
};
}

0 comments on commit 7a77fb6

Please sign in to comment.