Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proceds blockly #316

Merged
merged 26 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2c0a5cc
blockly 11
dlopezalvas Jun 10, 2024
8013920
procedure def no return (without behaviour)
dlopezalvas Jun 20, 2024
65ec0e3
add parameter
dlopezalvas Jun 24, 2024
2f3648b
using blockly-proceds
dlopezalvas Jul 8, 2024
cd0051c
ups
dlopezalvas Jul 12, 2024
a347a5e
merge develop
dlopezalvas Jul 16, 2024
b883127
deleting procedsBlockly file
dlopezalvas Jul 17, 2024
f8f14fb
callback
danielferro69 Jul 20, 2024
aa10cb8
Merge branch 'proceds-blockly' of github.com:Program-AR/pilas-bloques…
danielferro69 Jul 20, 2024
53695cd
blockly.ts to compare with develop
danielferro69 Jul 26, 2024
6007e8f
bad draft
danielferro69 Aug 2, 2024
5462a80
fixing variables_get
dlopezalvas Aug 8, 2024
f9d758c
Merge pull request #306 from Program-AR/proceds-blockly-variables
dlopezalvas Aug 9, 2024
c3a54f2
merge develop
dlopezalvas Oct 15, 2024
d5f68e5
para que no se ejecuten bloques por fuera del "al empezar a ejectuar"
rgonzalezt Nov 15, 2024
441aa3d
bumping proceds
dlopezalvas Nov 26, 2024
cf8fc8c
Merge branch 'proceds-blockly' of github.com:Program-AR/pilas-bloques…
dlopezalvas Nov 26, 2024
601a441
fixing tests
dlopezalvas Nov 27, 2024
e728b07
fixing ci?
dlopezalvas Nov 27, 2024
7499ac9
trying ci
dlopezalvas Nov 27, 2024
da7a9a6
trying ci
dlopezalvas Nov 27, 2024
821635f
trying ci again:(
dlopezalvas Nov 27, 2024
65497cf
ups
dlopezalvas Nov 27, 2024
60a641c
ci
dlopezalvas Nov 27, 2024
1aedf25
finally fixing ci?
dlopezalvas Nov 27, 2024
d034a83
traduccion comeToEnd e icono
rgonzalezt Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"babel-preset-react-app": "^10.0.1",
"bfj": "^7.0.2",
"blockly": "^10.4.3",
"blockly-proceds": "^1.0.15",
"browserslist": "^4.18.1",
"camelcase": "^6.2.1",
"case-sensitive-paths-webpack-plugin": "^2.4.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/blockly/PBBlocklyWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Toolbox, categorizedToolbox, setupBlockly, setupBlocklyBlocks, setXml,
import { PBCard } from "../PBCard";
import { Box, PaperProps, Typography } from "@mui/material";
import { useState } from "react";
import Blockly from "blockly/core"
import * as Blockly from 'blockly/core'
import { useThemeContext } from "../../theme/ThemeContext";

// inject options https://developers.google.com/blockly/reference/js/blockly.blocklyoptions_interface.md
Expand All @@ -31,7 +31,7 @@ export const PBBlocklyWorkspace = ({ blockIds, categorized, sx, title, ...props

setupBlocklyBlocks(t)

if (blocklyContainer) setupBlockly(blocklyContainer, { theme: blocklyTheme, toolbox, ...props.workspaceConfiguration } )
if (blocklyContainer) setupBlockly(blocklyContainer, { theme: blocklyTheme, toolbox, ...props.workspaceConfiguration } )

if (blocklyContainer && props.initialXml) setXml(props.initialXml )

Expand Down
21 changes: 14 additions & 7 deletions src/components/blockly/blockly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type BlocklyBlockDefinition = {
export type Toolbox = { kind: "categoryToolbox" | "flyoutToolbox", contents: ToolboxItem[] }
type ToolboxItem = ToolboxBlock | ToolBoxCategory
type ToolboxBlock = { kind: "block", type: string }
type ToolBoxCategory = { kind: "category" | '', name: string, contents: ToolboxItem[] }
type ToolBoxCategory = { kind: "category" | '', name: string, contents: ToolboxItem[], custom?: string }

export const xmlBloqueEmpezarAEjecutar = `<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="al_empezar_a_ejecutar" x="15" y="15"></block>
Expand Down Expand Up @@ -67,7 +67,8 @@ export const setXml = (xml: string) => {
export const setupBlockly = (container: Element, workspaceConfiguration: Blockly.BlocklyOptions) => {
container.replaceChildren() //Removes previous injection, otherwise it might keep inserting below the current workspace
container.ariaValueText = 'child-blockly'
Blockly.inject(container, workspaceConfiguration)
const workspace = Blockly.inject(container, workspaceConfiguration)
workspace.addChangeListener(Blockly.Events.disableOrphans);
}

export const workspaceToCode = () => javascriptGenerator.workspaceToCode(Blockly.getMainWorkspace())
Expand Down Expand Up @@ -109,15 +110,17 @@ export const messageBlock = (message: string) => {
}

const createCommonCode = () => {
javascriptGenerator.addReservedWords('main', 'hacer', 'out_hacer', 'evaluar');
javascriptGenerator.addReservedWords('main,hacer,out_hacer,evaluar');

/*
javascriptGenerator.required_value = function () {
return null
};

javascriptGenerator.required_statement = function () {
return null
};
*/

javascriptGenerator.STATEMENT_PREFIX = 'highlightBlock(%1);\n';
javascriptGenerator.addReservedWords('highlightBlock');
Expand Down Expand Up @@ -155,7 +158,6 @@ const defineBlocklyTranslations = (t: (key: string) => string) => {
Blockly.Msg.CLEAN_UP = t("contextMenu.cleanUp")
Blockly.Msg.EXTERNAL_INPUTS = t("contextMenu.externalInputs")


// ProcedsBlockly.init() needs all procedure blocks to work, so we need to put them back
// After calling init(), we disable unwanted toolbox blocks again
enableUnwantedProcedureBlocks()
Expand All @@ -167,10 +169,15 @@ export const categorizedToolbox = (t: (key: string) => string, blocks: BlockType

const categoryBlocksFor = (categoryId: string): ToolboxItem => {
const contents = blocks.filter(block => block.categoryId === categoryId).map(blockTypeToToolboxBlock)
return contents.length ? {
return contents.length ? categoryId === 'myprocedures' ? {
kind: "category",
name: `${t(`categories.${categoryId}`)}`,
contents: contents,
custom: "PROCEDURE"
} : {
kind: "category",
name: `${t(`categories.${categoryId}`)}`,
contents: contents
contents: contents,
} : {
kind: '',
name: '',
Expand All @@ -187,4 +194,4 @@ export const categorizedToolbox = (t: (key: string) => string, blocks: BlockType
export const uncategorizedToolbox = (blocks: BlockType[]): Toolbox => ({
kind: "flyoutToolbox",
contents: blocks.map(blockTypeToToolboxBlock)
})
})
9 changes: 8 additions & 1 deletion src/components/blockly/blocksGallery/others.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createCommonBlocklyBlocks } from "../utils";
import { createCommonBlocklyBlocks, disableUnwantedProcedureBlocks, enableUnwantedProcedureBlocks } from "../utils";
import Blockly, { Block } from "blockly/core"
import { sensorsColor } from "./sensors";
import { javascriptGenerator, Order } from "blockly/javascript";
import { procedsBlocklyInit } from 'blockly-proceds'

const othersColor = '#cc5b22';
const eventsColor = '#00a65a'; // == boton ejecutar
Expand Down Expand Up @@ -138,4 +139,10 @@ export const createOthersBlocks = (t: (key: string) => string) => {
init: Blockly.Blocks["logic_compare"].init,
categoryId: 'operators',
}

enableUnwantedProcedureBlocks()

procedsBlocklyInit(Blockly)

disableUnwantedProcedureBlocks()
}
Loading