aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/PaintButtonView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-01-31 20:39:47 -0500
committerbobzel <zzzman@gmail.com>2024-01-31 20:39:47 -0500
commit0d8c05db9cbb5a23a94554c65015c347ff8c38b9 (patch)
treefa1cd6ba23262e81ee7b1b03a89783d0026cbba0 /src/client/views/nodes/formattedText/PaintButtonView.tsx
parent8ac814bbb81b690a6a10f5a07aa5ce0e8cafe283 (diff)
cleaned up accessing/setting proto_embeddings with api on Doc. fixed some css related to IconButtons. added a paintView toggle button to dec decorations for text with code blocks. enabled text with code to modify Docs and get this and documentView as params.
Diffstat (limited to 'src/client/views/nodes/formattedText/PaintButtonView.tsx')
-rw-r--r--src/client/views/nodes/formattedText/PaintButtonView.tsx113
1 files changed, 0 insertions, 113 deletions
diff --git a/src/client/views/nodes/formattedText/PaintButtonView.tsx b/src/client/views/nodes/formattedText/PaintButtonView.tsx
deleted file mode 100644
index 74423c772..000000000
--- a/src/client/views/nodes/formattedText/PaintButtonView.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-import { action, computed, IReactionDisposer, makeObservable } from 'mobx';
-import { observer } from 'mobx-react';
-import * as React from 'react';
-import * as ReactDOM from 'react-dom/client';
-import { Doc } from '../../../../fields/Doc';
-import { ObservableReactComponent } from '../../ObservableReactComponent';
-import './DashFieldView.scss';
-import { FormattedTextBox } from './FormattedTextBox';
-import { CollectionViewType } from '../../../documents/DocumentTypes';
-import { CollectionView } from '../../collections/CollectionView';
-import { StrCast } from '../../../../fields/Types';
-
-export class PaintButtonView {
- dom: HTMLDivElement; // container for label and value
- root: any;
- node: any;
- tbox: FormattedTextBox;
-
- constructor(node: any, view: any, getPos: any, tbox: FormattedTextBox) {
- this.node = node;
- this.tbox = tbox;
- this.dom = document.createElement('div');
- this.dom.style.width = node.attrs.width;
- this.dom.style.height = node.attrs.height;
- this.dom.style.position = 'relative';
- this.dom.style.display = 'inline-block';
- this.dom.onkeypress = function (e: any) {
- e.stopPropagation();
- };
- this.dom.onkeydown = function (e: any) {
- e.stopPropagation();
- };
- this.dom.onkeyup = function (e: any) {
- e.stopPropagation();
- };
- this.dom.onmousedown = function (e: any) {
- e.stopPropagation();
- };
-
- this.root = ReactDOM.createRoot(this.dom);
- this.root.render(<PaintButtonViewInternal node={node} getPos={getPos} width={node.attrs.width} height={node.attrs.height} tbox={tbox} />);
- }
- destroy() {
- setTimeout(() => {
- try {
- this.root.unmount();
- } catch {}
- });
- }
- deselectNode() {
- this.dom.classList.remove('ProseMirror-selectednode');
- }
- selectNode() {
- this.dom.classList.add('ProseMirror-selectednode');
- }
-}
-
-interface IPaintButtonViewInternal {
- tbox: FormattedTextBox;
- width: number;
- height: number;
- node: any;
- getPos: any;
-}
-
-@observer
-export class PaintButtonViewInternal extends ObservableReactComponent<IPaintButtonViewInternal> {
- _reactionDisposer: IReactionDisposer | undefined;
- _textBoxDoc: Doc;
-
- constructor(props: IPaintButtonViewInternal) {
- super(props);
- makeObservable(this);
- this._textBoxDoc = this._props.tbox.Document;
- }
-
- return100 = () => 100;
- @computed get _checked() {
- return this._props.tbox.Document.onClick ? true : false;
- }
-
- onCheckClick = () => {
- const textView = this._props.tbox.DocumentView?.();
- if (textView) {
- const paintedField = 'layout_' + this._props.tbox.fieldKey + 'Painted';
- const layoutFieldKey = StrCast(textView.layoutDoc.layout_fieldKey, 'layout');
- if (textView.layoutDoc.onClick) {
- textView.layoutDoc[paintedField] = undefined;
- textView.layoutDoc.onClick = undefined;
- } else {
- textView.layoutDoc.type_collection = CollectionViewType.Freeform;
- textView.dataDoc[paintedField] = CollectionView.LayoutString(this._props.tbox.fieldKey);
- textView.layoutDoc.layout_fieldKey = paintedField;
- textView.setToggleDetail(layoutFieldKey.replace('layout_', '').replace('layout', ''));
- textView.layoutDoc.layout_fieldKey = layoutFieldKey;
- }
- }
- };
-
- render() {
- return (
- <div
- className="dashFieldView"
- style={{
- width: this._props.width,
- height: this._props.height,
- pointerEvents: this._props.tbox._props.isSelected() || this._props.tbox.isAnyChildContentActive?.() ? undefined : 'none',
- }}>
- <input type="checkbox" value="paint" checked={this._checked} onChange={e => this.onCheckClick()} />
- </div>
- );
- }
-}