@@ -9,6 +9,9 @@ import { MetaBindBindTargetError } from './utils/MetaBindErrors';
99import { API } from './API' ;
1010import { ScriptMarkdownRenderChild } from './ScriptMarkdownRenderChild' ;
1111import { plugins } from 'pretty-format' ;
12+ import { Extension } from '@codemirror/state' ;
13+ import { cmPlugin } from './frontmatterDisplay/CmPlugin' ;
14+ import { setFirstWeekday } from './inputFields/DatePicker/DatePickerInputSvelteHelpers' ;
1215
1316export default class MetaBindPlugin extends Plugin {
1417 // @ts -ignore defined in `onload`
@@ -23,6 +26,9 @@ export default class MetaBindPlugin extends Plugin {
2326 // @ts -ignore defined in `onload`
2427 api : API ;
2528
29+ // @ts -ignore defined in `onload`
30+ editorExtensions : Extension [ ] ;
31+
2632 async onload ( ) : Promise < void > {
2733 console . log ( `meta-bind | Main >> load` ) ;
2834
@@ -32,6 +38,7 @@ export default class MetaBindPlugin extends Plugin {
3238
3339 DateParser . dateFormat = this . settings . preferredDateFormat ;
3440 this . api . parser . parseTemplates ( this . settings . inputTemplates ) ;
41+ setFirstWeekday ( this . settings . firstWeekday ) ;
3542
3643 this . activeMarkdownInputFields = [ ] ;
3744 this . metadataManager = new MetadataManager ( this ) ;
@@ -63,72 +70,11 @@ export default class MetaBindPlugin extends Plugin {
6370 ctx . addChild ( new ScriptMarkdownRenderChild ( el , source , ctx , this ) ) ;
6471 } ) ;
6572
73+ // this.registerEditorExtension(cmPlugin);
74+
6675 this . addSettingTab ( new MetaBindSettingTab ( this . app , this ) ) ;
6776 }
6877
69- /**
70- * Accessible function for building an input field.
71- *
72- * @param {string|InputFieldDeclaration } declaration The input field declaration as a string or object.
73- * @param {string } sourcePath The path of the file the element will be inserted into.
74- * @param {HTMLElement } container The container element for the input element.
75- * @param {RenderChildType } renderType Inline or Code Block.
76- *
77- * @returns The render child produced.
78- */
79- // buildInputFieldMarkdownRenderChild(
80- // declaration: string | InputFieldDeclaration,
81- // sourcePath: string,
82- // container: HTMLElement,
83- // renderType: InputFieldMarkdownRenderChildType = InputFieldMarkdownRenderChildType.INLINE_CODE_BLOCK
84- // ): InputFieldMarkdownRenderChild {
85- // if (typeof declaration === 'string') {
86- // declaration = InputFieldDeclarationParser.parseString(declaration);
87- // } else {
88- // declaration = InputFieldDeclarationParser.parseDeclaration(declaration);
89- // }
90- //
91- // return new InputFieldMarkdownRenderChild(container, renderType, declaration, this, sourcePath, crypto.randomUUID());
92- // }
93-
94- /**
95- * Helper method to build a declaration from some initial data or a string.
96- *
97- * @param {string | InputFieldDeclaration | {} } declarationData The base declaration data or a string to parse for it. Can also be an empty object with the other arguments provided to fill it.
98- * @param {Record<InputFieldArgumentType, string> | {} | undefined } inputFieldArguments (Optional) The input field arguments, indexed by argument name.
99- * @param {InputFieldType | undefined } inputFieldType (Optional) The input field type if not provided in the base object.
100- * @param {boolean | undefined } isBound (Optional) If the field should try to be bound to a bindTarget.
101- * @param {string | undefined } bindTarget (Optional) The bind target of the field.
102- * @param {string | undefined } templateName (Optional) A template to use.
103- *
104- * @returns A constructed InputFieldDeclaration.
105- */
106- // buildDeclaration(
107- // declarationData: string | InputFieldDeclaration | {},
108- // inputFieldArguments?: Record<InputFieldArgumentType, string> | {},
109- // inputFieldType?: InputFieldType,
110- // isBound?: boolean,
111- // bindTarget?: string,
112- // templateName?: string
113- // ): InputFieldDeclaration {
114- // if (typeof declarationData === 'string') {
115- // return InputFieldDeclarationParser.parseString(declarationData);
116- // } else {
117- // const declarationBase = declarationData as InputFieldDeclaration;
118- // declarationBase.inputFieldType = inputFieldType ?? declarationBase.inputFieldType ?? InputFieldType.INVALID;
119- // declarationBase.isBound = isBound ?? declarationBase.isBound ?? false;
120- // declarationBase.bindTarget = bindTarget ?? declarationBase.bindTarget ?? undefined;
121- //
122- // // if the input field is bound should be determined by `isBound`
123- // // `isBound` is true, `bindTarget` must be set
124- // if (declarationBase.isBound && !declarationBase.bindTarget) {
125- // throw new MetaBindBindTargetError('input field declaration is bound but bind target is undefined');
126- // }
127- //
128- // return InputFieldDeclarationParser.parseDeclaration(declarationBase, inputFieldArguments, templateName);
129- // }
130- // }
131-
13278 onunload ( ) : void {
13379 console . log ( `meta-bind | Main >> unload` ) ;
13480 for ( const activeMarkdownInputField of this . activeMarkdownInputFields ) {
@@ -179,6 +125,7 @@ export default class MetaBindPlugin extends Plugin {
179125
180126 DateParser . dateFormat = this . settings . preferredDateFormat ;
181127 this . api . parser . parseTemplates ( this . settings . inputTemplates ) ;
128+ setFirstWeekday ( this . settings . firstWeekday ) ;
182129 await this . saveData ( this . settings ) ;
183130 }
184131}
0 commit comments