Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions 6 apps/src/sites/studio/pages/levelbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import _ from 'lodash';
import codemirror from 'codemirror';
import marked from 'marked';
import renderer from '@cdo/apps/util/StylelessRenderer';
import copyToClipboard from '@cdo/apps/util/copyToClipboard';

window.levelbuilder = window.levelbuilder || {};
_.extend(window.levelbuilder, {
Expand All @@ -23,6 +24,11 @@ window.levelbuilder.installBlocks = function (app, blockly, options) {
appBlocks.install(blockly, options);
};

window.levelbuilder.copyWorkspaceToClipboard = function () {
const str = Blockly.Xml.domToPrettyText(Blockly.Xml.blockSpaceToDom(Blockly.mainBlockSpace));
copyToClipboard(str);
};

// TODO: Remove when global `CodeMirror` is no longer required.
window.CodeMirror = codemirror;
// TODO: Remove when global `marked` is no longer required.
Expand Down
15 changes: 15 additions & 0 deletions 15 apps/src/util/copyToClipboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default function copyToClipboard(str) {
window.getSelection().removeAllRanges();

const tempDiv = document.createElement('pre');
tempDiv.innerText = str;
document.body.appendChild(tempDiv);

try {
window.getSelection().selectAllChildren(tempDiv);
document.execCommand('copy');
window.getSelection().removeAllRanges();
} finally {
document.body.removeChild(tempDiv);
}
}
1 change: 1 addition & 0 deletions 1 dashboard/app/models/levels/gamelab_jr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def self.create_from_level_builder(params, level_params)
hide_animation_mode: true,
show_type_hints: true,
include_shared_functions: true,
hide_custom_blocks: true,
}
)
)
Expand Down
2 changes: 2 additions & 0 deletions 2 dashboard/app/views/levels/_admin.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
%li= link_to "initialization (#{Blockly.count_xml_blocks(@level.initialization_blocks)})", level_edit_blocks_path(@level, :initialization_blocks)
- if @level.is_a? Artist
%li= link_to 'pre-draw', level_edit_blocks_path(@level, :predraw_blocks)
%button{type: 'button', onclick: 'window.levelbuilder.copyWorkspaceToClipboard()', class: 'btn btn-default btn-sm'}
Copy workspace to clipboard
%li= link_to 'delete', level_path(@level), method: :delete, data: { confirm: t('crud.confirm') }, style: 'color: red'
%li
= link_to 'clone', '', onclick: "$('#clone_#{@level.id}').toggle(); return false;"
Expand Down
2 changes: 0 additions & 2 deletions 2 dashboard/app/views/levels/editors/_gamelab_jr.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#custom_blocks_output.collapse
~ f.text_area :custom_blocks, placeholder: 'Custom blocks', rows: 4, value: @level.custom_blocks
#custom-blocks-validation
.field
= render partial: 'levels/editors/checkboxes', locals: {f: f, field_name: :hide_custom_blocks, description: "Do not automatically add block pool and custom blocks to the toolbox"}
.field
=f.label 'Custom helper library code'
%p
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.