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

feat: support monaco editor offline usage and most fabric fonts offline display #5547

Closed
wants to merge 12 commits into from
Closed
2 changes: 1 addition & 1 deletion Composer/packages/adaptive-flow/demo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EventsEditorDemo } from './stories/EventsEditorDemo';
import { VisualSDKDemo } from './stories/VisualSDKDemo';
import './index.css';

initializeIcons(undefined, { disableWarnings: true });
initializeIcons('/fonts/', { disableWarnings: true });

EditorConfig.features.showEvents = true;

Expand Down
12 changes: 11 additions & 1 deletion Composer/packages/client/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

const path = require('path');
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'production';
process.env.NODE_ENV = 'production';
Expand Down Expand Up @@ -35,6 +35,16 @@ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;

const isInteractive = process.stdout.isTTY;

//copy monaco editor resouce to public folder to support offline usage
const monacoEditor = path.resolve(__dirname, '../../../node_modules/monaco-editor/min');
const monacoEditorInPublicFolder = path.resolve(__dirname, '../public/min');
fs.copySync(monacoEditor, monacoEditorInPublicFolder);

//copy fabric fonts to public folder to support offline usage
const fabricFonts = path.resolve(__dirname, '../../../node_modules/@uifabric/icons/fonts');
const fabricFontsInPublicFolder = path.resolve(__dirname, '../public/fonts');
fs.copySync(fabricFonts, fabricFontsInPublicFolder);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this as part of the prod build only seems like it would break local development. Is that true? I was thinking it should happen as a postinstall script.

// Warn and crash if required files are missing
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { loadLocale } from './utils/fileUtil';
import { dispatcherState } from './recoilModel/DispatcherWrapper';
import { useInitializeLogger } from './telemetry/useInitializeLogger';

initializeIcons(undefined, { disableWarnings: true });
initializeIcons('/fonts/', { disableWarnings: true });

const Logger = () => {
useInitializeLogger();
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/plugin-host-preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { syncStore, Shell } from '@bfc/extension-client';

import './index.css';

Fabric.initializeIcons(undefined, { disableWarnings: true });
Fabric.initializeIcons('/fonts/', { disableWarnings: true });

if (!document.head.title) {
const title = document.createElement('title');
Expand Down
6 changes: 6 additions & 0 deletions Composer/packages/lib/code-editor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

import { monaco } from '@monaco-editor/react';

monaco.config({
urls: {
monacoLoader: '/min/vs/loader.js',
monacoBase: '/min/vs',
},
});
// initialize moanco api as early as possible
monaco.init();

Expand Down