From 78a97f9b5696795c3e356c06ad39ef06d545052b Mon Sep 17 00:00:00 2001 From: "mathieu.cottret" Date: Wed, 26 Aug 2020 16:00:04 +0200 Subject: [PATCH 1/2] Fix retrieval of text component content with custom RTE. Fixes artf/grapesjs#2916 --- src/dom_components/view/ComponentTextView.js | 16 ++++----- .../dom_components/view/ComponentTextView.js | 34 +++++++++++++++++++ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index f5223e49d..0c6535443 100644 --- a/src/dom_components/view/ComponentTextView.js +++ b/src/dom_components/view/ComponentTextView.js @@ -78,17 +78,13 @@ export default ComponentView.extend({ * @return string */ getContent() { - const { rte } = this; - const { activeRte } = rte || {}; - let content = ''; + const { activeRte } = this; + const canGetRteContent = + activeRte && typeof activeRte.getContent === 'function'; - if (activeRte && typeof activeRte.getContent === 'function') { - content = activeRte.getContent(); - } else { - content = this.getChildrenContainer().innerHTML; - } - - return content; + return canGetRteContent + ? activeRte.getContent() + : this.getChildrenContainer().innerHTML; }, /** diff --git a/test/specs/dom_components/view/ComponentTextView.js b/test/specs/dom_components/view/ComponentTextView.js index 72f36f0a9..4a35fb63f 100644 --- a/test/specs/dom_components/view/ComponentTextView.js +++ b/test/specs/dom_components/view/ComponentTextView.js @@ -39,4 +39,38 @@ describe('ComponentTextView', () => { fixtures.appendChild(view.render().el); expect(view.el.innerHTML).toEqual('test'); }); + + describe('.getContent', () => { + let fakeRte, fakeRteContent, fakeChildContainer; + + beforeEach(() => { + fakeRteContent = 'fakeRteContent'; + + fakeRte = { + getContent: jest.fn(() => fakeRteContent) + }; + + fakeChildContainer = { + innerHTML: 'fakeChildInnerHTML' + }; + + spyOn(view, 'getChildrenContainer').and.returnValue(fakeChildContainer); + }); + + it('should get content from active RTE if available', () => { + view.activeRte = fakeRte; + expect(view.getContent()).toEqual(fakeRteContent); + expect(fakeRte.getContent).toHaveBeenCalled(); + }); + + it("should get child container's `innerHTML` if active RTE is not available or if it has no `getContent` function", () => { + expect(view.getContent()).toEqual(fakeChildContainer.innerHTML); + + fakeRte.getContent = null; + view.activeRte = fakeRte; + expect(view.getContent()).toEqual(fakeChildContainer.innerHTML); + + expect(view.getChildrenContainer).toHaveBeenCalledTimes(2); + }); + }); }); From dc5a0f360e9c0df40ce4d08d11d0a9d0331bc32f Mon Sep 17 00:00:00 2001 From: louisraccoon Date: Thu, 27 Aug 2020 03:00:44 +0900 Subject: [PATCH 2/2] Korean language support closes artf#2978 --- src/i18n/locale/ko.js | 117 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 src/i18n/locale/ko.js diff --git a/src/i18n/locale/ko.js b/src/i18n/locale/ko.js new file mode 100644 index 000000000..1634874f9 --- /dev/null +++ b/src/i18n/locale/ko.js @@ -0,0 +1,117 @@ +const traitInputAttr = { placeholder: 'eg. 텍스트 입력' }; + +export default { + assetManager: { + addButton: '이미지 추가', + inputPlh: 'http://path/to/the/image.jpg', + modalTitle: '이미지 선택', + uploadTitle: '원하는 파일을 여기에 놓거나 업로드를 위해 클릭' + }, + // Here just as a reference, GrapesJS core doesn't contain any block, + // so this should be omitted from other local files + blockManager: { + labels: { + // 'block-id': 'Block Label', + }, + categories: { + // 'category-id': 'Category Label', + } + }, + domComponents: { + names: { + '': '상자', + wrapper: 'Body', + text: '텍스트', + comment: 'Comment', + image: '이미지', + video: '동영상', + label: 'Label', + link: '링크', + map: '지도', + tfoot: 'Table foot', + tbody: 'Table body', + thead: 'Table head', + table: 'Table', + row: 'Table row', + cell: 'Table cell' + } + }, + deviceManager: { + device: 'Device', + devices: { + desktop: '데스크탑', + tablet: '태블릿', + mobileLandscape: '모바일 환경', + mobilePortrait: '모바일 Portrait' + } + }, + panels: { + buttons: { + titles: { + preview: '미리보기', + fullscreen: '전체화면', + 'sw-visibility': 'components 보기', + 'export-template': '코드 보기', + 'open-sm': 'Style Manager 열기', + 'open-tm': '설정', + 'open-layers': 'Layer Manager 열기', + 'open-blocks': 'Blocks 열기' + } + } + }, + selectorManager: { + label: 'Classes', + selected: '선택된', + emptyState: '- 상태 -', + states: { + hover: 'Hover', + active: 'Click', + 'nth-of-type(2n)': '짝수/홀수' + } + }, + styleManager: { + empty: 'Style Manager 사용하려면, 먼저 element를 선택해주세요', + layer: '레이어', + fileButton: 'Images', + sectors: { + general: '기본설정', + layout: '레이아웃', + typography: '글꼴', + decorations: '꾸미기', + extra: 'Extra', + flex: 'Flex', + dimension: '크기 및 위치' + }, + // The core library generates the name by their `property` name + properties: { + // float: 'Float', + } + }, + traitManager: { + empty: 'Trait Manager 사용하려면, 먼저 element를 선택해주세요', + label: 'Component 설정', + traits: { + // The core library generates the name by their `name` property + labels: { + // id: 'Id', + // alt: 'Alt', + // title: 'Title', + // href: 'Href', + }, + // In a simple trait, like text input, these are used on input attributes + attributes: { + id: traitInputAttr, + alt: traitInputAttr, + title: traitInputAttr, + href: { placeholder: 'eg. https://google.com' } + }, + // In a trait like select, these are used to translate option names + options: { + target: { + false: '현재 창', + _blank: '새 창' + } + } + } + } +};