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

Remove element border reset #6093

Merged
merged 4 commits into from
Aug 26, 2024
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
3 changes: 3 additions & 0 deletions src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Backbone from 'backbone';
import { HTMLParserOptions } from '../parser/config/config';
export { default as $ } from '../utils/cash-dom';

interface NOOP {}
Expand All @@ -13,6 +14,8 @@ export type DisableOptions = { fromMove?: boolean };

export type LocaleOptions = { locale?: boolean };

export type WithHTMLParserOptions = { parserOptions?: HTMLParserOptions };

export type RemoveOptions = Backbone.Silenceable;

export type EventHandler = Backbone.EventHandler;
Expand Down
8 changes: 4 additions & 4 deletions src/dom_components/model/Components.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isEmpty, isArray, isString, isFunction, each, includes, extend, flatten, keys } from 'underscore';
import Component from './Component';
import { AddOptions, Collection, OptionAsDocument } from '../../common';
import { AddOptions, Collection } from '../../common';
import { DomComponentsConfig } from '../config/config';
import EditorModel from '../../editor/model/Editor';
import ComponentManager from '..';
Expand All @@ -15,7 +15,7 @@ import {
} from './types';
import ComponentText from './ComponentText';
import ComponentWrapper from './ComponentWrapper';
import { ComponentsEvents } from '../types';
import { ComponentsEvents, ParseStringOptions } from '../types';
import { isSymbolInstance, isSymbolRoot, updateSymbolComps } from './SymbolUtils';

export const getComponentIds = (cmp?: Component | Component[] | Components, res: string[] = []) => {
Expand Down Expand Up @@ -252,11 +252,11 @@ Component> {
return new model(attrs, options) as Component;
}

parseString(value: string, opt: AddOptions & OptionAsDocument & { temporary?: boolean; keepIds?: string[] } = {}) {
parseString(value: string, opt: ParseStringOptions = {}) {
const { em, domc, parent } = this;
const asDocument = opt.asDocument && parent?.is('wrapper');
const cssc = em.Css;
const parsed = em.Parser.parseHtml(value, { asDocument });
const parsed = em.Parser.parseHtml(value, { asDocument, ...opt.parserOptions });
let components = parsed.html;

if (asDocument) {
Expand Down
5 changes: 5 additions & 0 deletions src/dom_components/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AddOptions, OptionAsDocument, WithHTMLParserOptions } from '../common';
import Component from './model/Component';

export enum ActionLabelComponents {
Expand All @@ -16,6 +17,10 @@ export interface SymbolInfo {
relatives: Component[];
}

export interface ParseStringOptions extends AddOptions, OptionAsDocument, WithHTMLParserOptions {
keepIds?: string[];
}

export enum ComponentsEvents {
/**
* @event `component:add` New component added.
Expand Down
4 changes: 2 additions & 2 deletions src/dom_components/view/ComponentTextView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bindAll } from 'underscore';
import { AddOptions, DisableOptions, ObjectAny } from '../../common';
import { AddOptions, DisableOptions, ObjectAny, WithHTMLParserOptions } from '../../common';
import RichTextEditorModule from '../../rich_text_editor';
import RichTextEditor from '../../rich_text_editor/model/RichTextEditor';
import { off, on } from '../../utils/dom';
Expand Down Expand Up @@ -108,7 +108,7 @@ export default class ComponentTextView<TComp extends ComponentText = ComponentTe
* Disable element content editing
* @private
* */
async disableEditing(opts: DisableOptions = {}) {
async disableEditing(opts: DisableOptions & WithHTMLParserOptions = {}) {
const { model, rte, activeRte, em } = this;
// There are rare cases when disableEditing is called when the view is already removed
// so, we have to check for the model, this will avoid breaking stuff.
Expand Down
1 change: 0 additions & 1 deletion src/utils/Droppable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export default class Droppable {
const { dragContent } = this;
const dt = (ev as DragEvent).dataTransfer;
const content = this.getContentByData(dt).content;
(ev.target as HTMLElement).style.border = '';
content && dragContent && dragContent(content);
this.endDrop(!content, ev);
}
Expand Down