@difizen/libro-code-cell 0.2.28 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,15 @@
1
+ import type { LanguageSpecRegistry } from '@difizen/libro-code-editor';
2
+ import { LanguageSpecContribution } from '@difizen/libro-code-editor';
1
3
  import { CellModelContribution, CellViewContribution } from '@difizen/libro-core';
2
4
  import type { CellMeta, CellModel, CellOptions } from '@difizen/libro-core';
3
5
  import { CodeCellModelFactory } from './code-cell-protocol.js';
4
6
  import { LibroCodeCellView } from './code-cell-view.js';
5
- export declare class CodeEditorCellContribution implements CellModelContribution, CellViewContribution {
7
+ export declare class CodeEditorCellContribution implements CellModelContribution, CellViewContribution, LanguageSpecContribution {
6
8
  libroCellModelFactory: CodeCellModelFactory;
7
9
  cellMeta: CellMeta;
8
10
  canHandle(options: CellOptions): number;
9
11
  createModel(options: CellOptions): Promise<CellModel>;
10
12
  view: typeof LibroCodeCellView;
13
+ registerLanguageSpec: (register: LanguageSpecRegistry) => void;
11
14
  }
12
15
  //# sourceMappingURL=code-cell-contribution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-cell-contribution.d.ts","sourceRoot":"","sources":["../src/code-cell-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBACa,0BACX,YAAW,qBAAqB,EAAE,oBAAoB;IAExB,qBAAqB,EAAE,oBAAoB,CAAC;IAE1E,QAAQ,EAAE,QAAQ,CAIhB;IAEF,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM;IAIjC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IAO3D,IAAI,2BAAqB;CAC1B"}
1
+ {"version":3,"file":"code-cell-contribution.d.ts","sourceRoot":"","sources":["../src/code-cell-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAGa,0BACX,YAAW,qBAAqB,EAAE,oBAAoB,EAAE,wBAAwB;IAElD,qBAAqB,EAAE,oBAAoB,CAAC;IAE1E,QAAQ,EAAE,QAAQ,CAIhB;IAEF,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM;IAIjC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IAO3D,IAAI,2BAAqB;IAEzB,oBAAoB,aAAc,oBAAoB,UAOpD;CACH"}
@@ -11,12 +11,13 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
11
11
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
12
  function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
13
13
  function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
14
+ import { LanguageSpecContribution } from '@difizen/libro-code-editor';
14
15
  import { CellModelContribution, CellViewContribution } from '@difizen/libro-core';
15
16
  import { inject, singleton } from '@difizen/mana-app';
16
17
  import { CodeCellModelFactory } from "./code-cell-protocol.js";
17
18
  import { LibroCodeCellView } from "./code-cell-view.js";
18
19
  export var CodeEditorCellContribution = (_dec = singleton({
19
- contrib: [CellModelContribution, CellViewContribution]
20
+ contrib: [CellModelContribution, CellViewContribution, LanguageSpecContribution]
20
21
  }), _dec2 = inject(CodeCellModelFactory), _dec(_class = (_class2 = /*#__PURE__*/function () {
21
22
  function CodeEditorCellContribution() {
22
23
  _classCallCheck(this, CodeEditorCellContribution);
@@ -27,6 +28,14 @@ export var CodeEditorCellContribution = (_dec = singleton({
27
28
  order: 'b'
28
29
  };
29
30
  this.view = LibroCodeCellView;
31
+ this.registerLanguageSpec = function (register) {
32
+ register.registerLanguageSpec({
33
+ name: 'Python',
34
+ language: 'python',
35
+ ext: ['.py'],
36
+ mime: 'text/x-python'
37
+ });
38
+ };
30
39
  }
31
40
  _createClass(CodeEditorCellContribution, [{
32
41
  key: "canHandle",
@@ -1 +1 @@
1
- {"version":3,"file":"code-cell-view.d.ts","sourceRoot":"","sources":["../src/code-cell-view.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KA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IAElC,OAAO,EAAE,OAAO,EAAE,CAAC;IAGnB,UAAU,CAAC,EAAE,cAAc,CAAC;IAG5B,gBAAgB,SAAK;IAGZ,kBAAkB,SAAK;IAGvB,cAAc,SAAK;IAGnB,YAAY,EAAE,YAAY,CAA0B;IAE7D,SAAS,CAAC,kBAAkB,4BAAmC;IAC/D,IAAI,eAAe,6BAElB;IAEQ,YAAY,uDAKnB;IAEO,YAAY,CAAC,IAAI,EAAE,QAAQ;IAMpC,oBAAoB;gBAqBE,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EAClB,iBAAiB,EAAE,iBAAiB;IA6BxD,WAAW;IAQX,MAAM,IAAI,SAAS;IAQnB,WAAW;IAIpB,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;IAKlD,SAAS,CAAC,eAAe,IAAI,qBAAqB;cAclC,YAAY;cA0BZ,gBAAgB;IAoBhC,SAAS,CAAC,WAAW;IAgBZ,qBAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;IAMtD,IAAI,aAGX;IAEO,KAAK,WAAY,OAAO,UAS/B;IAEO,cAAc,aAGrB;CACH"}
@@ -28,6 +28,7 @@ function _initializerWarningHelper(descriptor, context) { throw new Error('Decor
28
28
  /* eslint-disable @typescript-eslint/parameter-properties */
29
29
 
30
30
  import { CodeEditorManager } from '@difizen/libro-code-editor';
31
+ import { CellUri } from '@difizen/libro-common';
31
32
  import { isOutput } from '@difizen/libro-common';
32
33
  import { CellService, EditorStatus, LibroExecutableCellView, LibroOutputArea, VirtualizedManagerHelper, LibroContextKey } from '@difizen/libro-core';
33
34
  import { Disposable } from '@difizen/mana-app';
@@ -240,7 +241,7 @@ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-ce
240
241
  key: "getEditorOption",
241
242
  value: function getEditorOption() {
242
243
  var option = {
243
- uuid: "".concat(this.parent.model.id, "-").concat(this.model.id),
244
+ uuid: CellUri.from(this.parent.model.id, this.model.id).toString(),
244
245
  editorHostId: this.parent.id + this.id,
245
246
  model: this.model,
246
247
  config: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-code-cell",
3
- "version": "0.2.28",
3
+ "version": "0.2.30",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -32,9 +32,9 @@
32
32
  "src"
33
33
  ],
34
34
  "dependencies": {
35
- "@difizen/libro-code-editor": "^0.2.28",
36
- "@difizen/libro-common": "^0.2.28",
37
- "@difizen/libro-core": "^0.2.28",
35
+ "@difizen/libro-code-editor": "^0.2.30",
36
+ "@difizen/libro-common": "^0.2.30",
37
+ "@difizen/libro-core": "^0.2.30",
38
38
  "@difizen/mana-app": "latest"
39
39
  },
40
40
  "peerDependencies": {
@@ -1,3 +1,5 @@
1
+ import type { LanguageSpecRegistry } from '@difizen/libro-code-editor';
2
+ import { LanguageSpecContribution } from '@difizen/libro-code-editor';
1
3
  import { CellModelContribution, CellViewContribution } from '@difizen/libro-core';
2
4
  import type { CellMeta, CellModel, CellOptions } from '@difizen/libro-core';
3
5
  import { inject, singleton } from '@difizen/mana-app';
@@ -5,9 +7,11 @@ import { inject, singleton } from '@difizen/mana-app';
5
7
  import { CodeCellModelFactory } from './code-cell-protocol.js';
6
8
  import { LibroCodeCellView } from './code-cell-view.js';
7
9
 
8
- @singleton({ contrib: [CellModelContribution, CellViewContribution] })
10
+ @singleton({
11
+ contrib: [CellModelContribution, CellViewContribution, LanguageSpecContribution],
12
+ })
9
13
  export class CodeEditorCellContribution
10
- implements CellModelContribution, CellViewContribution
14
+ implements CellModelContribution, CellViewContribution, LanguageSpecContribution
11
15
  {
12
16
  @inject(CodeCellModelFactory) libroCellModelFactory: CodeCellModelFactory;
13
17
 
@@ -29,4 +33,13 @@ export class CodeEditorCellContribution
29
33
  }
30
34
 
31
35
  view = LibroCodeCellView;
36
+
37
+ registerLanguageSpec = (register: LanguageSpecRegistry) => {
38
+ register.registerLanguageSpec({
39
+ name: 'Python',
40
+ language: 'python',
41
+ ext: ['.py'],
42
+ mime: 'text/x-python',
43
+ });
44
+ };
32
45
  }
@@ -4,6 +4,7 @@
4
4
  import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-editor';
5
5
  import { CodeEditorManager } from '@difizen/libro-code-editor';
6
6
  import type { ICodeCell, IOutput } from '@difizen/libro-common';
7
+ import { CellUri } from '@difizen/libro-common';
7
8
  import { isOutput } from '@difizen/libro-common';
8
9
  import type {
9
10
  IOutputAreaOption,
@@ -227,7 +228,7 @@ export class LibroCodeCellView extends LibroExecutableCellView {
227
228
 
228
229
  protected getEditorOption(): CodeEditorViewOptions {
229
230
  const option: CodeEditorViewOptions = {
230
- uuid: `${this.parent.model.id}-${this.model.id}`,
231
+ uuid: CellUri.from(this.parent.model.id, this.model.id).toString(),
231
232
  editorHostId: this.parent.id + this.id,
232
233
  model: this.model,
233
234
  config: {