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

Modules feature #1

Merged
merged 62 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
7d26273
Modules: first implementations
Feb 25, 2020
b0eb006
Modules: order blocks by modules
Mar 3, 2020
123f778
Modules: add modules context menu
Mar 4, 2020
7d6587a
Modules: bugfixes
Mar 12, 2020
592d08e
Modules: add localisation
Mar 12, 2020
73030ac
Modules: build with modules
Mar 12, 2020
33b59b7
Modules: fixed custom build
Mar 12, 2020
ee88d2d
Modules: bump version
Mar 12, 2020
da57023
Modules: fixed dependency
Mar 12, 2020
83c0529
Modules: bugfixes
Mar 16, 2020
7bc16dc
modeules: fixed console log
Mar 16, 2020
5483e66
modeules: fixed modules movement
Mar 24, 2020
4159a17
modeules: record and restore workspace scroll for any module
Mar 24, 2020
0b57eda
modeules: no record scroll to xml
Mar 24, 2020
0f27fa2
modeules: restore record scroll to xml
Mar 24, 2020
4281f4e
modeules: restore record scroll to xml
Mar 24, 2020
62cd33b
modeules: fixed labels
Mar 31, 2020
37cc936
modeules: fixed labels
Mar 31, 2020
fbf3a41
Modules: first implementations
Feb 25, 2020
b7e340f
Modules: order blocks by modules
Mar 3, 2020
fafc243
Modules: add modules context menu
Mar 4, 2020
73d8713
Modules: bugfixes
Mar 12, 2020
c507468
Modules: add localisation
Mar 12, 2020
ad2916c
Modules: build with modules
Mar 12, 2020
ff1be70
Modules: fixed custom build
Mar 12, 2020
7879f96
Modules: fixed dependency
Mar 12, 2020
0bd6788
Modules: bugfixes
Mar 16, 2020
e5f3465
modeules: fixed console log
Mar 16, 2020
5ad7f83
modeules: fixed modules movement
Mar 24, 2020
a029a7a
modeules: record and restore workspace scroll for any module
Mar 24, 2020
c35633f
modeules: no record scroll to xml
Mar 24, 2020
ea01d71
modeules: restore record scroll to xml
Mar 24, 2020
d5ec21c
modeules: fixed labels
Mar 31, 2020
1cd0601
Merge remote-tracking branch 'origin/master' into modules-feature
Jul 23, 2020
3db1f3a
Bug fixes
Aug 14, 2020
0fa2ce1
Add move block to module context menu option
Sep 21, 2020
cf54678
Fixed bug
Sep 23, 2020
573caab
Move to ru translations
Sep 23, 2020
c6f1303
Diable plus/minus feature
Oct 1, 2020
49c3bfa
Bugfix: activate previous module after delete current
Nov 19, 2020
a2d7b2d
Bugfix: move block descendants to module
Nov 19, 2020
a21a833
Bump version
Nov 20, 2020
0da1ee8
Merge remote-tracking branch 'origin/modules-feature' into modules-fe…
Feb 8, 2021
88643fd
Switch modules optimisation
Feb 11, 2021
5cf5da8
modules: store ws scale for module, fix bounding box bug for modules
Feb 13, 2021
41aefd7
zoom controls: use zoom to fit instead scroll center
Feb 13, 2021
7f1d096
bump version
Feb 13, 2021
4ddc6fe
feature: implement obsolete attribute for blocks
Feb 24, 2021
f29caf9
bump version
Feb 24, 2021
0cf9de9
bugfix: paths
Feb 25, 2021
94c6160
feature: removed and obsolete states for blocks
Mar 1, 2021
f6f719d
bugfix: fixed blocks
Mar 1, 2021
58f3fc1
Merge remote-tracking branch 'origin/modules-feature' into modules-fe…
Mar 26, 2021
b4d1236
fix scroll on menu highlight
Apr 1, 2021
ccf0dc1
bump version
Apr 1, 2021
b4a4ce0
revert previous scrolling fix
Apr 2, 2021
ca473da
Add custom text element in block dropdown options
May 26, 2021
0559c85
Merge pull request #19 from varwin/custom-text-in-block-dropdown-options
prusov May 26, 2021
5814927
Merge branch 'master' into modules-feature
Oct 6, 2021
dc7d65e
Modules feature update 6.20210701.1 (#35)
LionKenedi95 Oct 20, 2021
ad845ba
Merge branch 'modules-feature' of https://github.com/varwin/blockly i…
Oct 20, 2021
eb9d662
Update README.md
Oct 20, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build-debug.log
.DS_Store
.settings
.project
.idea
*.gz
*.pyc
*.komodoproject
Expand Down
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
# Varwin Blockly

Это форк Google Blockly с доработками для [Varwin](https://varwin.com/).
Основная фича Varwin Blockly: "Модули" (`/core/module.*`), которая сильно затрагивает core blockly.

# Алгоритм обновления репозитория

1. Подтягиваем изменения из `google/blockly`. (Github сам предложит это сделать, если обнаружит новые коммиты в master `google/blockly`)
2. Если есть конфликты, будет создан PR для мерджа
3. Переходим на ветку слияния и решаем все конфликты
4. Выполняем
```bash
npm run build
```
6. Запускаем локальный playground, которые лежит в `tests/playground.html`
7. Если обнаруживаются ошибки, то переходим к пункту 3 и решаем возникшие проблемы. Обратите внимание на раздел с частыми проблемами ниже
8. Выполняем
```bash
npm run prepare
```
10. Переходим в директорию `dist`
11. Выполняем npm publish

# Как удобно тестировать Varwin Blockly сразу в RMS

Можно вызывать `gulp package` с аргументом `--output "path"` где `path` это путь до папки `blockly` в `node_modules` RMS.
Учитывайте, что путь должен быть относительно корня репозитория Varwin Blockly.

Т.е.
1. Делаем правки в Varwin Blockly
2. Вызываем
```bash
npm run build
```
3. Вызываем
```bash
gulp package --output "~/node_modules/blockly/"
```
6. Запускаем сборку RMS (или hot reload сам подтянет node_modules)

# Частые проблемы

### Playground не может найти файлы

Идем в файл `/blockly_uncompresed.js` и исправляем пути до файлов.

### Build падает с ошибкой "No supported platform for closure-compiler found"

Можно попробовать установить не поддерживаемый пакет `google-closure-compiler-js`.
Затем залезть в `node_modules/google-closure-compiler/lib/utils.js` и в методе `getFirstSupportedPlatform` всегда возвращать
`"google-closure-compiler-js"`.

Так пакет будет собираться средствами node.js, но это медленнее, зато работает. Пока что.


=======

# Blockly [![Build Status]( https://travis-ci.org/google/blockly.svg?branch=master)](https://travis-ci.org/google/blockly)

Google's Blockly is a library that adds a visual code editor to web and mobile apps. The Blockly editor uses interlocking, graphical blocks to represent code concepts like variables, logical expressions, loops, and more. It allows users to apply programming principles without having to worry about syntax or the intimidation of a blinking cursor on the command line. All code is free and open source.
Expand Down
406 changes: 293 additions & 113 deletions blockly_compressed.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blockly_compressed.js.map

Large diffs are not rendered by default.

410 changes: 207 additions & 203 deletions blockly_uncompressed.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions blocks/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,10 @@ Blockly.Blocks['procedures_callnoreturn'] = {
option.callback = function() {
var def = Blockly.Procedures.getDefinition(name, workspace);
if (def) {
if (!def.InActiveModule()) {
workspace.getModuleManager().activateModule(workspace.getModuleManager().getModuleById(def.getModuleId()));
def = workspace.getBlockById(def.id);
}
workspace.centerOnBlock(def.id);
def.select();
}
Expand Down
17 changes: 14 additions & 3 deletions blocks_compressed.js

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

2 changes: 1 addition & 1 deletion blocks_compressed.js.map

Large diffs are not rendered by default.

103 changes: 102 additions & 1 deletion core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ goog.requireType('Blockly.VariableModel');
* type-specific functions for this block.
* @param {string=} opt_id Optional ID. Use this ID if provided, otherwise
* create a new ID.
* @param {string=} moduleId Optional module ID. Use this ID if provided, otherwise use active module.
* @constructor
* @implements {Blockly.IASTNodeLocation}
* @implements {Blockly.IDeletable}
* @throws When the prototypeName is not valid or not allowed.
*/
Blockly.Block = function(workspace, prototypeName, opt_id) {
Blockly.Block = function(workspace, prototypeName, opt_id, moduleId) {
if (Blockly.Generator &&
typeof Blockly.Generator.prototype[prototypeName] != 'undefined') {
// Occluding Generator class members is not allowed.
Expand All @@ -83,6 +84,21 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
this.inputList = [];
/** @type {boolean|undefined} */
this.inputsInline = undefined;
/**
* @type {string}
* @private
* */
this.moduleId_ = moduleId ? moduleId : workspace.getModuleManager().getActiveModule().getId();
/**
* @type {boolean}
* @private
*/
this.obsolete = false;
/**
* @type {boolean}
* @private
*/
this.removed = false;
/**
* @type {boolean}
* @private
Expand Down Expand Up @@ -548,6 +564,43 @@ Blockly.Block.prototype.unplugFromStack_ = function(opt_healStack) {
}
};


/**
* Returns module id for this block.
* @return string
* @package
*/
Blockly.Block.prototype.getModuleId = function() {
return this.moduleId_;
};

/**
* Returns module order for this block.
* @return int
* @package
*/
Blockly.Block.prototype.getModuleOrder = function() {
return this.workspace.getModuleManager().getModuleOrder(this.getModuleId());
};

/**
* Returns is this block in active module.
* @return string
* @package
*/
Blockly.Block.prototype.InActiveModule = function() {
return this.moduleId_ === this.workspace.getModuleManager().getActiveModule().getId();
};

/**
* Set module module id for this block.
* @param {string} moduleId module id.
* @package
*/
Blockly.Block.prototype.setModuleId = function(moduleId) {
return this.moduleId_ = moduleId;
};

/**
* Returns all connections originating from this block.
* @param {boolean} _all If true, return all connections even hidden ones.
Expand Down Expand Up @@ -1307,6 +1360,48 @@ Blockly.Block.prototype.setEnabled = function(enabled) {
}
};

/**
* Get whether this block is obsolete or not.
* @return {boolean} True if obsolete.
*/
Blockly.Block.prototype.isObsolete = function() {
return this.obsolete;
};

/**
* Set whether the block is obsolete or not.
* @param {boolean} obsolete True if obsolete.
*/
Blockly.Block.prototype.setObsolete = function(obsolete) {
this.obsolete = obsolete;
if (obsolete) {
this.setWarningText(Blockly.Msg["OBSOLETE_WARNING"]);
} else {
this.setWarningText(null);
}
};

/**
* Get whether this block is removed or not.
* @return {boolean} True if removed.
*/
Blockly.Block.prototype.isRemoved = function() {
return this.removed;
};

/**
* Set whether the block is removed or not.
* @param {boolean} removed True if removed.
*/
Blockly.Block.prototype.setRemoved = function(removed) {
this.removed = removed;
if (removed) {
this.setWarningText(Blockly.Msg["REMOVED_WARNING"]);
} else {
this.setWarningText(null);
}
};

/**
* Get whether the block is disabled or not due to parents.
* The block's own disabled property is not considered.
Expand Down Expand Up @@ -1540,6 +1635,12 @@ Blockly.Block.prototype.jsonInit = function(json) {
if (json['nextStatement'] !== undefined) {
this.setNextStatement(true, json['nextStatement']);
}
if (json['obsolete'] === true) {
this.setObsolete(true);
}
if (json['removed'] === true) {
this.setRemoved(true);
}
if (json['tooltip'] !== undefined) {
var rawValue = json['tooltip'];
var localizedText = Blockly.utils.replaceMessageReferences(rawValue);
Expand Down
Loading